use of org.jgroups.View in project JGroups by belaban.
the class ServerGmsImpl method handleViewChange.
/**
* Called by the GMS when a VIEW is received.
* @param view The view to be installed
* @param digest If view is a MergeView, the digest contains the seqnos of all members and has to be set by GMS
*/
public void handleViewChange(View view, Digest digest) {
if (gms.isLeaving() && !view.containsMember(gms.getAddress()))
return;
View prev_view = gms.view();
gms.installView(view, digest);
Address prev_coord = prev_view != null ? prev_view.getCoord() : null, curr_coord = view.getCoord();
if (!Objects.equals(curr_coord, prev_coord))
coordChanged(prev_coord, curr_coord);
}
use of org.jgroups.View in project JGroups by belaban.
the class TCPGOSSIP_Test method testDisconnectConnectTwo.
/**
* Tests connect-disconnect-connect sequence for a group with two members (using the default configuration).
*/
public void testDisconnectConnectTwo() throws Exception {
coordinator = createTcpgossipChannel("A");
channel = createTcpgossipChannel("B");
coordinator.connect(GROUP);
channel.connect("DisconnectTest.testgroup-1");
channel.disconnect();
channel.connect(GROUP);
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 TCPGOSSIP_Test method testConnectThreeChannelsWithGRAlreadyDown.
public void testConnectThreeChannelsWithGRAlreadyDown() throws Exception {
JChannel third = null;
try {
coordinator = createTcpgossipChannel("A");
channel = createTcpgossipChannel("B");
// kill router
gossipRouter.stop();
// cannot discover others since GR is down
coordinator.connect("testConnectThreeChannelsWithGRAlreadyDown");
channel.connect("testConnectThreeChannelsWithGRAlreadyDown");
third = createTcpgossipChannel("C");
third.connect("testConnectThreeChannelsWithGRAlreadyDown");
// 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 InfinispanStackMerge3Test method main.
public static void main(String[] args) throws Exception {
Map<String, List<Long>> results = new HashMap<>();
for (Supplier<TP> transport : TRANSPORTS) {
results.put(transport.get().getClass().getSimpleName(), new LinkedList<>());
for (int run = 0; run < RUNS; run++) {
JChannel[] channels = new JChannel[MEMBERS];
// Setup
for (int member = 0; member < MEMBERS; member++) channels[member] = createChannel(transport.get(), String.valueOf(member + 1));
Util.waitUntilAllChannelsHaveSameView(10_000, 500, channels);
System.out.printf("-- run #%d: cluster formed:\n%s\n", run + 1, printViews(channels));
// Partition
Stream.of(channels).forEach(channel -> {
GMS gms = channel.getProtocolStack().findProtocol(GMS.class);
View view = View.create(channel.getAddress(), gms.getViewId().getId() + 1, channel.getAddress());
gms.installView(view);
});
System.out.printf("-- injected partition (waiting for merge):\n%s\n", printViews(channels));
// Merge
long timeBeforeMerge = System.currentTimeMillis();
Util.waitUntilAllChannelsHaveSameView(360_000, 100, channels);
long timeAfterMerge = System.currentTimeMillis();
System.out.printf("-- run #%d: %s cluster merged in %d ms:\n%s\n", run + 1, transport.get().getClass().getSimpleName(), timeAfterMerge - timeBeforeMerge, printViews(channels));
// Cleanup
Stream.of(channels).forEach(JChannel::close);
results.get(transport.get().getClass().getSimpleName()).add(timeAfterMerge - timeBeforeMerge);
}
}
printStats(results);
}
use of org.jgroups.View in project JGroups by belaban.
the class ViewTest method testDiff3.
public void testDiff3() {
View one = View.create(a, 1, a, b, c, d, e);
View two = View.create(a, 2, a, b, c);
Address[][] diff = View.diff(one, two);
System.out.println("diffs: " + printDiff(diff));
Address[] joined = diff[0], left = diff[1];
assert joined.length == 0;
assert left.length == 2;
assert left[0].equals(d) && left[1].equals(e);
}
Aggregations