brooklyn.management
Interface Task<T>

All Superinterfaces:
Future<T>, com.google.common.util.concurrent.ListenableFuture<T>, TaskAdaptable<T>

public interface Task<T>
extends com.google.common.util.concurrent.ListenableFuture<T>, TaskAdaptable<T>

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 Runnable or Callable and thereafter it can be treated just like a Future.


Method Summary
 void blockUntilEnded()
          Causes calling thread to block until the task is ended.
 boolean blockUntilEnded(brooklyn.util.time.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.
 T get(brooklyn.util.time.Duration duration)
          As Future.get(long, java.util.concurrent.TimeUnit)
 String getDescription()
           
 String getDisplayName()
           
 long getEndTimeUtc()
          if Future.isDone() (for any reason) returns the time when the task ended; guaranteed to be >= getStartTimeUtc() > 0 if ended, or -1 otherwise
 String getId()
           
 long getStartTimeUtc()
          if isBegun() returns the time when the task was starts; guaranteed to be >= getSubmitTimeUtc() > 0 if started, or -1 otherwise
 String getStatusDetail(boolean multiline)
          Returns detailed status, suitable for a hover.
 String getStatusSummary()
           
 Task<?> getSubmittedByTask()
          task which submitted this task, if was submitted by a task
 long getSubmitTimeUtc()
          if isSubmitted() returns the time when the task was submitted; or -1 otherwise
 Set<Object> getTags()
           
 Thread getThread()
          The thread where the task is running, if it is running.
 T getUnchecked()
          As Future.get(), but propagating checked exceptions as unchecked for convenience.
 T getUnchecked(brooklyn.util.time.Duration duration)
          As Future.get(), but propagating checked exceptions as unchecked for convenience (including a TimeoutException if the duration expires)
 boolean isBegun()
          Whether task has started running.
 boolean isError()
          Whether the task threw an error, including cancellation (implies Future.isDone())
 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.
 
Methods inherited from interface com.google.common.util.concurrent.ListenableFuture
addListener
 
Methods inherited from interface java.util.concurrent.Future
cancel, get, get, isCancelled, isDone
 
Methods inherited from interface brooklyn.management.TaskAdaptable
asTask
 

Method Detail

getId

String getId()

getTags

Set<Object> getTags()

getSubmitTimeUtc

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


getStartTimeUtc

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


getEndTimeUtc

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


getDisplayName

String getDisplayName()

getDescription

String getDescription()

getSubmittedByTask

Task<?> getSubmittedByTask()
task which submitted this task, if was submitted by a task


getThread

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


isSubmitted

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.


isBegun

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

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


blockUntilStarted

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


blockUntilEnded

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

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


getStatusSummary

String getStatusSummary()

getStatusDetail

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


get

T get(brooklyn.util.time.Duration duration)
      throws InterruptedException,
             ExecutionException,
             TimeoutException
As Future.get(long, java.util.concurrent.TimeUnit)

Throws:
InterruptedException
ExecutionException
TimeoutException

getUnchecked

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


getUnchecked

T getUnchecked(brooklyn.util.time.Duration duration)
As Future.get(), but propagating checked exceptions as unchecked for convenience (including a TimeoutException if the duration expires)



Copyright © 2013. All Rights Reserved.