use of org.jgroups.stack.NonReflectiveProbeHandler in project JGroups by belaban.
the class ProgrammaticUPerf method init.
public void init(String name, AddressGenerator generator, String bind_addr, int bind_port, boolean udp, String mcast_addr, int mcast_port, String initial_hosts) throws Throwable {
InetAddress bind_address = bind_addr != null ? Util.getAddress(bind_addr, Util.getIpStackType()) : Util.getLoopback();
Protocol[] prot_stack = { // transport
null, // discovery protocol
null, new MERGE3(), new FD_SOCK(), new FD_ALL3(), new VERIFY_SUSPECT(), new NAKACK2(), new UNICAST3(), new STABLE(), new GMS().setJoinTimeout(1000), new UFC(), new MFC(), new FRAG4() };
if (udp) {
UDP u = new UDP().setMulticastAddress(InetAddress.getByName(mcast_addr)).setMulticastPort(mcast_port);
u.getDiagnosticsHandler().setMcastAddress(InetAddress.getByName("224.0.75.75")).enableUdp(true);
prot_stack[0] = u;
prot_stack[1] = new PING();
} else {
if (initial_hosts == null) {
InetAddress host = bind_addr == null ? InetAddress.getLocalHost() : Util.getAddress(bind_addr, Util.getIpStackType());
initial_hosts = String.format("%s[%d]", host.getHostAddress(), bind_port);
}
TCP tcp = new TCP();
tcp.getDiagnosticsHandler().enableUdp(false).enableTcp(true);
prot_stack[0] = tcp;
prot_stack[1] = new TCPPING().setInitialHosts2(Util.parseCommaDelimitedHosts(initial_hosts, 2));
}
((TP) prot_stack[0]).setBindAddress(bind_address).setBindPort(bind_port);
channel = new JChannel(prot_stack).addAddressGenerator(generator).setName(name);
TP transport = channel.getProtocolStack().getTransport();
// todo: remove default ProbeHandler for "jmx" and "op"
NonReflectiveProbeHandler h = new NonReflectiveProbeHandler(channel);
transport.registerProbeHandler(h);
h.initialize(channel.getProtocolStack().getProtocols());
// System.out.printf("contents:\n%s\n", h.dump());
disp = new RpcDispatcher(channel, this).setReceiver(this).setMethodInvoker(this);
channel.connect(groupname);
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);
}
Aggregations