You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/25 06:13:12 UTC

brooklyn-server git commit: allow load-bal-policy to retry if failed, usu because containers becoming unmanaged

Repository: brooklyn-server
Updated Branches:
  refs/heads/master 401d05a82 -> 798fbbbd0


allow load-bal-policy to retry if failed, usu because containers becoming unmanaged


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/798fbbbd
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/798fbbbd
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/798fbbbd

Branch: refs/heads/master
Commit: 798fbbbd0c4b9585b968cb3d9c449893bdc4f2bd
Parents: 401d05a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Wed Feb 24 21:12:41 2016 -0800
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Wed Feb 24 21:12:41 2016 -0800

----------------------------------------------------------------------
 .../policy/loadbalancing/LoadBalancingPolicy.java | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/798fbbbd/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java b/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java
index d4baf63..4b6afd8 100644
--- a/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java
+++ b/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.exceptions.Exceptions;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
@@ -196,8 +197,12 @@ public class LoadBalancingPolicy<NodeType extends Entity, ItemType extends Movab
             long delay = Math.max(0, (executorTime + minPeriodBetweenExecs) - now);
             
             executor.schedule(new Runnable() {
-                @SuppressWarnings("rawtypes")
                 public void run() {
+                    runWithRetries(3);
+                }
+                
+                @SuppressWarnings("rawtypes")
+                private void runWithRetries(int retriesRemaining) {
                     try {
                         executorTime = System.currentTimeMillis();
                         executorQueued.set(false);
@@ -245,10 +250,17 @@ public class LoadBalancingPolicy<NodeType extends Entity, ItemType extends Movab
                         }
 
                     } catch (Exception e) {
+                        Exceptions.propagateIfFatal(e);
                         if (isRunning()) {
-                            LOG.error("Error rebalancing", e);
+                            if (retriesRemaining>0) {
+                                // probably we failed because a container was leaving, trying again should fix it
+                                LOG.error("Error rebalancing (ignoring and retrying, "+retriesRemaining+" left): "+Exceptions.collapseText(e), e);
+                                runWithRetries(retriesRemaining-1);
+                            } else {
+                                LOG.error("Error rebalancing (ignoring, another event may trigger a rebalance): "+Exceptions.collapseText(e), e);
+                            }
                         } else {
-                            LOG.debug("Error rebalancing, but no longer running", e);
+                            LOG.debug("Error rebalancing, but no longer running: "+Exceptions.collapseText(e), e);
                         }
                     }
                 }},