1 package org.jgroups.tests.adapt; 2 3 import org.apache.log4j.Logger; 4 5 import java.io.BufferedReader ; 6 import java.io.FileNotFoundException ; 7 import java.io.FileReader ; 8 import java.io.IOException ; 9 10 19 public class Test { 20 21 public static void main(String [] args) { 22 23 String config="config.txt"; 24 BufferedReader fileReader; 25 String line; 26 27 boolean sender=false; 28 int num_msgs=1000; 29 int msg_size=500; 30 int grpMembers=4; 31 int num_senders=1; 32 String props=null; 33 long log_interval=1000; 34 35 36 for(int i=0; i < args.length; i++) { 37 if("-sender".equals(args[i])) { 38 sender=true; 39 continue; 40 } 41 if("-receiver".equals(args[i])) { 42 sender=false; 43 continue; 44 } 45 if("-config".equals(args[i])) { 46 config=args[++i]; 47 continue; 48 } 49 if("-props".equals(args[i])) { 50 props=args[++i]; 51 continue; 52 } 53 help(); 54 return; 55 } 56 57 58 59 try { 60 fileReader=new BufferedReader (new FileReader (config)); 61 while((line=fileReader.readLine()) != null) { 62 if(line.startsWith("#")) 63 continue; 64 else if(line.startsWith("NUM_MSGS=")) { 65 num_msgs=Integer.parseInt(line.substring(line.indexOf('=') + 1, 66 line.indexOf(';'))); 67 } 68 else if(line.startsWith("MSG_SIZE=")) { 69 msg_size=Integer.parseInt(line.substring(line.indexOf('=') + 1, 70 line.indexOf(';'))); 71 } 72 else if(line.startsWith("GRPMEMBERS=")) { 73 grpMembers=Integer.parseInt(line.substring(line.indexOf('=') + 1, 74 line.indexOf(';'))); 75 } 76 else if(line.startsWith("NUM_SENDERS=")) { 77 num_senders=Integer.parseInt(line.substring(line.indexOf('=') + 1, 78 line.indexOf(';'))); 79 } 80 else if(line.startsWith("LOG_INTERVAL=")) { 81 log_interval=Long.parseLong(line.substring(line.indexOf('=') + 1, 82 line.indexOf(';'))); 83 } 84 else if(line.startsWith("PROPS=")) { 85 if(props == null) { 86 props=line.substring(line.indexOf('=') + 1, 87 line.indexOf(';')).trim(); 88 } 89 else { 90 System.out.println("-- properties " + props + " given on command line override file properies"); 91 } 92 } 93 else if(line.startsWith("GNUPLOT_OUTPUT=")) { 94 if(System.getProperty("gnuplot_output") == null) { 96 String gnuplot_output=line.substring(line.indexOf('=') + 1, 97 line.indexOf(';')).trim(); 98 if(gnuplot_output != null) 99 System.setProperty("gnuplot_output", gnuplot_output); 100 } 101 } 102 } 103 fileReader.close(); 104 105 System.out.println("Javagroups test:"); 106 String s="Initial params parsing completed. Starting test" 107 + " with these values:\n" 108 + "Sender:" + sender + " num_msgs:" + num_msgs 109 + " Size(bytes):" + msg_size + " # Mbrs:" + grpMembers 110 + " Senders: " + num_senders 111 + "\nLog interval: " + log_interval + '\n'; 112 113 System.out.println(s); 114 Logger.getLogger(Test.class).info("main(): " + s); 115 116 new JGroupsTester(sender, num_msgs, 117 msg_size, grpMembers, num_senders, props, log_interval).initialize(); 118 } 119 catch(FileNotFoundException notFound) { 120 System.err.println("File not found.\n" + notFound); 121 } 122 catch(IOException ioError) { 123 ioError.printStackTrace(); 124 } 125 } 126 127 static void help() { 128 System.out.println("Test [-help] ([-sender] | [-receiver]) [-config <config file>] [-props <stack config>]"); 129 } 130 } 131 | Popular Tags |