|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.management.NotificationBroadcasterSupport com.cosylab.jcosyne.server.RemoteTask com.cosylab.jcosyne.server.Executor
Executor is one of the predefined MBeans provided by JCosyne framework, which keeps
track of other executing remote tasks. Executor launches new remote tasks in separate
threads, suspends and resumes them and returns data about currently active tasks.
Because the executor cannot forcefully stop or suspend or resume other tasks (since
this is deprecated in Java Thread API), executor sets Suspended
or
Running
flags on remote tasks. It is the duty of remote tasks to
periodically check these flags (by, by default, calling their RemoteTask::checkState()
method periodically) and respond. The executor will, however, listen to remote task
notifications that infom it when the remote task took appropriate action.
Field Summary |
Fields inherited from class com.cosylab.jcosyne.server.RemoteTask |
log, name, running, sequence, SERVER_DELEGATE, serverRef, suspended |
Constructor Summary | |
Executor()
|
Method Summary | |
javax.management.ObjectName[] |
getRunningRemoteTasks()
Returns a list of all currently running remote tasks by name. |
long |
getSpeedMetrics()
Returns the estimate of the processor speed on which the server is executing. |
void |
handleNotification(javax.management.Notification not,
java.lang.Object handback)
Listens to execution notifications from other remote tasks. |
protected void |
internalInitialize()
Registers to the server as server listener, catches notifications whereby a remote task is removed from the server. |
boolean |
isReadyToRun()
Always returns true . |
boolean |
isRunningRemoteTask(javax.management.ObjectName name)
Returns true if the remote task passed as parameter is currently
executing (in running state). |
void |
postDeregister()
Overrides the parent postDeregister to do specific cleanup. |
void |
preDeregister()
Deregisters as server listener and deregisters from all active tasks. |
void |
resumeRemoteTask(javax.management.ObjectName name,
boolean block)
Resumes the remote task if it has been suspended. |
void |
run()
Performs some canonical computation and measures the attribute SpeedMetrics . |
boolean |
startRemoteTask(int localRepositoryID)
Starts remote task that has its state stored in a local repository. |
boolean |
startRemoteTask(javax.management.ObjectName name)
Starts a remote task that exists in this server. |
boolean |
stopRemoteTask(javax.management.ObjectName name)
Stops the currently executing remote task. |
void |
suspendRemoteTask(javax.management.ObjectName name,
boolean block)
Suspends remote task if it is running. |
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, postRegister, 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 |
public Executor()
Method Detail |
public long getSpeedMetrics()
getSpeedMetrics
in interface ExecutorMBean
public boolean startRemoteTask(javax.management.ObjectName name)
true
when its
ReadyToRun
attribute is evaluated. If the remote task is not yet
initialized, its initialize()
is called by this method. After that, a
new thread is created for the remote task, the task is added to the active list, thread is
started and this executor starts listening to execution events from the remote task.
Running
attribute of the remote task is set to true
startRemoteTask
in interface ExecutorMBean
name
- the name of the collocated remote task that will be started
true
iff the task was started succesfullypublic boolean isRunningRemoteTask(javax.management.ObjectName name)
true
if the remote task passed as parameter is currently
executing (in running state).
isRunningRemoteTask
in interface ExecutorMBean
name
- the name of the remote task to check
true
iff the task is in the list of currently
active taskspublic boolean stopRemoteTask(javax.management.ObjectName name)
Running
attribute on the remote task to
false
and removes the task from the active list.
stopRemoteTask
in interface ExecutorMBean
name
- the name of the remote task to stop
true
if the task was stopped successfullypublic javax.management.ObjectName[] getRunningRemoteTasks()
getRunningRemoteTasks
in interface ExecutorMBean
public void run()
SpeedMetrics
. Fires attribute change notification when done.
run
in interface java.lang.Runnable
public boolean isReadyToRun()
true
.
isReadyToRun
in interface RemoteTaskMBean
public void handleNotification(javax.management.Notification not, java.lang.Object handback)
handleNotification
in interface javax.management.NotificationListener
not
- notification object of type ExecutionNotification
handback
- not usedpublic void suspendRemoteTask(javax.management.ObjectName name, boolean block)
run()
method that it chooses, until it is resumed. While
in suspended mode, it must be possible for any client to look up intermediate results without
affecting the computation. Calling suspend on non-running or already suspended tasks
has no effect.
suspendRemoteTask
in interface ExecutorMBean
name
- the name of the remote task to be suspendedblock
- if true
, this method blocks until the remote task confirms
that it has been suspended by firing execution event; if false
,
this method returns immediately, and after the return, the task may not have been
suspended alreadypublic void resumeRemoteTask(javax.management.ObjectName name, boolean block)
resumeRemoteTask
in interface ExecutorMBean
name
- the name of remote task to suspendblock
- if true
this method blocks until the remote
task notifies (through execution notifications) listeners
that it has resumed processing; if false
this
method may return before the remote task has been resumedprotected void internalInitialize()
internalInitialize
in class RemoteTask
RemoteTask.initialize()
public boolean startRemoteTask(int localRepositoryID)
ResultRepository
MBean, take its record with
localRepositoryID
index, and from it instantiate the remote task
This is a sort of simple deserialization, done by invoking
RemoteTask::copyStateFrom()
on the newly instantiated task. Note
that the task cannot be instantiated if the same task already exists in the
server.
startRemoteTask
in interface ExecutorMBean
localRepositoryID
- the ID of the remote task invocation (index) entry
in the local result repository
true
if the instantiation was
succesfullpublic void postDeregister()
postDeregister
to do specific cleanup. Call super
post-deregistration method here!.
postDeregister
in interface javax.management.MBeanRegistration
postDeregister
in class RemoteTask
public void preDeregister() throws java.lang.Exception
preDeregister
in interface javax.management.MBeanRegistration
preDeregister
in class RemoteTask
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |