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();
}
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();
}
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);
}
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);
}
}
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);
}
}
Aggregations