brooklyn.management.ExecutionManager Maven / Gradle / Ivy
package brooklyn.management;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import brooklyn.entity.Entity;
/**
* 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:
*
* - Tracked with tags/buckets
*
- Be {@link Runnable}s, {@link Callable}s, or {@link groovy.lang.Closure}s
*
- Remembered after completion
*
- Treated as {@link Task} instances (see below)
*
- Given powerful synchronization capabilities
*
*
* The advantage of treating them as {@link Task} instances include:
*
* - Richer status information
*
- Started-by, contained-by relationships automatically remembered
*
- Runtime metadata (start, stop, etc)
*
- Grid and multi-machine support)
*
*
* For usage instructions see {@link #submit(Map, Task)}, and for examples see the various
* {@code ExecutionTest} and {@code TaskTest} instances.
*
* It has been developed for multi-location provisioning and management to track work being
* done by each {@link Entity}.
*
* Note the use of the environment variable {@code THREAD_POOL_SIZE} which is used to size
* the {@link 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.
*/
public interface ExecutionManager {
public boolean isShutdown();
/** returns the task with the given ID, or null if none */
public Task> getTask(String id);
/** returns all tasks with the given tag (immutable) */
public Set> getTasksWithTag(Object tag);
/** returns all tasks that have any of the given tags (immutable) */
public Set> getTasksWithAnyTag(Iterable> tags);
/** returns all tasks that have all of the given tags (immutable) */
public Set> getTasksWithAllTags(Iterable> tags);
/** returns all tags known to this manager (immutable) */
public Set