public class BrooklynTaskTags extends TaskTags
Eventually it may be better to replace these 'tags' on Tasks with strongly typed context objects. (Tags there are used mainly for determining who called it (caller), what they called it on (target entity), and what type of task it is (effector, schedule/sensor, etc).)
Modifier and Type | Class and Description |
---|---|
static class |
BrooklynTaskTags.EffectorCallTag |
static class |
BrooklynTaskTags.EntitlementTag |
static class |
BrooklynTaskTags.WrappedEntity |
static class |
BrooklynTaskTags.WrappedItem<T> |
static class |
BrooklynTaskTags.WrappedObject<T> |
static class |
BrooklynTaskTags.WrappedStream |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BROOKLYN_SERVER_TASK_TAG
Tag for tasks which are running on behalf of the management server, rather than any entity
|
static java.lang.String |
CALLER_ENTITY |
static java.lang.String |
CONTEXT_ADJUNCT |
static java.lang.String |
CONTEXT_ENTITY |
static java.lang.String |
EFFECTOR_TAG
Tag for a task which represents an effector
|
static java.lang.String |
IMMEDIATE_TASK_TAG
marks that a task is meant to return immediately, without blocking (or if absolutely necessary blocking for a short while)
|
static java.lang.String |
NON_TRANSIENT_TASK_TAG
Tag for a task which *is* interesting, in contrast to
TRANSIENT_TASK_TAG |
static java.lang.String |
SENSOR_TAG
Tag for a task which represents a sensor being published
|
static java.lang.String |
STREAM_ENV
not a stream, but inserted with the same mechanism
|
static java.lang.String |
STREAM_STDERR |
static java.lang.String |
STREAM_STDIN |
static java.lang.String |
STREAM_STDOUT |
static java.lang.String |
TARGET_ENTITY |
static java.lang.String |
TRANSIENT_TASK_TAG
indicates a task is transient, roughly that is to say it is uninteresting --
specifically this means it can be GC'd as soon as it is completed,
and that it need not appear in some task lists;
often used for framework lifecycle events and sensor polling
|
INESSENTIAL_TASK, SUB_TASK_TAG
Constructor and Description |
---|
BrooklynTaskTags() |
Modifier and Type | Method and Description |
---|---|
static Task<?> |
getClosestEffectorTask(Task<?> child,
Effector<?> effector)
finds the task up the
child hierarchy handling the effector call,
returns null if one doesn't exist. |
static Entity |
getContextEntity(Task<?> task) |
static ConfigBag |
getCurrentEffectorParameters() |
static ExecutionContext |
getCurrentExecutionContext()
This should always be identical to
BasicExecutionContext.getCurrentExecutionContext() as
there are two ways to derive the ExecutionContext : one is the ThreadLocal accessed from the above method
and set by BasicExecutionContext submissions; the other is by looking at getTargetOrContextEntity(Task)
and CONTEXT_ADJUNCT tags on the current task. |
static BrooklynTaskTags.EffectorCallTag |
getEffectorCallTag(Task<?> task,
boolean recurse)
finds the first
BrooklynTaskTags.EffectorCallTag tag on this tag, or optionally on submitters, or null |
static java.lang.String |
getEffectorName(Task<?> task)
finds the first
BrooklynTaskTags.EffectorCallTag tag on this tag or a submitter, and returns the effector name |
static ConfigBag |
getEffectorParameters(Task<?> task) |
static EntitlementContext |
getEntitlement(BrooklynTaskTags.EntitlementTag tag) |
static EntitlementContext |
getEntitlement(java.util.Collection<?> tags) |
static EntitlementContext |
getEntitlement(Task<?> task) |
static ExecutionContext |
getExecutionContext(java.util.Collection<?> tags) |
static ExecutionContext |
getExecutionContext(Task<?> t) |
static ManagementContext |
getManagementContext(Task<?> task) |
static Entity |
getTargetOrContextEntity(Task<?> t) |
static java.lang.Object |
getTargetOrContextEntityTag(Task<?> task) |
static java.util.Set<Task<?>> |
getTasksInAdjunctContext(ExecutionManager em,
EntityAdjunct a) |
static java.util.Set<Task<?>> |
getTasksInEntityContext(ExecutionManager em,
Entity e) |
static <T> T |
getUnwrappedObjectTagOfType(java.util.Collection<?> tags,
java.lang.String wrappingType,
java.lang.Class<T> type) |
static Entity |
getWrappedEntityOfType(java.util.Collection<?> tags,
java.lang.String wrappingType) |
static Entity |
getWrappedEntityOfType(Task<?> t,
java.lang.String wrappingType) |
static BrooklynTaskTags.WrappedEntity |
getWrappedEntityTagOfType(java.util.Collection<?> tags,
java.lang.String wrappingType) |
static BrooklynTaskTags.WrappedEntity |
getWrappedEntityTagOfType(Task<?> t,
java.lang.String wrappingType) |
static <T> BrooklynTaskTags.WrappedObject<T> |
getWrappedObjectTagOfType(java.util.Collection<?> tags,
java.lang.String wrappingType,
java.lang.Class<T> type) |
static boolean |
isEffectorTask(Task<?> task) |
static boolean |
isInEffectorTask(Task<?> task,
Entity entity,
Effector<?> effector,
boolean allowNestedEffectorCalls)
checks if the given task is part of the given effector call on the given entity;
|
static boolean |
isSubTask(Task<?> task) |
static boolean |
isTransient(Task<?> task) |
static void |
setEffectorParameters(Task<?> task,
ConfigBag parameters) |
static void |
setInessential(Task<?> task) |
static void |
setTransient(Task<?> task) |
static BrooklynTaskTags.WrappedStream |
stream(Task<?> task,
java.lang.String streamType)
returns the tag for the indicated stream, or null
|
static java.util.Set<BrooklynTaskTags.WrappedStream> |
streams(Task<?> task)
returns the set of tags indicating the streams available on a task
|
static BrooklynTaskTags.WrappedEntity |
tagForCallerEntity(Entity entity) |
static BrooklynTaskTags.WrappedObject<EntityAdjunct> |
tagForContextAdjunct(EntityAdjunct adjunct)
As
tagForContextEntity(Entity) but wrapping an adjunct. |
static BrooklynTaskTags.WrappedEntity |
tagForContextEntity(Entity entity)
Marks a task as running in the context of the entity.
|
static BrooklynTaskTags.EffectorCallTag |
tagForEffectorCall(Entity entity,
java.lang.String effectorName,
ConfigBag parameters) |
static BrooklynTaskTags.EntitlementTag |
tagForEntitlement(EntitlementContext context) |
static BrooklynTaskTags.WrappedStream |
tagForEnvStream(java.lang.String streamEnv,
java.util.Map<?,?> env)
creates a tag suitable for attaching a snapshot of an environment var map as a "stream" on a task;
mainly for use with STREAM_ENV
|
static BrooklynTaskTags.WrappedStream |
tagForStream(java.lang.String streamType,
<any> contents,
<any> size)
creates a tag suitable for marking a stream available on a task
|
static BrooklynTaskTags.WrappedStream |
tagForStream(java.lang.String streamType,
java.io.ByteArrayOutputStream stream)
creates a tag suitable for marking a stream available on a task
|
static BrooklynTaskTags.WrappedStream |
tagForStreamSoft(java.lang.String streamType,
java.io.ByteArrayOutputStream stream)
creates a tag suitable for marking a stream available on a task, but which might be GC'd
|
static BrooklynTaskTags.WrappedEntity |
tagForTargetEntity(Entity entity) |
addTagDynamically, addTagsDynamically, getTagsFast, hasTag, isInessential, markInessential
public static final java.lang.String BROOKLYN_SERVER_TASK_TAG
public static final java.lang.String EFFECTOR_TAG
public static final java.lang.String SENSOR_TAG
public static final java.lang.String NON_TRANSIENT_TASK_TAG
TRANSIENT_TASK_TAG
public static final java.lang.String TRANSIENT_TASK_TAG
public static final java.lang.String IMMEDIATE_TASK_TAG
public static final java.lang.String CONTEXT_ENTITY
public static final java.lang.String CALLER_ENTITY
public static final java.lang.String TARGET_ENTITY
public static final java.lang.String CONTEXT_ADJUNCT
public static final java.lang.String STREAM_STDIN
public static final java.lang.String STREAM_STDOUT
public static final java.lang.String STREAM_STDERR
public static final java.lang.String STREAM_ENV
public static BrooklynTaskTags.WrappedEntity tagForContextEntity(Entity entity)
DynamicTasks
.
The result from the call should be used only when reading tags (for example
to compare whether the tag already exists). The only place where the value is
added to the entity tags is AbstractManagementContext.getExecutionContext(Entity)
.public static BrooklynTaskTags.WrappedEntity tagForCallerEntity(Entity entity)
public static BrooklynTaskTags.WrappedEntity tagForTargetEntity(Entity entity)
public static BrooklynTaskTags.WrappedObject<EntityAdjunct> tagForContextAdjunct(EntityAdjunct adjunct)
tagForContextEntity(Entity)
but wrapping an adjunct.
Tasks with this tag will also have a tagForContextEntity(Entity)
.public static BrooklynTaskTags.WrappedEntity getWrappedEntityTagOfType(Task<?> t, java.lang.String wrappingType)
public static BrooklynTaskTags.WrappedEntity getWrappedEntityTagOfType(java.util.Collection<?> tags, java.lang.String wrappingType)
public static <T> BrooklynTaskTags.WrappedObject<T> getWrappedObjectTagOfType(java.util.Collection<?> tags, java.lang.String wrappingType, java.lang.Class<T> type)
public static <T> T getUnwrappedObjectTagOfType(java.util.Collection<?> tags, java.lang.String wrappingType, java.lang.Class<T> type)
public static Entity getWrappedEntityOfType(Task<?> t, java.lang.String wrappingType)
public static Entity getWrappedEntityOfType(java.util.Collection<?> tags, java.lang.String wrappingType)
public static java.lang.Object getTargetOrContextEntityTag(Task<?> task)
public static java.util.Set<Task<?>> getTasksInEntityContext(ExecutionManager em, Entity e)
public static java.util.Set<Task<?>> getTasksInAdjunctContext(ExecutionManager em, EntityAdjunct a)
public static ManagementContext getManagementContext(Task<?> task)
public static BrooklynTaskTags.WrappedStream tagForStream(java.lang.String streamType, java.io.ByteArrayOutputStream stream)
public static BrooklynTaskTags.WrappedStream tagForStreamSoft(java.lang.String streamType, java.io.ByteArrayOutputStream stream)
public static BrooklynTaskTags.WrappedStream tagForStream(java.lang.String streamType, <any> contents, <any> size)
public static BrooklynTaskTags.WrappedStream tagForEnvStream(java.lang.String streamEnv, java.util.Map<?,?> env)
public static java.util.Set<BrooklynTaskTags.WrappedStream> streams(Task<?> task)
public static BrooklynTaskTags.WrappedStream stream(Task<?> task, java.lang.String streamType)
public static void setInessential(Task<?> task)
public static void setTransient(Task<?> task)
public static boolean isTransient(Task<?> task)
public static boolean isSubTask(Task<?> task)
public static boolean isEffectorTask(Task<?> task)
public static BrooklynTaskTags.EffectorCallTag tagForEffectorCall(Entity entity, java.lang.String effectorName, ConfigBag parameters)
public static boolean isInEffectorTask(Task<?> task, @Nullable Entity entity, @Nullable Effector<?> effector, boolean allowNestedEffectorCalls)
task
- the task to check (false if null)entity
- the entity where this effector task should be running, or any entity if nulleffector
- the effector (matching name) where this task should be running, or any effector if nullallowNestedEffectorCalls
- whether to match ancestor effector calls, e.g. if eff1 calls eff2,
and we are checking eff2, whether to match eff1public static Task<?> getClosestEffectorTask(Task<?> child, Effector<?> effector)
child
hierarchy handling the effector
call,
returns null if one doesn't exist.public static BrooklynTaskTags.EffectorCallTag getEffectorCallTag(Task<?> task, boolean recurse)
BrooklynTaskTags.EffectorCallTag
tag on this tag, or optionally on submitters, or nullpublic static java.lang.String getEffectorName(Task<?> task)
BrooklynTaskTags.EffectorCallTag
tag on this tag or a submitter, and returns the effector namepublic static ConfigBag getCurrentEffectorParameters()
public static EntitlementContext getEntitlement(Task<?> task)
public static EntitlementContext getEntitlement(java.util.Collection<?> tags)
public static EntitlementContext getEntitlement(BrooklynTaskTags.EntitlementTag tag)
public static BrooklynTaskTags.EntitlementTag tagForEntitlement(EntitlementContext context)
public static ExecutionContext getExecutionContext(java.util.Collection<?> tags)
public static ExecutionContext getExecutionContext(Task<?> t)
public static ExecutionContext getCurrentExecutionContext()
BasicExecutionContext.getCurrentExecutionContext()
as
there are two ways to derive the ExecutionContext
: one is the ThreadLocal
accessed from the above method
and set by BasicExecutionContext
submissions; the other is by looking at getTargetOrContextEntity(Task)
and CONTEXT_ADJUNCT
tags on the current task. As BasicExecutionContext
also sets those tags,
the only time the two will be different is if ExecutionManager.submit(org.apache.brooklyn.api.mgmt.TaskAdaptable)
is used supplying one or more of these context tags, in which case only this method will determine the execution context.