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 TypeMethodDescriptionvoid
clear()
Return the description of the task passed when it was created.long
This 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 theTaskProgressIndicator
associated with the task.Return the user that started to task.boolean
Returns whether this supports requests to cancel it.boolean
Returns whether cancellation of task has been requested.boolean
Tells if caller if the task has finished running or not.boolean
Returns whether the task will be automatically picked up again by the cluster if the node that was executing it crashes.boolean
True if the task has been started.void
setCancelable
(boolean isCancelable) void
setCancelled
(boolean cancelled) Set flag to indicate this task has been cancelled;void
setDescription
(String description) void
setElapsedRunTime
(long elapsedRunTime) void
setFinishedTime
(Date finishedTime) void
void
Store the result in the descriptor.void
setSelfRecovering
(boolean selfRecovering) void
setSpanningOperation
(SpanningOperation spanningOperation) void
setStartedTime
(Date startedTime) void
setSubmittedTime
(Date submittedTime) void
setTaskContext
(TaskContext taskContext) void
void
setTaskProgressIndicator
(TaskProgressIndicator taskProgressIndicator) void
setUserName
(String userName)
-
Constructor Details
-
MockTaskDescriptor
public MockTaskDescriptor()
-
-
Method Details
-
clear
public void clear() -
getResult
Description copied from interface:TaskDescriptor
This returns the result of the long running task. Returns null if the task is not finished.- Specified by:
getResult
in 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:TaskDescriptor
True if the task has been started.- Specified by:
isStarted
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- true if the task has been started.
-
isFinished
public boolean isFinished()Description copied from interface:TaskDescriptor
Tells if caller if the task has finished running or not.- Specified by:
isFinished
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- true if the task has finished running.
-
getTaskId
Description copied from interface:TaskDescriptor
Return the identifier for this task. This is only unique in the current execution of the JVM.- Specified by:
getTaskId
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- The unique id of the task
-
getStartedTimestamp
Description copied from interface:TaskDescriptor
Return the date when the task was started.- Specified by:
getStartedTimestamp
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the time that task was started.
null
will be returned if the task has not started executing.
-
getFinishedTimestamp
Description copied from interface:TaskDescriptor
Return the date when the task was finished.- Specified by:
getFinishedTimestamp
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the time that task finished executing.
null
will be returned if the task has not finished executing.
-
getSubmittedTimestamp
Description copied from interface:TaskDescriptor
Return the date when the task was submitted.- Specified by:
getSubmittedTimestamp
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the time that task was submitted to the
TaskManager
. Anull
value will never be returned as the task will always have a submission time.
-
getElapsedRunTime
public long getElapsedRunTime()Description copied from interface:TaskDescriptor
This 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:
getElapsedRunTime
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the elapsed run time in milliseconds.
-
getUserName
Description copied from interface:TaskDescriptor
Return the user that started to task.- Specified by:
getUserName
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the user that caused the task to be submitted. This may be null.
-
getDescription
Description copied from interface:TaskDescriptor
Return the description of the task passed when it was created.- Specified by:
getDescription
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- a meaningful description of the task
-
getTaskContext
Description copied from interface:TaskDescriptor
Return the context of task. Code that starts long running tasks can implement their own variants of this.- Specified by:
getTaskContext
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the context of the task. This method will never return
null
as a task must always have a context.
-
getProgressURL
Description copied from interface:TaskDescriptor
Returns the URL that displays progress on this task. It is built using theTaskContext
.- Specified by:
getProgressURL
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the URL that displays progress for this task.
null
cannot be returned.
-
getTaskProgressIndicator
Description copied from interface:TaskDescriptor
Return theTaskProgressIndicator
associated with the task. A task will only have an indicator if its callable implements theProvidesTaskProgress
interface.- Specified by:
getTaskProgressIndicator
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- the
TaskProgressIndicator
associated with the task ornull
if there isn't one.
-
setResult
Description copied from interface:TaskDescriptor
Store the result in the descriptor.- Specified by:
setResult
in 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:TaskDescriptor
Returns whether cancellation of task has been requested. Long-running operations should poll to see if task has been requested.- Specified by:
isCancelled
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
true
if cancellation has been requested, andfalse
otherwise
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:TaskDescriptor
Set flag to indicate this task has been cancelled;- Specified by:
setCancelled
in interfaceTaskDescriptor<V extends Serializable>
- Parameters:
cancelled
- Cancelled flag
-
isSelfRecovering
public boolean isSelfRecovering()Description copied from interface:TaskDescriptor
Returns 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:
isSelfRecovering
in interfaceTaskDescriptor<V extends Serializable>
- See Also:
-
setSelfRecovering
public void setSelfRecovering(boolean selfRecovering) -
isCancellable
public boolean isCancellable()Description copied from interface:TaskDescriptor
Returns whether this supports requests to cancel it.- Specified by:
isCancellable
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
true
if cancellation is supported, andfalse
otherwise
-
setCancelable
public void setCancelable(boolean isCancelable) -
getNodeId
Description copied from interface:TaskDescriptor
Returns node id from where task was submitted- Specified by:
getNodeId
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- node id
-
setNodeId
-
getSpanningOperation
Description copied from interface:TaskDescriptor
Return operation that this task is part of.- Specified by:
getSpanningOperation
in interfaceTaskDescriptor<V extends Serializable>
- Returns:
- operation that this task is part of
-
setSpanningOperation
-