use of org.jgroups.View in project JGroups by belaban.
the class FD_HOST method down.
public Object down(Event evt) {
switch(evt.getType()) {
case Event.VIEW_CHANGE:
View view = evt.getArg();
handleView(view);
break;
case Event.CONNECT:
case Event.CONNECT_USE_FLUSH:
case Event.CONNECT_WITH_STATE_TRANSFER:
case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH:
local_host = getHostFor(local_addr);
break;
case Event.DISCONNECT:
Object retval = down_prot.down(evt);
local_host = null;
return retval;
case Event.UNSUSPECT:
Address mbr = evt.getArg();
unsuspect(mbr);
break;
}
return down_prot.down(evt);
}
use of org.jgroups.View in project JGroups by belaban.
the class TCPGOSSIP_Test method testConnectThreeChannelsWithGRDown.
public void testConnectThreeChannelsWithGRDown() throws Exception {
JChannel third = null;
try {
coordinator = createTcpgossipChannel("A");
channel = createTcpgossipChannel("B");
coordinator.connect("testConnectThreeChannelsWithGRDown");
channel.connect("testConnectThreeChannelsWithGRDown");
// kill router
gossipRouter.stop();
// cannot discover others since GR is down
third = createTcpgossipChannel("C");
third.connect("testConnectThreeChannelsWithGRDown");
// restart and....
gossipRouter.start();
Util.waitUntilAllChannelsHaveSameView(60000, 1000, coordinator, channel, third);
// confirm they found each other
View view = channel.getView();
assert channel.getView().size() == 3;
assert third.getView().size() == 3;
assert view.containsMember(channel.getAddress());
assert view.containsMember(coordinator.getAddress());
} finally {
Util.close(third);
}
}
use of org.jgroups.View in project JGroups by belaban.
the class TCPGOSSIP_Test method testConnectThree.
public void testConnectThree() throws Exception {
JChannel third = null;
try {
coordinator = createTcpgossipChannel("A");
channel = createTcpgossipChannel("B");
coordinator.connect(GROUP);
channel.connect(GROUP);
third = createTcpgossipChannel("C");
third.connect(GROUP);
Util.waitUntilAllChannelsHaveSameView(10000, 500, coordinator, channel, third);
View view = channel.getView();
assert channel.getView().size() == 3 : String.format("expected view size of 3 but got %d: %s", channel.getView().size(), channel.getView());
assert third.getView().size() == 3;
assert view.containsMember(channel.getAddress());
assert view.containsMember(coordinator.getAddress());
} finally {
Util.close(third);
}
}
use of org.jgroups.View in project JGroups by belaban.
the class TCPGOSSIP_Test method testAddInitialHosts.
public void testAddInitialHosts() throws Exception {
coordinator = createTcpgossipChannel("A");
channel = createTcpgossipChannel("B");
coordinator.connect(GROUP);
channel.connect(GROUP);
TCPGOSSIP p = channel.getProtocolStack().findProtocol(TCPGOSSIP.class);
String tmp_bind_addr = bind_addr.getHostAddress();
assert p.removeInitialHost(tmp_bind_addr, gossip_router_port);
p.addInitialHost(tmp_bind_addr, gossip_router_port);
View view = channel.getView();
assert view.size() == 2;
assert view.containsMember(channel.getAddress());
assert view.containsMember(coordinator.getAddress());
}
use of org.jgroups.View in project JGroups by belaban.
the class ViewTest method testSameMembers.
public void testSameMembers() {
View one = View.create(a, 1, a, b, c, d, e);
View two = View.create(a, 2, a, b, c);
assert !View.sameMembers(one, two);
two = View.create(a, 20, a, b, c, d, e);
assert View.sameMembers(one, two);
assert View.sameMembers(two, one);
one = two;
assert View.sameMembers(one, two);
one = View.create(b, 5, a, b, c);
two = View.create(c, 5, b, a, c);
assert View.sameMembers(one, two);
two = View.create(c, 5, b, a, c, d);
assert !View.sameMembers(one, two);
one = View.create(b, 5, d, b, c, a);
two = View.create(c, 5, b, a, c);
assert !View.sameMembers(one, two);
assert !View.sameMembers(two, one);
}
Aggregations