public class DependentConfiguration
extends java.lang.Object
ExecutionContext
s, blocking on attributes from other entities, possibly transforming those;
these Task
instances are typically passed in Entity#setConfig(ConfigKey, Object)
.
If using a lot it may be useful to:
import static org.apache.brooklyn.core.sensor.DependentConfiguration.*;
Note that these methods return one-time tasks. The DslComponent methods return long-lasting pointers and should now normally be used instead.
Modifier and Type | Class and Description |
---|---|
static class |
DependentConfiguration.AttributeAndSensorCondition<T> |
static class |
DependentConfiguration.Builder<T,V>
Builder for producing variants of attributeWhenReady.
|
static class |
DependentConfiguration.MaxThreadsTransformerFunction |
static class |
DependentConfiguration.MultiBuilder<T,V,V2>
Builder for producing variants of attributeWhenReady.
|
static class |
DependentConfiguration.ProtoBuilder
Builder for producing variants of attributeWhenReady.
|
static class |
DependentConfiguration.RegexTransformerFunction |
static class |
DependentConfiguration.RegexTransformerString |
Modifier and Type | Method and Description |
---|---|
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
<any> ready,
<any> postProcess) |
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
<any> ready,
groovy.lang.Closure<V> postProcess)
Deprecated.
since 0.11.0; explicit groovy utilities/support will be deleted.
|
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
groovy.lang.Closure<java.lang.Boolean> ready,
groovy.lang.Closure<V> postProcess)
Deprecated.
since 0.11.0; explicit groovy utilities/support will be deleted.
|
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
groovy.lang.Closure<V> postProcess)
Deprecated.
since 0.11.0; explicit groovy utilities/support will be deleted.
|
static <T> Task<T> |
attributeWhenReady(Entity source,
AttributeSensor<T> sensor)
Default readiness is Groovy truth.
|
static <T> Task<T> |
attributeWhenReady(Entity source,
AttributeSensor<T> sensor,
<any> ready)
returns an unsubmitted
Task which blocks until the given sensor on the given source entity gives a value that satisfies ready, then returns that value;
particular useful in Entity configuration where config will block until Tasks have a value |
static <T> Task<T> |
attributeWhenReady(Entity source,
AttributeSensor<T> sensor,
groovy.lang.Closure<java.lang.Boolean> ready)
Deprecated.
since 0.11.0; explicit groovy utilities/support will be deleted.
|
static DependentConfiguration.ProtoBuilder |
builder() |
static Task<java.lang.String> |
formatString(java.lang.Object spec,
java.lang.Object... args)
Method which returns a Future containing a string formatted using String.format,
where the arguments can be normal objects or tasks;
tasks will be waited on (submitted if necessary) and their results substituted in the call
to String.format.
|
static Maybe<java.lang.String> |
formatStringImmediately(java.lang.Object spec,
java.lang.Object... args) |
static <T> Task<java.util.List<T>> |
listAttributesWhenReady(AttributeSensor<T> sensor,
java.lang.Iterable<Entity> entities)
returns a task for parallel execution returning a list of values for the given sensor for the given entity list,
optionally when the values satisfy a given readiness predicate (defaulting to groovy truth if not supplied)
|
static <T> Task<java.util.List<T>> |
listAttributesWhenReady(AttributeSensor<T> sensor,
java.lang.Iterable<Entity> entities,
<any> readiness)
returns a task for parallel execution returning a list of values of the given sensor list on the given entity,
optionally when the values satisfy a given readiness predicate (defaulting to groovy truth if not supplied)
|
static <T> Task<java.util.List<T>> |
listAttributesWhenReady(AttributeSensor<T> sensor,
java.lang.Iterable<Entity> entities,
groovy.lang.Closure<java.lang.Boolean> readiness)
Deprecated.
since 0.11.0; explicit groovy utilities/support will be deleted.
|
static Task<ReleaseableLatch> |
maxConcurrency(java.lang.Object maxThreads) |
static Maybe<ReleaseableLatch> |
maxConcurrencyImmediately(java.lang.Object maxThreads) |
static Task<<any>> |
regexReplacement(java.lang.Object pattern,
java.lang.Object replacement) |
static Task<java.lang.String> |
regexReplacement(java.lang.Object source,
java.lang.Object pattern,
java.lang.Object replacement) |
static Maybe<<any>> |
regexReplacementImmediately(java.lang.Object pattern,
java.lang.Object replacement) |
static Maybe<java.lang.String> |
regexReplacementImmediately(java.lang.Object source,
java.lang.Object pattern,
java.lang.Object replacement) |
static <U,T> Task<T> |
transform(java.util.Map flags,
TaskAdaptable<U> task,
<any> transformer) |
static <U,T> Task<T> |
transform(Task<U> task,
<any> transformer)
Returns a
Task which waits for the result of first parameter, then applies the function in the second
parameter to it, returning that result. |
static <U,T> Task<T> |
transformMultiple(<any> transformer,
TaskAdaptable<U>... tasks)
Returns a task which waits for multiple other tasks (submitting if necessary)
and performs arbitrary computation over the List of results.
|
static <U,T> Task<T> |
transformMultiple(java.util.Map flags,
<any> transformer,
java.util.Collection<? extends TaskAdaptable<U>> tasks) |
static <U,T> Task<T> |
transformMultiple(java.util.Map flags,
<any> transformer,
TaskAdaptable<U>... tasks) |
static <U,T> Task<T> |
transformMultiple(java.util.Map flags,
groovy.lang.Closure transformer,
TaskAdaptable<U>... tasks)
Deprecated.
since 0.11.0; explicit groovy utilities/support will be deleted.
|
static Task<java.lang.String> |
urlEncode(java.lang.Object arg)
Method which returns a Future containing an escaped URL string (see
Urls.encode(String) ). |
static Maybe<java.lang.String> |
urlEncodeImmediately(java.lang.Object arg) |
static <T,V> Task<V> |
valueWhenAttributeReady(Entity source,
AttributeSensor<T> sensor,
<any> valueProvider) |
static <T> Task<T> |
valueWhenAttributeReady(Entity source,
AttributeSensor<T> sensor,
T value) |
static <T> T |
waitForTask(Task<T> t,
Entity context) |
static <T> T |
waitForTask(Task<T> t,
Entity context,
java.lang.String contextMessage)
blocks until the given task completes, submitting if necessary, returning the result of that task;
optional contextMessage is available in status if this is running in a task
|
static <T> T |
waitInTaskForAttributeReady(Entity source,
AttributeSensor<T> sensor,
<any> ready) |
static <T> T |
waitInTaskForAttributeReady(Entity source,
AttributeSensor<T> sensor,
<any> ready,
java.util.List<DependentConfiguration.AttributeAndSensorCondition<?>> abortConditions) |
static <T> T |
waitInTaskForAttributeReady(Entity source,
AttributeSensor<T> sensor,
<any> ready,
java.util.List<DependentConfiguration.AttributeAndSensorCondition<?>> abortConditions,
java.lang.String blockingDetails) |
static <T> Task<T> |
whenDone(java.util.concurrent.Callable<T> job)
Deprecated.
since 0.7; code will be moved into test utilities
|
public static <T> Task<T> attributeWhenReady(Entity source, AttributeSensor<T> sensor)
#attributeWhenReady(Entity, AttributeSensor, Predicate)
@Deprecated public static <T> Task<T> attributeWhenReady(Entity source, AttributeSensor<T> sensor, groovy.lang.Closure<java.lang.Boolean> ready)
public static <T> Task<T> attributeWhenReady(Entity source, AttributeSensor<T> sensor, <any> ready)
Task
which blocks until the given sensor on the given source entity gives a value that satisfies ready, then returns that value;
particular useful in Entity configuration where config will block until Tasks have a value@Deprecated public static <T,V> Task<V> attributePostProcessedWhenReady(Entity source, AttributeSensor<T> sensor, groovy.lang.Closure<java.lang.Boolean> ready, groovy.lang.Closure<V> postProcess)
@Deprecated public static <T,V> Task<V> attributePostProcessedWhenReady(Entity source, AttributeSensor<T> sensor, groovy.lang.Closure<V> postProcess)
public static <T> Task<T> valueWhenAttributeReady(Entity source, AttributeSensor<T> sensor, T value)
public static <T,V> Task<V> valueWhenAttributeReady(Entity source, AttributeSensor<T> sensor, <any> valueProvider)
@Deprecated public static <T,V> Task<V> attributePostProcessedWhenReady(Entity source, AttributeSensor<T> sensor, <any> ready, groovy.lang.Closure<V> postProcess)
public static <T,V> Task<V> attributePostProcessedWhenReady(Entity source, AttributeSensor<T> sensor, <any> ready, <any> postProcess)
public static <T> T waitInTaskForAttributeReady(Entity source, AttributeSensor<T> sensor, <any> ready)
public static <T> T waitInTaskForAttributeReady(Entity source, AttributeSensor<T> sensor, <any> ready, java.util.List<DependentConfiguration.AttributeAndSensorCondition<?>> abortConditions)
public static <T> T waitInTaskForAttributeReady(Entity source, AttributeSensor<T> sensor, <any> ready, java.util.List<DependentConfiguration.AttributeAndSensorCondition<?>> abortConditions, java.lang.String blockingDetails)
@Deprecated public static <T> Task<T> whenDone(java.util.concurrent.Callable<T> job)
Task
which blocks until the given job returns, then returns the value of that job.public static <U,T> Task<T> transform(Task<U> task, <any> transformer)
Task
which waits for the result of first parameter, then applies the function in the second
parameter to it, returning that result.
Particular useful in Entity configuration where config will block until Tasks have completed,
allowing for example an #attributeWhenReady(Entity, AttributeSensor, Predicate)
expression to be
passed in the first argument then transformed by the function in the second argument to generate
the value that is used for the configurationpublic static <U,T> Task<T> transform(java.util.Map flags, TaskAdaptable<U> task, <any> transformer)
#transform(Task, Function)
public static <U,T> Task<T> transformMultiple(<any> transformer, TaskAdaptable<U>... tasks)
but note argument order is reversed (counterintuitive) to allow for varargs
@Deprecated public static <U,T> Task<T> transformMultiple(java.util.Map flags, groovy.lang.Closure transformer, TaskAdaptable<U>... tasks)
#transformMultiple(Function, TaskAdaptable...)
public static <U,T> Task<T> transformMultiple(java.util.Map flags, <any> transformer, TaskAdaptable<U>... tasks)
#transformMultiple(Function, TaskAdaptable...)
public static <U,T> Task<T> transformMultiple(java.util.Map flags, <any> transformer, java.util.Collection<? extends TaskAdaptable<U>> tasks)
public static Task<java.lang.String> formatString(java.lang.Object spec, java.lang.Object... args)
Example:
setConfig(URL, DependentConfiguration.formatString("%s:%s",
DependentConfiguration.attributeWhenReady(target, Target.HOSTNAME),
DependentConfiguration.attributeWhenReady(target, Target.PORT) ) );
public static Maybe<java.lang.String> formatStringImmediately(java.lang.Object spec, java.lang.Object... args)
ImmediateSupplier.ImmediateUnsupportedException
- if cannot evaluate this in a timely mannerpublic static Maybe<java.lang.String> urlEncodeImmediately(java.lang.Object arg)
ImmediateSupplier.ImmediateUnsupportedException
- if cannot evaluate this in a timely mannerpublic static Task<java.lang.String> urlEncode(java.lang.Object arg)
Urls.encode(String)
).
The arguments can be normal objects, tasks or DeferredSupplier
s.
tasks will be waited on (submitted if necessary) and their results substituted.public static Maybe<java.lang.String> regexReplacementImmediately(java.lang.Object source, java.lang.Object pattern, java.lang.Object replacement)
public static Task<java.lang.String> regexReplacement(java.lang.Object source, java.lang.Object pattern, java.lang.Object replacement)
public static Maybe<<any>> regexReplacementImmediately(java.lang.Object pattern, java.lang.Object replacement)
public static Task<<any>> regexReplacement(java.lang.Object pattern, java.lang.Object replacement)
public static Maybe<ReleaseableLatch> maxConcurrencyImmediately(java.lang.Object maxThreads)
public static Task<ReleaseableLatch> maxConcurrency(java.lang.Object maxThreads)
public static <T> Task<java.util.List<T>> listAttributesWhenReady(AttributeSensor<T> sensor, java.lang.Iterable<Entity> entities)
@Deprecated public static <T> Task<java.util.List<T>> listAttributesWhenReady(AttributeSensor<T> sensor, java.lang.Iterable<Entity> entities, groovy.lang.Closure<java.lang.Boolean> readiness)
public static <T> Task<java.util.List<T>> listAttributesWhenReady(AttributeSensor<T> sensor, java.lang.Iterable<Entity> entities, <any> readiness)
public static <T> T waitForTask(Task<T> t, Entity context) throws java.lang.InterruptedException
java.lang.InterruptedException
waitForTask(Task, Entity, String)
public static <T> T waitForTask(Task<T> t, Entity context, java.lang.String contextMessage) throws java.lang.InterruptedException
java.lang.InterruptedException
public static DependentConfiguration.ProtoBuilder builder()