brooklyn.management
Interface ExecutionManager


public interface ExecutionManager

This class manages the execution of a number of jobs with tags. It is like an executor service (and it ends up delegating to one) but adds additional support where jobs can be:

The advantage of treating them as Task instances include:

For usage instructions see #submit(Map, Task), and for examples see the various ExecutionTest and TaskTest instances.

It has been developed for multi-location provisioning and management to track work being done by each Entity.

Note the use of the environment variable THREAD_POOL_SIZE which is used to size the ExecutorService thread pool. The default is calculated as twice the number of CPUs in the system plus two, giving 10 for a four core system, 18 for an eight CPU server and so on.


Method Summary
 Task<?> getTask(String id)
          returns the task with the given ID, or null if none
 Set<Task<?>> getTasksWithAllTags(Iterable<?> tags)
          returns all tasks that have all of the given tags (immutable)
 Set<Task<?>> getTasksWithAnyTag(Iterable<?> tags)
          returns all tasks that have any of the given tags (immutable)
 Set<Task<?>> getTasksWithTag(Object tag)
          returns all tasks with the given tag (immutable)
 Set<Object> getTaskTags()
          returns all tags known to this manager (immutable)
 boolean isShutdown()
           
<T> Task<T>
submit(Callable<T> c)
          see #submit(Map, Task)
<T> Task<T>
submit(Map<?,?> flags, Callable<T> c)
          see #submit(Map, Task)
<T> Task<T>
submit(Map<?,?> flags, Object c)
          Deprecated. since 0.5.0 or 0.6.0, while refactoring groovy->java; use strongly typed methods
 Task<?> submit(Map<?,?> flags, Runnable r)
          see #submit(Map, Task)
<T> Task<T>
submit(Map<?,?> flags, TaskAdaptable<T> task)
          Submits the given Task for execution in the context associated with this manager.
 Task<?> submit(Runnable r)
          see #submit(Map, Task)
<T> Task<T>
submit(TaskAdaptable<T> task)
          see #submit(Map, Task)
 

Method Detail

isShutdown

boolean isShutdown()

getTask

Task<?> getTask(String id)
returns the task with the given ID, or null if none


getTasksWithTag

Set<Task<?>> getTasksWithTag(Object tag)
returns all tasks with the given tag (immutable)


getTasksWithAnyTag

Set<Task<?>> getTasksWithAnyTag(Iterable<?> tags)
returns all tasks that have any of the given tags (immutable)


getTasksWithAllTags

Set<Task<?>> getTasksWithAllTags(Iterable<?> tags)
returns all tasks that have all of the given tags (immutable)


getTaskTags

Set<Object> getTaskTags()
returns all tags known to this manager (immutable)


submit

Task<?> submit(Runnable r)
see #submit(Map, Task)


submit

<T> Task<T> submit(Callable<T> c)
see #submit(Map, Task)


submit

<T> Task<T> submit(TaskAdaptable<T> task)
see #submit(Map, Task)


submit

Task<?> submit(Map<?,?> flags,
               Runnable r)
see #submit(Map, Task)


submit

<T> Task<T> submit(Map<?,?> flags,
                   Callable<T> c)
see #submit(Map, Task)


submit

@Deprecated
<T> Task<T> submit(Map<?,?> flags,
                              Object c)
Deprecated. since 0.5.0 or 0.6.0, while refactoring groovy->java; use strongly typed methods

See Also:
#submit(Map, Task)}

submit

<T> Task<T> submit(Map<?,?> flags,
                   TaskAdaptable<T> task)
Submits the given Task for execution in the context associated with this manager. The following optional flags supported (in the optional map first arg): Callbacks run in the task's thread, and if the callback is a groovy.lang.Closure it is passed the task for convenience. The closure can be any of the following types; either a groovy.lang.Closure, Runnable or Callable.

If a Map is supplied it must be modifiable (currently; may allow immutable maps in future).



Copyright © 2013. All Rights Reserved.