Modifier and Type | Class and Description |
---|---|
protected class |
MessageBatch.BatchIterator
Iterates over non-null elements of a batch, skipping null elements
|
static class |
MessageBatch.Mode |
Modifier and Type | Field and Description |
---|---|
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 static ToIntBiFunction<Message,MessageBatch> |
length_visitor |
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
|
protected static ToLongBiFunction<Message,MessageBatch> |
total_size_visitor |
Constructor and Description |
---|
MessageBatch(Address dest,
Address sender,
AsciiString cluster_name,
boolean multicast,
Collection<Message> msgs) |
MessageBatch(Address dest,
Address sender,
AsciiString cluster_name,
boolean multicast,
Collection<Message> msgs,
Predicate<Message> filter) |
MessageBatch(Address dest,
Address sender,
AsciiString cluster_name,
boolean multicast,
MessageBatch.Mode mode,
int capacity) |
MessageBatch(Collection<Message> msgs) |
MessageBatch(int capacity) |
Modifier and Type | Method and Description |
---|---|
MessageBatch |
add(Message msg) |
MessageBatch |
add(MessageBatch batch) |
int |
add(MessageBatch batch,
boolean resize)
Adds another batch to this one
|
int |
add(Message msg,
boolean resize)
Adds a message to the table
|
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() |
void |
forEach(BiConsumer<Message,MessageBatch> consumer) |
int |
getCapacity() |
AsciiString |
getClusterName() |
Address |
getDest() |
Collection<Message> |
getMatchingMessages(short id,
boolean remove)
Removes and returns all messages which have a header with ID == id
|
MessageBatch.Mode |
getMode() |
Address |
getSender() |
int |
index() |
boolean |
isEmpty() |
boolean |
isMulticast() |
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> Collection<T> |
map(BiFunction<Message,MessageBatch,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() |
MessageBatch |
multicast(boolean flag) |
String |
printHeaders() |
MessageBatch |
remove(Message msg)
Removes the current message (found by indentity (==)) by nulling it in the message array
|
MessageBatch |
remove(Predicate<Message> filter)
Removes all messages which match filter
|
MessageBatch |
replace(Message existing_msg,
Message new_msg)
Replaces a message in the batch with another one
|
MessageBatch |
replace(Predicate<Message> filter,
Message replacement,
boolean match_all)
Replaces all messages which match a given filter with a replacement message
|
int |
replaceIf(Predicate<Message> filter,
Message replacement,
boolean match_all)
Replaces all messages that match a given filter with a replacement message
|
MessageBatch |
reset() |
protected void |
resize() |
protected void |
resize(int new_capacity) |
Address |
sender() |
MessageBatch |
sender(Address sender) |
MessageBatch |
setClusterName(AsciiString name) |
MessageBatch |
setDest(Address dest) |
MessageBatch |
setMode(MessageBatch.Mode mode) |
MessageBatch |
setSender(Address sender) |
int |
size()
Returns the number of non-null messages
|
Stream<Message> |
stream() |
String |
toString() |
long |
totalSize()
Returns the size of the message batch (by calling
Message.size() on all messages) |
int |
transferFrom(MessageBatch other,
boolean clear)
Transfers messages from other to this batch.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
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
protected static final ToIntBiFunction<Message,MessageBatch> length_visitor
protected static final ToLongBiFunction<Message,MessageBatch> total_size_visitor
public MessageBatch(int capacity)
public MessageBatch(Collection<Message> msgs)
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, Collection<Message> msgs)
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, Collection<Message> msgs, Predicate<Message> filter)
public MessageBatch(Address dest, Address sender, AsciiString cluster_name, boolean multicast, MessageBatch.Mode mode, int capacity)
public Address getDest()
public Address dest()
public MessageBatch setDest(Address dest)
public MessageBatch dest(Address dest)
public Address getSender()
public Address sender()
public MessageBatch setSender(Address sender)
public MessageBatch sender(Address sender)
public AsciiString getClusterName()
public AsciiString clusterName()
public MessageBatch setClusterName(AsciiString name)
public MessageBatch clusterName(AsciiString name)
public boolean isMulticast()
public boolean multicast()
public MessageBatch multicast(boolean flag)
public MessageBatch.Mode getMode()
public MessageBatch.Mode mode()
public MessageBatch setMode(MessageBatch.Mode mode)
public MessageBatch mode(MessageBatch.Mode mode)
public int getCapacity()
public int capacity()
public int index()
public Message[] array()
public Message first()
public Message last()
public MessageBatch add(Message msg)
public int add(Message msg, boolean resize)
msg
- the messageresize
- whether or not to resize the table. If true, the method will always return 1public MessageBatch add(MessageBatch batch)
public int add(MessageBatch batch, boolean resize)
batch
- the batch to add to this batchresize
- when true, this batch will be resized to accommodate the other batchpublic 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(Predicate<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 int replaceIf(Predicate<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 int transferFrom(MessageBatch other, boolean clear)
other
- the other batchclear
- If true, the transferred messages are removed from the other batchpublic MessageBatch remove(Message msg)
msg
- public MessageBatch remove(Predicate<Message> filter)
filter
- the filter. If null, no removal takes placepublic MessageBatch clear()
public MessageBatch reset()
public Collection<Message> getMatchingMessages(short id, boolean remove)
public <T> Collection<T> map(BiFunction<Message,MessageBatch,T> visitor)
public void forEach(BiConsumer<Message,MessageBatch> consumer)
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 Iterator<Message> iterator()
public String printHeaders()
protected void resize()
protected void resize(int new_capacity)
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.