KickJava   Java API By Example, From Geeks To Geeks.

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


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
22 import java.io.IOException JavaDoc;
23
24 import org.apache.activeio.journal.Journal;
25 import org.apache.activeio.journal.JournalRWPerfToolSupport;
26 import org.apache.activemq.kaha.impl.async.AsyncDataManager;
27
28 /**
29  * A Performance statistics gathering tool for the AsyncDataManager based Journal.
30  *
31  * @version $Revision: 1.1 $
32  */

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

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