edu.mssm.crover.ims.tasks
Class TaskStatus

java.lang.Object
  |
  +--edu.mssm.crover.ims.tasks.TaskStatus

public class TaskStatus
extends java.lang.Object

TaskStatus is persistent and tracks the status of one task. See also the methods on the TaskManager that can alter the status of a task:

See Also:
TaskManager.submit(Task), TaskManager.requestTask(AbstractWorker), TaskManager.failTask(Task,Exception), TaskManager.completeTask(Task, TaskResult), TaskManager.acceptTask(Task)

Field Summary
 int ACCEPTED
           
 int COMPLETED
           
 int FAILED
           
 int MAX_RESCHEDULE
           
 int SCHEDULED
           
 int STARTED
           
 int TO_BE_SCHEDULED
           
 
Constructor Summary
TaskStatus()
           
 
Method Summary
 void accept()
          Call this when the task is accepted by a worker.
 void complete(TaskResult result)
           
 void fail(java.lang.Exception e)
           
 java.util.Date getAcceptationTime()
          Returns the time when the last time the task was accepted by a worker.
 java.util.Date getCompletionTime()
          Returns the time of completion.
 long getElapsedTime()
          Returns the time elapsed since acceptation by a worker.
 java.util.Date getFailureTime()
          Returns the time of failure.
 TaskResult getResult()
           
 java.util.Date getSubmissionTime()
          Returns the time of submission.
protected  void hasBeenRescheduled(Task task, TaskManager tm)
           
 boolean hasBeenSubmitted()
          Returns true when the task has been submitted.
 boolean hasFailed()
           
 boolean hasSucceeded()
           
 boolean hasTimedOut()
           
 boolean isReadyToStart()
           
 void setReadyToStart()
           
 void start()
           
 void submit()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FAILED

public final int FAILED
See Also:
Constant Field Values

COMPLETED

public final int COMPLETED
See Also:
Constant Field Values

STARTED

public final int STARTED
See Also:
Constant Field Values

ACCEPTED

public final int ACCEPTED
See Also:
Constant Field Values

SCHEDULED

public final int SCHEDULED
See Also:
Constant Field Values

TO_BE_SCHEDULED

public final int TO_BE_SCHEDULED
See Also:
Constant Field Values

MAX_RESCHEDULE

public int MAX_RESCHEDULE
Constructor Detail

TaskStatus

public TaskStatus()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hasFailed

public boolean hasFailed()

hasTimedOut

public boolean hasTimedOut()

hasSucceeded

public boolean hasSucceeded()

hasBeenSubmitted

public boolean hasBeenSubmitted()
Returns true when the task has been submitted. The task can now be in a different status than SUBMITTED, for instance, it can have STARTED, this method still returns true.


getResult

public TaskResult getResult()

start

public void start()
           throws IncorrectStateException
IncorrectStateException

accept

public void accept()
            throws IncorrectStateException
Call this when the task is accepted by a worker.

IncorrectStateException

fail

public void fail(java.lang.Exception e)
          throws IncorrectStateException
IncorrectStateException

complete

public void complete(TaskResult result)
              throws IncorrectStateException
IncorrectStateException

submit

public void submit()
            throws IncorrectStateException
IncorrectStateException

getSubmissionTime

public java.util.Date getSubmissionTime()
Returns the time of submission.


getElapsedTime

public long getElapsedTime()
Returns the time elapsed since acceptation by a worker. When the task is not in the accepted or started states, returns 0.

Returns:
Time elapsed since acceptation or start of task (whichever happened last), or 0 if not in accepted state.

getAcceptationTime

public java.util.Date getAcceptationTime()
Returns the time when the last time the task was accepted by a worker.


getCompletionTime

public java.util.Date getCompletionTime()
Returns the time of completion. This is the time when the task has been completed and the result stored.


getFailureTime

public java.util.Date getFailureTime()
Returns the time of failure. This is the time when the task has failed.


hasBeenRescheduled

protected void hasBeenRescheduled(Task task,
                                  TaskManager tm)

isReadyToStart

public boolean isReadyToStart()

setReadyToStart

public void setReadyToStart()


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