public void testMergeWithAsymetricViewsCoordIsolated() { // 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); Channel coord_channel = findChannel(coord); System.out.println("coord_channel: " + coord_channel.getAddress()); MutableDigest digest = new MutableDigest(coord_view.getMembersRaw()); NAKACK2 nakack = (NAKACK2) coord_channel.getProtocolStack().findProtocol(NAKACK2.class); digest.merge(nakack.getDigest(coord)); GMS 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 = (GMS) merge_leader.getProtocolStack().findProtocol(GMS.class); gms.up(new Event(Event.MERGE, merge_views)); Util.waitUntilAllChannelsHaveSameSize(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()); }
/** * Tests the scenario described by Dan in https://issues.jboss.org/browse/JGRP-1876; INFO messages * are injected */ public void testJGRP_1876_Dan2() throws Exception { Util.close(d, c, b, a); s = createChannel("S", false); t = createChannel("T", false); u = createChannel("U", false); v = createChannel("V", false); for (JChannel ch : Arrays.asList(s, t, u, v)) ch.getProtocolStack().removeProtocol(MERGE3.class); s.connect("MergeTest4"); t.connect("MergeTest4"); u.connect("MergeTest4"); v.connect("MergeTest4"); Util.waitUntilAllChannelsHaveSameSize(10000, 500, s, t, u, v); for (JChannel ch : Arrays.asList(s, t, u, v)) System.out.println(ch.getName() + ": " + ch.getView()); View v1 = View.create(s.getAddress(), 10, s.getAddress()); View v2 = View.create(t.getAddress(), 10, t.getAddress()); View v3 = View.create(u.getAddress(), 11, u.getAddress(), v.getAddress()); injectView(v1, s); injectView(v2, t); injectView(v3, u, v); Util.waitUntilAllChannelsHaveSameSize(10000, 500, s); Util.waitUntilAllChannelsHaveSameSize(10000, 500, t); Util.waitUntilAllChannelsHaveSameSize(10000, 500, u, v); System.out.printf("\nPartitions:\n"); for (JChannel ch : Arrays.asList(s, t, u, v)) System.out.println(ch.getName() + ": " + ch.getView()); System.out.println("\nInjecting MERGE events into GMS to merge subclusters"); Map<Address, View> different_views = new HashMap<>(); different_views.put(s.getAddress(), v1); different_views.put(t.getAddress(), v2); different_views.put(v.getAddress(), v3); Collection<Address> coords = Util.determineActualMergeCoords(different_views); Address merge_leader = new Membership().add(coords).sort().elementAt(0); System.out.printf("--> coords=%s, merge_leader=%s\n", coords, merge_leader); GMS gms = (GMS) findChannel(merge_leader).getProtocolStack().findProtocol(GMS.class); gms.up(new Event(Event.MERGE, different_views)); Util.waitUntilAllChannelsHaveSameSize(30000, 1000, s, t, u, v); System.out.println("\nResulting views:"); for (JChannel ch : Arrays.asList(s, t, u, v)) { gms = (GMS) ch.getProtocolStack().findProtocol(GMS.class); View mv = gms.view(); System.out.println(mv); } for (JChannel ch : Arrays.asList(s, t, u, v)) { gms = (GMS) ch.getProtocolStack().findProtocol(GMS.class); View mv = gms.view(); assert mv instanceof MergeView; assert mv.size() == 4; assert ((MergeView) mv).getSubgroups().size() == 3; } for (JChannel ch : Arrays.asList(s, t, u, v)) { View view = ch.getView(); assert view.size() == 4 : "view should have 4 members: " + view; } }