|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.dyade.aaa.agent.MessageVector
final class MessageVector
Class MessageVector
represents a persistent vector of
Message (source and target agent identifier, notification).
As messages have a relatively short life span, then the messages
are kept in main memory. If possible, the list is backed by a persistent
image on the disk for reliability needs. In this case, we can use
SoftReference to avoid memory overflow.
MessageVector
object state.
Field Summary | |
---|---|
private int |
count
The number of messages in this MessageVector object. |
private long |
cpt1
|
private long |
cpt2
|
private java.lang.Object[] |
data
The array buffer into which the Message objects are stored
in memory. |
private int |
first
The index of the first message in the circular buffer. |
private org.objectweb.util.monolog.api.Logger |
logmon
|
private java.lang.String |
logmsg
|
private boolean |
persistent
|
private int |
validated
The number of validated message in this MessageQueue. |
Constructor Summary | |
---|---|
MessageVector(java.lang.String name,
boolean persistent)
|
Method Summary | |
---|---|
Message |
get()
Looks at the message at the top of this queue without removing it from the queue. |
Message |
get(long timeout)
Looks at the message at the top of this queue without removing it from the queue. |
private Message |
getMessageAt(int index)
Returns the message at the specified index. |
Message |
getMessageTo(short to)
Looks at the first message of this queue where the destination server is the specified one. |
void |
insert(Message item)
Insert a message in the queue, it should only be used during initialization for restoring the queue state. |
private void |
insertMessageAt(Message item,
int index)
Inserts the specified message to this MessageVector at
the specified index. |
Message |
pop()
Removes the message at the top of this queue. |
void |
push(Message item)
Pushes a message onto the bottom of this queue. |
(package private) int |
remove(int stamp)
Removes all messages with a stamp less than the specified one. |
(package private) Message |
removeExpired(long currentTimeMillis)
Removes the first messages with a timestamp less than the specified one. |
(package private) void |
removeMessage(Message msg)
Removes the specified message from the queue if exists. |
private void |
removeMessageAt(int index)
Deletes the message at the specified index. |
int |
size()
Returns the number of messages in this vector. |
java.lang.String |
toString()
Returns a string representation of this MessageVector
object. |
void |
validate()
Atomically validates all messages pushed in queue during a reaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private org.objectweb.util.monolog.api.Logger logmon
private java.lang.String logmsg
private long cpt1
private long cpt2
private java.lang.Object[] data
Message
objects are stored
in memory. The capacity of this array buffer is at least large enough to
contain all the messages of the MessageVector
.Messages are stored in a circular way, first one in data[first] through data[(first+count-1)%length]. Any other array elements are null.
private int first
private int count
private int validated
private boolean persistent
Constructor Detail |
---|
MessageVector(java.lang.String name, boolean persistent)
Method Detail |
---|
public void insert(Message item)
insert
in interface MessageQueue
item
- the message to be pushed onto this queue.public void push(Message item)
push
in interface MessageQueue
item
- the message to be pushed onto this queue.public Message pop() throws EmptyQueueException
pop
in interface MessageQueue
EmptyQueueException
- if this queue is empty.public void validate()
validate
in interface MessageQueue
public Message get() throws java.lang.InterruptedException
get
in interface MessageQueue
java.lang.InterruptedException
- if another thread has interrupted the
current thread.public Message get(long timeout) throws java.lang.InterruptedException
get
in interface MessageQueue
timeout
- the maximum time to wait in milliseconds.
java.lang.InterruptedException
- if another thread has interrupted the
current thread.
java.lang.IllegalArgumentException
- if the value of timeout is negative.public Message getMessageTo(short to)
to
- the unique server id.
void removeMessage(Message msg)
msg
- the message to remove.int remove(int stamp)
Message removeExpired(long currentTimeMillis)
private void insertMessageAt(Message item, int index)
MessageVector
at
the specified index. Each component in this vector with an index greater
or equal to the specified index is shifted upward.
item
- the message to be pushed onto this queue.index
- where to insert the new message.private Message getMessageAt(int index)
index
- the index of the message.
private void removeMessageAt(int index)
index
- the index of the message to remove.public int size()
size
in interface MessageQueue
public java.lang.String toString()
MessageVector
object. Be careful we scan the vector without synchronization, so the
result can be incoherent.
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |