use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class ForkChannelTest method testRefcount2.
public void testRefcount2() throws Exception {
Prot p1 = new Prot("P1"), p2 = new Prot("P2");
fc1 = new ForkChannel(a, "stack", "fc1", p1, p2);
// uses p1 and p2 from fc1
fc2 = new ForkChannel(a, "stack", "fc2");
// uses p1 and p2 from fc1
fc3 = new ForkChannel(a, "stack", "fc3");
assert p1.inits == 1 && p2.inits == 1;
FORK fork = a.getProtocolStack().findProtocol(FORK.class);
Protocol prot = fork.get("stack");
ForkProtocolStack fork_stack = (ForkProtocolStack) getProtStack(prot);
int inits = fork_stack.getInits();
assert inits == 3;
a.connect(CLUSTER);
fc1.connect(CLUSTER);
int connects = fork_stack.getConnects();
assert connects == 1;
assert p1.starts == 1 && p2.starts == 1;
fc2.connect(CLUSTER);
fc3.connect(CLUSTER);
connects = fork_stack.getConnects();
assert connects == 3;
assert p1.starts == 1 && p2.starts == 1;
fc3.disconnect();
fc2.disconnect();
assert p1.starts == 1 && p2.starts == 1;
assert p1.stops == 0 && p2.stops == 0;
fc1.disconnect();
assert p1.starts == 1 && p2.starts == 1;
assert p1.stops == 1 && p2.stops == 1;
Util.close(fc3, fc2);
assert p1.destroys == 0 && p2.destroys == 0;
Util.close(fc1);
assert p1.destroys == 1 && p2.destroys == 1;
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class FrozenCoordinatorTest method create.
protected JChannel create(String name) throws Exception {
FILE_PING ping = new FILE_PING().setLocation(root_dir.toString()).removeAllDataOnViewChange(true);
Protocol[] protocols = { new SHARED_LOOPBACK(), ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS().setJoinTimeout(1000).setMaxJoinAttempts(5) };
return new JChannel(protocols).name(name);
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class InetAddressChecksTest method testIPVersionCheckingConsistentVersion.
/*
* Checks IP version mechanism for consistent version processing
*/
public void testIPVersionCheckingConsistentVersion() throws Exception {
List<ProtocolConfiguration> protocol_configs = new ArrayList<>();
List<Protocol> protocols = new ArrayList<>();
// create the layer described by IPCHECK
protocol = Configurator.createProtocol(ipCheckConsistentProps, stack);
// process the defaults
protocol_configs.add(new ProtocolConfiguration(ipCheckConsistentProps));
protocols.add(protocol);
Map<String, Map<String, InetAddressInfo>> inetAddressMap = null;
inetAddressMap = Configurator.createInetAddressMap(protocol_configs, protocols);
Collection<InetAddress> addrs = Configurator.getAddresses(inetAddressMap);
determineIpVersionFromAddresses(addrs);
// get the value which should have been assigned a default
InetAddress a = ((IPCHECK) protocol).getInetAddress1();
System.out.println("value of inetAddress1 = " + a);
InetAddress b = ((IPCHECK) protocol).getInetAddress2();
System.out.println("value of inetAddress2 = " + b);
InetAddress c = ((IPCHECK) protocol).getInetAddress3();
System.out.println("value of inetAddress3 = " + c);
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class MergeTest6 method testViewInconsistency.
/**
* Tests whether the following scenario is successfully healed by {@link MERGE3}:
* <pre>
* - (2 left)
* - 3: 3|6 -> {3,4,5,6,7}
* - 4: 3|6 -> {3,4,5,6,7}
* - 5: 3|6 -> {3,4,5,6,7}
* - 6: 3|6 -> {3,4,5,6,7}
* - 7: 2|5 -> {2,3,4,5,6,7}
* </pre>
* In this case, 7 and 3 should become merge coordinators and establish a MergeView
*/
public void testViewInconsistency() throws Exception {
System.out.println("Initial view:\n");
for (JChannel ch : Arrays.asList(two, three, four, five, six, seven)) System.out.printf("%s: %s\n", ch.getAddress(), ch.getView());
ProtocolStack stack = seven.getProtocolStack();
Protocol drop_view = new DropView().setAddress(seven.getAddress());
// GMS.class);
stack.insertProtocol(drop_view, ProtocolStack.Position.BELOW, NAKACK2.class);
Util.close(two);
for (int i = 0; i < 10; i++) {
View view_3 = three.getView();
boolean same = true;
for (JChannel ch : Arrays.asList(four, five, six)) {
if (!ch.getView().equals(view_3)) {
same = false;
break;
}
}
if (same)
break;
Util.sleep(500);
}
View view_3 = three.getView();
assert Stream.of(four, five, six).allMatch(ch -> ch.getView().equals(view_3)) : Stream.of(four, five, six).map(JChannel::getView).collect(Collectors.toList());
assert !view_3.equals(seven.getView());
System.out.println("Views after member 7 dropped view");
Stream.of(three, four, five, six, seven).forEach(ch -> System.out.printf("%s: %s\n", ch.getAddress(), ch.getView()));
stack.removeProtocol(drop_view);
System.out.println("-- waiting for merge to heal partition");
Util.waitUntilAllChannelsHaveSameView(1500000, 1000, three, four, five, six, seven);
Stream.of(three, four, five, six, seven).forEach(ch -> System.out.printf("%s: %s\n", ch.getAddress(), ch.getView()));
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class VERIFY_SUSPECT_Test method testUnsuspect.
public void testUnsuspect() throws TimeoutException {
VERIFY_SUSPECT ver = new VERIFY_SUSPECT().setTimeout(1000);
ProtImpl impl = new ProtImpl();
ver.setUpProtocol(impl);
ver.setDownProtocol(new Protocol() {
public Object down(Event evt) {
return null;
}
public Object down(Message msg) {
return null;
}
public ThreadFactory getThreadFactory() {
return new DefaultThreadFactory("foo", false, true);
}
});
Map<Address, Long> map = impl.getMap();
start = System.currentTimeMillis();
ver.up(new Event(Event.SUSPECT, Collections.singletonList(a)));
ver.up(new Event(Event.SUSPECT, Collections.singletonList(b)));
Util.waitUntil(10000, 500, () -> map.size() == 2);
ver.up(new Event(Event.SUSPECT, Collections.singletonList(a)));
ver.up(new Event(Event.SUSPECT, Collections.singletonList(b)));
ver.unsuspect(a);
Util.waitUntilTrue(10000, 500, () -> map.size() == 1);
assert map.size() == 1 && map.containsKey(b);
}
Aggregations