org.curjent.agent
Enum CallCompletion

java.lang.Object
  extended by java.lang.Enum<CallCompletion>
      extended by org.curjent.agent.CallCompletion
All Implemented Interfaces:
Serializable, Comparable<CallCompletion>

public enum CallCompletion
extends Enum<CallCompletion>

Reason codes for why a call finished.


Enum Constant Summary
CALL_EXPIRED
          Call waited too long to begin executing.
CALL_FAILED
          The caller failed with an unexpected exception.
CALLER_DEADLOCKED
          The caller deadlocked with other callers while waiting on the call, and the call was terminated because of the deadlock.
CALLER_INTERRUPTED
          The caller was interrupted while waiting on the call, and the call was terminated because of the interrupt.
CAPACITY_EXCEEDED
          The agent's queue capacity was exceeded.
FUTURE_CANCELLED
          Call was forcibly canceled with Future.cancel(boolean).
LISTENER_FINISHED
          Call was forcibly finished with either AgentCall.finish() or AgentCall.finish(boolean, boolean, Object, Throwable).
NOT_FINISHED
          Call is still queued or executing.
TASK_FINISHED
          Call completed normally.
 
Method Summary
static CallCompletion valueOf(String name)
          Returns the enum constant of this type with the specified name.
static CallCompletion[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NOT_FINISHED

public static final CallCompletion NOT_FINISHED
Call is still queued or executing.


TASK_FINISHED

public static final CallCompletion TASK_FINISHED
Call completed normally. This includes calls that throw an exception.


LISTENER_FINISHED

public static final CallCompletion LISTENER_FINISHED
Call was forcibly finished with either AgentCall.finish() or AgentCall.finish(boolean, boolean, Object, Throwable). The executing task was potentially abandoned.


FUTURE_CANCELLED

public static final CallCompletion FUTURE_CANCELLED
Call was forcibly canceled with Future.cancel(boolean). The executing task was potentially abandoned.


CAPACITY_EXCEEDED

public static final CallCompletion CAPACITY_EXCEEDED
The agent's queue capacity was exceeded. The caller received a CapacityExceededException.

See Also:
Capacity

CALL_EXPIRED

public static final CallCompletion CALL_EXPIRED
Call waited too long to begin executing. The caller received an ExpiredException.

See Also:
Expiration

CALLER_INTERRUPTED

public static final CallCompletion CALLER_INTERRUPTED
The caller was interrupted while waiting on the call, and the call was terminated because of the interrupt.

For example, an agent of a caller interrrupted while awaiting a pending call will terminate the call with an InterruptedException and a call completion value of CALLER_INTERRUPTED. (See Capacity for details on pending calls.)

This applies only to the caller's thread, not to the task's thread. If the task's thread is interrupted, and the task's method throws the InterruptedException, the call's completion value is TASK_FINISHED.

Not all caller thread interrupts terminate the call. Callers interrupted while waiting on Future.get() or Future.get(long, TimeUnit) are thrown an InterruptedException, but the state of the call does not change.

Synchronous calls are another specical case. Synchronous calls simulate direct method calls. Upon receiving the interrupt from the waiting client's thread, the agent propagates the interrupt to the task's thread by clearing the client thread's interrupt and setting the task thread's interrupt. If the task's method throws an InterruptedException, the call's completion value is set to TASK_FINISHED, and the agent throws an exception to the caller (either the InterruptedException if the agent's interface method explicitly declares that it can throw an InterruptedException, or a new AgentException with the InterruptedException as the cause). (See Synchronous for details on synchronous calls.)


CALLER_DEADLOCKED

public static final CallCompletion CALLER_DEADLOCKED
The caller deadlocked with other callers while waiting on the call, and the call was terminated because of the deadlock.

For example, an agent of two or more callers deadlocked while awaiting a pending call will terminate one of the calls with an DeadlockException and a call completion value of CALLER_DEADLOCKED. (See Capacity for details on pending calls.)

Similarly, a caller waiting on a synchronous call may receive a DeadlockException. The call is terminated in this case, and the call completion value is set to CALLER_DEADLOCKED. (Once a synchronous call starts executing, though, it is no longer considered for deadlock. See Synchronous for details on synchronous calls.)

Not all caller deadlocks terminate the call. One caller deadlocked while waiting on Future.get() or Future.get(long, TimeUnit) is thrown a DeadlockException, but the state of the call does not change.


CALL_FAILED

public static final CallCompletion CALL_FAILED
The caller failed with an unexpected exception.

For example, a custom implementation of AgentTasks may throw an unknown type of exception when a call is initially sent to an agent. The call is terminated with a CALL_FAILED completion value in this case, and the exception is thrown to the caller, wrapped in an unchecked AgentException as appropriate.

This applies only to the caller's thread of execution, not to the task's thread of execution. If the task's method throws an exception, the call's completion value is TASK_FINISHED.

Method Detail

values

public static CallCompletion[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (CallCompletion c : CallCompletion.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static CallCompletion valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null


Copyright 2009-2011 Tom Landon
Apache License 2.0