use of org.jgroups.util.MutableDigest in project JGroups by belaban.
the class MergeTest4 method testMergeWithAsymetricViewsCoordIsolated.
public void testMergeWithAsymetricViewsCoordIsolated() throws Exception {
// Isolate the coord
Address coord = a.getView().getCreator();
System.out.println("Isolating coord: " + coord);
List<Address> members = new ArrayList<>();
members.add(coord);
View coord_view = new View(coord, 4, members);
System.out.println("coord_view: " + coord_view);
JChannel coord_channel = findChannel(coord);
System.out.println("coord_channel: " + coord_channel.getAddress());
MutableDigest digest = new MutableDigest(coord_view.getMembersRaw());
NAKACK2 nakack = coord_channel.getProtocolStack().findProtocol(NAKACK2.class);
digest.merge(nakack.getDigest(coord));
GMS gms = coord_channel.getProtocolStack().findProtocol(GMS.class);
gms.installView(coord_view, digest);
System.out.println("gms.getView() " + gms.getView());
System.out.println("Views are:");
for (JChannel ch : Arrays.asList(a, b, c, d)) System.out.println(ch.getAddress() + ": " + ch.getView());
JChannel merge_leader = findChannel(coord);
MyReceiver receiver = new MyReceiver();
merge_leader.setReceiver(receiver);
System.out.println("merge_leader: " + merge_leader.getAddressAsString());
System.out.println("Injecting MERGE event into merge leader " + merge_leader.getAddress());
Map<Address, View> merge_views = new HashMap<>(4);
merge_views.put(a.getAddress(), a.getView());
merge_views.put(b.getAddress(), b.getView());
merge_views.put(c.getAddress(), c.getView());
merge_views.put(d.getAddress(), d.getView());
gms = merge_leader.getProtocolStack().findProtocol(GMS.class);
gms.up(new Event(Event.MERGE, merge_views));
Util.waitUntilAllChannelsHaveSameView(10000, 1000, a, b, c, d);
System.out.println("Views are:");
for (JChannel ch : Arrays.asList(a, b, c, d)) {
View view = ch.getView();
System.out.println(ch.getAddress() + ": " + view);
assert view.size() == 4;
}
MergeView merge_view = receiver.getView();
System.out.println("merge_view = " + merge_view);
assert merge_view.size() == 4;
assert merge_view.getSubgroups().size() == 2;
for (View view : merge_view.getSubgroups()) assert contains(view, a.getAddress()) || contains(view, b.getAddress(), c.getAddress(), d.getAddress());
}
use of org.jgroups.util.MutableDigest in project JGroups by belaban.
the class DigestTest method testAllSet.
public void testAllSet() {
Address[] mbrs = Util.createRandomAddresses(5);
MutableDigest dig = new MutableDigest(mbrs);
assert !dig.allSet();
for (int index : Arrays.asList(1, 3, 4)) dig.set(mbrs[index], index, index + 1);
System.out.println("dig = " + dig);
assert !dig.allSet();
Address[] non_set = dig.getNonSetMembers();
System.out.println("non_set = " + Arrays.toString(non_set));
assert non_set != null && non_set.length == 2;
Assert.assertEquals(non_set, new Address[] { mbrs[0], mbrs[2] });
for (int index : Arrays.asList(0, 2)) dig.set(mbrs[index], index, index + 1);
System.out.println("dig = " + dig);
assert dig.allSet();
non_set = dig.getNonSetMembers();
assert non_set.length == 0;
dig = new MutableDigest(members);
assert !dig.allSet();
non_set = dig.getNonSetMembers();
Assert.assertEquals(non_set, members);
dig.set(d);
System.out.println("dig = " + dig);
assert dig.allSet();
non_set = dig.getNonSetMembers();
assert non_set.length == 0;
}
use of org.jgroups.util.MutableDigest in project JGroups by belaban.
the class DigestTest method testContainsAll.
public void testContainsAll() {
MutableDigest digest = new MutableDigest(members);
digest.set(a1, 1, 1);
digest.set(a2, 1, 1);
assert digest.containsAll(a1, a2, a3);
digest.set(a3, 1, 1);
assert digest.containsAll(a1, a2, a3);
assert d.containsAll(a1, a2, a3);
}
use of org.jgroups.util.MutableDigest in project JGroups by belaban.
the class DigestTest method testSetDigest2.
public void testSetDigest2() {
MutableDigest tmp = new MutableDigest(members);
// ignored as view doesn't include this member
tmp.set(Util.createRandomAddress(), 2, 3);
// ditto
tmp.set(Util.createRandomAddress(), 2, 3);
tmp.set(a2, 2, 3);
tmp.set(a3, 2, 3);
md.set(tmp);
Assert.assertEquals(md.capacity(), 3);
}
use of org.jgroups.util.MutableDigest in project JGroups by belaban.
the class DigestTest method testReplace.
public void testReplace() {
MutableDigest digest = new MutableDigest(members);
digest.set(a1, 1, 1);
digest.set(a2, 2, 2);
md.set(digest);
assert digest.equals(md);
}
Aggregations