use of org.jgroups.EmptyMessage in project JGroups by belaban.
the class TableTest method createMessageBatch.
protected static MessageBatch createMessageBatch(long... seqnos) {
if (seqnos == null)
return null;
MessageBatch mb = new MessageBatch(seqnos.length);
for (long seqno : seqnos) {
Message m = new EmptyMessage().putHeader(NAKACK2_ID, NakAckHeader2.createMessageHeader(seqno));
mb.add(m);
}
return mb;
}
use of org.jgroups.EmptyMessage in project JGroups by belaban.
the class GmsImpl method sendMergeRejectedResponse.
protected void sendMergeRejectedResponse(Address sender, MergeId merge_id) {
Message msg = new EmptyMessage(sender).setFlag(Message.Flag.OOB);
GMS.GmsHeader hdr = new GMS.GmsHeader(GMS.GmsHeader.MERGE_RSP);
hdr.merge_rejected = true;
hdr.merge_id = merge_id;
msg.putHeader(gms.getId(), hdr);
log.debug("%s: merge response=%s", gms.getAddress(), hdr);
gms.getDownProtocol().down(msg);
}
use of org.jgroups.EmptyMessage in project JGroups by belaban.
the class Leaver method sendLeaveRequest.
protected void sendLeaveRequest(Address coord, Address leaving_mbr) {
Message msg = new EmptyMessage(coord).setFlag(Message.Flag.OOB).putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.LEAVE_REQ, leaving_mbr));
gms.getDownProtocol().down(msg);
}
use of org.jgroups.EmptyMessage in project JGroups by belaban.
the class RingBundlerTestLockless method testSendToMultipleDestinations.
public void testSendToMultipleDestinations() throws Exception {
RingBufferBundlerLockless bundler = new RingBufferBundlerLockless(16);
RingBundlerTest.MockTransport transport = new RingBundlerTest.MockTransport();
bundler.init(transport);
for (int i = 0; i < 6; i++) bundler.send(new EmptyMessage(null));
int cnt = bundler.size();
assert cnt == 6;
bundler._readMessages();
System.out.println("bundler = " + bundler);
assert bundler.readIndex() == 6;
assert bundler.writeIndex() == 6;
assert bundler.size() == 0;
assert transport.map.get(null) == 1;
transport.map.clear();
for (Message msg : create(10000, null, a, a, a, b, c, d, d, a, null, null, a)) bundler.send(msg);
System.out.println("bundler = " + bundler);
cnt = bundler.size();
assert cnt == 12;
assert bundler.readIndex() == 6;
assert bundler.writeIndex() == 2;
bundler._readMessages();
assert bundler.readIndex() == 2;
assert bundler.writeIndex() == 2;
assert bundler.size() == 0;
Stream.of(null, a, b, c, d).forEach(msg -> {
assert transport.map.get(msg) == 1;
});
}
use of org.jgroups.EmptyMessage in project JGroups by belaban.
the class TableTest method testAddMessageBatchWithConstValue.
public void testAddMessageBatchWithConstValue() {
Table<Message> buf = new Table<>(3, 10, 0);
MessageBatch mb = createMessageBatch(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
final Message DUMMY = new EmptyMessage();
boolean rc = buf.add(mb, SEQNO_GETTER, false, DUMMY);
System.out.println("buf = " + buf);
assert rc;
assert buf.size() == 10;
List<Message> list = buf.removeMany(true, 0, element -> element.hashCode() == DUMMY.hashCode());
System.out.println("list = " + list);
assert list.size() == 10;
for (Message msg : list) assert msg == DUMMY;
}
Aggregations