use of org.jgroups.Message in project JGroups by belaban.
the class MessageTest method testFlags3.
public static void testFlags3() {
Message msg = new Message();
assert !msg.isFlagSet(Message.Flag.OOB);
msg.setFlag(Message.Flag.OOB);
assert msg.isFlagSet(Message.Flag.OOB);
msg.setFlag(Message.Flag.OOB);
assert msg.isFlagSet(Message.Flag.OOB);
}
use of org.jgroups.Message in project JGroups by belaban.
the class MessageTest method testFlags2.
public static void testFlags2() {
Message m1 = new Message();
m1.setFlag(Message.Flag.OOB);
assert m1.isFlagSet(Message.Flag.OOB);
assert Message.isFlagSet(m1.getFlags(), Message.Flag.OOB);
assert !(m1.isFlagSet(Message.Flag.DONT_BUNDLE));
assert !Message.isFlagSet(m1.getFlags(), Message.Flag.DONT_BUNDLE);
}
use of org.jgroups.Message in project JGroups by belaban.
the class RSVPTest method testSynchronousUnicastSend.
public void testSynchronousUnicastSend() throws Exception {
// test with a unicast message:
short value = (short) Math.abs((short) Util.random(10000));
Message msg = new Message(channels[1].getAddress(), value).setFlag(Message.Flag.RSVP);
DISCARD discard = channels[0].getProtocolStack().findProtocol(DISCARD.class);
discard.setDropDownUnicasts(1);
long start = System.currentTimeMillis();
channels[0].send(msg);
long diff = System.currentTimeMillis() - start;
System.out.println("sending took " + diff + " ms");
// UNICAST3 retransmission will resend the message *not* RSVP
for (int i = 0; i < 20; i++) {
if (receivers[1].getValue() == value)
break;
Util.sleep(500);
}
long tmp_value = receivers[1].getValue();
assert tmp_value == value : "value is " + tmp_value + ", but should be " + value;
}
use of org.jgroups.Message in project JGroups by belaban.
the class RSVPTest method testAsyncLostRSVPMessages.
/**
* Tests that async RSVP tasks that are lost are removed after timeout ms
*/
public void testAsyncLostRSVPMessages() throws Exception {
// test with a multicast message:
short value = (short) Math.abs((short) Util.random(10000));
Message msg = new Message(null, value).setFlag(Message.Flag.RSVP_NB);
DISCARD discard = channels[0].getProtocolStack().findProtocol(DISCARD.class);
discard.setDiscardAll(true);
RSVP rsvp = channels[0].getProtocolStack().findProtocol(RSVP.class);
rsvp.setValue("timeout", 2000).setValue("resend_interval", 200);
channels[0].send(msg);
assert rsvp.getPendingRsvpRequests() == 1;
for (int i = 0; i < 10; i++) {
if (rsvp.getPendingRsvpRequests() == 0)
break;
Util.sleep(1000);
}
assert rsvp.getPendingRsvpRequests() == 0;
}
use of org.jgroups.Message in project JGroups by belaban.
the class MessageBatchTest method testRemove.
public void testRemove() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
int prev_size = batch.size();
remove(batch, 1, 4);
System.out.println("batch = " + batch);
assert batch.size() == prev_size - 2;
batch.clear();
System.out.println("batch = " + batch);
assert batch.isEmpty();
msgs.forEach(batch::add);
System.out.println("batch = " + batch);
assert batch.size() == prev_size;
assert batch.capacity() == prev_size;
}
Aggregations