use of org.jgroups.protocols.DISCARD in project JGroups by belaban.
the class LastMessageDroppedTest method testLastMessageDropped.
public void testLastMessageDropped() throws Exception {
DISCARD discard = new DISCARD();
a.getProtocolStack().insertProtocol(discard, ProtocolStack.Position.BELOW, NAKACK2.class);
MyReceiver receiver = new MyReceiver();
b.setReceiver(receiver);
a.send(null, 1);
a.send(null, 2);
// drop the next multicast
discard.dropDownMulticasts(1);
a.send(null, 3);
Collection<Integer> list = receiver.getMsgs();
for (int i = 0; i < 20 && list.size() < 3; i++) {
System.out.println("list=" + list);
Util.sleep(1000);
}
System.out.println("list=" + list);
assert list.size() == 3 : "list=" + list;
}
use of org.jgroups.protocols.DISCARD in project JGroups by belaban.
the class OOBTest method testRegularAndOOBMulticasts.
public void testRegularAndOOBMulticasts() throws Exception {
DISCARD discard = new DISCARD();
ProtocolStack stack = a.getProtocolStack();
stack.insertProtocol(discard, ProtocolStack.Position.BELOW, NAKACK2.class);
a.setDiscardOwnMessages(true);
// send to all
Address dest = null;
Message m1 = new BytesMessage(dest, 1);
Message m2 = new BytesMessage(dest, 2).setFlag(Message.Flag.OOB);
Message m3 = new BytesMessage(dest, 3);
MyReceiver receiver = new MyReceiver("B");
b.setReceiver(receiver);
a.send(m1);
discard.dropDownMulticasts(1);
a.send(m2);
a.send(m3);
Util.sleep(500);
Collection<Integer> list = receiver.getMsgs();
for (int i = 0; i < 10; i++) {
System.out.println("list = " + list);
if (list.size() == 3)
break;
// give the asynchronous msgs some time to be received
Util.sleep(1000);
sendStableMessages(a, b);
}
assert list.size() == 3 : "list is " + list;
assert list.contains(1) && list.contains(2) && list.contains(3);
}
use of org.jgroups.protocols.DISCARD in project JGroups by belaban.
the class OOBTest method testRegularAndOOBUnicasts2.
public void testRegularAndOOBUnicasts2() throws Exception {
DISCARD discard = new DISCARD();
ProtocolStack stack = a.getProtocolStack();
stack.insertProtocol(discard, ProtocolStack.Position.BELOW, Util.getUnicastProtocols());
Address dest = b.getAddress();
Message m1 = new BytesMessage(dest, 1);
Message m2 = new BytesMessage(dest, 2).setFlag(Message.Flag.OOB);
Message m3 = new BytesMessage(dest, 3).setFlag(Message.Flag.OOB);
Message m4 = new BytesMessage(dest, 4);
MyReceiver receiver = new MyReceiver("B");
b.setReceiver(receiver);
a.send(m1);
discard.dropDownUnicasts(2);
// dropped
a.send(m2);
// dropped
a.send(m3);
a.send(m4);
Collection<Integer> list = receiver.getMsgs();
int count = 10;
while (list.size() < 4 && --count > 0) {
// time for potential retransmission
Util.sleep(500);
sendStableMessages(a, b);
}
System.out.println("list = " + list);
assert list.size() == 4 : "list is " + list;
assert list.contains(1) && list.contains(2) && list.contains(3) && list.contains(4);
}
use of org.jgroups.protocols.DISCARD in project JGroups by belaban.
the class OOBTest method testRandomRegularAndOOBMulticasts.
@Test(invocationCount = 5)
public void testRandomRegularAndOOBMulticasts() throws Exception {
DISCARD discard = new DISCARD().setAddress(a.getAddress()).setUpDiscardRate(0.5);
ProtocolStack stack = a.getProtocolStack();
stack.insertProtocol(discard, ProtocolStack.Position.ABOVE, TP.class);
MyReceiver r1 = new MyReceiver("A"), r2 = new MyReceiver("B");
a.setReceiver(r1);
b.setReceiver(r2);
final int NUM_MSGS = 20;
final int NUM_THREADS = 10;
// send on random channel (a or b)
send(null, NUM_MSGS, NUM_THREADS, 0.5);
discard.setUpDiscardRate(0.1);
Collection<Integer> one = r1.getMsgs(), two = r2.getMsgs();
for (int i = 0; i < 30; i++) {
if (one.size() == NUM_MSGS && two.size() == NUM_MSGS)
break;
System.out.println("A: size=" + one.size() + ", B: size=" + two.size());
sendStableMessages(a, b);
Util.sleep(1000);
}
System.out.println("A: size=" + one.size() + ", B: size=" + two.size());
stack.removeProtocol(DISCARD.class);
System.out.println("A received " + one.size() + " messages (" + NUM_MSGS + " expected)" + "\nB received " + two.size() + " messages (" + NUM_MSGS + " expected)");
check(NUM_MSGS, one, "A");
check(NUM_MSGS, two, "B");
}
use of org.jgroups.protocols.DISCARD in project JGroups by belaban.
the class MergeTest2 method createChannel.
protected JChannel createChannel(String name) throws Exception {
SHARED_LOOPBACK shared_loopback = new SHARED_LOOPBACK();
shared_loopback.setDiagnosticsHandler(handler);
JChannel retval = new JChannel(shared_loopback, new DISCARD().setValue("discard_all", true), new SHARED_LOOPBACK_PING(), new NAKACK2().setValue("use_mcast_xmit", false).setValue("log_discard_msgs", false).setValue("log_not_found_msgs", false), new UNICAST3(), new STABLE().setValue("max_bytes", 50000), new GMS().setValue("print_local_addr", false).setValue("leave_timeout", 100).setValue("merge_timeout", 3000).setValue("log_view_warnings", false).setValue("view_ack_collection_timeout", 50).setValue("log_collect_msgs", false));
retval.setName(name);
JmxConfigurator.registerChannel(retval, Util.getMBeanServer(), name, retval.getClusterName(), true);
retval.connect("MergeTest2");
return retval;
}
Aggregations