    1   /***
    2    *
    3    * Copyright 2004 Hiram Chirino
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18  package org.activeio.journal.active;
    19
    20  import java.io.File;
    21  import java.io.IOException;
    22
    23  import org.activeio.journal.Journal;
    24  import org.activeio.journal.JournalPerfToolSupport;
    25
    26  /***
    27   * A Performance statistics gathering tool for the JournalImpl based Journal.
    28   *
    29   * @version $Revision: 1.1 $
    30   */
    31  public class JournalPerfTool extends JournalPerfToolSupport {
    32
    33  	private int logFileSize = 1024*1000*5;
    34      private int logFileCount = 4;
    35
    36  	public static void main(String[] args) throws Exception {
    37  		JournalPerfTool tool = new JournalPerfTool();
    38  		if( args.length > 0 ) {
    39  			tool.journalDirectory = new File(args[0]);
    40  		}
    41  		if( args.length > 1 ) {
    42  			tool.workerIncrement = Integer.parseInt(args[1]);
    43  		}
    44  		if( args.length > 2 ) {
    45  			tool.incrementDelay = Long.parseLong(args[2]);
    46  		}
    47  		if( args.length > 3 ) {
    48  			tool.verbose = Boolean.getBoolean(args[3]);
    49  		}
    50  		if( args.length > 4 ) {
    51  			tool.recordSize = Integer.parseInt(args[4]);
    52  		}
    53  		if( args.length > 5 ) {
    54  			tool.syncFrequency = Integer.parseInt(args[5]);
    55  		}
    56  		if( args.length > 6 ) {
    57  			tool.workerThinkTime = Integer.parseInt(args[6]);
    58  		}
    59  		if( args.length > 7 ) {
    60  			tool.logFileCount = Integer.parseInt(args[7]);
    61  		}
    62  		if( args.length > 8 ) {
    63  			tool.logFileSize = Integer.parseInt(args[8]);
    64  		}
    65  		tool.exec();
    66  	}
    67
    68  	/***
    69  	 * @throws IOException
    70  	 * @see org.activeio.journal.JournalPerfToolSupport#createJournal()
    71  	 */
    72  	public Journal createJournal() throws IOException {
    73  		return new JournalImpl( this.journalDirectory, logFileCount, logFileSize);
    74  	}
    75
    76  }