Brooklyn

brooklyn.event.basic
[Java] Class DependentConfiguration

java.lang.Object
  brooklyn.event.basic.DependentConfiguration

public class DependentConfiguration

Conveniences for making tasks which run in entity ExecutionContexts, subscribing to attributes from other entities, possibly transforming those; these Task instances are typically passed in AbstractEntity#setConfig(ConfigKey, Object)#setConfig(ConfigKey, Object).

If using a lot it may be useful to: import static brooklyn.event.basic.DependentConfiguration.*;


Field Summary
protected static Logger LOG

 
Method Summary
static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, groovy.lang.Closure ready, groovy.lang.Closure postProcess)

static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, groovy.lang.Closure postProcess)

static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, Predicate ready, groovy.lang.Closure postProcess)

static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, Predicate ready, Function postProcess)

static Task attributeWhenReady(Entity source, AttributeSensor sensor)

@see #attributeWhenReady(Entity, AttributeSensor, Predicate); default readiness (if no third argument) is Groovy truth

static Task attributeWhenReady(Entity source, AttributeSensor sensor, groovy.lang.Closure ready)

static Task attributeWhenReady(Entity source, AttributeSensor sensor, Predicate ready)

returns a 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 Task 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 Task listAttributesWhenReady(AttributeSensor sensor, java.lang.Iterable 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 Task listAttributesWhenReady(AttributeSensor sensor, java.lang.Iterable entities, groovy.lang.Closure readiness)

static Task listAttributesWhenReady(AttributeSensor sensor, java.lang.Iterable entities, Predicate 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 Task transform(Task task, Function 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 Task transform(Task task, groovy.lang.Closure transformer)

@see #transform(Task, Function)

static Task transformMultiple(Function transformer, Task... tasks)

Returns a task which waits for multiple other tasks (submitting if necessary) and performs arbitrary computation over the List of results.

static Task transformMultiple(groovy.lang.Closure transformer, Task... tasks)

Returns a task which waits for multiple other tasks (submitting if necessary) and performs arbitrary computation over the List of results.

static Task valueWhenAttributeReady(Entity source, AttributeSensor sensor, java.lang.Object value)

static Task valueWhenAttributeReady(Entity source, AttributeSensor sensor, Function valueProvider)

static Task valueWhenAttributeReady(Entity source, AttributeSensor sensor, groovy.lang.Closure valueProvider)

static java.lang.Object waitForTask(Task t, Entity context)

@see #waitForTask(Task, Entity, String)

static java.lang.Object waitForTask(Task 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 java.lang.Object waitInTaskForAttributeReady(Entity source, AttributeSensor sensor, Predicate ready)

static Task whenDone(java.util.concurrent.Callable job)

Returns a Task which blocks until the given job returns, then returns the value of that job.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

LOG

protected static final Logger LOG


 
Method Detail

attributePostProcessedWhenReady

public static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, groovy.lang.Closure ready, groovy.lang.Closure postProcess)


attributePostProcessedWhenReady

public static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, groovy.lang.Closure postProcess)


attributePostProcessedWhenReady

public static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, Predicate ready, groovy.lang.Closure postProcess)


attributePostProcessedWhenReady

public static Task attributePostProcessedWhenReady(Entity source, AttributeSensor sensor, Predicate ready, Function postProcess)


attributeWhenReady

public static Task attributeWhenReady(Entity source, AttributeSensor sensor)
See Also:
is Groovy truth


attributeWhenReady

public static Task attributeWhenReady(Entity source, AttributeSensor sensor, groovy.lang.Closure ready)


attributeWhenReady

public static Task attributeWhenReady(Entity source, AttributeSensor sensor, Predicate ready)
returns a 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


formatString

public static Task 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.

Example: setConfig(URL, DependentConfiguration.formatString("%s:%s", DependentConfiguration.attributeWhenReady(target, Target.HOSTNAME), DependentConfiguration.attributeWhenReady(target, Target.PORT) ) );


listAttributesWhenReady

public static Task listAttributesWhenReady(AttributeSensor sensor, java.lang.Iterable 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)


listAttributesWhenReady

public static Task listAttributesWhenReady(AttributeSensor sensor, java.lang.Iterable entities, groovy.lang.Closure readiness)


listAttributesWhenReady

public static Task listAttributesWhenReady(AttributeSensor sensor, java.lang.Iterable entities, Predicate 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)


transform

public static Task transform(Task task, Function 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. 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 configuration


transform

public static Task transform(Task task, groovy.lang.Closure transformer)
See Also:
transform(Task, Function)


transformMultiple

public static Task transformMultiple(Function transformer, Task... tasks)
Returns a task which waits for multiple other tasks (submitting if necessary) and performs arbitrary computation over the List of results.
See Also:
to allow for varargs


transformMultiple

public static Task transformMultiple(groovy.lang.Closure transformer, Task... tasks)
Returns a task which waits for multiple other tasks (submitting if necessary) and performs arbitrary computation over the List of results.
See Also:
to allow for varargs


valueWhenAttributeReady

public static Task valueWhenAttributeReady(Entity source, AttributeSensor sensor, java.lang.Object value)


valueWhenAttributeReady

public static Task valueWhenAttributeReady(Entity source, AttributeSensor sensor, Function valueProvider)


valueWhenAttributeReady

public static Task valueWhenAttributeReady(Entity source, AttributeSensor sensor, groovy.lang.Closure valueProvider)


waitForTask

public static java.lang.Object waitForTask(Task t, Entity context)
See Also:
waitForTask(Task, Entity, String)


waitForTask

public static java.lang.Object waitForTask(Task 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


waitInTaskForAttributeReady

public static java.lang.Object waitInTaskForAttributeReady(Entity source, AttributeSensor sensor, Predicate ready)


whenDone

public static Task whenDone(java.util.concurrent.Callable job)
Returns a Task which blocks until the given job returns, then returns the value of that job.


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.