Search in sources :

Example 1 with EmptyMessage

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;
}
Also used : BytesMessage(org.jgroups.BytesMessage) Message(org.jgroups.Message) EmptyMessage(org.jgroups.EmptyMessage) EmptyMessage(org.jgroups.EmptyMessage)

Example 2 with EmptyMessage

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);
}
Also used : Message(org.jgroups.Message) EmptyMessage(org.jgroups.EmptyMessage) EmptyMessage(org.jgroups.EmptyMessage)

Example 3 with EmptyMessage

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);
}
Also used : Message(org.jgroups.Message) EmptyMessage(org.jgroups.EmptyMessage) EmptyMessage(org.jgroups.EmptyMessage)

Example 4 with EmptyMessage

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;
    });
}
Also used : BytesMessage(org.jgroups.BytesMessage) Message(org.jgroups.Message) EmptyMessage(org.jgroups.EmptyMessage) RingBufferBundlerLockless(org.jgroups.protocols.RingBufferBundlerLockless) EmptyMessage(org.jgroups.EmptyMessage)

Example 5 with EmptyMessage

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;
}
Also used : BytesMessage(org.jgroups.BytesMessage) Message(org.jgroups.Message) EmptyMessage(org.jgroups.EmptyMessage) EmptyMessage(org.jgroups.EmptyMessage)

Aggregations

EmptyMessage (org.jgroups.EmptyMessage)5 Message (org.jgroups.Message)5 BytesMessage (org.jgroups.BytesMessage)3 RingBufferBundlerLockless (org.jgroups.protocols.RingBufferBundlerLockless)1