1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package jgroup.test.performance.upgrade;
20
21 import jgroup.core.registry.DependableRegistry;
22 import jgroup.core.registry.RegistryFactory;
23 import jgroup.test.performance.SpeedTest;
24
25
26
27
28
29
30
31
32
33 public class UpgradeSpeedTestClient
34 {
35
36
37 private static void help() {
38 System.out.println("UpgradeSpeedTestClient [-v][-method N][-calibrate C][-rate R][-time T][-clients][-server ServerName]");
39 }
40
41
42 public static void main(String[] argv)
43 throws Exception
44 {
45 if( argv.length <1 ) help();
46 boolean verbose = (PUtil.getStringParameter(argv, "-v", "verbose").compareTo("verbose") != 0);
47 int method = PUtil.getIntParameter(argv, "-method", "1");
48 int calibReqCallNo = PUtil.getIntParameter(argv, "-calibrate", "10");
49 int rps = PUtil.getIntParameter(argv, "-rate", "1");
50 int expTime = PUtil.getIntParameter(argv, "-time", "10");
51 int client_no = PUtil.getIntParameter(argv, "-clients", "1");
52 String serverName = PUtil.getStringParameter(argv, "-server", "UpgradeServer");
53 if( verbose )
54 System.out.println("Testing server " + serverName + " calibrating with " + calibReqCallNo + " calls of method " + method + " with rate " + rps + " sending for each of " + client_no + " clients for time of " + expTime +" sec.");
55 ClientThreadPool client[] = new ClientThreadPool[client_no];
56
57 DependableRegistry reg = RegistryFactory.getRegistry();
58 SpeedTest server = (SpeedTest) reg.lookup(serverName);
59 int times = expTime * rps;
60 for(int i=0; i<client_no; i++) {
61 client[i]= new ClientThreadPool(method, calibReqCallNo, rps, times, server);
62 client[i].start();
63 }
64 ClientThreadPool.allStart();
65 }
66
67
68
69
70 private static boolean completed = false;
71 private int method;
72 private int rps;
73 private int times;
74 private int calibReqCallNo;
75 private String serverName;
76
77 public UpgradeSpeedTestClient(int method, int calibReqCallNo, int rps, int times, String serverName)
78 {
79 this.method = method;
80 this.calibReqCallNo = calibReqCallNo;
81 this.rps = rps;
82 this.times = times;
83 this.serverName = serverName;
84
85 }
86
87
88 public synchronized void start()
89 throws Exception
90 {
91 UpgradeClientTest test = new UpgradeClientTest(serverName);
92 test.calibrate(method, calibReqCallNo);
93 test.generate_traffic(rps, times);
94
95 completed = true;
96 notify();
97 }
98
99 public synchronized void halt()
100 throws Exception
101 {
102 while (!completed)
103 try { wait(); } catch (Exception e) { }
104 }
105
106 }