use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class UPerf method init.
public void init(String props, String name, AddressGenerator generator, int bind_port, boolean use_fibers) throws Throwable {
thread_factory = new DefaultThreadFactory("invoker", false, true).useFibers(use_fibers);
if (use_fibers && Util.fibersAvailable())
System.out.println("-- using fibers instead of threads");
channel = new JChannel(props).addAddressGenerator(generator).setName(name);
if (bind_port > 0) {
TP transport = channel.getProtocolStack().getTransport();
transport.setBindPort(bind_port);
}
disp = new RpcDispatcher(channel, this).setReceiver(this).setMethodLookup(id -> METHODS[id]);
channel.connect(groupname);
local_addr = channel.getAddress();
try {
MBeanServer server = Util.getMBeanServer();
JmxConfigurator.registerChannel(channel, server, "jgroups", channel.getClusterName(), true);
} catch (Throwable ex) {
System.err.println("registering the channel in JMX failed: " + ex);
}
if (members.size() < 2)
return;
Address coord = members.get(0);
Config config = disp.callRemoteMethod(coord, new MethodCall(GET_CONFIG), new RequestOptions(ResponseMode.GET_ALL, 5000));
if (config != null) {
applyConfig(config);
System.out.println("Fetched config from " + coord + ": " + config + "\n");
} else
System.err.println("failed to fetch config from " + coord);
}
use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class ProgrammaticUPerf2 method startBenchmark.
/**
* Kicks off the benchmark on all cluster nodes
*/
protected void startBenchmark() {
RspList<Results> responses = null;
try {
RequestOptions options = new RequestOptions(ResponseMode.GET_ALL, 0);
options.flags(Message.Flag.OOB, Message.Flag.DONT_BUNDLE, Message.Flag.NO_FC);
responses = disp.callRemoteMethods(null, new CustomCall(START), options);
} catch (Throwable t) {
System.err.println("starting the benchmark failed: " + t);
return;
}
long total_reqs = 0;
long total_time = 0;
AverageMinMax avg_gets = null, avg_puts = null;
System.out.println("\n======================= Results: ===========================");
for (Map.Entry<Address, Rsp<Results>> entry : responses.entrySet()) {
Address mbr = entry.getKey();
Rsp<Results> rsp = entry.getValue();
Results result = rsp.getValue();
if (result != null) {
total_reqs += result.num_gets + result.num_puts;
total_time += result.total_time;
if (avg_gets == null)
avg_gets = result.avg_gets;
else
avg_gets.merge(result.avg_gets);
if (avg_puts == null)
avg_puts = result.avg_puts;
else
avg_puts.merge(result.avg_puts);
}
System.out.println(mbr + ": " + result);
}
double total_reqs_sec = total_reqs / (total_time / 1000.0);
double throughput = total_reqs_sec * BUFFER.length;
System.out.println("\n");
System.out.println(Util.bold(String.format("Throughput: %,.2f reqs/sec/node (%s/sec)\n" + "Roundtrip: gets %s, puts %s\n", total_reqs_sec, Util.printBytes(throughput), print(avg_gets, print_details), print(avg_puts, print_details))));
System.out.println("\n\n");
}
use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class ProgrammaticUPerf2 method eventLoop.
// ================================= end of callbacks =====================================
public void eventLoop() {
while (looping) {
try {
int c = Util.keyPress(String.format(format, num_threads, time, Util.printBytes(msg_size), sync, oob, anycast_count, read_percentage, allow_local_gets, print_details, print_invokers));
switch(c) {
case '1':
startBenchmark();
break;
case '2':
printView();
break;
case '4':
invoke(SET_NUM_THREADS, Util.readIntFromStdin("Number of sender threads: "));
break;
case '6':
invoke(SET_TIME, Util.readIntFromStdin("Time (secs): "));
break;
case '7':
invoke(SET_MSG_SIZE, Util.readIntFromStdin("Message size: "));
break;
case 'a':
int tmp = parseAnycastCount();
if (tmp >= 0)
invoke(SET_ANYCAST_COUNT, tmp);
break;
case 'o':
invoke(SET_OOB, !oob);
break;
case 's':
invoke(SET_SYNC, !sync);
break;
case 'r':
double percentage = parseReadPercentage();
if (percentage >= 0)
invoke(SET_READ_PERCENTAGE, percentage);
break;
case 'd':
invoke(PRINT_DETAILS, !print_details);
break;
case 'i':
invoke(PRINT_INVOKERS, !print_invokers);
break;
case 'l':
invoke(ALLOW_LOCAL_GETS, !allow_local_gets);
break;
case 'v':
System.out.printf("Version: %s\n", Version.printVersion());
break;
case 'x':
case -1:
looping = false;
break;
case 'X':
try {
RequestOptions options = new RequestOptions(ResponseMode.GET_NONE, 0).flags(Message.Flag.OOB, Message.Flag.DONT_BUNDLE, Message.Flag.NO_FC);
disp.callRemoteMethods(null, new CustomCall(QUIT_ALL), options);
break;
} catch (Throwable t) {
System.err.println("Calling quitAll() failed: " + t);
}
break;
default:
break;
}
} catch (Throwable t) {
t.printStackTrace();
}
}
stop();
}
use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class ProgrammaticUPerf2 method init.
public void init(String name, String bind_addr, int bind_port) throws Exception {
TP transport = channel.getProtocolStack().getTransport();
disp.setServerObject(this);
channel.setName(name);
if (bind_port > 0)
transport.setBindPort(bind_port);
if (bind_addr != null)
transport.setBindAddress(InetAddress.getByName(bind_addr));
channel.connect(groupname);
DiagnosticsHandler diag_handler = transport.getDiagnosticsHandler();
if (diag_handler != null) {
Set<DiagnosticsHandler.ProbeHandler> probe_handlers = diag_handler.getProbeHandlers();
probe_handlers.removeIf(probe_handler -> {
String[] keys = probe_handler.supportedKeys();
return keys != null && Stream.of(keys).anyMatch(s -> s.startsWith("jmx"));
});
}
transport.registerProbeHandler(h);
local_addr = channel.getAddress();
if (members.size() < 2)
return;
Address coord = members.get(0);
Config config = disp.callRemoteMethod(coord, new CustomCall(GET_CONFIG), new RequestOptions(ResponseMode.GET_ALL, 5000));
if (config != null) {
applyConfig(config);
System.out.println("Fetched config from " + coord + ": " + config + "\n");
} else
System.err.println("failed to fetch config from " + coord);
}
use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class RpcDispatcherSpeedTest method invokeRpcs.
protected void invokeRpcs() throws Exception {
Average avg = new Average();
long min = Long.MAX_VALUE, max = 0;
RequestOptions opts = new RequestOptions(ResponseMode.GET_FIRST, 0).transientFlags(Message.TransientFlag.DONT_LOOPBACK);
MethodCall call = new MethodCall((short) 0);
int print = num / 10;
if (oob)
opts.flags(Message.Flag.OOB);
if (dont_bundle)
opts.flags(Message.Flag.DONT_BUNDLE);
if (channel.getView().size() != 2) {
System.err.printf("Cluster must have exactly 2 members: %s\n", channel.getView());
return;
}
System.out.printf("\nInvoking %d blocking RPCs (oob: %b, dont_bundle: %b)\n", num, oob, dont_bundle);
for (int i = 0; i < num; i++) {
long start = System.nanoTime();
RspList<Void> rsps = disp.callRemoteMethods(null, call, opts);
long time_ns = System.nanoTime() - start;
if (i > 0 && i % print == 0)
System.out.print(".");
boolean all_received = rsps.values().stream().allMatch(Rsp::wasReceived);
if (!all_received)
System.err.printf("didn't receive all responses: %s\n", rsps);
avg.add(time_ns);
min = Math.min(min, time_ns);
max = Math.max(max, time_ns);
}
System.out.println("");
System.out.printf("\nround-trip = min/avg/max: %.2f / %.2f / %.2f us\n\n", min / 1000.0, avg.getAverage() / 1000.0, max / 1000.0);
}
Aggregations