public class MessageSoftList extends Object
Message
, waiting to be sent. After sending
one message it is marked as sent, which means it is kept until its
acknowledgment. Once acknowledged, the message is deleted.MessageSoftRef
in order to be garbaged from memory if necessary.Modifier and Type | Class and Description |
---|---|
(package private) static class |
MessageSoftList.MessageComparator
A comparator to keep list sorted by message stamp.
|
(package private) static class |
MessageSoftList.MessageSoftComparator
A comparator to keep list sorted by message stamp when using soft
references.
|
private static class |
MessageSoftList.MessageSoftIterator
An iterator returning the messages when going through a collection of
MessageSoftRef . |
Modifier and Type | Field and Description |
---|---|
private Message |
ack
Current ack message which will be sent in priority.
|
private org.objectweb.util.monolog.api.Logger |
logmon
Logger for this class.
|
private SortedSet |
msgSentlist
The list of sent messages waiting to be acknowledged.
|
private SortedSet |
msgToSendlist
The list of messages waiting to be sent.
|
private boolean |
persistent
Tells if messages are persisted on disk and can be garbaged from memory.
|
Constructor and Description |
---|
MessageSoftList(String name,
boolean persistent) |
Modifier and Type | Method and Description |
---|---|
void |
addMessage(Message msg)
Adds a message at the end of the list.
|
void |
deleteMessagesUpTo(int stamp)
Iterates over messages waiting for an acknowledge to delete the ones which
have a stamp inferior or equal to the given one.
|
Message |
getAck()
Returns the acknowledge waiting to be sent if present.
|
Message |
getFirst()
Returns the first non expired message waiting to be sent.
|
private void |
removeExpired(Message msg)
Removes the expired message, if needed an ExpiredNot is sent to the
deadNotificationAgentId specified.
|
private void |
removeExpired(MessageSoftRef msgRef)
Removes the expired message, if needed an ExpiredNot is sent to the
deadNotificationAgentId specified.
|
void |
reset()
Resets all messages waiting for an acknowledge: they are placed back at the
beginning of the list respecting their stamp order.
|
private Message |
selectFirst() |
int |
sentSize()
Returns the number of messages waiting for an ack.
|
void |
setAck(Message ack)
Sets the next ack to send.
|
void |
setSent(Message msg)
Mark specified message as sent (ie waiting for an ack).
|
Iterator |
toSendIterator()
Returns an iterator over the messages waiting to be sent.
|
int |
toSendSize()
Returns the number of messages waiting to be sent.
|
String |
toString() |
private org.objectweb.util.monolog.api.Logger logmon
private Message ack
private SortedSet msgToSendlist
private SortedSet msgSentlist
private final boolean persistent
public MessageSoftList(String name, boolean persistent)
public void addMessage(Message msg)
setAck(Message)
if you
want to add an ack to the list.public Message getAck()
public Message getFirst()
private Message selectFirst()
private void removeExpired(MessageSoftRef msgRef)
msg
- The message to remove.private void removeExpired(Message msg)
msg
- The message to remove.public void deleteMessagesUpTo(int stamp) throws IOException
stamp
- the stamp of the last message acked.IOException
public void setAck(Message ack)
public Iterator toSendIterator()
public void reset()
public int toSendSize()
public void setSent(Message msg)
getFirst()
.msg
- the message which have been sent.public int sentSize()
Copyright © 2018 ScalAgent D.T.. All Rights Reserved.