public class DependentConfiguration
extends java.lang.Object
ExecutionContext
s, subscribing to attributes from other entities, possibly transforming those;
these Task
instances are typically passed in EntityLocal.setConfig(ConfigKey, Object)
.
If using a lot it may be useful to:
import static brooklyn.event.basic.DependentConfiguration.*;
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.MultiBuilder<T,V,V2>
Builder for producing variants of attributeWhenReady.
|
static class |
DependentConfiguration.ProtoBuilder
Builder for producing variants of attributeWhenReady.
|
Modifier and Type | Method and Description |
---|---|
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
groovy.lang.Closure<java.lang.Boolean> ready,
groovy.lang.Closure<V> postProcess) |
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
groovy.lang.Closure<V> postProcess) |
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
com.google.common.base.Predicate<? super T> ready,
groovy.lang.Closure<V> postProcess) |
static <T,V> Task<V> |
attributePostProcessedWhenReady(Entity source,
AttributeSensor<T> sensor,
com.google.common.base.Predicate<? super T> ready,
com.google.common.base.Function<? super T,V> postProcess) |
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,
groovy.lang.Closure<java.lang.Boolean> ready) |
static <T> Task<T> |
attributeWhenReady(Entity source,
AttributeSensor<T> sensor,
com.google.common.base.Predicate<? super T> 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 DependentConfiguration.ProtoBuilder |
builder() |
static Task<java.lang.String> |
formatString(java.lang.String 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 <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,
groovy.lang.Closure<java.lang.Boolean> readiness) |
static <T> Task<java.util.List<T>> |
listAttributesWhenReady(AttributeSensor<T> sensor,
java.lang.Iterable<Entity> entities,
com.google.common.base.Predicate<? super T> 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 <U,T> Task<T> |
transform(java.util.Map flags,
TaskAdaptable<U> task,
com.google.common.base.Function<U,T> transformer) |
static <U,T> Task<T> |
transform(Task<U> task,
groovy.lang.Closure transformer) |
static <U,T> Task<T> |
transform(Task<U> task,
com.google.common.base.Function<U,T> 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(groovy.lang.Closure transformer,
TaskAdaptable<U>... tasks) |
static <U,T> Task<T> |
transformMultiple(com.google.common.base.Function<java.util.List<U>,T> 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,
groovy.lang.Closure transformer,
TaskAdaptable<U>... tasks) |
static <U,T> Task<T> |
transformMultiple(java.util.Map flags,
com.google.common.base.Function<java.util.List<U>,T> transformer,
java.util.Collection<? extends TaskAdaptable<U>> tasks) |
static <U,T> Task<T> |
transformMultiple(java.util.Map flags,
com.google.common.base.Function<java.util.List<U>,T> transformer,
TaskAdaptable<U>... tasks) |
static <T,V> Task<V> |
valueWhenAttributeReady(Entity source,
AttributeSensor<T> sensor,
groovy.lang.Closure<V> valueProvider) |
static <T,V> Task<V> |
valueWhenAttributeReady(Entity source,
AttributeSensor<T> sensor,
com.google.common.base.Function<? super T,V> 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,
com.google.common.base.Predicate<? super T> ready) |
static <T> T |
waitInTaskForAttributeReady(Entity source,
AttributeSensor<T> sensor,
com.google.common.base.Predicate<? super T> ready,
java.util.List<DependentConfiguration.AttributeAndSensorCondition<?>> abortConditions) |
static <T> T |
waitInTaskForAttributeReady(Entity source,
AttributeSensor<T> sensor,
com.google.common.base.Predicate<? super T> 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)
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, com.google.common.base.Predicate<? super T> 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 valuepublic static <T,V> Task<V> attributePostProcessedWhenReady(Entity source, AttributeSensor<T> sensor, groovy.lang.Closure<java.lang.Boolean> ready, groovy.lang.Closure<V> postProcess)
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, com.google.common.base.Function<? super T,V> valueProvider)
public static <T,V> Task<V> valueWhenAttributeReady(Entity source, AttributeSensor<T> sensor, groovy.lang.Closure<V> valueProvider)
public static <T,V> Task<V> attributePostProcessedWhenReady(Entity source, AttributeSensor<T> sensor, com.google.common.base.Predicate<? super T> ready, groovy.lang.Closure<V> postProcess)
public static <T,V> Task<V> attributePostProcessedWhenReady(Entity source, AttributeSensor<T> sensor, com.google.common.base.Predicate<? super T> ready, com.google.common.base.Function<? super T,V> postProcess)
public static <T> T waitInTaskForAttributeReady(Entity source, AttributeSensor<T> sensor, com.google.common.base.Predicate<? super T> ready)
public static <T> T waitInTaskForAttributeReady(Entity source, AttributeSensor<T> sensor, com.google.common.base.Predicate<? super T> ready, java.util.List<DependentConfiguration.AttributeAndSensorCondition<?>> abortConditions)
public static <T> T waitInTaskForAttributeReady(Entity source, AttributeSensor<T> sensor, com.google.common.base.Predicate<? super T> 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, com.google.common.base.Function<U,T> 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(Task<U> task, groovy.lang.Closure transformer)
transform(Task, Function)
public static <U,T> Task<T> transform(java.util.Map flags, TaskAdaptable<U> task, com.google.common.base.Function<U,T> transformer)
transform(Task, Function)
public static <U,T> Task<T> transformMultiple(com.google.common.base.Function<java.util.List<U>,T> transformer, TaskAdaptable<U>... tasks)
public static <U,T> Task<T> transformMultiple(groovy.lang.Closure transformer, TaskAdaptable<U>... tasks)
public static <U,T> Task<T> transformMultiple(java.util.Map flags, groovy.lang.Closure transformer, TaskAdaptable<U>... tasks)
public static <U,T> Task<T> transformMultiple(java.util.Map flags, com.google.common.base.Function<java.util.List<U>,T> transformer, TaskAdaptable<U>... tasks)
public static <U,T> Task<T> transformMultiple(java.util.Map flags, com.google.common.base.Function<java.util.List<U>,T> transformer, java.util.Collection<? extends TaskAdaptable<U>> tasks)
public static Task<java.lang.String> formatString(java.lang.String spec, java.lang.Object... args)
Example:
setConfig(URL, DependentConfiguration.formatString("%s:%s",
DependentConfiguration.attributeWhenReady(target, Target.HOSTNAME),
DependentConfiguration.attributeWhenReady(target, Target.PORT) ) );
public static <T> Task<java.util.List<T>> listAttributesWhenReady(AttributeSensor<T> sensor, java.lang.Iterable<Entity> entities)
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, com.google.common.base.Predicate<? super T> 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()