com.cosylab.jcosyne.server
Class Sentinel

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport
      extended bycom.cosylab.jcosyne.server.RemoteTask
          extended bycom.cosylab.jcosyne.server.Sentinel
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, RemoteTaskMBean, java.lang.Runnable, SentinelMBean

public class Sentinel
extends RemoteTask
implements SentinelMBean

The implementation of sentinel remote task. This task exposes only one method. When called, it stops all tasks running in the executor, sleeps for a period, unregisters all remote tasks from the server and sends a shutdown notification to the server, which must respond by gracefully exiting.

Author:
Gasper Tkacik (gasper.tkacik@cosylab.com)

Field Summary
 
Fields inherited from class com.cosylab.jcosyne.server.RemoteTask
log, name, running, sequence, SERVER_DELEGATE, serverRef, suspended
 
Constructor Summary
Sentinel()
          Constructs a new instance of the sentinel.
 
Method Summary
protected  void internalInitialize()
          Do NOP.
 boolean isReadyToRun()
          This is a framework remote task and is never executed.
 void run()
          Do NOP.
 void shutdownServer(int restart)
          Shuts down all remote tasks and dispatches shutdown notification to the server.
 
Methods inherited from class com.cosylab.jcosyne.server.RemoteTask
checkState, copyStateFrom, copyStateFrom, executeScript, getInputResource, getLastScriptResult, getName, getOutputResource, getPostExecutionScript, getPostInitializactionScript, getProgress, getSequence, getState, initialize, isAborting, isFinished, isInitialized, isRunning, isSuspended, loadMatrix, loadMatrix, notifyAttributeChange, notifyExecutionStarts, notifyExecutionStops, postDeregister, postRegister, preDeregister, preRegister, saveMatrix, setFinished, setPostExecutionScript, setPostInitializationScript, setProgress, setRunning, setSuspended
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.cosylab.jcosyne.server.RemoteTaskMBean
copyStateFrom, copyStateFrom, equals, executeScript, getLastScriptResult, getName, getPostExecutionScript, getPostInitializactionScript, getProgress, getState, hashCode, initialize, isFinished, isInitialized, isRunning, isSuspended, setPostExecutionScript, setPostInitializationScript, setRunning, setSuspended
 

Constructor Detail

Sentinel

public Sentinel()
Constructs a new instance of the sentinel.

Method Detail

shutdownServer

public void shutdownServer(int restart)
Shuts down all remote tasks and dispatches shutdown notification to the server.

Specified by:
shutdownServer in interface SentinelMBean
Parameters:
restart - the exit code to use if an exception is caught and sentinel forces shutdown with System.exit()

internalInitialize

protected void internalInitialize()
Do NOP.

Specified by:
internalInitialize in class RemoteTask
See Also:
RemoteTask.initialize()

run

public void run()
Do NOP.

Specified by:
run in interface java.lang.Runnable

isReadyToRun

public boolean isReadyToRun()
This is a framework remote task and is never executed.

Specified by:
isReadyToRun in interface RemoteTaskMBean
Returns:
false