brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [10/50] brooklyn-library git commit: AbstractController: server-pool member monitoring
Date Mon, 01 Feb 2016 17:46:13 GMT
AbstractController: server-pool member monitoring

- When getting members of group, get it right from beginning
  rather than waiting for notification events from listener
  (very important for rebind).
- Fix bugs exposed by rebind (e.g. reset cleared addresses but
  not targets, so after a reset we wouldn't re-add addresses
  already in that "target" list).
- Simplify responding to sever-pool membership changes
- Simplify inferring server ip:port
- Avoid unnecessary "rebind" calls, if reconfigureService makes
  no change.
- use "serverPool" instead of "cluster" in calls to controller


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

Branch: refs/heads/0.4.0
Commit: 2b096d667d437f301ba2fff522c859f3c607f99e
Parents: bd32e0d
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu Sep 27 09:59:11 2012 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Sep 27 10:28:20 2012 +0100

----------------------------------------------------------------------
 .../entity/proxy/AbstractController.java        | 226 ++++++++++---------
 .../entity/proxy/nginx/NginxController.groovy   |  14 +-
 .../ControlledDynamicWebAppCluster.groovy       |   2 +-
 .../entity/proxy/AbstractControllerTest.groovy  |  38 ++--
 .../nginx/NginxHttpsSslIntegrationTest.groovy   |   6 +-
 .../proxy/nginx/NginxIntegrationTest.groovy     |  28 +--
 6 files changed, 178 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/2b096d66/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractController.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractController.java b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractController.java
index cf34007..c73a224 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractController.java
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractController.java
@@ -5,7 +5,6 @@ import static brooklyn.util.JavaGroovyEquivalents.groovyTruth;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.Collection;
-import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -27,12 +26,11 @@ import brooklyn.event.basic.BasicAttributeSensor;
 import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
 import brooklyn.event.basic.BasicConfigKey;
 import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
-import brooklyn.location.Location;
-import brooklyn.location.MachineLocation;
 import brooklyn.util.MutableMap;
 import brooklyn.util.flags.SetFromFlag;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
 
 /**
  * Represents a controller mechanism for a {@link Cluster}.
@@ -64,18 +62,22 @@ public abstract class AbstractController extends SoftwareProcessEntity
implement
 
     public static final BasicAttributeSensor<String> ROOT_URL = WebAppService.ROOT_URL;
     
-    public static final BasicAttributeSensor<Set> TARGETS = new BasicAttributeSensor<Set>(
+    public static final BasicAttributeSensor<Set<String>> SERVER_POOL_TARGETS
= new BasicAttributeSensor(
             Set.class, "proxy.targets", "Main set of downstream targets");
     
+    /**
+     * @deprecated Use SERVER_POOL_TARGETS
+     */
+    public static final BasicAttributeSensor<Set<String>> TARGETS = SERVER_POOL_TARGETS;
+    
     public static final MethodEffector<Void> RELOAD = new MethodEffector(AbstractController.class,
"reload");
     
-    protected Group serverPool;
     protected boolean isActive;
     protected boolean updateNeeded = true;
 
