Brooklyn

brooklyn.util.task
[Java] Class Tasks

java.lang.Object
  brooklyn.util.task.Tasks

public class Tasks

Method Summary
static TaskBuilder builder()

static Task current()

the Task where the current thread is executing, if executing in a Task, otherwise null

static boolean isAncestorCancelled(Task t)

static boolean isQueuedOrSubmitted(TaskAdaptable task)

tries to add the given task in the given addition context, returns true if it could, false if it could not (doesn't throw anything)

static Task parallel(TaskAdaptable... tasks)

static Task parallel(java.lang.String name, TaskAdaptable... tasks)

static Task parallelInternal(java.lang.String name, Task[] tasks)

static void resetBlockingDetails()

static void resetBlockingTask()

static java.lang.Object resolveValue(java.lang.Object v, java.lang.Class type, ExecutionContext exec)

@see #resolveValue(Object, Class, ExecutionContext, String)

static java.lang.Object resolveValue(java.lang.Object v, java.lang.Class type, ExecutionContext exec, java.lang.String contextMessage)

attempt to resolve the given value as the given type, waiting on futures, submitting if necessary, and coercing as allowed by TypeCoercions; contextMessage (optional) will be displayed in status reports while it waits (e.g. the name of the config key being looked up)

static Task sequential(TaskAdaptable... tasks)

static Task sequential(java.lang.String name, TaskAdaptable... tasks)

static TaskFactory sequential(TaskFactory... taskFactories)

static TaskFactory sequential(java.lang.String name, TaskFactory... taskFactories)

static void setBlockingDetails(java.lang.String description)

convenience for setting "blocking details" on any task where the current thread is running; typically invoked prior to a wait, for transparency to a user; then invoked with 'null' just after the wait

static void setBlockingTask(Task blocker)

static void setExtraStatusDetails(java.lang.String notes)

sets extra status details on the current task, if possible (otherwise does nothing).

static Supplier supplier(TaskAdaptable task)

static java.lang.Object tag(Task task, java.lang.Class type, boolean recurseHierarchy)

returns the first tag found on the given task which matches the given type, looking up the submission hierarachy if necessary

static boolean tryQueueing(TaskQueueingContext adder, TaskAdaptable task)

static java.lang.Object withBlockingDetails(java.lang.String description, java.util.concurrent.Callable code)

convenience for setting "blocking details" on any task where the current thread is running, while the passed code is executed; often used from groovy as

withBlockingDetails("sleeping 5s") { Thread.sleep(5000);  }
If code block is null, the description is set until further notice (not cleareed).

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

builder

public static TaskBuilder builder()


current

@SuppressWarnings("rawtypes")
public static Task current()
the Task where the current thread is executing, if executing in a Task, otherwise null


isAncestorCancelled

public static boolean isAncestorCancelled(Task t)


isQueuedOrSubmitted

public static boolean isQueuedOrSubmitted(TaskAdaptable task)
tries to add the given task in the given addition context, returns true if it could, false if it could not (doesn't throw anything)


parallel

public static Task parallel(TaskAdaptable... tasks)


parallel

public static Task parallel(java.lang.String name, TaskAdaptable... tasks)


parallelInternal

public static Task parallelInternal(java.lang.String name, Task[] tasks)


resetBlockingDetails

public static void resetBlockingDetails()


resetBlockingTask

public static void resetBlockingTask()


resolveValue

public static java.lang.Object resolveValue(java.lang.Object v, java.lang.Class type, ExecutionContext exec)
See Also:
resolveValue(Object, Class, ExecutionContext, String)


resolveValue

@SuppressWarnings({ "unchecked", "rawtypes" })
public static java.lang.Object resolveValue(java.lang.Object v, java.lang.Class type, ExecutionContext exec, java.lang.String contextMessage)
attempt to resolve the given value as the given type, waiting on futures, submitting if necessary, and coercing as allowed by TypeCoercions; contextMessage (optional) will be displayed in status reports while it waits (e.g. the name of the config key being looked up)


sequential

public static Task sequential(TaskAdaptable... tasks)


sequential

public static Task sequential(java.lang.String name, TaskAdaptable... tasks)


sequential

public static TaskFactory sequential(TaskFactory... taskFactories)


sequential

public static TaskFactory sequential(java.lang.String name, TaskFactory... taskFactories)


setBlockingDetails

public static void setBlockingDetails(java.lang.String description)
convenience for setting "blocking details" on any task where the current thread is running; typically invoked prior to a wait, for transparency to a user; then invoked with 'null' just after the wait


setBlockingTask

public static void setBlockingTask(Task blocker)


setExtraStatusDetails

public static void setExtraStatusDetails(java.lang.String notes)
sets extra status details on the current task, if possible (otherwise does nothing). the extra status is presented in Task.getStatusDetails(true)


supplier

public static Supplier supplier(TaskAdaptable task)


tag

return tag(task.getSubmittedByTask(), type, true);
public static java.lang.Object tag( Task task, java.lang.Class type, boolean recurseHierarchy)
returns the first tag found on the given task which matches the given type, looking up the submission hierarachy if necessary


tryQueueing

public static boolean tryQueueing(TaskQueueingContext adder, TaskAdaptable task)


withBlockingDetails

@SuppressWarnings("rawtypes")
public static java.lang.Object withBlockingDetails(java.lang.String description, java.util.concurrent.Callable code)
convenience for setting "blocking details" on any task where the current thread is running, while the passed code is executed; often used from groovy as
withBlockingDetails("sleeping 5s") { Thread.sleep(5000);  }
If code block is null, the description is set until further notice (not cleareed).


 

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