1 26 27 package org.objectweb.benchmark.ccm.latency; 28 29 import org.objectweb.benchmark.util.ResultPrinter; 31 32 38 39 public class ClientImpl 40 extends org.objectweb.benchmark.ccm.latency.ClientSessionComposition.ComponentImpl 41 { 42 48 49 private int nb_step; 50 51 52 private int nb_step_invocation; 53 54 55 private int step_start; 56 57 58 private String result_file; 59 60 61 private String host; 62 63 69 70 public 71 ClientImpl() 72 { 73 java.util.Properties properties = new java.util.Properties (); 74 result_file = "OpenCCM.txt"; 75 76 try { 77 java.io.InputStream propStream = null; 78 79 propStream = getClass().getClassLoader().getResourceAsStream("benchmark.properties"); 80 properties.load(propStream); 81 82 nb_step = Integer.parseInt( properties.getProperty("step.number") ); 83 nb_step_invocation = Integer.parseInt( properties.getProperty("step.invocation.number") ); 84 step_start = Integer.parseInt( properties.getProperty("step.start") ); 85 host = properties.getProperty("com.host"); 86 } catch (Exception e) { 87 e.printStackTrace(); 88 } 89 } 90 91 97 103 109 115 public void 116 configuration_complete() 117 throws org.omg.Components.InvalidConfiguration 118 { 119 if(get_context().get_connection_to_server() == null) 121 throw new org.omg.Components.InvalidConfiguration(); 122 123 PingInterface to_server = get_context().get_connection_to_server(); 126 127 if(to_server == null) 129 { 130 System.err.println("The hello::Client::to_server receptacle is not set!"); 131 return; 132 } 133 134 for (int i=0; i<step_start; i++) 136 to_server.ping(); 137 138 System.out.println("Running Rmi Benchmark with " + nb_step + " step(s) of " + nb_step_invocation +" method calls."); 140 try 141 { 142 for(int j=0; j<nb_step; j++) 143 { 144 long timer = System.currentTimeMillis(); 145 146 for (int i=0; i<nb_step_invocation; i++) 147 to_server.ping(); 148 timer = (long) ( ( System.currentTimeMillis() - timer ) * 1000 / (float)nb_step_invocation ); 149 150 ResultPrinter p = new ResultPrinter(result_file); 152 p.write(timer); 153 p.close(); 154 } 155 }catch(Exception ex){ 156 ex.printStackTrace(); 157 } 158 } 159 160 166 171 public void 172 ccm_remove() 173 throws org.omg.Components.CCMException 174 { 175 } 176 177 183 } 184 | Popular Tags |