use of org.jgroups.protocols.DISCARD in project JGroups by belaban.
the class DiscardTest method _testLosslessReception.
private void _testLosslessReception(boolean discard) throws Exception {
long start, stop;
a = createChannel().name("A");
a.setReceiver(new MyReceiver(ch1_all_received, NUM_MSGS, "A"));
b = createChannel().name("B");
b.setReceiver(new MyReceiver(ch2_all_received, NUM_MSGS, "B"));
makeUnique(a, b);
a.connect(GROUP);
b.connect(GROUP);
Util.waitUntilAllChannelsHaveSameView(10000, 500, a, b);
if (discard) {
DISCARD discard_prot = new DISCARD();
Properties properties = new Properties();
properties.setProperty("down", "0.1");
a.getProtocolStack().insertProtocol(discard_prot, ProtocolStack.Position.BELOW, MERGE3.class);
discard_prot = new DISCARD();
properties = new Properties();
properties.setProperty("down", "0.1");
b.getProtocolStack().insertProtocol(discard_prot, ProtocolStack.Position.BELOW, MERGE3.class);
}
System.out.printf("sending %d %d-byte messages to all members (including myself)\n", NUM_MSGS, MSG_SIZE);
start = System.currentTimeMillis();
for (int i = 0; i < NUM_MSGS; i++) {
Message msg = createMessage(MSG_SIZE);
a.send(msg);
if (i % 1000 == 0)
System.out.println("-- sent " + i + " messages");
}
System.out.println("-- waiting for ch1 and ch2 to receive " + NUM_MSGS + " messages");
Long num_msgs;
num_msgs = ch1_all_received.getResultWithTimeout(10000);
System.out.println("-- received " + num_msgs + " messages on ch1");
num_msgs = ch2_all_received.getResultWithTimeout(10000);
stop = System.currentTimeMillis();
System.out.println("-- received " + num_msgs + " messages on ch2");
long diff = stop - start;
double msgs_sec = NUM_MSGS / (diff / 1000.0);
System.out.printf("== Sent and received %d in %d ms, %.2f msgs/sec\n", NUM_MSGS, diff, msgs_sec);
}
Aggregations