JChannel c1=new JChannel(use_flush_props? getFlushProps() : getProps()).name("A");
try {
c1.connect(cluster_name);
Message merge_request=new Message()
.putHeader(GMS_ID, new GMS.GmsHeader(GMS.GmsHeader.MERGE_REQ).mergeId(MergeId.create(c1.getAddress())));
GMS gms=(GMS)c1.getProtocolStack().findProtocol(GMS.class);
gms.setMergeTimeout(2000);
MergeId merge_id=gms._getMergeId();
assert merge_id == null;
System.out.println("starting merge");
gms.up(new Event(Event.MSG, merge_request));
long timeout=gms.getMergeTimeout() * 10;
System.out.println("sleeping for " + timeout + " ms, then fetching merge_id: should be null (cancelled by the MergeCanceller)");
long target_time=System.currentTimeMillis() + timeout;
while(System.currentTimeMillis() < target_time) {
merge_id=gms._getMergeId();
if(merge_id == null)
break;
Util.sleep(500);
}
merge_id=gms._getMergeId();
System.out.println("merge_id = " + merge_id);
assert merge_id == null : "MergeCanceller didn't kick in";
}
finally {
Util.close(c1);