You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2015/08/07 19:53:40 UTC

[07/10] incubator-brooklyn git commit: Fix logic to ensure that stop will be invoked on both the slaves and master

Fix logic to ensure that stop will be invoked on both the slaves and master


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

Branch: refs/heads/master
Commit: 891c8188ea961a3acf73d0be88fecf59d6ea6ce7
Parents: f968473
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Authored: Wed Aug 5 14:42:09 2015 -0400
Committer: Mike Zaccardo <mi...@cloudsoftcorp.com>
Committed: Wed Aug 5 14:42:09 2015 -0400

----------------------------------------------------------------------
 .../entity/nosql/redis/RedisClusterImpl.java    | 29 +++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/891c8188/software/nosql/src/main/java/brooklyn/entity/nosql/redis/RedisClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/redis/RedisClusterImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/redis/RedisClusterImpl.java
index 89ca43c..cca2254 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/redis/RedisClusterImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/redis/RedisClusterImpl.java
@@ -19,6 +19,7 @@
 package brooklyn.entity.nosql.redis;
 
 import java.util.Collection;
+import java.util.List;
 
 import brooklyn.enricher.Enrichers;
 import brooklyn.entity.basic.AbstractEntity;
@@ -32,16 +33,18 @@ import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.Sensors;
 import brooklyn.location.Location;
 import brooklyn.util.collections.QuorumCheck.QuorumChecks;
+import brooklyn.util.exceptions.CompoundRuntimeException;
 import brooklyn.util.exceptions.Exceptions;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
 
 public class RedisClusterImpl extends AbstractEntity implements RedisCluster {
 
-    private static AttributeSensor<RedisStore> MASTER = Sensors.newSensor(RedisStore.class, "redis.master");
-    private static AttributeSensor<DynamicCluster> SLAVES = Sensors.newSensor(DynamicCluster.class, "redis.slaves");
+    private static final AttributeSensor<RedisStore> MASTER = Sensors.newSensor(RedisStore.class, "redis.master");
+    private static final AttributeSensor<DynamicCluster> SLAVES = Sensors.newSensor(DynamicCluster.class, "redis.slaves");
 
     public RedisClusterImpl() {
     }
@@ -119,8 +122,26 @@ public class RedisClusterImpl extends AbstractEntity implements RedisCluster {
     }
 
     private void doStop() {
-        getSlaves().invoke(DynamicCluster.STOP, ImmutableMap.<String, Object>of()).getUnchecked();
-        getMaster().invoke(RedisStore.STOP, ImmutableMap.<String, Object>of()).getUnchecked();
+        StringBuilder message = new StringBuilder();
+        List<Exception> exceptions = Lists.newLinkedList();
+
+        try {
+            getSlaves().invoke(DynamicCluster.STOP, ImmutableMap.<String, Object>of()).getUnchecked();
+        } catch (Exception e) {
+            message.append("Failed to stop Redis slaves");
+            exceptions.add(e);
+        }
+
+        try {
+            getMaster().invoke(RedisStore.STOP, ImmutableMap.<String, Object>of()).getUnchecked();
+        } catch (Exception e) {
+            message.append((message.length() == 0) ? "Failed to stop Redis master" : " and master");
+            exceptions.add(e);
+        }
+
+        if (!exceptions.isEmpty()) {
+            throw new CompoundRuntimeException(message.toString(), exceptions);
+        }
     }
 
     @Override