brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [1/4] incubator-brooklyn git commit: Ensure deterministic DynamicCluster member removal order
Date Tue, 24 Nov 2015 18:07:49 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 09b4e2361 -> 9a9e780e8


Ensure deterministic DynamicCluster member removal order


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

Branch: refs/heads/master
Commit: 5947eb97d6a6559101be367bbbdf0c7be0d2f4ef
Parents: 4a03c46
Author: Mike Zaccardo <mike.zaccardo@cloudsoftcorp.com>
Authored: Tue Nov 24 10:59:54 2015 -0500
Committer: Mike Zaccardo <mike.zaccardo@cloudsoftcorp.com>
Committed: Tue Nov 24 10:59:54 2015 -0500

----------------------------------------------------------------------
 .../entity/group/DynamicClusterImpl.java        | 23 ++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5947eb97/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
index ac79dd6..61180db 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
@@ -139,18 +139,33 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements
DynamicClus
 
     private static final Function<Collection<Entity>, Entity> defaultRemovalStrategy
= new Function<Collection<Entity>, Entity>() {
         @Override public Entity apply(Collection<Entity> contenders) {
-            // choose newest entity that is stoppable, or if none are stoppable take the
newest non-stoppable
-            long newestTime = 0;
+            /*
+             * Choose the newest entity (largest cluster member ID or latest timestamp) that
is stoppable.
+             * If none are stoppable, take the newest non-stoppable.
+             * 
+             * Both cluster member ID and timestamp must be taken into consideration to account
for legacy
+             * clusters that were created before the addition of the cluster member ID config
value.
+             */
+            int largestClusterMemberId = -1;
+            long newestTime = 0L;
             Entity newest = null;
 
             for (Entity contender : contenders) {
-                boolean newer = contender.getCreationTime() > newestTime;
+                Integer contenderClusterMemberId = contender.config().get(CLUSTER_MEMBER_ID);
+                long contenderCreationTime = contender.getCreationTime();
+
+                boolean newer = (contenderClusterMemberId != null && contenderClusterMemberId
> largestClusterMemberId) ||
+                        contenderCreationTime > newestTime;
+
                 if ((contender instanceof Startable && newer) || 
                     (!(newest instanceof Startable) && ((contender instanceof Startable)
|| newer))) {
                     newest = contender;
-                    newestTime = contender.getCreationTime();
+
+                    if (contenderClusterMemberId != null) largestClusterMemberId = contenderClusterMemberId;
+                    newestTime = contenderCreationTime;
                 }
             }
+
             return newest;
         }
     };


Mime
View raw message