-    AbstractMembershipTrackingPolicy policy;
-    protected Set<String> addresses = new LinkedHashSet<String>();
-    protected Set<Entity> targets = new LinkedHashSet<Entity>();
+    protected AbstractMembershipTrackingPolicy serverPoolMemberTrackerPolicy;
+    protected Set<String> serverPoolAddresses = Sets.newLinkedHashSet();
+    protected Set<Entity> serverPoolTargets = Sets.newLinkedHashSet();
     
     public AbstractController() {
         this(MutableMap.of(), null, null);
@@ -95,10 +97,10 @@ public abstract class AbstractController extends SoftwareProcessEntity
implement
     public AbstractController(Map properties, Entity owner, Cluster cluster) {
         super(properties, owner);
 
-        policy = new AbstractMembershipTrackingPolicy(MutableMap.of("name", "Controller targets
tracker")) {
-            protected void onEntityChange(Entity member) { checkEntity(member); }
-            protected void onEntityAdded(Entity member) { addEntity(member); }
-            protected void onEntityRemoved(Entity member) { removeEntity(member); }
+        serverPoolMemberTrackerPolicy = new AbstractMembershipTrackingPolicy(MutableMap.of("name",
"Controller targets tracker")) {
+            protected void onEntityChange(Entity member) { onServerPoolMemberChanged(member);
}
+            protected void onEntityAdded(Entity member) { onServerPoolMemberChanged(member);
}
+            protected void onEntityRemoved(Entity member) { onServerPoolMemberChanged(member);
}
         };
     }
 
@@ -123,11 +125,19 @@ public abstract class AbstractController extends SoftwareProcessEntity
implement
      * Can pass in the 'cluster'.
      */
     public void bind(Map flags) {
-        if (flags.containsKey("cluster")) {
+        if (flags.containsKey("serverPool")) {
+            setConfig(SERVER_POOL, (Group) flags.get("serverPool"));
+            
+        } else if (flags.containsKey("cluster")) {
+            LOG.warn("Deprecated use of AbstractController.cluster: entity {}; value {}",
this, flags.get("cluster"));
             setConfig(SERVER_POOL, (Group) flags.get("cluster"));
         }
     }
 
+    private Group getServerPool() {
+        return getConfig(SERVER_POOL);
+    }
+    
     public boolean isActive() {
     	return isActive;
     }
@@ -173,6 +183,7 @@ public abstract class AbstractController extends SoftwareProcessEntity
implement
         return result;
     }
 
+    @Override
     protected void preStart() {
         super.preStart();
         
@@ -183,19 +194,88 @@ public abstract class AbstractController extends SoftwareProcessEntity
implement
         checkNotNull(getPortNumberSensor(), "port number sensor must not be null");
     }
     
-    public void checkEntity(Entity member) {
+    @Override
+    protected void postStart() {
+        super.postStart();
+        LOG.info("Adding policy {} to {} on AbstractController.start", serverPoolMemberTrackerPolicy,
this);
+        addPolicy(serverPoolMemberTrackerPolicy);
+        reset();
+        isActive = true;
+        update();
+    }
+    
+    protected void preStop() {
+        super.preStop();
+        serverPoolMemberTrackerPolicy.reset();
+    }
+
+    /** 
+     * Implementations should update the configuration so that 'addresses' are targeted.
+     * The caller will subsequently call reload if reconfigureService returned true.
+     * 
+     * @return True if the configuration has been modified (i.e. required reload); false
otherwise.
+     */
+    protected abstract boolean reconfigureService();
+    
+    public void update() {
+        if (!isActive()) updateNeeded = true;
+        else {
+            updateNeeded = false;
+            LOG.debug("Updating {} in response to changes", this);
+            boolean modified = reconfigureService();
+            if (modified) {
+                LOG.debug("Reloading {} in response to changes", this);
+                invokeFromJava(RELOAD);
+            } else {
+                LOG.debug("Reconfiguration made no change, so skipping reload", this);
+            }
+        }
+        setAttribute(SERVER_POOL_TARGETS, serverPoolAddresses);
+    }
+
+    protected synchronized void reset() {
+        serverPoolMemberTrackerPolicy.reset();
+        serverPoolAddresses.clear();
+        serverPoolTargets.clear();
+        if (groovyTruth(getServerPool())) {
+            serverPoolMemberTrackerPolicy.setGroup(getServerPool());
+            
+            // Initialize ourselves immediately with the latest set of members; don't wait
for
+            // listener notifications because then will be out-of-date for short period (causing

+            // problems for rebind)
+            for (Entity member : getServerPool().getMembers()) {
+                if (belongsInServerPool(member)) {
+                    if (LOG.isTraceEnabled()) LOG.trace("Done {} checkEntity {}", this, member);
+                    serverPoolTargets.add(member);
+                    String address = getAddressOfEntity(member);
+                    if (address != null) {
+                        serverPoolAddresses.add(address);
+                    }
+                }
+            }
+            
+            LOG.info("Resetting {}, members {} with address {}", new Object[] {this, serverPoolTargets,
serverPoolAddresses});
+        }
+        
+        setAttribute(SERVER_POOL_TARGETS, serverPoolAddresses);
+    }
+
+    protected void onServerPoolMemberChanged(Entity member) {
         if (LOG.isTraceEnabled()) LOG.trace("Start {} checkEntity {}", this, member);
-        if (belongs(member)) addEntity(member);
-        else removeEntity(member);
+        if (belongsInServerPool(member)) {
+            addServerPoolMember(member);
+        } else {
+            removeServerPoolMember(member);
+        }
         if (LOG.isTraceEnabled()) LOG.trace("Done {} checkEntity {}", this, member);
     }
     
-    public boolean belongs(Entity member) {
-        if (!member.getAttribute(Startable.SERVICE_UP)) {
+    protected boolean belongsInServerPool(Entity member) {
+        if (!groovyTruth(member.getAttribute(Startable.SERVICE_UP))) {
             LOG.debug("Members of {}, checking {}, eliminating because not up", getDisplayName(),
member.getDisplayName());
             return false;
         }
-        if (!serverPool.getMembers().contains(member)) {
+        if (!getServerPool().getMembers().contains(member)) {
             LOG.debug("Members of {}, checking {}, eliminating because not member", getDisplayName(),
member.getDisplayName());
             return false;
         }
@@ -203,101 +283,45 @@ public abstract class AbstractController extends SoftwareProcessEntity
implement
         return true;
     }
     
-    //FIXME members locations might be remote?
-    public synchronized void addEntity(Entity member) {
+    protected synchronized void addServerPoolMember(Entity member) {
         if (LOG.isTraceEnabled()) LOG.trace("Considering to add to {}, new member {} in locations
{} - "+
-                "waiting for service to be up", new Object[] {getDisplayName(), member.getDisplayName(),
member.getLocations()});
-        if (targets.contains(member)) return;
+                "waiting for service to be up", new Object[] {this, member, member.getLocations()});
+        if (serverPoolTargets.contains(member)) return;
         
-        if (!groovyTruth(member.getAttribute(Startable.SERVICE_UP))) {
-            LOG.debug("Members of {}, not adding {} because not yet up", getDisplayName(),
member.getDisplayName());
-            return;
+        String address = getAddressOfEntity(member);
+        if (address != null) {
+            serverPoolAddresses.add(address);
         }
-        
-        Set oldAddresses = new LinkedHashSet(addresses);
-        for (Location loc : member.getLocations()) {
-            MachineLocation machine = (MachineLocation) loc;
-            //use hostname as this is more portable (eg in amazon, ip doesn't resolve)
-            String ip = machine.getAddress().getHostName();
-            Integer port = member.getAttribute(getPortNumberSensor());
-            if (ip==null || port==null) {
-                LOG.warn("Missing ip/port for web controller {} target {}, skipping", this,
member);
-            } else {
-                addresses.add(ip+":"+port);
-            }
-        }
-        if (addresses==oldAddresses) {
-            if (LOG.isTraceEnabled()) LOG.trace("invocation of {}.addEntity({}) causes no
change", this, member);
-            return;
-        }
-        LOG.info("Adding to {}, new member {} in locations {}", new Object[] {getDisplayName(),
member.getDisplayName(), member.getLocations()});
+
+        LOG.info("Adding to {}, new member {} with address {}", new Object[] {this, member,
address});
         
         update();
-        targets.add(member);
+        serverPoolTargets.add(member);
     }
     
-    public synchronized void removeEntity(Entity member) {
-        if (!targets.contains(member)) return;
+    protected synchronized void removeServerPoolMember(Entity member) {
+        if (LOG.isTraceEnabled()) LOG.trace("Considering to remove from {}, member {} in
locations {} - "+
+                "waiting for service to be up", new Object[] {this, member, member.getLocations()});
+        if (!serverPoolTargets.contains(member)) return;
         
-        Set oldAddresses = new LinkedHashSet(addresses);
-        for (Location loc : member.getLocations()) {
-            MachineLocation machine = (MachineLocation) loc;
-            String ip = machine.getAddress().getHostAddress();
-            int port = member.getAttribute(getPortNumberSensor());
-            addresses.remove(ip+":"+port);
-        }
-        if (addresses==oldAddresses) {
-            LOG.debug("when removing from {}, member {}, not found (already removed?)", getDisplayName(),
member.getDisplayName());
-            return;
+        String address = getAddressOfEntity(member);
+        if (address != null) {
+            serverPoolAddresses.remove(address);
         }
         
-        LOG.info("Removing from {}, member {} previously in locations {}", 
-                new Object[] {getDisplayName(), member.getDisplayName(), member.getLocations()});
-        update();
-        targets.remove(member);
-    }
-    
-    public void start(Collection<? extends Location> locations) {
-        // TODO Should not add policy before NginxController is properly started; otherwise
-        // get callbacks for addEntity when fields like portNumber are still null.
-        serverPool = getConfig(SERVER_POOL);
-        LOG.info("Adding policy {} to {} on AbstractController.start", policy, this);
-        addPolicy(policy);
-        reset();
-        super.start(locations);
-        isActive = true;
+        LOG.info("Removing from {}, member {} with address {}", new Object[] {this, member,
address});
+        
         update();
+        serverPoolTargets.remove(member);
     }
-
-    /** should set up so that 'addresses' are targeted */
-    protected abstract void reconfigureService();
     
-    public void update() {
-        if (!isActive()) updateNeeded = true;
-        else {
-            updateNeeded = false;
-            LOG.debug("Updating {} in response to changes", this);
-            reconfigureService();
-            LOG.debug("Submitting restart for update to {}", this);
-            invokeFromJava(RELOAD);
+    protected String getAddressOfEntity(Entity member) {
+        String ip = member.getAttribute(Attributes.HOSTNAME);
+        Integer port = member.getAttribute(Attributes.HTTP_PORT);
+        if (ip!=null && port!=null) {
+            return ip+":"+port;
         }
-        setAttribute(TARGETS, addresses);
-    }
-
-    public void reset() {
-        policy.reset();
-        addresses.clear();
-        if (groovyTruth(serverPool)) {
-            policy.setGroup(serverPool);
-        }
-        setAttribute(TARGETS, addresses);
-    }
-
-	
-	protected void preStop() {
-		super.preStop();
-        policy.reset();
-        addresses.clear();
-        setAttribute(TARGETS, addresses);
+        LOG.error("Unable to construct hostname:port representation for "+member+"; skipping
in "+this);
+        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/2b096d66/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
b/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
index cf5e074..14eeed7 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
@@ -136,11 +136,13 @@ public class NginxController extends AbstractController {
         reconfigureService();
     }
     
-    protected void reconfigureService() {
+    @Override
+    protected boolean reconfigureService() {
 
         String cfg = getConfigFile();
-        if (cfg==null) return;
-        if (LOG.isDebugEnabled()) LOG.debug("Reconfiguring {}, targetting {} and {}", this,
addresses, findUrlMappings());
+        if (cfg==null) return false;
+        
+        if (LOG.isDebugEnabled()) LOG.debug("Reconfiguring {}, targetting {} and {}", this,
serverPoolAddresses, findUrlMappings());
         if (LOG.isTraceEnabled()) LOG.trace("Reconfiguring {}, config file:\n{}", this, cfg);
         
         NginxSshDriver driver = (NginxSshDriver)getDriver();
@@ -153,6 +155,8 @@ public class NginxController extends AbstractController {
             //cache ensures only the first is installed, which is what is assumed below
             installSslKeys(mapping.getDomain(), mapping.getConfig(UrlMapping.SSL_CONFIG));
         }
+        
+        return true;
     }
     
     Set<String> installedKeysCache = [];
@@ -199,12 +203,12 @@ public class NginxController extends AbstractController {
         config.append("  }\n");
         
         // For basic round-robin across the server-pool
-        if (addresses) {
+        if (serverPoolAddresses) {
             config.append(format("  upstream "+getId()+" {\n"))
             if (sticky){
                 config.append("    sticky;\n");
             }
-            for (String address: addresses){
+            for (String address: serverPoolAddresses){
                 config.append("    server "+address+";\n")
             }
             config.append("  }\n")

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/2b096d66/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.groovy
b/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.groovy
index 91bca59..495dd9d 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.groovy
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.groovy
@@ -98,7 +98,7 @@ public class ControlledDynamicWebAppCluster extends AbstractEntity implements
St
         
         addOwnedChild(controller);
         this.locations.addAll(locations);
-        controller.bind(cluster:cluster);
+        controller.bind(serverPool:cluster);
         Entities.invokeEffectorList(this, [cluster, controller], Startable.START, [locations:locations]).get();
         
         connectSensors();

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/2b096d66/software/webapp/src/test/java/brooklyn/entity/proxy/AbstractControllerTest.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/AbstractControllerTest.groovy
b/software/webapp/src/test/java/brooklyn/entity/proxy/AbstractControllerTest.groovy
index 87f0f12..c095a96 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/AbstractControllerTest.groovy
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/AbstractControllerTest.groovy
@@ -13,19 +13,20 @@ import org.testng.annotations.Test
 
 import brooklyn.entity.Entity
 import brooklyn.entity.basic.AbstractApplication
+import brooklyn.entity.basic.Attributes
 import brooklyn.entity.basic.EntityLocal
-import brooklyn.entity.basic.lifecycle.legacy.SshBasedAppSetup
 import brooklyn.entity.driver.MockSshBasedSoftwareSetup
 import brooklyn.entity.group.Cluster
 import brooklyn.entity.group.DynamicCluster
 import brooklyn.entity.trait.Startable
-import brooklyn.event.Sensor
-import brooklyn.event.basic.BasicAttributeSensor
+import brooklyn.event.AttributeSensor
 import brooklyn.location.Location
+import brooklyn.location.MachineLocation
 import brooklyn.location.MachineProvisioningLocation
 import brooklyn.location.basic.FixedListMachineProvisioningLocation
 import brooklyn.location.basic.SshMachineLocation
 import brooklyn.test.entity.TestEntity
+import brooklyn.util.flags.SetFromFlag
 
 class AbstractControllerTest {
 
@@ -53,14 +54,19 @@ class AbstractControllerTest {
         final AtomicInteger invokeCountForStart = new AtomicInteger(0);
         controller = new AbstractController(
                 owner:app, 
-                cluster:cluster, 
-                portNumberSensor:ClusteredEntity.MY_PORT,
+                serverPool:cluster, 
+                portNumberSensor:ClusteredEntity.HTTP_PORT,
                 domain:"mydomain") {
 
             @Override
-            protected void reconfigureService() {
-                log.info "test controller reconfigure, addresses $addresses"
-                if ((addresses && !updates) || (updates && addresses!=updates.last()))
updates.add(addresses)
+            protected boolean reconfigureService() {
+                log.info "test controller reconfigure, addresses $serverPoolAddresses"
+                if ((serverPoolAddresses && !updates) || (updates && serverPoolAddresses!=updates.last()))
{
+                    updates.add(serverPoolAddresses)
+                    return true;
+                } else {
+                    return false;
+                }
             }
 
             @Override
@@ -84,7 +90,7 @@ class AbstractControllerTest {
         def u = new ArrayList(updates);
         assertEquals(u, [], "expected empty list but got $u")
         
-        child.setAttribute(ClusteredEntity.MY_PORT, 1234)
+        child.setAttribute(ClusteredEntity.HTTP_PORT, 1234)
         child.setAttribute(Startable.SERVICE_UP, true)
         assertEventuallyAddressesMatchCluster()
 
@@ -93,7 +99,7 @@ class AbstractControllerTest {
         executeUntilSucceeds { cluster.ownedChildren.size() == 2 }
         EntityLocal child2 = cluster.ownedChildren.asList().get(1)
         
-        child2.setAttribute(ClusteredEntity.MY_PORT, 1234)
+        child2.setAttribute(ClusteredEntity.HTTP_PORT, 1234)
         child2.setAttribute(Startable.SERVICE_UP, true)
         assertEventuallyAddressesMatchCluster()
     }
@@ -119,7 +125,7 @@ class AbstractControllerTest {
         // Get some children, so we can remove one...
         cluster.resize(2)
         cluster.ownedChildren.each {
-            it.setAttribute(ClusteredEntity.MY_PORT, 1234)
+            it.setAttribute(ClusteredEntity.HTTP_PORT, 1234)
             it.setAttribute(Startable.SERVICE_UP, true)
         }
         assertEventuallyAddressesMatchCluster()
@@ -156,13 +162,19 @@ class ClusteredEntity extends TestEntity {
     public ClusteredEntity(Map flags=[:], Entity owner=null) { super(flags,owner) }
     public ClusteredEntity(Entity owner) { this([:],owner) }
     
-    public static final Sensor<Integer> MY_PORT = new BasicAttributeSensor<Integer>(Integer.class,
"port", "My port");
+    @SetFromFlag("hostname")
+    public static final AttributeSensor<String> HOSTNAME = Attributes.HOSTNAME;
+    
+    @SetFromFlag("port")
+    public static final AttributeSensor<Integer> HTTP_PORT = Attributes.HTTP_PORT;
     
     MachineProvisioningLocation provisioner
     
     public void start(Collection<? extends Location> locs) {
         provisioner = locs.first()
-        locations << provisioner.obtain([:])
+        MachineLocation machine = provisioner.obtain([:]);
+        locations << machine
+        setAttribute(HOSTNAME, machine.address.hostName);
     }
     public void stop() {
         provisioner?.release(firstLocation())

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/2b096d66/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
index 462f72e..a284054 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
@@ -33,7 +33,9 @@ public class NginxHttpsSslIntegrationTest {
     private NginxController nginx
     private DynamicCluster cluster
 
-    private static String WAR_URL = "classpath://hello-world.war";
+    private static final String WAR_URL = "classpath://hello-world.war";
+    private static final String CERTIFICATE_URL = "classpath://ssl/certs/localhost/server.crt";
+    private static final String KEY_URL = "classpath://ssl/certs/localhost/server.key";
     
     @BeforeMethod(groups = "Integration")
     public void setup() {
@@ -54,7 +56,7 @@ public class NginxHttpsSslIntegrationTest {
         cluster = new DynamicCluster(owner:app, factory:template, initialSize:1)
         cluster.setConfig(JavaWebAppService.ROOT_WAR, WAR_URL)
         
-        ProxySslConfig ssl = new ProxySslConfig(certificate:"classpath://ssl/certs/localhost/server.crt",
key:"classpath://ssl/certs/localhost/server.key");
+        ProxySslConfig ssl = new ProxySslConfig(certificate:CERTIFICATE_URL, key:KEY_URL);
         nginx = new NginxController(app,
 	            cluster: cluster,
 	            domain : "localhost",

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/2b096d66/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.groovy
b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.groovy
index 062164f..5dd7eda 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.groovy
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.groovy
@@ -34,7 +34,7 @@ public class NginxIntegrationTest {
 
     private TestApplication app
     private NginxController nginx
-    private DynamicCluster cluster
+    private DynamicCluster serverPool
 
     @BeforeMethod(groups = "Integration")
     public void setup() {
@@ -52,11 +52,11 @@ public class NginxIntegrationTest {
     @Test(groups = "Integration")
     public void testWhenNoServersReturns404() {
         def serverFactory = { throw new UnsupportedOperationException(); }
-        cluster = new DynamicCluster(owner:app, factory:serverFactory, initialSize:0)
+        serverPool = new DynamicCluster(owner:app, factory:serverFactory, initialSize:0)
         
         nginx = new NginxController([
                 "owner" : app,
-                "cluster" : cluster,
+                "serverPool" : serverPool,
                 "domain" : "localhost"
             ])
         
@@ -75,12 +75,12 @@ public class NginxIntegrationTest {
         URL war = getClass().getClassLoader().getResource("hello-world.war")
         Preconditions.checkState war != null, "Unable to locate resource $war"
         
-        cluster = new DynamicCluster(owner:app, factory:template, initialSize:1)
-        cluster.setConfig(JavaWebAppService.ROOT_WAR, war.path)
+        serverPool = new DynamicCluster(owner:app, factory:template, initialSize:1)
+        serverPool.setConfig(JavaWebAppService.ROOT_WAR, war.path)
         
         nginx = new NginxController([
 	            "owner" : app,
-	            "cluster" : cluster,
+	            "serverPool" : serverPool,
 	            "domain" : "localhost",
 	            "portNumberSensor" : WebAppService.HTTP_PORT,
             ])
@@ -88,15 +88,15 @@ public class NginxIntegrationTest {
         app.start([ new LocalhostMachineProvisioningLocation() ])
         
         // App-servers and nginx has started
-        assertAttributeEventually(cluster, SoftwareProcessEntity.SERVICE_UP, true);
-        cluster.members.each {
+        assertAttributeEventually(serverPool, SoftwareProcessEntity.SERVICE_UP, true);
+        serverPool.members.each {
             assertAttributeEventually(it, SoftwareProcessEntity.SERVICE_UP, true);
         }
         assertAttributeEventually(nginx, SoftwareProcessEntity.SERVICE_UP, true);
 
         // URLs reachable        
         assertUrlStatusCodeEventually(nginx.getAttribute(NginxController.ROOT_URL), 200);
-        cluster.members.each {
+        serverPool.members.each {
             assertUrlStatusCodeEventually(it.getAttribute(WebAppService.ROOT_URL), 200);
         }
 
@@ -104,8 +104,8 @@ public class NginxIntegrationTest {
 
         // Services have stopped
         assertFalse(nginx.getAttribute(SoftwareProcessEntity.SERVICE_UP));
-        assertFalse(cluster.getAttribute(SoftwareProcessEntity.SERVICE_UP));
-        cluster.members.each {
+        assertFalse(serverPool.getAttribute(SoftwareProcessEntity.SERVICE_UP));
+        serverPool.members.each {
             assertFalse(it.getAttribute(SoftwareProcessEntity.SERVICE_UP));
         }
     }
@@ -113,17 +113,17 @@ public class NginxIntegrationTest {
     @Test(groups = "Integration")
     public void testTwoNginxesGetDifferentPorts() {
         def serverFactory = { throw new UnsupportedOperationException(); }
-        cluster = new DynamicCluster(owner:app, factory:serverFactory, initialSize:0)
+        serverPool = new DynamicCluster(owner:app, factory:serverFactory, initialSize:0)
         
         def nginx1 = new NginxController([
                 "owner" : app,
-                "cluster" : cluster,
+                "serverPool" : serverPool,
                 "domain" : "localhost",
                 "port" : "14000+"
             ]);
         def nginx2 = new NginxController([
             "owner" : app,
-            "cluster" : cluster,
+            "serverPool" : serverPool,
             "domain" : "localhost",
             "port" : "14000+"
         ])


Mime
View raw message