brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [6/9] git commit: explicitly fix two of the instances where enrichers and policies were being added again on rebind
Date Fri, 01 Aug 2014 16:47:40 GMT
explicitly fix two of the instances where enrichers and policies were being added again on
rebind


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

Branch: refs/heads/master
Commit: 51145520aced1b20a482f78bde4b43cfa4697b8d
Parents: d135df4
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Jul 31 02:55:35 2014 -0400
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Jul 31 03:40:09 2014 -0400

----------------------------------------------------------------------
 .../brooklyn/entity/proxy/AbstractControllerImpl.java    | 11 ++++++++++-
 .../brooklyn/entity/webapp/DynamicWebAppClusterImpl.java |  9 +++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/51145520/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
index 9542b88..9e0b151 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
@@ -32,8 +32,8 @@ import org.slf4j.LoggerFactory;
 import brooklyn.entity.Entity;
 import brooklyn.entity.Group;
 import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
 import brooklyn.entity.basic.EntityInternal;
+import brooklyn.entity.basic.Lifecycle;
 import brooklyn.entity.basic.SoftwareProcessImpl;
 import brooklyn.entity.group.AbstractMembershipTrackingPolicy;
 import brooklyn.entity.group.Cluster;
@@ -42,6 +42,7 @@ import brooklyn.event.AttributeSensor;
 import brooklyn.event.feed.ConfigToAttributes;
 import brooklyn.location.access.BrooklynAccessUtils;
 import brooklyn.management.Task;
+import brooklyn.policy.Policy;
 import brooklyn.policy.PolicySpec;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.guava.Maybe;
@@ -110,6 +111,14 @@ public abstract class AbstractControllerImpl extends SoftwareProcessImpl
impleme
             LOG.warn("Call to addServerPoolMemberTrackingPolicy when serverPoolMemberTrackingPolicy
already exists, in {}", this);
             removeServerPoolMemberTrackingPolicy();
         }
+        for (Policy p: getPolicies()) {
+            if (p instanceof ServerPoolMemberTrackerPolicy) {
+                // TODO want a more elegant idiom for this!
+                LOG.info(this+" picking up "+p+" as the tracker (already set, often due to
rebind)");
+                serverPoolMemberTrackerPolicy = (ServerPoolMemberTrackerPolicy) p;
+                return;
+            }
+        }
         
         AttributeSensor<?> hostAndPortSensor = getConfig(HOST_AND_PORT_SENSOR);
         AttributeSensor<?> hostnameSensor = getConfig(HOSTNAME_SENSOR);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/51145520/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppClusterImpl.java
b/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppClusterImpl.java
index 1b40195..bfdc666 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppClusterImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppClusterImpl.java
@@ -76,7 +76,8 @@ public class DynamicWebAppClusterImpl extends DynamicClusterImpl implements
Dyna
     }
     
     @Override
-    public void onManagementBecomingMaster() {
+    public void init() {
+        super.init();
         // Enricher attribute setup.  A way of automatically discovering these (but avoiding
         // averaging things like HTTP port and response codes) would be neat.
         List<? extends List<? extends AttributeSensor<? extends Number>>>
summingEnricherSetup = ImmutableList.of(
@@ -120,7 +121,11 @@ public class DynamicWebAppClusterImpl extends DynamicClusterImpl implements
Dyna
                     .computingAverage()
                     .build());
         }
-
+    }
+    
+    public void onManagementStarted() {
+        super.onManagementStarted();
+        
         subscribeToMembers(this, SERVICE_UP, new SensorEventListener<Boolean>() {
             @Override public void onEvent(SensorEvent<Boolean> event) {
                 if (!isRebinding()) {


Mime
View raw message