edu.mssm.crover.ims.tasks.rmi
Class TaskManagerRMIServerImpl

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--edu.mssm.crover.ims.tasks.rmi.TaskManagerRMIServerImpl
All Implemented Interfaces:
java.rmi.Remote, java.io.Serializable, TaskManagerRMIServer

public class TaskManagerRMIServerImpl
extends java.rmi.server.UnicastRemoteObject
implements TaskManagerRMIServer

RMI server for TaskManager. Allow clients to connect to the task manager from pure java client platforms.

See Also:
<{TaskManagerRMIServer}>, Serialized Form

Field Summary
static int ONE_DAY
           
static int ONE_HOUR
           
static int ONE_MINUTE
           
static int ONE_WEEK
           
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Method Summary
 void acceptTask(RMITask task)
          Must be called when task is accepted by a worker.
 void checkWorkerType(java.lang.String taskEngineClassName)
          Attempts to instanciate a TaskEngine of this class.
 void completeTask(RMITask task, TaskResult result)
          Must be called when task is completed by a worker.
 void failTask(RMITask task, java.lang.Exception e)
          Must be called when a worker fails to complete a task.
 TaskStatus getStatus(java.lang.String taskid)
           
 TaskResult getTaskResult(java.lang.String taskid)
          Returns the result of a task.
 boolean isTaskCompleted(java.lang.String taskid)
          Test if a task status is completed.
 boolean isTaskFailed(java.lang.String taskid)
          Test if a task status is failed.
static void main(java.lang.String[] args)
           
 RMITask requestTask(java.lang.String[] worker_types)
          Requests a task.
 void reschedule()
          Reschedules tasks.
 void setReadyToStart(RMITask task)
          Notify the task manager that this task is now ready to start.
 void startTask(RMITask task)
          Must be called when task is started by a worker.
 java.lang.String submit(java.lang.String taskEngineClassName, TaskData data, long timeout)
          Submits a new task.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ONE_WEEK

public static final int ONE_WEEK
See Also:
Constant Field Values

ONE_DAY

public static final int ONE_DAY
See Also:
Constant Field Values

ONE_HOUR

public static final int ONE_HOUR
See Also:
Constant Field Values

ONE_MINUTE

public static final int ONE_MINUTE
See Also:
Constant Field Values
Method Detail

main

public static void main(java.lang.String[] args)

submit

public java.lang.String submit(java.lang.String taskEngineClassName,
                               TaskData data,
                               long timeout)
                        throws java.rmi.RemoteException
Submits a new task.

Specified by:
submit in interface TaskManagerRMIServer
Parameters:
taskEngineClassName - Name of the class for the TaskEngine that will process this class.
data - Instance of TaskData that contains the data used to initialize this task.
Returns:
task-id Task identifier used to inquire about the task after submission.
java.rmi.RemoteException

getTaskResult

public TaskResult getTaskResult(java.lang.String taskid)
                         throws TaskNotFoundException
Returns the result of a task. After a task has completed, this method returns the result computed by the task. If the task has not yet completed, or has failed, this method return null.

Specified by:
getTaskResult in interface TaskManagerRMIServer
Parameters:
taskid - Identifier of the task.
TaskNotFoundException

getStatus

public TaskStatus getStatus(java.lang.String taskid)

reschedule

public void reschedule()
Reschedules tasks. This method should be called periodically to allow the TaskManager to discover tasks which were not completed within their allowed execution window. When such tasks are discovered, they are rescheduled as freshly submitted tasks.


failTask

public void failTask(RMITask task,
                     java.lang.Exception e)
Must be called when a worker fails to complete a task.

Specified by:
failTask in interface TaskManagerRMIServer

completeTask

public void completeTask(RMITask task,
                         TaskResult result)
Must be called when task is completed by a worker.

Specified by:
completeTask in interface TaskManagerRMIServer

startTask

public void startTask(RMITask task)
Must be called when task is started by a worker.

Specified by:
startTask in interface TaskManagerRMIServer

setReadyToStart

public void setReadyToStart(RMITask task)
Notify the task manager that this task is now ready to start. The status cannot be changed back later as a task which is ready to start can be started at any time.

Specified by:
setReadyToStart in interface TaskManagerRMIServer

acceptTask

public void acceptTask(RMITask task)
Must be called when task is accepted by a worker.

Specified by:
acceptTask in interface TaskManagerRMIServer

checkWorkerType

public void checkWorkerType(java.lang.String taskEngineClassName)
                     throws java.lang.ClassNotFoundException,
                            java.lang.InstantiationException,
                            java.lang.IllegalAccessException
Attempts to instanciate a TaskEngine of this class.

java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

requestTask

public RMITask requestTask(java.lang.String[] worker_types)
                    throws java.lang.ClassNotFoundException,
                           java.lang.InstantiationException,
                           java.lang.IllegalAccessException
Requests a task. This method checks that a TaskEngine can be instanciated for each worker type submitted. This makes sure specific classes of the TaskEngines are in the classpath before the task is requested from the TaskManager and should avoid tasks failed because of incorrect classpath configurations.

Specified by:
requestTask in interface TaskManagerRMIServer
Throws:
java.lang.ClassNotFoundException - When the class of the TaskEngine corresponding to a given worker_type cannot be found.
java.lang.InstantiationException - When the TaskEngine corresponding to a given worker_type cannot be instanciated.
java.lang.IllegalAccessException - When the TaskEngine constructor cannot be accessed.
See Also:
<{TaskManager}>

isTaskCompleted

public boolean isTaskCompleted(java.lang.String taskid)
                        throws TaskNotFoundException
Test if a task status is completed.

Specified by:
isTaskCompleted in interface TaskManagerRMIServer
TaskNotFoundException

isTaskFailed

public boolean isTaskFailed(java.lang.String taskid)
                     throws TaskNotFoundException
Test if a task status is failed.

Specified by:
isTaskFailed in interface TaskManagerRMIServer
TaskNotFoundException


Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.