KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > kaha > impl > async > JournalPerfTool


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.kaha.impl.async;
19
20 import java.io.File JavaDoc;
21 import java.io.IOException JavaDoc;
22
23 import org.apache.activeio.journal.Journal;
24 import org.apache.activeio.journal.JournalPerfToolSupport;
25 import org.apache.activemq.kaha.impl.async.AsyncDataManager;
26
27 /**
28  * A Performance statistics gathering tool for the AsyncDataManager based Journal.
29  *
30  * @version $Revision: 1.1 $
31  */

32 public class JournalPerfTool extends JournalPerfToolSupport {
33     
34     private int logFileSize = 1024*1024*50;
35         
36     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
37         JournalPerfTool tool = new JournalPerfTool();
38         
39         tool.initialWorkers=10;
40         tool.syncFrequency=15;
41         tool.workerIncrement=0;
42         tool.workerThinkTime=0;
43         tool.verbose=false;
44         tool.incrementDelay=5*1000;
45
46         if( args.length > 0 ) {
47             tool.journalDirectory = new File JavaDoc(args[0]);
48         }
49         if( args.length > 1 ) {
50             tool.workerIncrement = Integer.parseInt(args[1]);
51         }
52         if( args.length > 2 ) {
53             tool.incrementDelay = Long.parseLong(args[2]);
54         }
55         if( args.length > 3 ) {
56             tool.verbose = Boolean.getBoolean(args[3]);
57         }
58         if( args.length > 4 ) {
59             tool.recordSize = Integer.parseInt(args[4]);
60         }
61         if( args.length > 5 ) {
62             tool.syncFrequency = Integer.parseInt(args[5]);
63         }
64         if( args.length > 6 ) {
65             tool.workerThinkTime = Integer.parseInt(args[6]);
66         }
67         tool.exec();
68     }
69
70     /**
71      * @throws IOException
72      * @see org.apache.activeio.journal.JournalPerfToolSupport#createJournal()
73      */

74     public Journal createJournal() throws IOException JavaDoc {
75         AsyncDataManager dm = new AsyncDataManager();
76         dm.setMaxFileLength(logFileSize);
77         dm.setDirectory(this.journalDirectory);
78         dm.start();
79         return new JournalFacade(dm);
80     }
81     
82 }
83
Popular Tags