Class MessageBatch
java.lang.Object
org.jgroups.util.MessageBatch
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AsciiStringThe name of the cluster in which the message batch is sent, this is equivalent to TpHeader.cluster_nameprotected AddressThe destination address.The storage of the messages; removed messages have a null elementprotected MessageBatch.ModeWhether this message batch contains only OOB messages, or only regular messagesprotected booleanWhether all messages have dest == null (multicast) or notprotected AddressThe sender of the message batchprotected longFor benchmarking; may get removed without notice -
Constructor Summary
ConstructorsConstructorDescriptionMessageBatch(int capacity) MessageBatch(Collection<Message> msgs) MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, Collection<Message> msgs) MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, MessageBatch.Mode mode, int capacity) -
Method Summary
Modifier and TypeMethodDescriptionadd(Collection<Message> msgs) Adds message to this batch from a message arrayAdds a message to the tableAdds a message to the tableadd(MessageBatch batch) add(MessageBatch batch, boolean resize) Adds another batch to this onebooleanarray()Returns the underlying message array.intcapacity()clear()cluster(AsciiString name) clusterName(AsciiString name) dest()<T extends Message>
Tfirst()getDest()getMode()incr(int i) increment(int i) booleanisEmpty()booleaniterator()Iterator which iterates only over non-null messages, skipping null messagesIterates over all non-null message which match filter<T extends Message>
Tlast()intlength()Returns the total number of bytes of the message batch (by callingMessage.getLength()on all messages)mcast(boolean flag) mode()booleanmulticast(boolean flag) reset()resize(int new_capacity) sender()setClusterName(AsciiString name) intsize()Returns the number of non-null messagesstream()longtimestamp(long ts) toString()longReturns the size of the message batch (by callingMessage.size()on all messages)inttransferFrom(MessageBatch other, boolean clear) Transfers messages from other to this batch.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
dest
The destination address. Null if this is a multicast message batch, non-null if the batch is sent to a specific member -
sender
The sender of the message batch -
cluster_name
The name of the cluster in which the message batch is sent, this is equivalent to TpHeader.cluster_name -
messages
-
multicast
protected boolean multicastWhether all messages have dest == null (multicast) or not -
mode
Whether this message batch contains only OOB messages, or only regular messages -
timestamp
protected long timestampFor benchmarking; may get removed without notice
-
-
Constructor Details
-
MessageBatch
public MessageBatch() -
MessageBatch
public MessageBatch(int capacity) -
MessageBatch
-
MessageBatch
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, Collection<Message> msgs) -
MessageBatch
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, MessageBatch.Mode mode, int capacity)
-
-
Method Details
-
getDest
-
dest
-
setDest
-
dest
-
getSender
-
sender
-
setSender
-
sender
-
getClusterName
-
clusterName
-
setClusterName
-
clusterName
-
cluster
-
isMulticast
public boolean isMulticast() -
multicast
public boolean multicast() -
multicast
-
mcast
-
getMode
-
mode
-
setMode
-
mode
-
capacity
public int capacity() -
timestamp
public long timestamp() -
timestamp
-
increment
-
incr
-
array
-
first
-
last
-
add
-
add
Adds a message to the table- Parameters:
msg- the messageresize- whether or not to resize the table- Returns:
- always true if resize==true, else true if the message was added or false if not
-
add
Adds a message to the table- Parameters:
msg- the messageresize- whether or not to resize the table- Returns:
- always true if resize==true, else true if the message was added or false if not
-
add
-
add
Adds another batch to this one- Parameters:
batch- the batch to add to this batchresize- when true, this batch will be resized to accommodate the other batch- Returns:
- the number of messages from the other batch that were added successfully. Will always be batch.size() unless resize is false: in this case, the number of messages that were added successfully is returned
-
add
Adds message to this batch from a message array- Parameters:
msgs- the message arraynum_msgs- the number of messages to add, should be <= msgs.length
-
add
-
set
-
removeIf
-
transferFrom
Transfers messages from other to this batch. Optionally clears the other batch after the transfer- Parameters:
other- the other batchclear- If true, the transferred messages are removed from the other batch- Returns:
- the number of transferred messages (may be 0 if the other batch was empty)
-
clear
-
reset
-
anyMatch
-
determineMode
-
size
public int size()Returns the number of non-null messages -
isEmpty
public boolean isEmpty() -
totalSize
public long totalSize()Returns the size of the message batch (by callingMessage.size()on all messages) -
length
public int length()Returns the total number of bytes of the message batch (by callingMessage.getLength()on all messages) -
resize
-
iterator
-
iterator
-
stream
-
stream
-
stream
-
toString
-
printHeaders
-