Package com.atlassian.jira.task
Class MockTaskDescriptor<V extends Serializable>
java.lang.Object
com.atlassian.jira.task.MockTaskDescriptor<V>
- All Implemented Interfaces:
TaskDescriptor<V>,Serializable
- Since:
- v5.1
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Return the description of the task passed when it was created.longThis returns number of milliseconds the task has been running for.Return the date when the task was finished.Returns node id from where task was submittedReturns the URL that displays progress on this task.This returns the result of the long running task.Return operation that this task is part of.Return the date when the task was started.Return the date when the task was submitted.Return the context of task.Return the identifier for this task.Return theTaskProgressIndicatorassociated with the task.Return the user that started to task.booleanReturns whether this supports requests to cancel it.booleanReturns whether cancellation of task has been requested.booleanTells if caller if the task has finished running or not.booleanReturns whether the task will be automatically picked up again by the cluster if the node that was executing it crashes.booleanTrue if the task has been started.voidsetCancelable(boolean isCancelable) voidsetCancelled(boolean cancelled) Set flag to indicate this task has been cancelled;voidsetDescription(String description) voidsetElapsedRunTime(long elapsedRunTime) voidsetFinishedTime(Date finishedTime) voidvoidStore the result in the descriptor.voidsetSelfRecovering(boolean selfRecovering) voidsetSpanningOperation(SpanningOperation spanningOperation) voidsetStartedTime(Date startedTime) voidsetSubmittedTime(Date submittedTime) voidsetTaskContext(TaskContext taskContext) voidvoidsetTaskProgressIndicator(TaskProgressIndicator taskProgressIndicator) voidsetUserName(String userName)
-
Constructor Details
-
MockTaskDescriptor
public MockTaskDescriptor()
-
-
Method Details
-
clear
public void clear() -
getResult
Description copied from interface:TaskDescriptorThis returns the result of the long running task. Returns null if the task is not finished.- Specified by:
getResultin interfaceTaskDescriptor<V extends Serializable>- Returns:
- the result of the long running task or null if it has not return value.
-
isStarted
public boolean isStarted()Description copied from interface:TaskDescriptorTrue if the task has been started.- Specified by:
isStartedin interfaceTaskDescriptor<V extends Serializable>- Returns:
- true if the task has been started.
-
isFinished
public boolean isFinished()Description copied from interface:TaskDescriptorTells if caller if the task has finished running or not.- Specified by:
isFinishedin interfaceTaskDescriptor<V extends Serializable>- Returns:
- true if the task has finished running.
-
getTaskId
Description copied from interface:TaskDescriptorReturn the identifier for this task. This is only unique in the current execution of the JVM.- Specified by:
getTaskIdin interfaceTaskDescriptor<V extends Serializable>- Returns:
- The unique id of the task
-
getStartedTimestamp
Description copied from interface:TaskDescriptorReturn the date when the task was started.- Specified by:
getStartedTimestampin interfaceTaskDescriptor<V extends Serializable>- Returns:
- the time that task was started.
nullwill be returned if the task has not started executing.
-
getFinishedTimestamp
Description copied from interface:TaskDescriptorReturn the date when the task was finished.- Specified by:
getFinishedTimestampin interfaceTaskDescriptor<V extends Serializable>- Returns:
- the time that task finished executing.
nullwill be returned if the task has not finished executing.
-
getSubmittedTimestamp
Description copied from interface:TaskDescriptorReturn the date when the task was submitted.- Specified by:
getSubmittedTimestampin interfaceTaskDescriptor<V extends Serializable>- Returns:
- the time that task was submitted to the
TaskManager. Anullvalue will never be returned as the task will always have a submission time.
-
getElapsedRunTime
public long getElapsedRunTime()Description copied from interface:TaskDescriptorThis returns number of milliseconds the task has been running for. Will return zero if the task has not started. When the task has started but not finished, it will return the the difference between the current time and the time was started (i.e. it will change). When the task has finished, it will return the difference between the start time and the end time (i.e. it will not change).- Specified by:
getElapsedRunTimein interfaceTaskDescriptor<V extends Serializable>- Returns:
- the elapsed run time in milliseconds.
-
getUserName
Description copied from interface:TaskDescriptorReturn the user that started to task.- Specified by:
getUserNamein interfaceTaskDescriptor<V extends Serializable>- Returns:
- the user that caused the task to be submitted. This may be null.
-
getDescription
Description copied from interface:TaskDescriptorReturn the description of the task passed when it was created.- Specified by:
getDescriptionin interfaceTaskDescriptor<V extends Serializable>- Returns:
- a meaningful description of the task
-
getTaskContext
Description copied from interface:TaskDescriptorReturn the context of task. Code that starts long running tasks can implement their own variants of this.- Specified by:
getTaskContextin interfaceTaskDescriptor<V extends Serializable>- Returns:
- the context of the task. This method will never return
nullas a task must always have a context.
-
getProgressURL
Description copied from interface:TaskDescriptorReturns the URL that displays progress on this task. It is built using theTaskContext.- Specified by:
getProgressURLin interfaceTaskDescriptor<V extends Serializable>- Returns:
- the URL that displays progress for this task.
nullcannot be returned.
-
getTaskProgressIndicator
Description copied from interface:TaskDescriptorReturn theTaskProgressIndicatorassociated with the task. A task will only have an indicator if its callable implements theProvidesTaskProgressinterface.- Specified by:
getTaskProgressIndicatorin interfaceTaskDescriptor<V extends Serializable>- Returns:
- the
TaskProgressIndicatorassociated with the task ornullif there isn't one.
-
setResult
Description copied from interface:TaskDescriptorStore the result in the descriptor.- Specified by:
setResultin interfaceTaskDescriptor<V extends Serializable>- Parameters:
result- The Result
-
setSubmittedTime
-
setStartedTime
-
setFinishedTime
-
setTaskProgressIndicator
-
setDescription
-
setTaskId
-
setElapsedRunTime
public void setElapsedRunTime(long elapsedRunTime) -
setTaskContext
-
setUserName
-
isCancelled
public boolean isCancelled()Description copied from interface:TaskDescriptorReturns whether cancellation of task has been requested. Long-running operations should poll to see if task has been requested.- Specified by:
isCancelledin interfaceTaskDescriptor<V extends Serializable>- Returns:
trueif cancellation has been requested, andfalseotherwise
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:TaskDescriptorSet flag to indicate this task has been cancelled;- Specified by:
setCancelledin interfaceTaskDescriptor<V extends Serializable>- Parameters:
cancelled- Cancelled flag
-
isSelfRecovering
public boolean isSelfRecovering()Description copied from interface:TaskDescriptorReturns whether the task will be automatically picked up again by the cluster if the node that was executing it crashes.Used by Jira to determine which tasks it should clean up after detecting such crashed node.
- Specified by:
isSelfRecoveringin interfaceTaskDescriptor<V extends Serializable>- See Also:
-
setSelfRecovering
public void setSelfRecovering(boolean selfRecovering) -
isCancellable
public boolean isCancellable()Description copied from interface:TaskDescriptorReturns whether this supports requests to cancel it.- Specified by:
isCancellablein interfaceTaskDescriptor<V extends Serializable>- Returns:
trueif cancellation is supported, andfalseotherwise
-
setCancelable
public void setCancelable(boolean isCancelable) -
getNodeId
Description copied from interface:TaskDescriptorReturns node id from where task was submitted- Specified by:
getNodeIdin interfaceTaskDescriptor<V extends Serializable>- Returns:
- node id
-
setNodeId
-
getSpanningOperation
Description copied from interface:TaskDescriptorReturn operation that this task is part of.- Specified by:
getSpanningOperationin interfaceTaskDescriptor<V extends Serializable>- Returns:
- operation that this task is part of
-
setSpanningOperation
-