public static void main(String[] args) { String props = null; String name = null; for (int i = 0; i < args.length; i++) { if ("-props".equals(args[i])) { props = args[++i]; continue; } if ("-name".equals(args[i])) { name = args[++i]; continue; } help(); return; } UPerf test = null; try { test = new UPerf(); test.init(props, name); test.eventLoop(); } catch (Throwable ex) { ex.printStackTrace(); if (test != null) test.stop(); } }
public void run() { final byte[] buf = new byte[msg_size]; Object[] put_args = {0, buf}; Object[] get_args = {0}; MethodCall get_call = new MethodCall(GET, get_args); MethodCall put_call = new MethodCall(PUT, put_args); RequestOptions get_options = new RequestOptions(ResponseMode.GET_ALL, 40000, false, null); RequestOptions put_options = new RequestOptions( sync ? ResponseMode.GET_ALL : ResponseMode.GET_NONE, 40000, true, null); if (oob) { get_options.setFlags(Message.OOB); put_options.setFlags(Message.OOB); } if (sync) { get_options.setFlags(Message.DONT_BUNDLE, Message.NO_FC); put_options.setFlags(Message.DONT_BUNDLE, Message.NO_FC); } while (true) { long i = num_msgs_sent.getAndIncrement(); if (i >= num_msgs_to_send) break; boolean get = Util.tossWeightedCoin(read_percentage); try { if (get) { // sync GET Address target = pickTarget(); get_args[0] = i; disp.callRemoteMethod(target, get_call, get_options); num_gets++; } else { // sync or async (based on value of 'sync') PUT Collection<Address> targets = pickAnycastTargets(); put_args[0] = i; disp.callRemoteMethods(targets, put_call, put_options); num_puts++; } } catch (Throwable throwable) { throwable.printStackTrace(); } } }