You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/09/11 19:05:45 UTC

[1/2] incubator-brooklyn git commit: Adds CUSTOMIZE_LATCH to redis slaves, allowing async start

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 5c9153e85 -> 4ea52475f


Adds CUSTOMIZE_LATCH to redis slaves, allowing async start


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/0a66eb8e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/0a66eb8e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/0a66eb8e

Branch: refs/heads/master
Commit: 0a66eb8eeac7dbb03c3b2759138a65fbd7f1fc16
Parents: e92dd1e
Author: Martin Harris <gi...@nakomis.com>
Authored: Wed Sep 9 13:34:58 2015 +0100
Committer: Martin Harris <gi...@nakomis.com>
Committed: Wed Sep 9 17:19:53 2015 +0100

----------------------------------------------------------------------
 .../entity/nosql/redis/RedisClusterImpl.java    | 21 +++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0a66eb8e/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/redis/RedisClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/redis/RedisClusterImpl.java b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/redis/RedisClusterImpl.java
index 92c7593..7e71b29 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/redis/RedisClusterImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/redis/RedisClusterImpl.java
@@ -23,15 +23,19 @@ import java.util.List;
 
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic.ServiceProblemsLogic;
+import org.apache.brooklyn.core.sensor.DependentConfiguration;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.enricher.stock.Enrichers;
 import org.apache.brooklyn.entity.group.DynamicCluster;
+import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 import org.apache.brooklyn.util.collections.QuorumCheck.QuorumChecks;
 import org.apache.brooklyn.util.exceptions.CompoundRuntimeException;
 import org.apache.brooklyn.util.exceptions.Exceptions;
@@ -64,11 +68,12 @@ public class RedisClusterImpl extends AbstractEntity implements RedisCluster {
         super.init();
 
         RedisStore master = addChild(EntitySpec.create(RedisStore.class));
-        setAttribute(MASTER, master);
+        sensors().set(MASTER, master);
 
         DynamicCluster slaves = addChild(EntitySpec.create(DynamicCluster.class)
-                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(RedisSlave.class).configure(RedisSlave.MASTER, master)));
-        setAttribute(SLAVES, slaves);
+                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(RedisSlave.class).configure(RedisSlave.MASTER, master)
+                .configure(SoftwareProcess.CUSTOMIZE_LATCH, DependentConfiguration.attributeWhenReady(master, Attributes.SERVICE_UP))));
+        sensors().set(SLAVES, slaves);
 
         addEnricher(Enrichers.builder()
                 .propagating(RedisStore.HOSTNAME, RedisStore.ADDRESS, RedisStore.SUBNET_HOSTNAME, RedisStore.SUBNET_ADDRESS, RedisStore.REDIS_PORT)
@@ -101,11 +106,13 @@ public class RedisClusterImpl extends AbstractEntity implements RedisCluster {
     }
 
     private void doStart(Collection<? extends Location> locations) {
-        RedisStore master = getMaster();
-        master.invoke(RedisStore.START, ImmutableMap.<String, Object>of("locations", ImmutableList.copyOf(locations))).getUnchecked();
+        // Start the master and slaves asynchronously (the slave has a LAUNCH_LATCH on master to ensure it is available before the slaves are launched)
+        Task<Void> masterStartTask = getMaster().invoke(RedisStore.START, ImmutableMap.<String, Object>of("locations", ImmutableList.copyOf(locations)));
+        Task<Void> slaveStartTask = getSlaves().invoke(DynamicCluster.START, ImmutableMap.<String, Object>of("locations", ImmutableList.copyOf(locations)));
 
-        DynamicCluster slaves = getSlaves();
-        slaves.invoke(DynamicCluster.START, ImmutableMap.<String, Object>of("locations", ImmutableList.copyOf(locations))).getUnchecked();
+        // Wait for both master and slave to start before returning
+        masterStartTask.getUnchecked();
+        slaveStartTask.getUnchecked();
     }
 
     @Override


[2/2] incubator-brooklyn git commit: This closes #885

Posted by al...@apache.org.
This closes #885


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4ea52475
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4ea52475
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4ea52475

Branch: refs/heads/master
Commit: 4ea52475f5f009f3fca3178128414bab19ddec3c
Parents: 5c9153e 0a66eb8
Author: Aled Sage <al...@gmail.com>
Authored: Fri Sep 11 18:05:29 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Sep 11 18:05:29 2015 +0100

----------------------------------------------------------------------
 .../entity/nosql/redis/RedisClusterImpl.java    | 21 +++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------