Search in sources :

Example 56 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageBatchTest method testAddBatchNoResizeOK.

public void testAddBatchNoResizeOK() {
    MessageBatch batch = new MessageBatch(16);
    List<Message> msgs = createMessages();
    MessageBatch other = new MessageBatch(3);
    msgs.forEach(other::add);
    assert other.size() == msgs.size();
    assert batch.isEmpty();
    int added = batch.add(other, false);
    assert added == other.size();
    assert batch.size() == msgs.size() && batch.capacity() == 16;
    assert other.size() == msgs.size();
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Example 57 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageBatchTest method testAddBatchNoResizeFail.

public void testAddBatchNoResizeFail() {
    MessageBatch batch = new MessageBatch(3);
    List<Message> msgs = createMessages();
    MessageBatch other = new MessageBatch(3);
    msgs.forEach(other::add);
    assert other.size() == msgs.size();
    assert batch.isEmpty();
    int added = batch.add(other, false);
    assert added == batch.size();
    assert batch.size() == 3 && batch.capacity() == 3;
    assert other.size() == msgs.size();
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Example 58 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class ClientGmsImpl method sendJoinMessage.

void sendJoinMessage(Address coord, Address mbr, boolean joinWithTransfer, boolean useFlushIfPresent) {
    byte type = joinWithTransfer ? GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER : GMS.GmsHeader.JOIN_REQ;
    GMS.GmsHeader hdr = new GMS.GmsHeader(type, mbr, useFlushIfPresent);
    Message msg = new Message(coord).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL).putHeader(gms.getId(), hdr);
    gms.getDownProtocol().down(msg);
}
Also used : Message(org.jgroups.Message)

Example 59 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class CoordGmsImpl method sendLeaveResponses.

private void sendLeaveResponses(Collection<Address> leaving_members) {
    for (Address address : leaving_members) {
        Message msg = new Message(address).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL, Message.Flag.NO_RELIABILITY).putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.LEAVE_RSP));
        log.trace("%s: sending LEAVE response to %s", gms.local_addr, address);
        gms.getDownProtocol().down(msg);
    }
}
Also used : Address(org.jgroups.Address) Message(org.jgroups.Message)

Example 60 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class TOA method handleDataMessage.

private void handleDataMessage(Message message, ToaHeader header) {
    final long startTime = statsCollector.now();
    try {
        final MessageID messageID = header.getMessageID();
        // create the sequence number and put it in deliver manager
        long myProposeSequenceNumber = deliverManager.addRemoteMessageToDeliver(messageID, message, header.getSequencerNumber(), header.getViewId());
        if (log.isTraceEnabled()) {
            log.trace("Received the message with %s. The proposed sequence number is %d", header, myProposeSequenceNumber);
        }
        if (myProposeSequenceNumber == -1) {
            // message discarded. not sending ack back.
            return;
        }
        // create a new message and send it back
        ToaHeader newHeader = ToaHeader.newProposeMessageHeader(messageID, myProposeSequenceNumber);
        Message proposeMessage = new Message().src(localAddress).dest(messageID.getAddress()).putHeader(this.id, newHeader).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE);
        // multicastSenderThread.addUnicastMessage(proposeMessage);
        down_prot.down(proposeMessage);
    } catch (Exception e) {
        logException("Exception caught while processing the data message " + header.getMessageID(), e);
    } finally {
        statsCollector.addDataMessageDuration(statsCollector.now() - startTime);
    }
}
Also used : Message(org.jgroups.Message)

Aggregations

Message (org.jgroups.Message)246 Address (org.jgroups.Address)50 MessageBatch (org.jgroups.util.MessageBatch)37 BytesMessage (org.jgroups.BytesMessage)31 NioMessage (org.jgroups.NioMessage)14 ObjectMessage (org.jgroups.ObjectMessage)14 EmptyMessage (org.jgroups.EmptyMessage)12 Test (org.testng.annotations.Test)12 Event (org.jgroups.Event)11 ToaHeader (org.jgroups.protocols.tom.ToaHeader)11 Test (org.junit.Test)11 IOException (java.io.IOException)8 JChannel (org.jgroups.JChannel)8 MessageID (org.jgroups.protocols.tom.MessageID)8 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)7 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)7 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)7 TimeoutException (java.util.concurrent.TimeoutException)6 Collectors (java.util.stream.Collectors)6 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)6