|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.curjent.impl.agent.Messages
final class Messages
Custom linked list for queuing instances of Message
. This
implementation eliminates the need to allocated list nodes. Instead, the
message instances are used as list nodes. They are linked together with the
Message.next
and Message.prev
fields.
Pending messages are queued separately from accepted messages. This class
coordinates the pending and accepted states described for Capacity
.
Field Summary | |
---|---|
private Queue |
accepted
Queue of accepted messages. |
private static long |
DEADCHECK_TIMEOUT
Default timeout in seconds before a waiting thread checks for deadlock. |
private static long |
DEADCHECK_TIMEOUT_NANOS
DEADCHECK_TIMEOUT in nanosecond units. |
private long |
deadcheckNanos
deadcheckTimeout in nanosecond units. |
private long |
deadcheckTimeout
Timeout before a waiting thread checks for deadlock. |
private TimeUnit |
deadcheckUnit
Time unit for deadcheckTimeout . |
private int |
executing
Number of accepted messages executing. |
private Queue |
pending
Queue of pending messages. |
private long |
pendingNanos
Nanosecond equivalent of the pending message timeout value. |
private long |
pendingTimeout
Pending message timeout value. |
private TimeUnit |
pendingUnit
Pending message timeout unit. |
Constructor Summary | |
---|---|
Messages()
|
Method Summary | |
---|---|
(package private) Message |
dequeue(Message message)
Called in the controller's message pump loop to remove the current message for processing and evaluate the next message for processing. |
(package private) void |
dispatched(Message message)
Notification from the controller that a message has finished executing. |
(package private) void |
dispatching(Message message)
Notification from the controller that it has selected a message to execute. |
(package private) boolean |
empty()
Returns true if there are no messages queued, accepted or
waiting. |
(package private) long |
enqueue(Mark mark,
Message message)
Adds a message to the end of the queue, assigned the given mark to it, and increments the mark's count. |
(package private) void |
finish(Message message)
The controller has finished processing the given message. |
(package private) int |
getAcceptedCapacity()
Returns the current maximum for accepted messages. |
(package private) int |
getCurrentAccepted()
Returns the current number of messages accepted, including executing messages. |
(package private) int |
getCurrentExecuting()
Returns the number of executing messages. |
(package private) int |
getCurrentPending()
Returns the number of messages currently pending. |
(package private) long |
getDeadcheckNanos()
Returns getDeadcheckTimeout() in nanosecond units. |
(package private) long |
getDeadcheckTimeout()
Returns the deadcheck timeout value. |
(package private) TimeUnit |
getDeadcheckUnit()
Returns the deadcheck timeout unit. |
(package private) int |
getPendingCapacity()
Returns the current maximum for pending messages. |
(package private) long |
getPendingTimeout()
Returns the current maximum amount of time a caller waits for the agent to accept its call. |
(package private) TimeUnit |
getPendingUnit()
Returns the time unit for getPendingCapacity() . |
(package private) void |
init(ProxyInfo info)
Initializes the capacity values. |
(package private) Message |
next(Message message)
Returns a references to the next accepted message without removing it. |
(package private) Message |
peek()
Returns a reference to the first accepted message without removing it. |
private void |
pump()
Transitions pending messages to the accepted queue as availability and capacity permits. |
(package private) void |
setAcceptedCapacity(int value)
Updates the current maximum for accepted messages and calls pump() . |
(package private) void |
setDeadcheckTimeout(long value,
TimeUnit unit)
Sets the amount of time a thread waits before it checks for deadlock. |
(package private) void |
setPendingCapacity(int value)
Updates the current maximum for pending messages. |
(package private) void |
setPendingTimeout(long value,
TimeUnit unit)
Updates the current maximum amount of time a caller waits for the agent to accept its call. |
String |
toString()
Returns the number of pending, accepted, and exeucting messages. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final Queue pending
private final Queue accepted
private int executing
private long pendingTimeout
private TimeUnit pendingUnit
private long pendingNanos
private static final long DEADCHECK_TIMEOUT
private static final long DEADCHECK_TIMEOUT_NANOS
DEADCHECK_TIMEOUT
in nanosecond units.
private long deadcheckTimeout
private TimeUnit deadcheckUnit
deadcheckTimeout
.
private long deadcheckNanos
deadcheckTimeout
in nanosecond units.
Constructor Detail |
---|
Messages()
Method Detail |
---|
void init(ProxyInfo info)
boolean empty()
true
if there are no messages queued, accepted or
waiting.
Message peek()
null
when empty.
Message next(Message message)
null
if the given message is the last message.
void dispatching(Message message)
AgentStats.getCurrentExecuting()
void dispatched(Message message)
long enqueue(Mark mark, Message message)
0L
if the message
was accepted. Returns a value greater than OL
if the message
is pending acceptance. The returned non-zero value is the current number
of nanoseconds the caller can wait for the message to be accepted before
the agent throws a CapacityExceededException
.
CapacityExceededException
- The accepted and pending queues are
both full. The mark's count is unchanged in this case.Message dequeue(Message message)
void finish(Message message)
private void pump()
int getAcceptedCapacity()
void setAcceptedCapacity(int value)
pump()
.
IllegalArgumentException
- Invalid value
int getCurrentAccepted()
AgentStats.getCurrentAccepted()
int getCurrentExecuting()
AgentStats.getCurrentExecuting()
int getPendingCapacity()
void setPendingCapacity(int value)
IllegalArgumentException
- Invalid value
long getPendingTimeout()
TimeUnit getPendingUnit()
getPendingCapacity()
.
void setPendingTimeout(long value, TimeUnit unit)
IllegalArgumentException
- Invalid value
NullPointerException
- unit
is required but null
int getCurrentPending()
AgentStats.getCurrentPending()
long getDeadcheckTimeout()
AgentConfig.setDeadcheckTimeout(long, TimeUnit)
TimeUnit getDeadcheckUnit()
AgentConfig.setDeadcheckTimeout(long, TimeUnit)
long getDeadcheckNanos()
getDeadcheckTimeout()
in nanosecond units.
void setDeadcheckTimeout(long value, TimeUnit unit)
IllegalArgumentException
- value < 0
NullPointerException
- unit is required but nullAgentConfig.setDeadcheckTimeout(long, TimeUnit)
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |