限定符和类型 | 类和说明 |
---|---|
protected class |
MessageBatch.BatchIterator
Iterates over non-null elements of a batch, skipping null elements
|
static class |
MessageBatch.Mode |
static interface |
MessageBatch.Visitor<T>
Used for iteration over the messages
|
限定符和类型 | 字段和说明 |
---|---|
protected AsciiString |
cluster_name
The name of the cluster in which the message batch is sent, this is equivalent to TpHeader.cluster_name
|
protected Address |
dest
The destination address.
|
protected static int |
INCR |
protected int |
index
Index of the next message to be inserted
|
protected Message[] |
messages
The storage of the messages; removed messages have a null element
|
protected MessageBatch.Mode |
mode
Whether this message batch contains only OOB messages, or only regular messages
|
protected boolean |
multicast
Whether all messages have dest == null (multicast) or not
|
protected Address |
sender
The sender of the message batch
|
构造器和说明 |
---|
MessageBatch(Address dest,
Address sender,
AsciiString cluster_name,
boolean multicast,
java.util.Collection<Message> msgs) |
MessageBatch(Address dest,
Address sender,
AsciiString cluster_name,
boolean multicast,
java.util.Collection<Message> msgs,
Filter<Message> filter) |
MessageBatch(Address dest,
Address sender,
AsciiString cluster_name,
boolean multicast,
MessageBatch.Mode mode,
int capacity) |
MessageBatch(java.util.Collection<Message> msgs) |
MessageBatch(int capacity) |
限定符和类型 | 方法和说明 |
---|---|
MessageBatch |
add(Message msg) |
Message[] |
array()
Returns the underlying message array.
|
int |
capacity() |
MessageBatch |
clear() |
AsciiString |
clusterName() |
MessageBatch |
clusterName(AsciiString name) |
Address |
dest() |
MessageBatch |
dest(Address dest) |
MessageBatch.Mode |
determineMode() |
Message |
first() |
java.util.Collection<Message> |
getMatchingMessages(short id,
boolean remove)
Removes and returns all messages which have a header with ID == id
|
boolean |
isEmpty() |
java.util.Iterator<Message> |
iterator()
Iterator which iterates only over non-null messages, skipping null messages
|
Message |
last() |
int |
length()
Returns the total number of bytes of the message batch (by calling
Message.getLength() on all messages) |
<T> java.util.Collection<T> |
map(MessageBatch.Visitor<T> visitor)
Applies a function to all messages and returns a list of the function results
|
MessageBatch.Mode |
mode() |
MessageBatch |
mode(MessageBatch.Mode mode) |
boolean |
multicast() |
java.lang.String |
printHeaders() |
MessageBatch |
remove(Filter<Message> filter)
Removes all messages which match filter
|
MessageBatch |
remove(Message msg)
Removes the current message (found by indentity (==)) by nulling it in the message array
|
MessageBatch |
replace(Filter<Message> filter,
Message replacement,
boolean match_all)
Replaces all messages which match a given filter with a replacement message
|
MessageBatch |
replace(Message existing_msg,
Message new_msg)
Replaces a message in the batch with another one
|
protected void |
resize() |
Address |
sender() |
MessageBatch |
sender(Address sender) |
int |
size()
Returns the number of non-null messages
|
java.lang.String |
toString() |
long |
totalSize()
Returns the size of the message batch (by calling
Message.size() on all messages) |
protected Address dest
protected Address sender
protected AsciiString cluster_name
protected Message[] messages
protected int index
protected boolean multicast
protected MessageBatch.Mode mode
protected static final int INCR
public MessageBatch(int capacity)
public MessageBatch(java.util.Collection<Message> msgs)
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, java.util.Collection<Message> msgs)
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, java.util.Collection<Message> msgs, Filter<Message> filter)
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, MessageBatch.Mode mode, int capacity)
public Address dest()
public MessageBatch dest(Address dest)
public Address sender()
public MessageBatch sender(Address sender)
public AsciiString clusterName()
public MessageBatch clusterName(AsciiString name)
public boolean multicast()
public MessageBatch.Mode mode()
public MessageBatch mode(MessageBatch.Mode mode)
public int capacity()
public Message[] array()
public Message first()
public Message last()
public MessageBatch add(Message msg)
public MessageBatch replace(Message existing_msg, Message new_msg)
existing_msg
- The message to be replaced. The message has to be non-null and is found by identity (==)
comparisonnew_msg
- The message to replace the existing message with, can be nullpublic MessageBatch replace(Filter<Message> filter, Message replacement, boolean match_all)
filter
- the filter. If null, no changes take place. Note that filter needs to be able to handle null msgsreplacement
- the replacement message. Can be null, which essentially removes all messages matching filtermatch_all
- whether to replace the first or all matchespublic MessageBatch remove(Message msg)
msg
- public MessageBatch remove(Filter<Message> filter)
filter
- the filter. If null, no removal takes placepublic MessageBatch clear()
public java.util.Collection<Message> getMatchingMessages(short id, boolean remove)
public <T> java.util.Collection<T> map(MessageBatch.Visitor<T> visitor)
public int size()
public boolean isEmpty()
public MessageBatch.Mode determineMode()
public long totalSize()
Message.size()
on all messages)public int length()
Message.getLength()
on all messages)public java.util.Iterator<Message> iterator()
iterator
在接口中 java.lang.Iterable<Message>
public java.lang.String toString()
toString
在类中 java.lang.Object
public java.lang.String printHeaders()
protected void resize()