@Override public Task<T> apply(Entity it) { return attributeWhenReady(it, sensor, readiness); } }));
@SuppressWarnings({ "unchecked", "serial" }) public static <T> Supplier<T> attributeSupplierWhenReady(final Entity entity, final AttributeSensor<T> sensor) { final Task<T> task = DependentConfiguration.attributeWhenReady(entity, sensor); return new Supplier<T>() { @Override public T get() { try { TypeToken<T> type = new TypeToken<T>(sensor.getType()) {}; return Tasks.resolveValue(task, (Class<T>) type.getRawType(), ((EntityInternal) entity).getExecutionContext(), "attributeSupplierWhenReady"); } catch (Exception e) { throw Exceptions.propagate(e); } } }; }
/** * Default readiness is Groovy truth. * * @see #attributeWhenReady(Entity, AttributeSensor, Predicate) */ public static <T> Task<T> attributeWhenReady(Entity source, AttributeSensor<T> sensor) { return attributeWhenReady(source, sensor, GroovyJavaMethods.truthPredicate()); }
public static <T> Task<T> attributeWhenReady(Entity source, AttributeSensor<T> sensor, Closure ready) { Predicate<T> readyPredicate = (ready != null) ? GroovyJavaMethods.predicateFromClosure(ready) : GroovyJavaMethods.truthPredicate(); return attributeWhenReady(source, sensor, readyPredicate); }
/** * {@inheritDoc} * <p/> * Adds support for binding to brooklyn DatabaseNodes (so the user doesn't have to call attributeWhenReady, etc) */ @Override public void init() { super.init(); DatabaseNode leftNode = getConfig(LEFT_DATABASE); DatabaseNode rightNode = getConfig(RIGHT_DATABASE); if (leftNode != null) { setConfig(LEFT_DATABASE_URL, DependentConfiguration.attributeWhenReady(leftNode, DatabaseNode.DB_URL)); } if (rightNode != null) { setConfig(RIGHT_DATABASE_URL, DependentConfiguration.attributeWhenReady(rightNode, DatabaseNode.DB_URL)); } }
@Override public void initApp() { RedisStore redis = addChild(EntitySpec.create(RedisStore.class) .configure(SoftwareProcess.SUGGESTED_VERSION, "3.0.0")); addChild(EntitySpec.create(NodeJsWebAppService.class) .configure(NodeJsWebAppService.APP_GIT_REPOSITORY_URL, "https://github.com/grkvlt/nodejs-todo/") .configure(NodeJsWebAppService.APP_FILE, "server.js") .configure(NodeJsWebAppService.APP_NAME, "nodejs-todo") .configure(NodeJsWebAppService.NODE_PACKAGE_LIST, ImmutableList.of("express", "ejs", "jasmine-node", "underscore", "method-override", "cookie-parser", "express-session", "body-parser", "cookie-session", "redis", "redis-url", "connect")) .configure(SoftwareProcess.SHELL_ENVIRONMENT, ImmutableMap.<String, Object>of("REDISTOGO_URL", DependentConfiguration.formatString("redis://%s/", attributeWhenReady(redis, DockerUtils.mappedPortSensor(RedisStore.REDIS_PORT))))) .configure(SoftwareProcess.LAUNCH_LATCH, attributeWhenReady(redis, Startable.SERVICE_UP))); }
if (isClustered()) { entity.setConfig(CassandraNode.INITIAL_SEEDS, DependentConfiguration.attributeWhenReady(entity.getParent(), CassandraCluster.CURRENT_SEEDS)); } else { entity.setConfig(CassandraNode.INITIAL_SEEDS, MutableSet.<Entity>of(entity));
if (isClustered() && !isFirst && CassandraCluster.WAIT_FOR_FIRST) { long firstStartTime = Entities.submit(entity, DependentConfiguration.attributeWhenReady(getEntity().getParent(), CassandraCluster.FIRST_NODE_STARTED_TIME_UTC)).getUnchecked();
.configure(javaSysProp("brooklyn.example.db.url"), formatString("jdbc:%s%s?user=%s&password=%s", attributeWhenReady(mysql, mappedDatastoreUrl), DB_TABLE, DB_USERNAME, DB_PASSWORD))) .configure(ControlledDynamicWebAppCluster.CONTROLLER_SPEC, EntitySpec.create(NginxController.class)