com.cosylab.jcosyne.server
Class ExecutionNotification

java.lang.Object
  extended byjava.util.EventObject
      extended byjavax.management.Notification
          extended bycom.cosylab.jcosyne.server.ExecutionNotification
All Implemented Interfaces:
java.io.Serializable

public class ExecutionNotification
extends javax.management.Notification

JMX Notification dispatched by Executor and remote tasks. This notification informs the listeners about the change of execution status of the remote task. The notifications are dispatched by remote tasks by calling their notifyExecutionStarts() and notifyExecutionStops() methods. They are also dispatched by checkState() in remote task, which checks if the execution should be suspended/resumed, based on the signal send by executor. Executor by default listens to these notifications to keep its list of active tasks up-to-date.

Author:
Gasper Tkacik (gasper.tkacik@cosylab.com)
See Also:
Serialized Form

Field Summary
static java.lang.String MESSAGE_EXECUTION_RESUMED
          Notification type denoting that the execution has been resumed.
static java.lang.String MESSAGE_EXECUTION_STARTS
          Notification type denoting that the execution has started.
static java.lang.String MESSAGE_EXECUTION_STOPS
          Notification type denoting that the execution has stopped.
static java.lang.String MESSAGE_EXECUTION_SUSPENDED
          Notification type denoting that the execution has been suspended.
static int SUCCESS_ABORTED
          Success flag carried by execution notification of stop type, when the execution was aborted as a result of some error, or system shutdown or a similar condition.
static int SUCCESS_NORMAL_STOP
          Success flag carried by execution notification of stop type, when the execution has completed naturally.
static int SUCCESS_STARTED
          Success flag carried by execution notifications of resume or start type.
static int SUCCESS_STOPPED
          Success flag carried by execution notification of stop type, when the execution was manually stopped by the executor (probably because of user intervention).
 
Fields inherited from class javax.management.Notification
source
 
Constructor Summary
ExecutionNotification(RemoteTask task)
          Creates a new execution notification of start type.
ExecutionNotification(RemoteTask task, int success, java.lang.String desc)
          Execution notification of stop type.
ExecutionNotification(RemoteTask task, java.lang.String type)
          Execution notification of type specified by the user, with sequence number and name inferred from the task paramter.
 
Method Summary
 javax.management.AttributeList getState()
          Returns the state carried by start or stop notification.
 int getSuccess()
          Returns the success flag of this notification, one of the predefined constants of this class.
 
Methods inherited from class javax.management.Notification
getMessage, getSequenceNumber, getTimeStamp, getType, getUserData, setSequenceNumber, setSource, setTimeStamp, setUserData
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MESSAGE_EXECUTION_STARTS

public static final java.lang.String MESSAGE_EXECUTION_STARTS
Notification type denoting that the execution has started. This is usually posted on the entry of run() method of a remote task.

See Also:
Constant Field Values

MESSAGE_EXECUTION_STOPS

public static final java.lang.String MESSAGE_EXECUTION_STOPS
Notification type denoting that the execution has stopped. This is posted either when the run() method of a remote task finishes successfully and has already produced output data, or if the execution is forcefully stopped or aborted. The success flag in this case carries the reason for aborting.

See Also:
Constant Field Values

MESSAGE_EXECUTION_SUSPENDED

public static final java.lang.String MESSAGE_EXECUTION_SUSPENDED
Notification type denoting that the execution has been suspended. This notification will be fired automatically by the checkState method of the remote task, which should be called periodically during the execution of the remote task. This notification may also be manually sent, if default state checking mechanism is not used. After dispatching this notification, the remote task stays in a well-determined state in which it can either be resumed, or from which intermediate results can be extracted without disturbing the computation using getter methods.

See Also:
Constant Field Values

MESSAGE_EXECUTION_RESUMED

public static final java.lang.String MESSAGE_EXECUTION_RESUMED
Notification type denoting that the execution has been resumed. This notification will be fired automatically by the checkState method of the remote task, which should be called periodically during the execution of the remote task. This notification should be sent only if the remote task was before in the suspended state.

See Also:
Constant Field Values

SUCCESS_STARTED

public static final int SUCCESS_STARTED
Success flag carried by execution notifications of resume or start type.

See Also:
Constant Field Values

SUCCESS_NORMAL_STOP

public static final int SUCCESS_NORMAL_STOP
Success flag carried by execution notification of stop type, when the execution has completed naturally.

See Also:
Constant Field Values

SUCCESS_STOPPED

public static final int SUCCESS_STOPPED
Success flag carried by execution notification of stop type, when the execution was manually stopped by the executor (probably because of user intervention).

See Also:
Constant Field Values

SUCCESS_ABORTED

public static final int SUCCESS_ABORTED
Success flag carried by execution notification of stop type, when the execution was aborted as a result of some error, or system shutdown or a similar condition.

See Also:
Constant Field Values
Constructor Detail

ExecutionNotification

public ExecutionNotification(RemoteTask task)
Creates a new execution notification of start type. Sequence number and name are determined from the remote task automatically. This constructor will capture the initial state of the remote task by calling its getState(). Invoke this constructor immediately prior to dispatching this notification.

Parameters:
task - that is starting up

ExecutionNotification

public ExecutionNotification(RemoteTask task,
                             java.lang.String type)
Execution notification of type specified by the user, with sequence number and name inferred from the task paramter.

Parameters:
task - that is dispatching notification
type - one of predefined constants of this class

ExecutionNotification

public ExecutionNotification(RemoteTask task,
                             int success,
                             java.lang.String desc)
Execution notification of stop type. User specifies a success flag and arbitrary description. This notification will capture the state of the remote task by calling its getState(). Invoke this constructor immediately prior to dispatching notification.

Parameters:
task - that has stopped
success - the flag that denotes the reason for task stopping, one of the predefined constants of this class
desc - an arbitrary string message carried by this notification
Method Detail

getState

public javax.management.AttributeList getState()
Returns the state carried by start or stop notification. The state is captured automatically by the constructor.

Returns:
state of the remote task

getSuccess

public int getSuccess()
Returns the success flag of this notification, one of the predefined constants of this class.

Returns:
success flag