com.cosylab.jcosyne.server
Interface ExecutorMBean

All Superinterfaces:
RemoteTaskMBean, java.lang.Runnable
All Known Implementing Classes:
Executor

public interface ExecutorMBean
extends RemoteTaskMBean

Parametrizes JMX interface to the Executor. Executor manages other currently running active tasks, by maintaining them in a list and keeping the list up-to-date. Executor also contains methods whereby a remote task can be started, stopped, resumed and suspended. It manages threads by allocating them when the remote task is started. As a side-effect, the executor also can take performance measurements of the remote system, when it is executed on itself, and return the measurements as SpeedMetrics attribute. This remote task is installed by default when the JMX server starts up and should not be deinstalled.

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

Method Summary
 javax.management.ObjectName[] getRunningRemoteTasks()
          Returns the list of active tasks as currently maintained by this executor.
 long getSpeedMetrics()
          Returns the speed metrics of the remote system where this executor runs.
 boolean isRunningRemoteTask(javax.management.ObjectName name)
          Returns true iff the task with a given name is tagged as active by this executor.
 void resumeRemoteTask(javax.management.ObjectName name, boolean block)
          Resumes currently suspended remote task.
 boolean startRemoteTask(int repositoryIndex)
          Starts the remote task by first interrogating collocated result repository for a given index entry, and from entry reconstructing the remote task instance and its state.
 boolean startRemoteTask(javax.management.ObjectName name)
          Starts a remote task that already exists in the server.
 boolean stopRemoteTask(javax.management.ObjectName name)
          Stops the remote task that is currently runnning.
 void suspendRemoteTask(javax.management.ObjectName name, boolean block)
          Suspends currently running remote task.
 
Methods inherited from interface com.cosylab.jcosyne.server.RemoteTaskMBean
copyStateFrom, copyStateFrom, equals, executeScript, getLastScriptResult, getName, getPostExecutionScript, getPostInitializactionScript, getProgress, getState, hashCode, initialize, isFinished, isInitialized, isReadyToRun, isRunning, isSuspended, setPostExecutionScript, setPostInitializationScript, setRunning, setSuspended
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

getSpeedMetrics

public long getSpeedMetrics()
Returns the speed metrics of the remote system where this executor runs. If executor itself is executed, its run() method should invoke some standard computation and store the time elapsed for that canonical computation into SpeedMetrics attribute.

Returns:
the speed metrics if they have been measured or 0 otherwise

startRemoteTask

public boolean startRemoteTask(javax.management.ObjectName name)
Starts a remote task that already exists in the server. The named task, if it is in the correct state (ready-to-run) will be started in a separate thread, and initialized prior to that (if it has not yet been initialized). It is added to the list of active tasks maintained by the executor.

Parameters:
name - the name of RemoteTask extending object that should be started by this executor
Returns:
true iff the start was succesfull; false is returned if such object does not exist, is of incorrect type or in incorrect state or if an exception is thrown during start attempt

isRunningRemoteTask

public boolean isRunningRemoteTask(javax.management.ObjectName name)
Returns true iff the task with a given name is tagged as active by this executor.

Parameters:
name - the name of MBean that should be checked for status
Returns:
true iff the named remote task is running; note that false is returned even if the supplied name denotes unexisting entity or entity of incorrect type

stopRemoteTask

public boolean stopRemoteTask(javax.management.ObjectName name)
Stops the remote task that is currently runnning. Deregisters from the task as execution listener and removes it from the list of active tasks.

Parameters:
name - the name of the remote task to stop
Returns:
true iff the stop operation was initiated correctly by locating the remote task and setting its Running attribute to false; returns false if such remote task does not exist, is of incorrect type or if exception occurs

resumeRemoteTask

public void resumeRemoteTask(javax.management.ObjectName name,
                             boolean block)
Resumes currently suspended remote task. Does nothing if the task is not suspended.

Parameters:
name - the name of remote task to resume
block - if true this method blocks until the executor receives notification back from the remote task that it has really resumed execution in its thread; if false this method returns as soon as the resume request is sent.

suspendRemoteTask

public void suspendRemoteTask(javax.management.ObjectName name,
                              boolean block)
Suspends currently running remote task. Does nothing if the task is not running.

Parameters:
name - the name of remote task to suspend
block - if true this method blocks until the executor receives notification back from the remote task that it has really suspended execution in its thread; if false this method returns as soon as the susped request is sent.

getRunningRemoteTasks

public javax.management.ObjectName[] getRunningRemoteTasks()
Returns the list of active tasks as currently maintained by this executor. All names refer to MBeans that are subclasses of RemoteTask.

Returns:
a list of currently active remote tasks

startRemoteTask

public boolean startRemoteTask(int repositoryIndex)
Starts the remote task by first interrogating collocated result repository for a given index entry, and from entry reconstructing the remote task instance and its state. Remote task of the same type must not already exist in the system and the remote task must support state transfer.

Parameters:
repositoryIndex - the ID of the result repository entry that contains data about remote task run
Returns:
true only iff the record was obtained, the c corresponding bean initialized with the state from the record