Brooklyn

brooklyn.management
[Java] Interface Task

brooklyn.management.TaskAdaptable
  brooklyn.management.Task
      com.google.common.util.concurrent.ListenableFuture
All Superinterfaces:
TaskAdaptable, ListenableFuture

public interface Task
extends ListenableFuture, TaskAdaptable

Represents a unit of work for execution. When used with an ExecutionManager or ExecutionContext it will record submission time, execution start time, end time, and any result. A task can be submitted to the ExecutionManager or ExecutionContext, in which case it will be returned, or it may be created by submission of a java.lang.Runnable or java.util.concurrent.Callable and thereafter it can be treated just like a java.util.concurrent.Future.


Method Summary
void blockUntilEnded()

Causes calling thread to block until the task is ended.

boolean blockUntilEnded(Duration timeout)

As blockUntilEnded(), but returning after the given timeout; true if the task has ended and false otherwise

void blockUntilStarted()

Causes calling thread to block until the task is started.

java.lang.Object get(Duration duration)

As get(long, java.util.concurrent.TimeUnit)

java.lang.String getDescription()

java.lang.String getDisplayName()

long getEndTimeUtc()

if isDone() (for any reason) returns the time when the task ended; guaranteed to be >= getStartTimeUtc() > 0 if ended, or -1 otherwise

java.lang.String getId()

long getStartTimeUtc()

if isBegun() returns the time when the task was starts; guaranteed to be >= getSubmitTimeUtc() > 0 if started, or -1 otherwise

java.lang.String getStatusDetail(boolean multiline)

Returns detailed status, suitable for a hover.

java.lang.String getStatusSummary()

long getSubmitTimeUtc()

if isSubmitted() returns the time when the task was submitted; or -1 otherwise

Task getSubmittedByTask()

task which submitted this task, if was submitted by a task

java.util.Set getTags()

java.lang.Thread getThread()

The thread where the task is running, if it is running.

java.lang.Object getUnchecked()

As get(), but propagating checked exceptions as unchecked for convenience.

java.lang.Object getUnchecked(Duration duration)

As get(), but propagating checked exceptions as unchecked for convenience (including a java.util.concurrent.TimeoutException if the duration expires)

boolean isBegun()

Whether task has started running.

boolean isError()

Whether the task threw an error, including cancellation (implies isDone())

boolean isSubmitted()

Whether task has been submitted

 
Methods inherited from interface TaskAdaptable
asTask
 

Method Detail

blockUntilEnded

public void blockUntilEnded()
Causes calling thread to block until the task is ended.

Either normally or by cancellation or error, but without throwing error on cancellation or error. (Errors are logged at debug.)


blockUntilEnded

public boolean blockUntilEnded(Duration timeout)
As blockUntilEnded(), but returning after the given timeout; true if the task has ended and false otherwise


blockUntilStarted

public void blockUntilStarted()
Causes calling thread to block until the task is started.


get

public java.lang.Object get(Duration duration)
As get(long, java.util.concurrent.TimeUnit)


getDescription

public java.lang.String getDescription()


getDisplayName

public java.lang.String getDisplayName()


getEndTimeUtc

public long getEndTimeUtc()
if isDone() (for any reason) returns the time when the task ended; guaranteed to be >= getStartTimeUtc() > 0 if ended, or -1 otherwise


getId

public java.lang.String getId()


getStartTimeUtc

public long getStartTimeUtc()
if isBegun() returns the time when the task was starts; guaranteed to be >= getSubmitTimeUtc() > 0 if started, or -1 otherwise


getStatusDetail

public java.lang.String getStatusDetail(boolean multiline)
Returns detailed status, suitable for a hover. Plain-text format, with new-lines (and sometimes extra info) if multiline enabled.


getStatusSummary

public java.lang.String getStatusSummary()


getSubmitTimeUtc

public long getSubmitTimeUtc()
if isSubmitted() returns the time when the task was submitted; or -1 otherwise


getSubmittedByTask

public Task getSubmittedByTask()
task which submitted this task, if was submitted by a task


getTags

public java.util.Set getTags()


getThread

public java.lang.Thread getThread()
The thread where the task is running, if it is running.


getUnchecked

public java.lang.Object getUnchecked()
As get(), but propagating checked exceptions as unchecked for convenience.


getUnchecked

public java.lang.Object getUnchecked(Duration duration)
As get(), but propagating checked exceptions as unchecked for convenience (including a java.util.concurrent.TimeoutException if the duration expires)


isBegun

public boolean isBegun()
Whether task has started running. Will remain true after normal completion or non-cancellation error. will be true on cancel iff the thread did actually start.


isError

public boolean isError()
Whether the task threw an error, including cancellation (implies isDone())


isSubmitted

public boolean isSubmitted()
Whether task has been submitted Submitted tasks are normally expected to start running then complete, but unsubmitted tasks are sometimes passed around for someone else to submit them.


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.