use of org.jgroups.JChannel in project JGroups by belaban.
the class GossipRouterTest method createTunnelChannel.
protected JChannel createTunnelChannel(String name, boolean include_failure_detection) throws Exception {
TUNNEL tunnel = new TUNNEL().setValue("bind_addr", bind_addr).setValue("reconnect_interval", 1000);
tunnel.setGossipRouterHosts(gossip_router_hosts);
List<Protocol> protocols = new ArrayList<>();
protocols.addAll(Arrays.asList(tunnel, new PING(), new MERGE3().setValue("min_interval", 1000).setValue("max_interval", 3000)));
if (include_failure_detection) {
List<Protocol> tmp = new ArrayList<>(2);
tmp.add(new FD().setValue("timeout", 2000).setValue("max_tries", 2));
tmp.add(new VERIFY_SUSPECT());
protocols.addAll(tmp);
}
protocols.addAll(Arrays.asList(new NAKACK2().setValue("use_mcast_xmit", false), new UNICAST3(), new STABLE(), new GMS().joinTimeout(10)));
JChannel ch = new JChannel(protocols);
if (name != null)
ch.setName(name);
return ch;
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class LargeStateTransferTest method setThreadPoolSize.
private static void setThreadPoolSize(JChannel... channels) {
for (JChannel channel : channels) {
TP transport = channel.getProtocolStack().getTransport();
transport.setThreadPoolMinThreads(2);
transport.setThreadPoolMaxThreads(8);
}
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class INJECT_VIEWTest method testInjectView.
public static void testInjectView() throws Exception {
JChannel[] channels = null;
try {
channels = create(false, true, "testInjectView", "A", "B", "C");
print(channels);
View view = channels[channels.length - 1].getView();
assert view.size() == channels.length : "view is " + view;
String injectionViewString = "A=A/B;B=B/C;C=C";
System.out.println("\ninjecting views: " + injectionViewString);
for (JChannel channel : channels) {
channel.getProtocolStack().addProtocol(new INJECT_VIEW());
}
for (JChannel channel : channels) {
INJECT_VIEW iv = channel.getProtocolStack().findProtocol(INJECT_VIEW.class);
iv.injectView(injectionViewString);
}
System.out.println("\nInjected views: " + injectionViewString);
print(channels);
System.out.println("\nchecking views: ");
checkViews(channels, "A", "A", "B");
System.out.println("\nA is OK");
checkViews(channels, "B", "B", "C");
System.out.println("\nB is OK");
checkViews(channels, "C", "C");
System.out.println("\nC is OK");
System.out.println("\ndigests:");
printDigests(channels);
Address leader = determineLeader(channels, "A", "B", "C");
long end_time = System.currentTimeMillis() + 30000;
do {
System.out.println("\n==== injecting merge events into " + leader + " ====");
injectMergeEvent(channels, leader, "A", "B", "C");
Util.sleep(1000);
if (allChannelsHaveViewOf(channels, channels.length))
break;
} while (end_time > System.currentTimeMillis());
System.out.println("\n");
print(channels);
assertAllChannelsHaveViewOf(channels, channels.length);
System.out.println("\ndigests:");
printDigests(channels);
} finally {
System.out.println("closing channels");
close(channels);
System.out.println("done");
}
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class INJECT_VIEWTest method create.
private static JChannel[] create(boolean use_flush_props, boolean simple_ids, String cluster_name, String... names) throws Exception {
JChannel[] retval = new JChannel[names.length];
for (int i = 0; i < retval.length; i++) {
JChannel ch;
Protocol[] props = use_flush_props ? getFlushProps() : getProps();
if (simple_ids) {
ch = new MyChannel(props);
((MyChannel) ch).setId(i + 1);
} else
ch = new JChannel(props);
ch.setName(names[i]);
retval[i] = ch;
ch.connect(cluster_name);
if (i == 0)
Util.sleep(3000);
}
return retval;
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class SUPERVISOR_Test method assertFailureDetectorRunning.
protected void assertFailureDetectorRunning(JChannel... channels) {
for (JChannel ch : channels) {
System.out.print("Checking " + ch.getName() + ": ");
FD fd = (FD) ch.getProtocolStack().findProtocol(FD.class);
assert fd.isMonitorRunning();
System.out.println("running");
}
}
Aggregations