KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > rubbos > client > ClientEmulator


1 package edu.rice.rubbos.client;
2
3 import edu.rice.rubbos.beans.TimeManagement;
4 import java.io.BufferedReader JavaDoc;
5 import java.io.InputStreamReader JavaDoc;
6 import java.io.IOException JavaDoc;
7 import java.io.File JavaDoc;
8 import java.io.FileOutputStream JavaDoc;
9 import java.io.PrintStream JavaDoc;
10 import java.lang.Runtime JavaDoc;
11 import java.net.URL JavaDoc;
12 import java.util.GregorianCalendar JavaDoc;
13 import java.util.Random JavaDoc;
14 import java.util.Vector JavaDoc;
15
16 /**
17  * RUBBoS client emulator.
18  * This class plays random user sessions emulating a Web browser.
19  *
20  * @author <a HREF="mailto:cecchet@rice.edu">Emmanuel Cecchet</a> and <a HREF="mailto:julie.marguerite@inrialpes.fr">Julie Marguerite</a>
21  * @version 1.0
22  */

23 public class ClientEmulator
24 {
25   private RUBBoSProperties rubbos = null; // access to rubbos.properties file
26
private URLGenerator urlGen = null; // URL generator corresponding to the version to be used (PHP, EJB or Servlets)
27
private static float slowdownFactor = 0;
28   private static boolean endOfSimulation = false;
29
30   /**
31    * Creates a new <code>ClientEmulator</code> instance.
32    * The program is stopped on any error reading the configuration files.
33    */

34   public ClientEmulator()
35   {
36     // Initialization, check that all files are ok
37
rubbos = new RUBBoSProperties();
38     urlGen = rubbos.checkPropertiesFileAndGetURLGenerator();
39     if (urlGen == null)
40       Runtime.getRuntime().exit(1);
41     // Check that the transition table is ok and print it
42
TransitionTable transition = new TransitionTable(rubbos.getNbOfColumns(), rubbos.getNbOfRows(), null, rubbos.useTPCWThinkTime());
43     if (!transition.ReadExcelTextFile(rubbos.getUserTransitionTable()))
44       Runtime.getRuntime().exit(1);
45     else
46       transition.displayMatrix("User");
47     if (!transition.ReadExcelTextFile(rubbos.getAuthorTransitionTable()))
48       Runtime.getRuntime().exit(1);
49     else
50       transition.displayMatrix("Author");
51   }
52
53
54   /**
55    * Updates the slowdown factor.
56    *
57    * @param newValue new slowdown value
58    */

59   private synchronized void setSlowDownFactor(float newValue)
60   {
61     slowdownFactor = newValue;
62   }
63
64
65   /**
66    * Get the slowdown factor corresponding to current ramp (up, session or down).
67    */

68   public static synchronized float getSlowDownFactor()
69   {
70     return slowdownFactor;
71   }
72
73
74   /**
75    * Set the end of the current simulation
76    */

77   private synchronized void setEndOfSimulation()
78   {
79     endOfSimulation = true;
80   }
81
82
83   /**
84    * True if end of simulation has been reached.
85    */

86   public static synchronized boolean isEndOfSimulation()
87   {
88     return endOfSimulation;
89   }
90
91
92   /**
93    * Main program take an optional output file argument only
94    * if it is run on as a remote client.
95    *
96    * @param args optional output file if run as remote client
97    */

98   public static void main(String JavaDoc[] args)
99   {
100     GregorianCalendar JavaDoc startDate;
101     GregorianCalendar JavaDoc endDate;
102     GregorianCalendar JavaDoc upRampDate;
103     GregorianCalendar JavaDoc runSessionDate;
104     GregorianCalendar JavaDoc downRampDate;
105     GregorianCalendar JavaDoc endDownRampDate;
106     Process JavaDoc webServerMonitor = null;
107     Process JavaDoc cjdbcServerMonitor = null;
108     Process JavaDoc dbServerMonitor = null;
109     Process JavaDoc clientMonitor = null;
110     Process JavaDoc[] remoteClientMonitor = null;
111     Process JavaDoc[] remoteClient = null;
112     String JavaDoc reportDir = "";
113     String JavaDoc tmpDir = "/tmp/";
114     boolean isMainClient = args.length == 0; // Check if we are the main client
115

116     if (isMainClient)
117     {
118       // Start by creating a report directory and redirecting output to an index.html file
119
System.out.println("RUBBoS client emulator - (C) Rice University/INRIA 2001\n");
120       reportDir = "bench/"+TimeManagement.currentDateToString()+"/";
121       reportDir = reportDir.replace(' ', '@');
122       try
123       {
124         System.out.println("Creating report directory "+reportDir);
125         File JavaDoc dir = new File JavaDoc(reportDir);
126         dir.mkdirs();
127         if (!dir.isDirectory())
128         {
129           System.out.println("Unable to create "+reportDir+" using current directory instead");
130           reportDir = "./";
131         }
132         else
133           reportDir = dir.getCanonicalPath()+"/";
134         System.out.println("Redirecting output to '"+reportDir+"index.html'");
135         PrintStream JavaDoc outputStream = new PrintStream JavaDoc(new FileOutputStream JavaDoc(reportDir+"index.html"));
136         System.out.println("Please wait while experiment is running ...");
137         System.setOut(outputStream);
138         System.setErr(outputStream);
139       }
140       catch (Exception JavaDoc e)
141       {
142         System.out.println("Output redirection failed, displaying results on standard output ("+e.getMessage()+")");
143       }
144       System.out.println("<h2>RUBBoS client emulator - (C) Rice University/INRIA 2001</h2><p>\n");
145       startDate = new GregorianCalendar JavaDoc();
146       System.out.println("<h3>Test date: "+TimeManagement.dateToString(startDate)+"</h3><br>\n");
147     
148       System.out.println("<A HREF=\"#config\">Test configuration</A><br>");
149       System.out.println("<A HREF=\"trace_client0.html\">Test trace</A><br>");
150       System.out.println("<A HREF=\"perf.html\">Test performance report</A><br><p>");
151       System.out.println("<p><hr><p>");
152
153       System.out.println("<CENTER><A NAME=\"config\"></A><h2>*** Test configuration ***</h2></CENTER>");
154     }
155     else
156     {
157       System.out.println("RUBBoS remote client emulator - (C) Rice University/INRIA 2001\n");
158       startDate = new GregorianCalendar JavaDoc();
159     }
160
161     ClientEmulator client = new ClientEmulator(); // Get also rubbos.properties info
162

163     Stats stats = new Stats(client.rubbos.getNbOfRows());
164     Stats upRampStats = new Stats(client.rubbos.getNbOfRows());
165     Stats runSessionStats = new Stats(client.rubbos.getNbOfRows());
166     Stats downRampStats = new Stats(client.rubbos.getNbOfRows());
167     Stats allStats = new Stats(client.rubbos.getNbOfRows());
168     UserSession[] sessions = new UserSession[client.rubbos.getNbOfClients()];
169     
170     System.out.println("<p><hr><p>");
171
172     if (isMainClient)
173     {
174       // Start remote clients
175
System.out.println("Total number of clients for this experiment: "+(client.rubbos.getNbOfClients()*(client.rubbos.getRemoteClients().size()+1))+"<br>");
176       remoteClient = new Process JavaDoc[client.rubbos.getRemoteClients().size()];
177       for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
178       {
179         try
180         {
181           System.out.println("ClientEmulator: Starting remote client on "+client.rubbos.getRemoteClients().get(i)+"<br>\n");
182           String JavaDoc[] rcmdClient = new String JavaDoc[4];
183           rcmdClient[0] = client.rubbos.getMonitoringRsh();
184       rcmdClient[1] = "-x";
185           rcmdClient[2] = (String JavaDoc)client.rubbos.getRemoteClients().get(i);
186           rcmdClient[3] = client.rubbos.getClientsRemoteCommand()+" "+tmpDir+"trace_client"+(i+1)+".html "+tmpDir+"stat_client"+(i+1)+".html";
187           remoteClient[i] = Runtime.getRuntime().exec(rcmdClient);
188           System.out.println("&nbsp &nbsp Command is: "+rcmdClient[0]+" "+rcmdClient[1]+" "+rcmdClient[2]+" "+rcmdClient[3]+"<br>\n");
189         }
190         catch (IOException JavaDoc ioe)
191         {
192           System.out.println("An error occured while executing remote client ("+ioe.getMessage()+")");
193         }
194       }
195
196       // Start monitoring programs
197
System.out.println("<CENTER></A><A NAME=\"trace\"><h2>*** Monitoring ***</h2></CENTER>");
198       try
199       {
200
201     // First clean up all of the log files as we could be
202
// recording binary files. Sar by default "appends"
203
try
204     {
205       String JavaDoc[] delFiles = new String JavaDoc[4];
206       Process JavaDoc delProcess;
207       delFiles[0] = client.rubbos.getMonitoringRsh();
208       delFiles[1] = "-x";
209       // Web server
210
delFiles[2] = client.rubbos.getWebServerName();
211       delFiles[3] = "rm -f "+tmpDir+"web_server";
212       System.out.println("&nbsp &nbsp Command is: "+delFiles[0]+" "+delFiles[1]+" "+delFiles[2]+" "+delFiles[3]+"<br>\n");
213       delProcess = Runtime.getRuntime().exec(delFiles);
214       delProcess.waitFor();
215       // CJDBC server
216
if(client.rubbos.getCJDBCServerName() != null
217          && !client.rubbos.getCJDBCServerName().equals(""))
218       {
219         delFiles[2] = client.rubbos.getCJDBCServerName();
220         delFiles[3] = "rm -f "+tmpDir+"cjdbc_server";
221         System.out.println("&nbsp &nbsp Command is: "+delFiles[0]+" "+delFiles[1]+" "+delFiles[2]+" "+delFiles[3]+"<br>\n");
222         delProcess = Runtime.getRuntime().exec(delFiles);
223         delProcess.waitFor();
224       }
225       // Database Server
226
delFiles[2] = client.rubbos.getDBServerName();
227       delFiles[3] = "rm -f "+tmpDir+"db_server";
228       System.out.println("&nbsp &nbsp Command is: "+delFiles[0]+" "+delFiles[1]+" "+delFiles[2]+" "+delFiles[3]+"<br>\n");
229       delProcess = Runtime.getRuntime().exec(delFiles);
230       delProcess.waitFor();
231       // Local client
232
delFiles[2] = "localhost";
233       delFiles[3] = "rm -f "+tmpDir+"client0";
234       System.out.println("&nbsp &nbsp Command is: "+delFiles[0]+" "+delFiles[1]+" "+delFiles[2]+" "+delFiles[3]+"<br>\n");
235       delProcess = Runtime.getRuntime().exec(delFiles);
236       delProcess.waitFor();
237       // Remote clients
238
for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
239       {
240         delFiles[2] = (String JavaDoc)client.rubbos.getRemoteClients().get(i);
241         delFiles[3] = "rm -f "+tmpDir+"client"+(i+1);
242         System.out.println("&nbsp &nbsp Command is: "+delFiles[0]+" "+delFiles[1]+" "+delFiles[2]+" "+delFiles[3]+"<br>\n");
243         delProcess = Runtime.getRuntime().exec(delFiles);
244         delProcess.waitFor();
245       }
246     }
247     catch(java.lang.InterruptedException JavaDoc ie)
248     {
249       ie.printStackTrace();
250     }
251     System.out.println("&nbsp &nbsp Finished deleting old files<br>\n");
252
253         // Monitor Web server
254
int fullTimeInSec = (client.rubbos.getUpRampTime()+client.rubbos.getSessionTime()+client.rubbos.getDownRampTime())/1000 + 5; // Give 5 seconds extra for init
255
System.out.println("ClientEmulator: Starting monitoring program on Web server "+client.rubbos.getWebServerName()+"<br>\n");
256         String JavaDoc[] cmdWeb = new String JavaDoc[6];
257         cmdWeb[0] = client.rubbos.getMonitoringRsh();
258         cmdWeb[1] = "-x";
259         cmdWeb[2] = client.rubbos.getWebServerName();
260         cmdWeb[3] = "/bin/bash";
261         cmdWeb[4] = "-c";
262         cmdWeb[5] = "'LANG=en_GB.UTF-8 "+client.rubbos.getMonitoringProgram()+" "+client.rubbos.getMonitoringOptions()+" "+
263           client.rubbos.getMonitoringSampling()+" "+fullTimeInSec+" -o "+tmpDir+"web_server'";
264         webServerMonitor = Runtime.getRuntime().exec(cmdWeb);
265         System.out.println("&nbsp &nbsp Command is: "+cmdWeb[0]+" "+cmdWeb[1]+" "+cmdWeb[2]+" "+cmdWeb[3]+" "+cmdWeb[4]+" "+cmdWeb[5]+"<br>\n");
266
267     // Monitor C-JDBC server (if any)
268
if(client.rubbos.getCJDBCServerName() != null
269        && !client.rubbos.getCJDBCServerName().equals("")) {
270         System.out.println("ClientEmulator: Starting monitoring program on CJDBC server "+client.rubbos.getCJDBCServerName()+"<br>\n");
271         cmdWeb[0] = client.rubbos.getMonitoringRsh();
272         cmdWeb[1] = "-x";
273         cmdWeb[2] = client.rubbos.getCJDBCServerName();
274         cmdWeb[3] = "/bin/bash";
275         cmdWeb[4] = "-c";
276         cmdWeb[5] = "'LANG=en_GB.UTF-8 "+client.rubbos.getMonitoringProgram()+" "+client.rubbos.getMonitoringOptions()+" "+
277         client.rubbos.getMonitoringSampling()+" "+fullTimeInSec+" -o "+tmpDir+"cjdbc_server'";
278         cjdbcServerMonitor = Runtime.getRuntime().exec(cmdWeb);
279         System.out.println("&nbsp &nbsp Command is: "+cmdWeb[0]+" "+cmdWeb[1]+" "+cmdWeb[2]+" "+cmdWeb[3]+" "+cmdWeb[4]+" "+cmdWeb[5]+"<br>\n");
280     }
281       
282         // Monitor Database server
283
System.out.println("ClientEmulator: Starting monitoring program on Database server "+client.rubbos.getDBServerName()+"<br>\n");
284         String JavaDoc[] cmdDB = new String JavaDoc[6];
285         cmdDB[0] = client.rubbos.getMonitoringRsh();
286         cmdDB[1] = "-x";
287         cmdDB[2] = client.rubbos.getDBServerName();
288         cmdDB[3] = "/bin/bash";
289         cmdDB[4] = "-c";
290         cmdDB[5] = "'LANG=en_GB.UTF-8 "+client.rubbos.getMonitoringProgram()+" "+client.rubbos.getMonitoringOptions()+" "+
291           client.rubbos.getMonitoringSampling()+" "+fullTimeInSec+" -o "+tmpDir+"db_server'";
292         dbServerMonitor = Runtime.getRuntime().exec(cmdDB);
293         System.out.println("&nbsp &nbsp Command is: "+cmdDB[0]+" "+cmdDB[1]+" "+cmdDB[2]+" "+cmdDB[3]+" "+cmdDB[4]+" "+cmdDB[5]+"<br>\n");
294
295         // Monitor local client
296
System.out.println("ClientEmulator: Starting monitoring program locally on client<br>\n");
297         String JavaDoc[] cmdClient = new String JavaDoc[6];
298         cmdClient[0] = client.rubbos.getMonitoringRsh();
299         cmdClient[1] = "-x";
300         cmdClient[2] = "localhost";
301         cmdClient[3] = "/bin/bash";
302         cmdClient[4] = "-c";
303         cmdClient[5] = "'LANG=en_GB.UTF-8 "+client.rubbos.getMonitoringProgram()+" "+client.rubbos.getMonitoringOptions()+" "+
304           client.rubbos.getMonitoringSampling()+" "+fullTimeInSec+" -o "+reportDir+"client0'";
305         clientMonitor = Runtime.getRuntime().exec(cmdClient);
306         System.out.println("&nbsp &nbsp Command is: "+cmdClient[0]+" "+cmdClient[1]+" "+cmdClient[2]+" "+cmdClient[3]+" "+cmdClient[4]+" "+cmdClient[5]+"<br>\n");
307
308         remoteClientMonitor = new Process JavaDoc[client.rubbos.getRemoteClients().size()];
309         // Monitor remote clients
310
for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
311         {
312           System.out.println("ClientEmulator: Starting monitoring program locally on client<br>\n");
313           String JavaDoc[] rcmdClient = new String JavaDoc[6];
314           rcmdClient[0] = client.rubbos.getMonitoringRsh();
315           rcmdClient[1] = "-x";
316           rcmdClient[2] = (String JavaDoc)client.rubbos.getRemoteClients().get(i);
317           rcmdClient[3] = "/bin/bash";
318           rcmdClient[4] = "-c";
319           rcmdClient[5] = "'LANG=en_GB.UTF-8 "+client.rubbos.getMonitoringProgram()+" "+client.rubbos.getMonitoringOptions()+" "+
320             client.rubbos.getMonitoringSampling()+" "+fullTimeInSec+" -o "+tmpDir+"client"+(i+1)+"'";
321           remoteClientMonitor[i] = Runtime.getRuntime().exec(rcmdClient);
322           System.out.println("&nbsp &nbsp Command is: "+rcmdClient[0]+" "+rcmdClient[1]+" "+rcmdClient[2]+" "+rcmdClient[3]+" "+rcmdClient[4]+" "+rcmdClient[5]+"<br>\n");
323         }
324
325         // Redirect output for traces
326
PrintStream JavaDoc outputStream = new PrintStream JavaDoc(new FileOutputStream JavaDoc(reportDir+"trace_client0.html"));
327         System.setOut(outputStream);
328         System.setErr(outputStream);
329       }
330       catch (IOException JavaDoc ioe)
331       {
332         System.out.println("An error occured while executing monitoring program ("+ioe.getMessage()+")");
333       }
334     }
335     else
336     { // Redirect output of remote clients
337
System.out.println("Redirecting output to '"+args[0]+"'");
338       try
339       {
340         PrintStream JavaDoc outputStream = new PrintStream JavaDoc(new FileOutputStream JavaDoc(args[0]));
341         System.out.println("Please wait while experiment is running ...");
342         System.setOut(outputStream);
343         System.setErr(outputStream);
344       }
345       catch (Exception JavaDoc e)
346       {
347         System.out.println("Output redirection failed, displaying results on standard output ("+e.getMessage()+")");
348       }
349       startDate = new GregorianCalendar JavaDoc();
350     }
351
352
353     // #############################
354
// ### TEST TRACE BEGIN HERE ###
355
// #############################
356

357     System.out.println("<CENTER></A><A NAME=\"trace\"><h2>*** Test trace ***</h2></CENTER><p>");
358     System.out.println("<A HREF=\"trace_client0.html\">Main client traces</A><br>");
359     for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
360       System.out.println("<A HREF=\"trace_client"+(i+1)+".html\">client1 ("+client.rubbos.getRemoteClients().get(i)+") traces</A><br>");
361     System.out.println("<br><p>");
362     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#up\">Up ramp trace</A><br>");
363     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#run\">Runtime session trace</A><br>");
364     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#down\">Down ramp trace</A><br><p><p>");
365
366     // Run user sessions
367
System.out.println("ClientEmulator: Starting "+client.rubbos.getNbOfClients()+" session threads<br>");
368     Random JavaDoc rand = new Random JavaDoc(); // random number generator
369
for (int i = 0 ; i < client.rubbos.getNbOfClients() ; i++)
370     {
371       if (rand.nextInt(100) < client.rubbos.getPercentageOfAuthors())
372         sessions[i] = new UserSession("AuthorSession"+i, client.urlGen, client.rubbos, stats, true);
373       else
374         sessions[i] = new UserSession("UserSession"+i, client.urlGen, client.rubbos, stats, false);
375       sessions[i].start();
376     }
377
378     // Start up-ramp
379
System.out.println("<br><A NAME=\"up\"></A>");
380     System.out.println("<h3>ClientEmulator: Switching to ** UP RAMP **</h3><br><p>");
381     client.setSlowDownFactor(client.rubbos.getUpRampSlowdown());
382     upRampDate = new GregorianCalendar JavaDoc();
383     try
384     {
385       Thread.currentThread().sleep(client.rubbos.getUpRampTime());
386     }
387     catch (java.lang.InterruptedException JavaDoc ie)
388     {
389       System.err.println("ClientEmulator has been interrupted.");
390     }
391     upRampStats.merge(stats);
392     stats.reset(); // Note that as this is not atomic we may lose some stats here ...
393

394     // Start runtime session
395
System.out.println("<br><A NAME=\"run\"></A>");
396     System.out.println("<h3>ClientEmulator: Switching to ** RUNTIME SESSION **</h3><br><p>");
397     client.setSlowDownFactor(1);
398     runSessionDate = new GregorianCalendar JavaDoc();
399     try
400     {
401       Thread.currentThread().sleep(client.rubbos.getSessionTime());
402     }
403     catch (java.lang.InterruptedException JavaDoc ie)
404     {
405       System.err.println("ClientEmulator has been interrupted.");
406     }
407     runSessionStats.merge(stats);
408     stats.reset(); // Note that as this is not atomic we may lose some stats here ...
409

410     // Start down-ramp
411
System.out.println("<br><A NAME=\"down\"></A>");
412     System.out.println("<h3>ClientEmulator: Switching to ** DOWN RAMP **</h3><br><p>");
413     client.setSlowDownFactor(client.rubbos.getDownRampSlowdown());
414     downRampDate = new GregorianCalendar JavaDoc();
415     try
416     {
417       Thread.currentThread().sleep(client.rubbos.getDownRampTime());
418     }
419     catch (java.lang.InterruptedException JavaDoc ie)
420     {
421       System.err.println("ClientEmulator has been interrupted.");
422     }
423     downRampStats.merge(stats);
424     endDownRampDate = new GregorianCalendar JavaDoc();
425
426     // Wait for completion
427
client.setEndOfSimulation();
428     System.out.println("ClientEmulator: Shutting down threads ...<br>");
429     for (int i = 0 ; i < client.rubbos.getNbOfClients() ; i++)
430     {
431       try
432       {
433         sessions[i].join(2000);
434       }
435       catch (java.lang.InterruptedException JavaDoc ie)
436       {
437         System.err.println("ClientEmulator: Thread "+i+" has been interrupted.");
438       }
439     }
440     System.out.println("Done\n");
441     endDate = new GregorianCalendar JavaDoc();
442     allStats.merge(stats);
443     allStats.merge(runSessionStats);
444     allStats.merge(upRampStats);
445     System.out.println("<p><hr><p>");
446
447
448     // #############################################
449
// ### EXPERIMENT IS OVER, COLLECT THE STATS ###
450
// #############################################
451

452     // All clients completed, here is the performance report !
453
// but first redirect the output
454
try
455     {
456       PrintStream JavaDoc outputStream;
457       if (isMainClient)
458         outputStream = new PrintStream JavaDoc(new FileOutputStream JavaDoc(reportDir+"perf.html"));
459       else
460         outputStream = new PrintStream JavaDoc(new FileOutputStream JavaDoc(args[1]));
461       System.setOut(outputStream);
462       System.setErr(outputStream);
463     }
464     catch (Exception JavaDoc e)
465     {
466       System.out.println("Output redirection failed, displaying results on standard output ("+e.getMessage()+")");
467     }
468
469     System.out.println("<center><h2>*** Performance Report ***</h2></center><br>");
470     System.out.println("<A HREF=\"perf.html\">Overall performance report</A><br>");
471     System.out.println("<A HREF=\"stat_client0.html\">Main client (localhost) statistics</A><br>");
472     for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
473       System.out.println("<A HREF=\"stat_client"+(i+1)+".html\">client1 ("+client.rubbos.getRemoteClients().get(i)+") statistics</A><br>");
474
475     System.out.println("<p><br>&nbsp&nbsp&nbsp<A HREF=\"perf.html#node\">Node information</A><br>");
476     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#time\">Test timing information</A><br>");
477     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#up_stat\">Up ramp statistics</A><br>");
478     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#run_stat\">Runtime session statistics</A><br>");
479     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#down_stat\">Down ramp statistics</A><br>");
480     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#all_stat\">Overall statistics</A><br>");
481     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#cpu_graph\">CPU usage graphs</A><br>");
482     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#procs_graph\">Processes usage graphs</A><br>");
483     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#mem_graph\">Memory usage graph</A><br>");
484     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#disk_graph\">Disk usage graphs</A><br>");
485     System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#net_graph\">Network usage graphs</A><br>");
486
487     if (isMainClient)
488     {
489       // Get information about each node
490
System.out.println("<br><A NAME=\"node\"></A><h3>Node Information</h3><br>");
491       try
492       {
493         File JavaDoc dir = new File JavaDoc(".");
494         String JavaDoc nodeInfoProgram = "/bin/echo \"Host : \"`/bin/hostname` ; " +
495             "/bin/echo \"Kernel: \"`/bin/cat /proc/version` ; " +
496             "/bin/grep net /proc/pci ; " +
497             "/bin/grep processor /proc/cpuinfo ; " +
498             "/bin/grep vendor_id /proc/cpuinfo ; " +
499             "/bin/grep model /proc/cpuinfo ; " +
500             "/bin/grep MHz /proc/cpuinfo ; " +
501             "/bin/grep cache /proc/cpuinfo ; " +
502             "/bin/grep MemTotal /proc/meminfo ; " +
503             "/bin/grep SwapTotal /proc/meminfo ";
504
505
506         // Web server
507
System.out.println("<B>Web server</B><br>");
508         String JavaDoc[] cmdWeb = new String JavaDoc[3];
509         cmdWeb[0] = client.rubbos.getMonitoringRsh();
510         cmdWeb[1] = client.rubbos.getWebServerName();
511         cmdWeb[2] = nodeInfoProgram;
512         Process JavaDoc p = Runtime.getRuntime().exec(cmdWeb);
513         BufferedReader JavaDoc read = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(p.getInputStream()));
514         String JavaDoc msg;
515         while ((msg = read.readLine()) != null)
516           System.out.println(msg+"<br>");
517         read.close();
518
519     // CJDBC Server
520
if(client.rubbos.getCJDBCServerName() != null
521        && !client.rubbos.getCJDBCServerName().equals("")) {
522       System.out.println("<br><B>CJDBC server</B><br>");
523       cmdWeb[0] = client.rubbos.getMonitoringRsh();
524       cmdWeb[1] = client.rubbos.getCJDBCServerName();
525       cmdWeb[2] = nodeInfoProgram;
526       p = Runtime.getRuntime().exec(cmdWeb);
527       read = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(p.getInputStream()));
528       while ((msg = read.readLine()) != null)
529           System.out.println(msg+"<br>");
530       read.close();
531       }
532
533
534         // Database server
535
System.out.println("<br><B>Database server</B><br>");
536         String JavaDoc[] cmdDB = new String JavaDoc[3];
537         cmdDB[0] = client.rubbos.getMonitoringRsh();
538         cmdDB[1] = client.rubbos.getDBServerName();
539         cmdDB[2] =nodeInfoProgram;
540         p = Runtime.getRuntime().exec(cmdDB);
541         read = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(p.getInputStream()));
542         while ((msg = read.readLine()) != null)
543           System.out.println(msg+"<br>");
544         read.close();
545
546         // Client
547
System.out.println("<br><B>Local client</B><br>");
548         String JavaDoc[] cmdClient = new String JavaDoc[3];
549         cmdClient[0] = client.rubbos.getMonitoringRsh();
550         cmdClient[1] = "localhost";
551         cmdClient[2] = nodeInfoProgram;
552         p = Runtime.getRuntime().exec(cmdClient);
553         read = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(p.getInputStream()));
554         while ((msg = read.readLine()) != null)
555           System.out.println(msg+"<br>");
556         read.close();
557
558         // Remote Clients
559
for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
560         {
561           System.out.println("<br><B>Remote client "+i+"</B><br>");
562           String JavaDoc[] rcmdClient = new String JavaDoc[3];
563           rcmdClient[0] = client.rubbos.getMonitoringRsh();
564           rcmdClient[1] = (String JavaDoc)client.rubbos.getRemoteClients().get(i);
565           rcmdClient[2] = nodeInfoProgram;
566           p = Runtime.getRuntime().exec(rcmdClient);
567           read = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(p.getInputStream()));
568           while ((msg = read.readLine()) != null)
569             System.out.println(msg+"<br>");
570           read.close();
571         }
572
573         PrintStream JavaDoc outputStream = new PrintStream JavaDoc(new FileOutputStream JavaDoc(reportDir+"stat_client0.html"));
574         System.setOut(outputStream);
575         System.setErr(outputStream);
576         System.out.println("<center><h2>*** Performance Report ***</h2></center><br>");
577         System.out.println("<A HREF=\"perf.html\">Overall performance report</A><br>");
578         System.out.println("<A HREF=\"stat_client0.html\">Main client (localhost) statistics</A><br>");
579         for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
580           System.out.println("<A HREF=\"stat_client"+(i+1)+".html\">client1 ("+client.rubbos.getRemoteClients().get(i)+") statistics</A><br>");
581         System.out.println("<p><br>&nbsp&nbsp&nbsp<A HREF=\"perf.html#node\">Node information</A><br>");
582         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#time\">Test timing information</A><br>");
583         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#up_stat\">Up ramp statistics</A><br>");
584         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#run_stat\">Runtime session statistics</A><br>");
585         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#down_stat\">Down ramp statistics</A><br>");
586         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#all_stat\">Overall statistics</A><br>");
587         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#cpu_graph\">CPU usage graphs</A><br>");
588         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#procs_graph\">Processes usage graphs</A><br>");
589         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#mem_graph\">Memory usage graph</A><br>");
590         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#disk_graph\">Disk usage graphs</A><br>");
591         System.out.println("&nbsp&nbsp&nbsp<A HREF=\"#net_graph\">Network usage graphs</A><br>");
592
593       }
594       catch (Exception JavaDoc ioe)
595       {
596         System.out.println("An error occured while getting node information ("+ioe.getMessage()+")");
597       }
598     }
599
600     // Test timing information
601
System.out.println("<br><p><A NAME=\"time\"></A><h3>Test timing information</h3><p>");
602     System.out.println("<TABLE BORDER=1>");
603     System.out.println("<TR><TD><B>Test start</B><TD>"+TimeManagement.dateToString(startDate));
604     System.out.println("<TR><TD><B>Up ramp start</B><TD>"+TimeManagement.dateToString(upRampDate));
605     System.out.println("<TR><TD><B>Runtime session start</B><TD>"+TimeManagement.dateToString(runSessionDate));
606     System.out.println("<TR><TD><B>Down ramp start</B><TD>"+TimeManagement.dateToString(downRampDate));
607     System.out.println("<TR><TD><B>Test end</B><TD>"+TimeManagement.dateToString(endDate));
608     System.out.println("<TR><TD><B>Up ramp length</B><TD>"+TimeManagement.diffTime(upRampDate, runSessionDate)+
609                        " (requested "+client.rubbos.getUpRampTime()+" ms)");
610     System.out.println("<TR><TD><B>Runtime session length</B><TD>"+TimeManagement.diffTime(runSessionDate, downRampDate)+
611                        " (requested "+client.rubbos.getSessionTime()+" ms)");
612     System.out.println("<TR><TD><B>Down ramp length</B><TD>"+TimeManagement.diffTime(downRampDate, endDownRampDate)+
613                        " (requested "+client.rubbos.getDownRampTime()+" ms)");
614     System.out.println("<TR><TD><B>Total test length</B><TD>"+TimeManagement.diffTime(startDate, endDate));
615     System.out.println("</TABLE><p>");
616
617     // Stats for each ramp
618
System.out.println("<br><A NAME=\"up_stat\"></A>");
619     upRampStats.display_stats("Up ramp", TimeManagement.diffTimeInMs(upRampDate, runSessionDate), false);
620     System.out.println("<br><A NAME=\"run_stat\"></A>");
621     runSessionStats.display_stats("Runtime session", TimeManagement.diffTimeInMs(runSessionDate, downRampDate), false);
622     System.out.println("<br><A NAME=\"down_stat\"></A>");
623     downRampStats.display_stats("Down ramp", TimeManagement.diffTimeInMs(downRampDate, endDownRampDate), false);
624     System.out.println("<br><A NAME=\"all_stat\"></A>");
625     allStats.display_stats("Overall", TimeManagement.diffTimeInMs(upRampDate, endDownRampDate), false);
626
627
628     if (isMainClient)
629     {
630       // Wait for end of all monitors and remote clients
631
try
632       {
633         for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
634         {
635           remoteClientMonitor[i].waitFor();
636           remoteClient[i].waitFor();
637         }
638         webServerMonitor.waitFor();
639         dbServerMonitor.waitFor();
640     cjdbcServerMonitor.waitFor();
641       }
642
643       catch (Exception JavaDoc e)
644       {
645         System.out.println("An error occured while waiting for remote processes termination ("+e.getMessage()+")");
646       }
647
648       // scp the sar log files over at this point
649
try
650       {
651         String JavaDoc [] scpCmd = new String JavaDoc[3];
652         Process JavaDoc p;
653         scpCmd[0] = client.rubbos.getMonitoringScp();
654         scpCmd[2] = reportDir+"/";
655         for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
656         {
657           scpCmd[1] = (String JavaDoc)client.rubbos.getRemoteClients().get(i) + ":"+tmpDir+"/client"+(i+1);
658           p = Runtime.getRuntime().exec(scpCmd);
659       p.waitFor();
660         }
661         scpCmd[1] = client.rubbos.getWebServerName() + ":"+tmpDir+"/web_server";
662         p = Runtime.getRuntime().exec(scpCmd);
663         p.waitFor();
664     if(client.rubbos.getCJDBCServerName() != null
665        && !client.rubbos.getCJDBCServerName().equals("")) {
666         scpCmd[1] = client.rubbos.getCJDBCServerName() + ":"+tmpDir+"/cjdbc_server";
667         p = Runtime.getRuntime().exec(scpCmd);
668         p.waitFor();
669     }
670         scpCmd[1] = client.rubbos.getDBServerName() + ":"+tmpDir+"/db_server";
671         p = Runtime.getRuntime().exec(scpCmd);
672         p.waitFor();
673         // Fetch html files created by the remote clients
674
for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
675         {
676           scpCmd[1] = (String JavaDoc)client.rubbos.getRemoteClients().get(i)
677               + ":"+tmpDir+"trace_client"+(i+1)+".html";
678           p = Runtime.getRuntime().exec(scpCmd);
679           p.waitFor();
680           scpCmd[1] = (String JavaDoc)client.rubbos.getRemoteClients().get(i)
681               + ":"+tmpDir+"stat_client"+(i+1)+".html";
682           p = Runtime.getRuntime().exec(scpCmd);
683           p.waitFor();
684         }
685       }
686       catch (Exception JavaDoc e)
687       {
688         System.out.println("An error occured while scping the files over ("+e.getMessage()+")");
689       }
690
691
692       // Time to go and convert the binary files into something that generate_graphs.sh can understand
693
try
694       {
695     String JavaDoc cmd;
696     Process JavaDoc p;
697     // Web server
698
cmd = "mv "+reportDir+"/"+"web_server "+reportDir+"/"+"web_server.bin";
699     p = Runtime.getRuntime().exec(cmd);
700     p.waitFor();
701
702     // CJDBC server
703
if(client.rubbos.getCJDBCServerName() != null
704        && !client.rubbos.getCJDBCServerName().equals(""))
705     {
706       cmd = "mv "+reportDir+"/"+"cjdbc_server "+reportDir+"/"+"cjdbc_server.bin";
707       p = Runtime.getRuntime().exec(cmd);
708       p.waitFor();
709     }
710
711     // Database Server
712
cmd = "mv "+reportDir+"/"+"db_server "+reportDir+"/"+"db_server.bin";
713     p = Runtime.getRuntime().exec(cmd);
714     p.waitFor();
715
716     // Localhost
717
cmd = "mv "+reportDir+"/"+"client0 "+reportDir+"/"+"client0.bin";
718     p = Runtime.getRuntime().exec(cmd);
719     p.waitFor();
720     
721     // Remote clients
722
for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
723         {
724       cmd = "mv "+reportDir+"/"+"client"+(i+1)+" "+reportDir+"/"+"client"+(i+1)+".bin";
725           p = Runtime.getRuntime().exec(cmd);
726       p.waitFor();
727         }
728
729     // All files rename at this point in time. Time to go forth and convert them into ascii
730
String JavaDoc[] convCmd = new String JavaDoc[5];
731     int fullTimeInSec = (client.rubbos.getUpRampTime()+client.rubbos.getSessionTime()+client.rubbos.getDownRampTime())/1000 + 5; // Give 5 seconds extra for init
732
String JavaDoc common = "'LANG=en_GB.UTF-8 "+client.rubbos.getMonitoringProgram()+" "+client.rubbos.getMonitoringOptions()+" "+
733         client.rubbos.getMonitoringSampling()+" "+fullTimeInSec+" -f "+reportDir;
734     convCmd[0] = client.rubbos.getMonitoringRsh();
735     convCmd[1] = "localhost";
736     convCmd[2] = "/bin/bash";
737         convCmd[3] = "-c";
738         convCmd[4] = common+"web_server.bin > "+reportDir+""+"web_server'";
739         System.out.println("&nbsp &nbsp Command is: "+convCmd[0]+" "+convCmd[1]+" "+convCmd[2]+" "+convCmd[3]+" "+convCmd[4]+"<br>\n");
740     p = Runtime.getRuntime().exec(convCmd);
741     
742     if(client.rubbos.getCJDBCServerName() != null
743        && !client.rubbos.getCJDBCServerName().equals(""))
744     {
745       convCmd[4] = common+"cjdbc_server.bin > "+reportDir+""+"cjdbc_server'";
746       System.out.println("&nbsp &nbsp Command is: "+convCmd[0]+" "+convCmd[1]+" "+convCmd[2]+" "+convCmd[3]+" "+convCmd[4]+"<br>\n");
747       p = Runtime.getRuntime().exec(convCmd);
748       p.waitFor();
749     }
750     
751     convCmd[4] = common+"db_server.bin > "+reportDir+""+"db_server'";
752         System.out.println("&nbsp &nbsp Command is: "+convCmd[0]+" "+convCmd[1]+" "+convCmd[2]+" "+convCmd[3]+" "+convCmd[4]+"<br>\n");
753     p = Runtime.getRuntime().exec(convCmd);
754     p.waitFor();
755
756     convCmd[4] = common+"client0.bin > "+reportDir+""+"client0'";
757         System.out.println("&nbsp &nbsp Command is: "+convCmd[0]+" "+convCmd[1]+" "+convCmd[2]+" "+convCmd[3]+" "+convCmd[4]+"<br>\n");
758     p = Runtime.getRuntime().exec(convCmd);
759     p.waitFor();
760
761     for (int i = 0 ; i < client.rubbos.getRemoteClients().size() ; i++)
762         {
763       convCmd[2] =common+"client"+(i+1)+".bin > "+reportDir+""+"client"+(i+1)+"'";
764       System.out.println("&nbsp &nbsp Command is: "+convCmd[0]+" "+convCmd[1]+" "+convCmd[2]+" "+convCmd[3]+" "+convCmd[4]+"<br>\n");
765       p = Runtime.getRuntime().exec(convCmd);
766       p.waitFor();
767     }
768     
769
770       }
771       catch (Exception JavaDoc e)
772       {
773         System.out.println("An error occured while convering log files ("+e.getMessage()+")");
774       }
775
776       // Generate the graphics
777
try
778       {
779         String JavaDoc[] cmd = new String JavaDoc[4];
780         cmd[0] = "bench/generate_graphs.sh";
781         cmd[1] = reportDir;
782         cmd[2] = client.rubbos.getGnuPlotTerminal();
783         cmd[3] = Integer.toString(client.rubbos.getRemoteClients().size()+1);
784         Process JavaDoc graph = Runtime.getRuntime().exec(cmd);
785     // Need to read input so program does not stall.
786
BufferedReader JavaDoc read = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(graph.getInputStream()));
787     String JavaDoc msg;
788         while ((msg = read.readLine()) != null)
789         System.out.println(msg+"<br>");
790         read.close();
791         graph.waitFor();
792       }
793       catch (Exception JavaDoc e)
794       {
795         System.out.println("An error occured while generating the graphs ("+e.getMessage()+")");
796       }
797     }
798     boolean cjdbcFlag = false;
799     if(client.rubbos.getCJDBCServerName() != null
800        && !client.rubbos.getCJDBCServerName().equals("")) {
801     cjdbcFlag = true;
802     }
803     System.out.println("<br><A NAME=\"cpu_graph\"></A>");
804     System.out.println("<br><h3>CPU Usage graphs</h3><p>");
805     System.out.println("<TABLE>");
806     System.out.println("<TR><TD><IMG SRC=\"cpu_busy."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_cpu_busy."+client.rubbos.getGnuPlotTerminal()+"\">");
807     if(cjdbcFlag)
808     {
809       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_cpu_busy."+client.rubbos.getGnuPlotTerminal()+"\">");
810     }
811     System.out.println("<TR><TD><IMG SRC=\"cpu_idle."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_cpu_idle."+client.rubbos.getGnuPlotTerminal()+"\">");
812     if(cjdbcFlag)
813     {
814       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_cpu_idle."+client.rubbos.getGnuPlotTerminal()+"\">");
815     }
816     System.out.println("<TR><TD><IMG SRC=\"cpu_user_kernel."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_cpu_user_kernel."+client.rubbos.getGnuPlotTerminal()+"\">");
817     if(cjdbcFlag)
818     {
819       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_cpu_user_kernel."+client.rubbos.getGnuPlotTerminal()+"\">");
820     }
821     System.out.println("</TABLE><p>");
822
823     System.out.println("<br><A NAME=\"procs_graph\"></A>");
824     System.out.println("<TABLE>");
825     System.out.println("<br><h3>Processes Usage graphs</h3><p>");
826     System.out.println("<TR><TD><IMG SRC=\"procs."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_procs."+client.rubbos.getGnuPlotTerminal()+"\">");
827     if(cjdbcFlag)
828     {
829       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_procs."+client.rubbos.getGnuPlotTerminal()+"\">");
830     }
831     System.out.println("<TR><TD><IMG SRC=\"ctxtsw."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_ctxtsw."+client.rubbos.getGnuPlotTerminal()+"\">");
832     if(cjdbcFlag)
833     {
834       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_ctxtsw."+client.rubbos.getGnuPlotTerminal()+"\">");
835     }
836     System.out.println("</TABLE><p>");
837
838     System.out.println("<br><A NAME=\"mem_graph\"></A>");
839     System.out.println("<br><h3>Memory Usage graph</h3><p>");
840     System.out.println("<TABLE>");
841     System.out.println("<TR><TD><IMG SRC=\"mem_usage."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_mem_usage."+client.rubbos.getGnuPlotTerminal()+"\">");
842     if(cjdbcFlag)
843     {
844       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_mem_usage."+client.rubbos.getGnuPlotTerminal()+"\">");
845     }
846     System.out.println("<TR><TD><IMG SRC=\"mem_cache."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_mem_cache."+client.rubbos.getGnuPlotTerminal()+"\">");
847     if(cjdbcFlag)
848     {
849       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_mem_cache."+client.rubbos.getGnuPlotTerminal()+"\">");
850     }
851     System.out.println("</TABLE><p>");
852
853     System.out.println("<br><A NAME=\"disk_graph\"></A>");
854     System.out.println("<br><h3>Disk Usage graphs</h3><p>");
855     System.out.println("<TABLE>");
856     System.out.println("<TR><TD><IMG SRC=\"disk_rw_req."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_disk_rw_req."+client.rubbos.getGnuPlotTerminal()+"\">");
857     if(cjdbcFlag)
858     {
859       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_disk_rw_req."+client.rubbos.getGnuPlotTerminal()+"\">");
860     }
861     System.out.println("<TR><TD><IMG SRC=\"disk_tps."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_disk_tps."+client.rubbos.getGnuPlotTerminal()+"\">");
862     if(cjdbcFlag)
863     {
864       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_disk_tps."+client.rubbos.getGnuPlotTerminal()+"\">");
865     }
866     System.out.println("</TABLE><p>");
867
868     System.out.println("<br><A NAME=\"net_graph\"></A>");
869     System.out.println("<br><h3>Network Usage graphs</h3><p>");
870     System.out.println("<TABLE>");
871     System.out.println("<TR><TD><IMG SRC=\"net_rt_byt."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_net_rt_byt."+client.rubbos.getGnuPlotTerminal()+"\">");
872     if(cjdbcFlag)
873     {
874       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_net_rt_byt."+client.rubbos.getGnuPlotTerminal()+"\">");
875     }
876     System.out.println("<TR><TD><IMG SRC=\"net_rt_pack."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_net_rt_pack."+client.rubbos.getGnuPlotTerminal()+"\">");
877     if(cjdbcFlag)
878     {
879       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_net_rt_pack."+client.rubbos.getGnuPlotTerminal()+"\">");
880     }
881     System.out.println("<TR><TD><IMG SRC=\"socks."+client.rubbos.getGnuPlotTerminal()+"\"><TD><IMG SRC=\"client_socks."+client.rubbos.getGnuPlotTerminal()+"\">");
882     if(cjdbcFlag)
883     {
884       System.out.println("<TR><TD><IMG SRC=\"cjdbc_server_socks."+client.rubbos.getGnuPlotTerminal()+"\">");
885     }
886     System.out.println("</TABLE><p>");
887
888
889     if (isMainClient)
890     {
891       // Compute the global stats
892
try
893       {
894         String JavaDoc[] cmd = new String JavaDoc[6];
895         cmd[0] = "bench/compute_global_stats.awk";
896         cmd[1] = "-v";
897         cmd[2] = "path="+reportDir;
898         cmd[3] = "-v";
899         cmd[4] = "nbscript="+Integer.toString(client.rubbos.getRemoteClients().size()+1);
900         cmd[5] = reportDir+"stat_client0.html";
901         Process JavaDoc computeStats = Runtime.getRuntime().exec(cmd);
902     // Need to read input so program does not stall.
903
BufferedReader JavaDoc read = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(computeStats.getInputStream()));
904     String JavaDoc msg;
905         while ((msg = read.readLine()) != null)
906         System.out.println(msg+"<br>");
907         read.close();
908         computeStats.waitFor();
909       }
910       catch (Exception JavaDoc e)
911       {
912         System.out.println("An error occured while generating the graphs ("+e.getMessage()+")");
913       }
914     }
915
916     Runtime.getRuntime().exit(0);
917   }
918
919 }
920
Popular Tags