MergeId busy_merge_id=MergeId.create(a.getAddress());
setMergeIdIn(busy_first, busy_merge_id);
setMergeIdIn(busy_second, busy_merge_id);
for(JChannel ch: new JChannel[]{a,b,c,d,e,f}) { // excluding faulty member, as it still discards messages
assert ch.getView().size() == 3;
GMS gms=(GMS)ch.getProtocolStack().findProtocol(GMS.class);
gms.setJoinTimeout(3000);
DISCARD discard=(DISCARD)ch.getProtocolStack().findProtocol(DISCARD.class);
discard.setDiscardAll(false);
}
System.out.println("Injecting MERGE event into merge leader " + merge_leader.getAddress());
Map<Address,View> merge_views=new HashMap<Address,View>(6);
merge_views.put(first_coord, findChannel(first_coord).getView());
merge_views.put(second_coord, findChannel(second_coord).getView());
GMS gms=(GMS)merge_leader.getProtocolStack().findProtocol(GMS.class);
gms.up(new Event(Event.MERGE, merge_views));
for(int i=0; i < 20; i++) {
boolean done=true;
System.out.println();
for(JChannel ch: new JChannel[]{a,b,c,d,e,f}) {
System.out.println("==> " + ch.getAddress() + ": " + ch.getView());
Address addr=ch.getAddress();
if(addr.equals(busy_first) || addr.equals(busy_second)) {
if(ch.getView().size() != 3)
done=false;
}
else {
if(ch.getView().size() != 4)
done=false;
}
}
if(done)
break;
Util.sleep(1000);
}
for(JChannel ch: new JChannel[]{a,b,c,d,e,f}) {
if(ch.getAddress().equals(busy_first) || ch.getAddress().equals(busy_second))
assert ch.getView().size() == 3;
else
assert ch.getView().size() == 4 : ch.getAddress() + "'s view: " + ch.getView();
}
System.out.println("\n************************ Now merging the entire cluster ****************");
cancelMerge(busy_first);
cancelMerge(busy_second);
System.out.println("Injecting MERGE event into merge leader " + merge_leader.getAddress());
merge_views=new HashMap<Address,View>(6);
merge_views.put(merge_leader.getAddress(), merge_leader.getView());
merge_views.put(busy_first, findChannel(busy_first).getView());
merge_views.put(busy_second, findChannel(busy_second).getView());
System.out.println("merge event is " + merge_views);
gms=(GMS)merge_leader.getProtocolStack().findProtocol(GMS.class);
gms.up(new Event(Event.MERGE, merge_views));
for(int i=0; i < 20; i++) {
boolean done=true;
System.out.println();
for(JChannel ch: new JChannel[]{a,b,c,d,e,f}) {