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/01 18:48:47 UTC

[01/50] brooklyn-server git commit: Override AbstractApplication.init()

Repository: brooklyn-server
Updated Branches:
  refs/heads/0.5.0 [created] 8ebab0b2f


Override AbstractApplication.init()

- AbstractApplication.init() logs warning that the method will be
  most likely be deprecated in a future release.
- Override init() in sub-classes.


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

Branch: refs/heads/0.5.0
Commit: d2ed034adb2b79e2954a5730eee8325c857d4a96
Parents: 320289e
Author: Aled Sage <al...@gmail.com>
Authored: Thu Mar 28 14:52:48 2013 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Mar 29 09:37:57 2013 +0000

----------------------------------------------------------------------
 .../entity/basic/AbstractApplication.java       | 10 ++++++++++
 .../brooklyn/entity/basic/AbstractEntity.groovy | 16 +++++++++------
 .../entity/basic/BasicApplicationImpl.java      |  5 +++++
 .../catalog/internal/MyCatalogItems.java        |  7 ++++++-
 .../test/entity/TestApplicationImpl.java        |  6 +++++-
 .../CloudFoundryJavaClusterExample.groovy       | 10 +++++++---
 ...FoundryJavaClusterFromLocationExample.groovy |  5 +++++
 .../OpenshiftExpressJavaWebAppCluster.groovy    |  4 ++--
 ...penshiftExpressJavaClusterOnlyExample.groovy | 21 ++++++++++++--------
 .../rest/testing/mocks/RestMockApp.java         |  4 ++++
 .../util/BrooklynRestResourceUtilsTest.java     |  4 ++++
 11 files changed, 71 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java b/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
index 5923dd9..8cddb6e 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
@@ -20,6 +20,11 @@ import brooklyn.util.ResourceUtils;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.flags.SetFromFlag;
 
+/**
+ * Users can extend this to define the entities in their application, and the relationships between
+ * those entities. Users should override the {@link #init()} method, and in there should create 
+ * their entities.
+ */
 public abstract class AbstractApplication extends AbstractEntity implements StartableApplication {
     public static final Logger log = LoggerFactory.getLogger(AbstractApplication.class);
     
@@ -88,6 +93,11 @@ public abstract class AbstractApplication extends AbstractEntity implements Star
     }
 
     @Override
+    public void init() {
+        log.warn("Deprecated: AbstractApplication.init() will be declared abstract in a future release; please override for code instantiating child entities");
+    }
+
+    @Override
     public Application getApplication() {
         if (application!=null) {
             if (application.getId().equals(getId()))

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
index f8ce84b..7d1e51d 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
@@ -57,13 +57,18 @@ import com.google.common.collect.Maps
 
 /**
  * Default {@link Entity} implementation, which should be extended whenever implementing an entity.
- *
+ * <p>
  * Provides several common fields ({@link #name}, {@link #id}), and supports the core features of
  * an entity such as configuration keys, attributes, subscriptions and effector invocation.
- * 
+ * <p>
+ * If a sub-class is creating other entities, this should be done in an overridden {@link #init()}
+ * method.
+ * <p>
+ * Note that config is typically inherited by children, whereas the fields and attributes are not.
+ * <p>
  * Though currently Groovy code, this is very likely to change to pure Java in a future release of 
  * Brooklyn so Groovy'isms should not be relied on.
- * 
+ * <p>
  * Sub-classes should have a no-argument constructor. When brooklyn creates an entity, it will:
  * <ol>
  *   <li>Construct the entity via the no-argument constructor
@@ -74,11 +79,9 @@ import com.google.common.collect.Maps
  *   <li>Configure the entity, first via the "flags" map and then via configuration keys
  *   <li>Set  the parent
  * </ol>
- * 
+ * <p>
  * The legacy (pre 0.5) mechanism for creating entities is for others to call the constructor directly.
  * This is now deprecated.
- * 
- * Note that config is typically inherited by children, whereas the fields and attributes are not.
  */
 public abstract class AbstractEntity extends GroovyObjectSupport implements EntityLocal, EntityInternal, GroovyInterceptable {
     
@@ -403,6 +406,7 @@ public abstract class AbstractEntity extends GroovyObjectSupport implements Enti
      * </pre>
      */
     public void init() {
+        // no-op
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/core/src/main/java/brooklyn/entity/basic/BasicApplicationImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/BasicApplicationImpl.java b/core/src/main/java/brooklyn/entity/basic/BasicApplicationImpl.java
index d68d14e..6237b10 100644
--- a/core/src/main/java/brooklyn/entity/basic/BasicApplicationImpl.java
+++ b/core/src/main/java/brooklyn/entity/basic/BasicApplicationImpl.java
@@ -3,4 +3,9 @@ package brooklyn.entity.basic;
 public class BasicApplicationImpl extends AbstractApplication implements BasicApplication {
     public BasicApplicationImpl() {
     }
+    
+    @Override
+    public void init() {
+        // no-op
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/core/src/test/java/brooklyn/catalog/internal/MyCatalogItems.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/catalog/internal/MyCatalogItems.java b/core/src/test/java/brooklyn/catalog/internal/MyCatalogItems.java
index 70b6ba1..9914c40 100644
--- a/core/src/test/java/brooklyn/catalog/internal/MyCatalogItems.java
+++ b/core/src/test/java/brooklyn/catalog/internal/MyCatalogItems.java
@@ -8,7 +8,12 @@ import brooklyn.entity.basic.ApplicationBuilder;
 public class MyCatalogItems {
 
     @Catalog(description="Some silly app test")
-    public static class MySillyAppTemplate extends AbstractApplication {}
+    public static class MySillyAppTemplate extends AbstractApplication {
+        @Override
+        public void init() {
+            // no-op
+        }
+    }
     
     @Catalog(description="Some silly app builder test")
     public static class MySillyAppBuilderTemplate extends ApplicationBuilder {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java b/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java
index 9d07706..1cc983c 100644
--- a/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java
+++ b/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java
@@ -9,7 +9,6 @@ import org.testng.Assert;
 import brooklyn.entity.Entity;
 import brooklyn.entity.Group;
 import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.AbstractEntity;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.event.Sensor;
@@ -29,6 +28,11 @@ public class TestApplicationImpl extends AbstractApplication implements TestAppl
         super(properties);
     }
 
+    @Override
+    public void init() {
+        // no-op
+    }
+    
     /**
      * @deprecated Use {@link #addChild(EntitySpec)}
      */

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy
index ec73603..89db1bd 100644
--- a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy
+++ b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy
@@ -33,9 +33,13 @@ public class CloudFoundryJavaClusterExample extends AbstractApplication {
     private static final Logger log = LoggerFactory.getLogger(CloudFoundryJavaClusterExample.class)
     
     public static final String WAR_FILE_URL = "classpath://hello-world.war";
-                
-    CloudFoundryJavaWebAppCluster cloudfoundry = 
-      new CloudFoundryJavaWebAppCluster(this, war: WAR_FILE_URL);
+    
+    CloudFoundryJavaWebAppCluster cloudfoundry;
+    
+    @Override
+    public void init() {
+        cloudfoundry = new CloudFoundryJavaWebAppCluster(this, war: WAR_FILE_URL);
+    }
     
     // TODO a richer example which starts CloudFoundry alongside Tomcats in EC2 with geoscaling
       

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy
index 0eb66a9..4f21441 100644
--- a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy
+++ b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy
@@ -41,6 +41,11 @@ class CloudFoundryJavaClusterFromLocationExample extends AbstractApplication {
     ElasticJavaWebAppService svc;
     
     @Override
+    public void init() {
+        // no-op; see preStart
+    }
+
+    @Override
     public void preStart(Collection<? extends Location> locations) {
         svc = new ElasticJavaWebAppService.Factory().newFactoryForLocation( Iterables.getOnlyElement(locations) ).
             newEntity(this, war: WAR_FILE_URL);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/systems/paas/openshift/src/main/java/brooklyn/extras/openshift/OpenshiftExpressJavaWebAppCluster.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/openshift/src/main/java/brooklyn/extras/openshift/OpenshiftExpressJavaWebAppCluster.groovy b/systems/paas/openshift/src/main/java/brooklyn/extras/openshift/OpenshiftExpressJavaWebAppCluster.groovy
index 7e6acd6..d1911d4 100644
--- a/systems/paas/openshift/src/main/java/brooklyn/extras/openshift/OpenshiftExpressJavaWebAppCluster.groovy
+++ b/systems/paas/openshift/src/main/java/brooklyn/extras/openshift/OpenshiftExpressJavaWebAppCluster.groovy
@@ -21,6 +21,8 @@ class OpenshiftExpressJavaWebAppCluster extends AbstractEntity implements Starta
 
     private static final Logger log = LoggerFactory.getLogger(OpenshiftExpressJavaWebAppCluster.class)
     
+    public static final BasicConfigKey<String> APP_NAME = [ String, "appName", "System name for uniquely referring to application; defaults to Brooklyn999999 " ]
+                    
     public OpenshiftExpressJavaWebAppCluster(Map flags=[:], Entity parent=null) {
         super(flags, parent)
         setConfigIfValNonNull(ROOT_WAR, flags.war)
@@ -28,8 +30,6 @@ class OpenshiftExpressJavaWebAppCluster extends AbstractEntity implements Starta
         setAttribute(AbstractService.SERVICE_STATUS, "uninitialized")
     }
 
-    public static final BasicConfigKey<String> APP_NAME = [ String, "appName", "System name for uniquely referring to application; defaults to Brooklyn999999 " ]
-    
     public String getAppName() {
         def appName = getConfig(APP_NAME);
         if (appName) return appName;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/systems/paas/openshift/src/test/java/brooklyn/extras/openshift/OpenshiftExpressJavaClusterOnlyExample.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/openshift/src/test/java/brooklyn/extras/openshift/OpenshiftExpressJavaClusterOnlyExample.groovy b/systems/paas/openshift/src/test/java/brooklyn/extras/openshift/OpenshiftExpressJavaClusterOnlyExample.groovy
index 0d2faa9..50d79f5 100644
--- a/systems/paas/openshift/src/test/java/brooklyn/extras/openshift/OpenshiftExpressJavaClusterOnlyExample.groovy
+++ b/systems/paas/openshift/src/test/java/brooklyn/extras/openshift/OpenshiftExpressJavaClusterOnlyExample.groovy
@@ -56,23 +56,28 @@ class OpenshiftExpressJavaClusterOnlyExample extends AbstractApplication {
     private static final Logger log = LoggerFactory.getLogger(OpenshiftExpressJavaClusterOnlyExample.class)
     
     File warFile = TestUtils.getResource("hello-world.war", getClass().getClassLoader())
-                
-    OpenshiftExpressJavaWebAppCluster openshift = 
-      new OpenshiftExpressJavaWebAppCluster(this, war: warFile.getAbsolutePath());
+    
+    OpenshiftExpressJavaWebAppCluster openshift;
+    
+    @Override
+    public void init() {
+        openshift = new OpenshiftExpressJavaWebAppCluster(this, war: warFile.getAbsolutePath());
+    }
+
     
     // TODO a richer example which starts Openshift alongside JBosses in EC2 with geoscaling
     // TODO (shouldn't use the tomcat-branded hello world for this :)
       
     // ---- the code above is your app descriptor; code below runs it ----
       
-    OpenshiftLocation loc = new OpenshiftLocation(
-          username: OpenshiftExpressAccessIntegrationTest.TEST_USER,
-          password: OpenshiftExpressAccessIntegrationTest.TEST_PASSWORD)
-      
     public static void main(String[] args) {
+        OpenshiftLocation loc = new OpenshiftLocation(
+              username: OpenshiftExpressAccessIntegrationTest.TEST_USER,
+              password: OpenshiftExpressAccessIntegrationTest.TEST_PASSWORD)
+      
         def app = new OpenshiftExpressJavaClusterOnlyExample();
         
-        app.start([app.loc]);
+        app.start([loc]);
         
         log.info "should now be able to visit site (for 60s): {}", app.openshift.getWebAppAddress()
         //should now be able to visit (assert?)

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/usage/rest/src/test/java/brooklyn/rest/testing/mocks/RestMockApp.java
----------------------------------------------------------------------
diff --git a/usage/rest/src/test/java/brooklyn/rest/testing/mocks/RestMockApp.java b/usage/rest/src/test/java/brooklyn/rest/testing/mocks/RestMockApp.java
index 249082b..f1575a8 100644
--- a/usage/rest/src/test/java/brooklyn/rest/testing/mocks/RestMockApp.java
+++ b/usage/rest/src/test/java/brooklyn/rest/testing/mocks/RestMockApp.java
@@ -15,4 +15,8 @@ public class RestMockApp extends AbstractApplication {
         super(properties);
     }
 
+    @Override
+    public void init() {
+        // no-op
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2ed034a/usage/rest/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
----------------------------------------------------------------------
diff --git a/usage/rest/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java b/usage/rest/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
index 319e87d..1e705de 100644
--- a/usage/rest/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
+++ b/usage/rest/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
@@ -95,6 +95,10 @@ public class BrooklynRestResourceUtilsTest {
 
     @Catalog
     public static class MyApplicationImpl extends AbstractApplication implements MyInterface {
+        @Override
+        public void init() {
+            // no-op
+        }
     }
     
     public static class MyPolicy extends AbstractPolicy {


[39/50] brooklyn-server git commit: geo-dns: update member list of entity.hostname changes

Posted by he...@apache.org.
geo-dns: update member list of entity.hostname changes

- Useful for some private subnet examples, where the hostname/url
  gets transformed.
- Transforms tests from groovy to Java.


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

Branch: refs/heads/0.5.0
Commit: 187ffdbdd6b63aedf9a6887f795f048fc22bf046
Parents: 7358417
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 17 14:38:04 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 11:18:21 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/location/geo/HostGeoInfo.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/187ffdbd/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java b/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
index 3c9c9a5..3903aad 100644
--- a/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
+++ b/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
@@ -1,5 +1,7 @@
 package brooklyn.location.geo;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.net.InetAddress;
@@ -99,12 +101,16 @@ public class HostGeoInfo implements Serializable {
     
     
     public HostGeoInfo(String address, String displayName, double latitude, double longitude) {
-        this.address = address;
+        this.address = checkNotNull(address, "address");
         this.displayName = displayName==null ? "" : displayName;
         this.latitude = latitude;
         this.longitude = longitude;
     }
 
+    public String getAddress() {
+        return address;
+    }
+    
     @Override
     public String toString() {
         return "HostGeoInfo["+displayName+": "+address+" at ("+latitude+","+longitude+")]";


[36/50] brooklyn-server git commit: Refresh inherited config when setting parent

Posted by he...@apache.org.
Refresh inherited config when setting parent


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

Branch: refs/heads/0.5.0
Commit: 32d1432bd6812696d796a927ae839cc2f2d8c46a
Parents: 0136a41
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Tue Apr 16 01:08:37 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Tue Apr 23 23:31:46 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/32d1432b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
index c9ff73a..775b905 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
@@ -440,7 +440,7 @@ public abstract class AbstractEntity extends GroovyObjectSupport implements Enti
         parent = entity
         //previously tested entity!=null but that should be guaranteed?
         entity.addChild(getProxyIfAvailable())
-        configsInternal.setInheritedConfig(((EntityInternal)entity).getAllConfig());
+        refreshInheritedConfig();
         previouslyOwned = true
         
         getApplication()


[32/50] brooklyn-server git commit: Added What:Brooklyn, removed Versioning, simplified licence, & other small tweaks.

Posted by he...@apache.org.
Added What:Brooklyn, removed Versioning, simplified licence, & other small tweaks.


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

Branch: refs/heads/0.5.0
Commit: 1e291593575b5145a7c8f22afd2d858905fd05c3
Parents: acb0e7a
Author: David Toy <d...@vidtoy.co.uk>
Authored: Thu Apr 18 14:35:14 2013 +0100
Committer: David Toy <d...@vidtoy.co.uk>
Committed: Mon Apr 22 12:52:47 2013 +0100

----------------------------------------------------------------------
 README.md | 72 ++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 42 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1e291593/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index e5691b5..6072351 100644
--- a/README.md
+++ b/README.md
@@ -4,41 +4,62 @@ Brooklyn is a library and control plane for deploying and managing distributed a
 
 See [brooklyncentral.github.com](http://brooklyncentral.github.com) for details and examples.
 
-## Quick Start
+Brooklyn's main emphasis is managing live applications (e.g auto-scaling, exception handling, auto recovery from failure, and working across multiple clouds). Brooklyn considers deployment part of management, like the opening move in a game of chess. (Distributed-application-management-chess, no less).
 
-Three quick start options are available:
+### Deployment
 
-* Follow the [getting started guide](http://brooklyncentral.github.io/use/guide/quickstart/index.html)
-* [Download the latest release](https://github.com/brooklyncentral/brooklyn/tarball/master).
-* Clone the repo: `git clone git://github.com/brooklyncentral/brooklyn.git`.
+Brooklyn enables single-click deployment of complex applications.
 
-## Versioning
 
-For transparency and insight into our release cycle, and for striving to maintain backward compatibility, Brooklyn will be maintained under the [Semantic Versioning guidelines](http://semver.org/).
+Brooklyn features:
 
-Releases will be numbered with the following format:
+* out-of-the-box support for many common software entities.
+* integration with jclouds, allowing deployment to the majority of public and private clouds, in addition to pools of fixed IP machines.
+* integration with Apache Whirr (and thereby Chef and Puppet), allowing deployment of well-known services such as Hadoop and elasticsearch (and you can still use POBS, plain-old-bash-scripts).
+* integration with PaaS's such as OpenShift, allowing use of PaaSes alongside self-built clusters, for maximum flexibility.
 
-`<major>.<minor>.<patch>`
+Brooklyn works with and ties into other tools, adding the concepts of manageable clusters and fabrics.
 
-And constructed with the following guidelines:
+In DevOps fashion, Brooklyn allows applications and roll-outs to be version controlled, tested programatically, and reused across locations and contexts. Develop on localhost, then reuse the same application descriptor to deploy to QA, and then to your production environment.
 
-* Breaking backward compatibility bumps the major (and resets the minor and patch)
-* New additions without breaking backward compatibility bumps the minor (and resets the patch)
-* Bug fixes and misc changes bumps the patch
+### Management
 
-Milestones (`<major>.<minor>.<patch>-M<milestone>`) and Release Candidates (`<major>.<minor>.<patch>-rc.<candidate>`) are used in the release process.
+Brooklyn enables [autonomic management](http://en.wikipedia.org/wiki/Autonomic_computing) of applications. (i.e. many small, local, distributed control loops).
 
-## Bug Tracker
+Management policies can be attached to every component part in an application, and to logic groupings of components (clusters, fabrics). Policies can implement both technical and non-technical (business) requirements.
 
-Have a bug or a feature request? [Please open a new issue](https://github.com/brooklyncentral/brooklyn/issues).
+At runtime, policies have access to all aspects of the deployment, including deployment topology (hierarchical) and locations (machines, PaaSes, and jurisdictions), as well as scripts, instrumentation, and operational goals and constraints. This means that once the application is launched, the policies are all set to keep the application running optimally, based on whatever optimally means in that context.
+
+These deployment patterns and management policies are expressed as Java (or Groovy) classes, open-sourced here and giving you full control over what you want to happen. More importantly, however, this code can be shared, improved, and extended.
+
+### Use As a Library
+
+Import Brooklyn into your application to natively use its distributed management smarts. e.g. [Cloudera's Certification Cluster Builder Tool](http://www.cloudsoftcorp.com/blog/creating-a-cloudera-certification-cluster-with-cloudsofts-brooklyn/).
+
+### Use As a Control Plane
+
+Alternatively, use Brooklyn as an integrated-stand-alone management node for your application or bespoke platform.
+
+## Quick Start
+
+Three quick start options are available:
+
+* The [getting started guide](http://brooklyncentral.github.io/use/guide/quickstart/index.html) will step you through downloading and installing Brooklyn and running the examples.
+* Alternatively, [download the latest release](https://github.com/brooklyncentral/brooklyn/tarball/master) (tgz),
+* or, fork or clone the repo: `git clone git://github.com/brooklyncentral/brooklyn.git` then `mvn clean install`.
 
 ## Community
 
-Keep track of development and community news.
 
-* Follow [@brooklyncentral on Twitter](http://twitter.com/brooklyncentral).
-* Have a question that's not a feature request or bug report? [Ask on the mailing list.](http://groups.google.com/group/brooklyn-dev)
+* Have a question that's not a feature request or bug report? Ask on the mailing lists: [brooklyn-users](http://groups.google.com/group/brooklyn-users) or [brooklyn-dev](http://groups.google.com/group/brooklyn-dev)
 * Chat with us over IRC. On the `irc.freenode.net` server, in the `#brooklyncentral` channel.
+* Follow [@brooklyncentral on Twitter](http://twitter.com/brooklyncentral).
+
+
+## Bug Tracker
+
+Have a bug or a feature request? [Please open a new issue](https://github.com/brooklyncentral/brooklyn/issues).
+
 
 ## Contributing
 
@@ -53,16 +74,7 @@ Thanks!
 
 Copyright 2013 Cloudsoft Corporation, ltd.
 
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this work except in compliance with the License.
-You may obtain a copy of the License in the LICENSE file, or at:
-
-  [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+Licensed under the Apache License, Version 2.0:
+You may obtain a copy of the License in the LICENSE file, or at: [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).
 
 brooklyn is a registered trademark of Cloudsoft Corporation.


[06/50] brooklyn-server git commit: Merge pull request #634 from aledsage/api/deprecate-Attributes-version

Posted by he...@apache.org.
Merge pull request #634 from aledsage/api/deprecate-Attributes-version

Deprecate Attributes.VERSION

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

Branch: refs/heads/0.5.0
Commit: 7dbfb885eab1a011d8ef9887b05e1b3fde51f706
Parents: 6d6cae2 8c3bfdd
Author: ahgittin <al...@cloudsoftcorp.com>
Authored: Mon Apr 1 04:08:36 2013 -0700
Committer: ahgittin <al...@cloudsoftcorp.com>
Committed: Mon Apr 1 04:08:36 2013 -0700

----------------------------------------------------------------------
 core/src/main/java/brooklyn/entity/basic/Attributes.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[41/50] brooklyn-server git commit: JcloudsLocation: allow disabling of opening IP Tables

Posted by he...@apache.org.
JcloudsLocation: allow disabling of opening IP Tables

- If not WAIT_FOR_SSHABLE then don't try to
  mapSecurityGroupRuleToIpTables.
  With private subnets, this fails because the IP that
  jclouds knows about isn't visible.
  Subsequent code in brooklyn can set up port-forwarding
  to make it usable, but this code blocked waiting and then
  failed.


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

Branch: refs/heads/0.5.0
Commit: a253e39c6a680d9b2ae458c28ff8006fc5fddb3f
Parents: 1a41019
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 17 14:44:43 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 11:22:15 2013 +0100

----------------------------------------------------------------------
 .../java/brooklyn/location/jclouds/JcloudsLocation.java   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a253e39c/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index c044232..43baea3 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -336,8 +336,14 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
             JcloudsSshMachineLocation sshLocByHostname = registerJcloudsSshMachineLocation(node, vmHostname, setup);
             
             // Apply same securityGroups rules to iptables, if iptables is running on the node
-            mapSecurityGroupRuleToIpTables(computeService, node, initialCredentials, "eth0", 
-                    (Iterable<Integer>) setup.get(INBOUND_PORTS));
+            String waitForSshable = setup.get(WAIT_FOR_SSHABLE);
+            if (!(waitForSshable!=null && "false".equalsIgnoreCase(waitForSshable))) {
+                mapSecurityGroupRuleToIpTables(computeService, node, initialCredentials, "eth0", 
+                        (Iterable<Integer>) setup.get(INBOUND_PORTS));
+            } else {
+                // Otherwise would break CloudStack, where port-forwarding means that jclouds opinion 
+                // of using port 22 is wrong.
+            }
             
             // Apply any optional app-specific customization.
             for (JcloudsLocationCustomizer customizer : getCustomizers(setup)) {


[04/50] brooklyn-server git commit: AbstractEntity: javadoc for creation order

Posted by he...@apache.org.
AbstractEntity: javadoc for creation order


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

Branch: refs/heads/0.5.0
Commit: 6d6cae2b3992755fb2c9435dda006f8d767de969
Parents: b2471c2
Author: Aled Sage <al...@gmail.com>
Authored: Thu Mar 28 10:50:27 2013 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Mar 29 09:47:47 2013 +0000

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/AbstractEntity.groovy | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6d6cae2b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
index 7d1e51d..5f4117f 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
@@ -72,12 +72,15 @@ import com.google.common.collect.Maps
  * Sub-classes should have a no-argument constructor. When brooklyn creates an entity, it will:
  * <ol>
  *   <li>Construct the entity via the no-argument constructor
- *   <li>Set the managment context
- *   <li>Set the proxy, which should be used by everything else when referring to this entity
- *       (except for drivers/policies that are attached to the entity, which can be given a 
- *       reference to this entity itself).
- *   <li>Configure the entity, first via the "flags" map and then via configuration keys
- *   <li>Set  the parent
+ *   <li>Call {@link #setDisplayName(String)}
+ *   <li>Call {@link #setManagementContext(ManagementContextInternal)}
+ *   <li>Call {@link #setProxy(Entity)}; the proxy should be used by everything else when referring 
+ *       to this entity (except for drivers/policies that are attached to the entity, which can be  
+ *       given a reference to this entity itself).
+ *   <li>Call {@link #configure(Map)} and then {@link #setConfig(ConfigKey, Object)}
+ *   <li>Call {@link #postConstruct()}
+ *   <li>Call {@link #addPolicy()} (for any policies defined in the {@link EntitySpec})
+ *   <li>Call {@link #setParent(Entity)}, if a parent is specified in the {@link EntitySpec}
  * </ol>
  * <p>
  * The legacy (pre 0.5) mechanism for creating entities is for others to call the constructor directly.


[08/50] brooklyn-server git commit: Mark ApplicationBuilder as @Beta

Posted by he...@apache.org.
Mark ApplicationBuilder as @Beta


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

Branch: refs/heads/0.5.0
Commit: bd2256ffad7a6b13cfae152290f1bb0cacc04cbc
Parents: f19185a
Author: Aled Sage <al...@gmail.com>
Authored: Thu Mar 28 16:20:10 2013 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Apr 1 12:41:41 2013 +0100

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/ApplicationBuilder.java   | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bd2256ff/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java b/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
index 6164b31..7887b86 100644
--- a/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
+++ b/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
@@ -15,7 +15,13 @@ import brooklyn.entity.proxying.EntitySpecs;
 import brooklyn.management.EntityManager;
 import brooklyn.management.ManagementContext;
 
+import com.google.common.annotations.Beta;
+
 /**
+ * Experimental mechanism for defining/building applications. In future releases, this
+ * API will change. Its concepts will most likely be merged with a TOSCA implementation
+ * and with {@link EntitySpec}.
+ *
  * For building an application. Users can sub-class and override doBuild(), putting the logic for  
  * creating and wiring together entities in there.
  * 
@@ -37,17 +43,20 @@ import brooklyn.management.ManagementContext;
  * 
  * @author aled
  */
+@Beta
 public abstract class ApplicationBuilder {
 
     @SuppressWarnings("unused")
     private static final Logger LOG = LoggerFactory.getLogger(ApplicationBuilder.class);
 
     @SuppressWarnings("unchecked")
+    @Beta
     public static <T extends StartableApplication> T newManagedApp(Class<T> type) {
         return (T) newManagedApp(EntitySpecs.appSpec(type));
     }
 
     @SuppressWarnings("unchecked")
+    @Beta
     public static <T extends StartableApplication> T newManagedApp(EntitySpec<T> spec) {
         return (T) new ApplicationBuilder(spec) {
             @Override protected void doBuild() {
@@ -56,11 +65,13 @@ public abstract class ApplicationBuilder {
     }
 
     @SuppressWarnings("unchecked")
+    @Beta
     public static <T extends StartableApplication> T newManagedApp(Class<T> type, ManagementContext managementContext) {
         return (T) newManagedApp(EntitySpecs.appSpec(type), managementContext);
     }
 
     @SuppressWarnings("unchecked")
+    @Beta
     public static <T extends StartableApplication> T newManagedApp(EntitySpec<T> spec, ManagementContext managementContext) {
         return (T) new ApplicationBuilder(spec) {
             @Override protected void doBuild() {


[23/50] brooklyn-server git commit: Tidy up the Exceptions class - Better javadoc - Unwrap ExecutionExceptions

Posted by he...@apache.org.
Tidy up the Exceptions class
- Better javadoc
- Unwrap ExecutionExceptions


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

Branch: refs/heads/0.5.0
Commit: f7ac179bd95de7482564bf3a021768641a56d5d2
Parents: b3a1b05
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Wed Apr 3 23:14:45 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Fri Apr 19 10:37:17 2013 +0100

----------------------------------------------------------------------
 .../brooklyn/util/exceptions/Exceptions.java    | 27 +++++++++++++++-----
 .../exceptions/RuntimeInterruptedException.java |  6 ++---
 2 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f7ac179b/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/exceptions/Exceptions.java b/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
index 6428f85..e4866c9 100644
--- a/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
+++ b/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
@@ -5,25 +5,38 @@ import static com.google.common.base.Throwables.getCausalChain;
 import static com.google.common.collect.Iterables.find;
 
 import java.util.NoSuchElementException;
+import java.util.concurrent.ExecutionException;
 
 import com.google.common.base.Throwables;
 
 public class Exceptions {
 
-    /** like guava {@link Throwables#propagate(Throwable)}, 
-     * but set interrupted if interrupted exception (why doesn't guava do this?!), 
-     * and throw {@link RuntimeInterruptedException} */
+    /**
+     * Propagate a {@link Throwable} as a {@link RuntimeException}.
+     * <p>
+     * Like Guava {@link Throwables#propagate(Throwable)} but throws {@link RuntimeInterruptedException}
+     * to handle {@link InterruptedException}s and unpacks the {@link Exception#getCause() cause} and propagates
+     * it for {@link ExecutionException}s.
+     */
     public static RuntimeException propagate(Throwable throwable) {
         if (throwable instanceof InterruptedException)
-            throw new RuntimeInterruptedException((InterruptedException)throwable);
+            throw new RuntimeInterruptedException((InterruptedException) throwable);
+        if (throwable instanceof ExecutionException)
+            return Throwables.propagate(throwable.getCause());
         return Throwables.propagate(throwable);
     }
 
-    /** propagates exceptions which are fatal, ie those which one rarely if ever wants to capture
-     * (such as InterruptedException and Errors) */
+    /** 
+     * Propagate exceptions which are fatal.
+     * <p>
+     * Propagates only those exceptions which one rarely (if ever) wants to capture,
+     * such as {@link InterruptedException} and {@link Error}s.
+     */
     public static void propagateIfFatal(Throwable throwable) {
         if (throwable instanceof InterruptedException)
-            throw new RuntimeInterruptedException((InterruptedException)throwable);
+            throw new RuntimeInterruptedException((InterruptedException) throwable);
+        if (throwable instanceof ExecutionException)
+            propagateIfFatal(throwable.getCause());
         if (throwable instanceof Error)
             throw (Error) throwable;
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f7ac179b/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java b/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java
index f1ba196..2083131 100644
--- a/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java
+++ b/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java
@@ -2,11 +2,11 @@ package brooklyn.util.exceptions;
 
 /**
  * A {@link RuntimeException} that is thrown when a Thread is interrupted.
- *
+ * <p>
  * This exception is useful if a Thread needs to be interrupted, but the {@link InterruptedException} can't be thrown
  * because it is checked.
- *
- * When the RuntimeInterruptedException is created, it will automatically set the interrupt status on the calling
+ * <p>
+ * When the {@link RuntimeInterruptedException} is created, it will automatically set the interrupt status on the calling
  * thread.
  *
  * @author Peter Veentjer.


[13/50] brooklyn-server git commit: Increase timeout in HttpLatencyDetectorTest

Posted by he...@apache.org.
Increase timeout in HttpLatencyDetectorTest


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

Branch: refs/heads/0.5.0
Commit: 64da3fcd6e22152a87303d93492305c9ee519968
Parents: 3e16469 bb76210
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Tue Apr 9 01:26:58 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Tue Apr 9 01:30:44 2013 +0100

----------------------------------------------------------------------
 .../src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/64da3fcd/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
----------------------------------------------------------------------
diff --cc policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
index 614104e,614104e..df9fdb0
--- a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
+++ b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
@@@ -57,7 -57,7 +57,7 @@@ public class HttpLatencyDetectorTest 
                  Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
                  Predicates.equalTo(null));
          entity.setAttribute(TEST_URL, "http://www.google.com");
--        TestUtils.assertEventually(MutableMap.of("timeout", 400), 
++        TestUtils.assertEventually(MutableMap.of("timeout", 10000), 
                  Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
                  Predicates.notNull());
          log.info("Latency to "+entity.getAttribute(TEST_URL)+" is "+entity.getAttribute(HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT));


[17/50] brooklyn-server git commit: Merge pull request #652 from aledsage/fix/HttpFeed-reuses-polls

Posted by he...@apache.org.
Merge pull request #652 from aledsage/fix/HttpFeed-reuses-polls

Fix HttpFeed so again reuses polls

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

Branch: refs/heads/0.5.0
Commit: 8df88525547252b600e44a9ba1519641b1022db2
Parents: e5d2185 0ea1a02
Author: Peter Veentjer <al...@gmail.com>
Authored: Tue Apr 16 22:21:19 2013 -0700
Committer: Peter Veentjer <al...@gmail.com>
Committed: Tue Apr 16 22:21:19 2013 -0700

----------------------------------------------------------------------
 .../java/brooklyn/event/feed/http/HttpFeed.java |  6 +--
 .../brooklyn/event/feed/http/HttpFeedTest.java  | 39 +++++++++++++++++++-
 2 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------



[37/50] brooklyn-server git commit: Fixing CatalogResourceTest because RedisStore switched to new entity interface implementation

Posted by he...@apache.org.
Fixing CatalogResourceTest because RedisStore switched to new entity interface implementation


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

Branch: refs/heads/0.5.0
Commit: 73584177bc5c522e557d637594c644e1c8b4ee3d
Parents: 32d1432
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Mon Apr 22 22:29:00 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Wed Apr 24 13:25:44 2013 +0100

----------------------------------------------------------------------
 .../test/java/brooklyn/rest/resources/CatalogResourceTest.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73584177/usage/rest/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java b/usage/rest/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
index d6aa435..25a8bb7 100644
--- a/usage/rest/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
+++ b/usage/rest/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
@@ -96,7 +96,8 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
   @Test
   public void testGetCatalogEntityDetails() {
       CatalogEntitySummary details = client().resource(
-              URI.create("/v1/catalog/entities/brooklyn.entity.nosql.redis.RedisStore"))
+              // FIXME entity ids should use interface class not imp[lementation
+              URI.create("/v1/catalog/entities/brooklyn.entity.nosql.redis.RedisStoreImpl"))
               .get(CatalogEntitySummary.class);
       assertTrue(details.toString().contains("redis.port"));
       assertTrue(details.toString().contains("run.dir"));


[48/50] brooklyn-server git commit: Fix BasicTaskExecutionTest.testScheduledTaskExecutedAfterDelay

Posted by he...@apache.org.
Fix BasicTaskExecutionTest.testScheduledTaskExecutedAfterDelay

- Failed in buildhive with:
  (actualDelay=40) not greater than (delay=100 + earlyReturnGrace=25)
- Fix is to start stopwatch before calling submit.
  Also increase "maxOverhead" to avoid similar errors in the other
  direction.


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

Branch: refs/heads/0.5.0
Commit: 755d1ed262f61d35b43a14018b01bc050f2f86aa
Parents: 24c3a4c
Author: Aled Sage <al...@gmail.com>
Authored: Mon Apr 22 10:38:26 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed May 1 21:28:33 2013 +0100

----------------------------------------------------------------------
 .../test/java/brooklyn/util/task/BasicTaskExecutionTest.groovy   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/755d1ed2/core/src/test/java/brooklyn/util/task/BasicTaskExecutionTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/task/BasicTaskExecutionTest.groovy b/core/src/test/java/brooklyn/util/task/BasicTaskExecutionTest.groovy
index 669957e..c07960d 100644
--- a/core/src/test/java/brooklyn/util/task/BasicTaskExecutionTest.groovy
+++ b/core/src/test/java/brooklyn/util/task/BasicTaskExecutionTest.groovy
@@ -350,7 +350,7 @@ public class BasicTaskExecutionTest {
     @Test
     public void testScheduledTaskExecutedAfterDelay() {
         int delay = 100;
-        int maxOverhead = 250;
+        int maxOverhead = 500;
         int earlyReturnGrace = 25; // saw 13ms early return on jenkins!
         final CountDownLatch latch = new CountDownLatch(1);
         
@@ -363,9 +363,9 @@ public class BasicTaskExecutionTest {
             }};
         ScheduledTask t = new ScheduledTask(taskFactory).delay(delay);
 
+        Stopwatch stopwatch = new Stopwatch().start();
         em.submit(t);
         
-        Stopwatch stopwatch = new Stopwatch().start();
         assertTrue(latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
         long actualDelay = stopwatch.elapsedMillis();
         


[02/50] brooklyn-server git commit: HttpLatencyDetector: cleanup

Posted by he...@apache.org.
HttpLatencyDetector: cleanup

- Some minor cleanup, following Alex's commits for HttpLatencyDetector


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

Branch: refs/heads/0.5.0
Commit: 9714edc3d5381b827c0f5019d1c974c8c473718b
Parents: d2ed034
Author: Aled Sage <al...@gmail.com>
Authored: Thu Mar 28 09:30:45 2013 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Mar 29 09:41:06 2013 +0000

----------------------------------------------------------------------
 .../java/brooklyn/event/feed/http/HttpFeed.java |  3 +-
 .../brooklyn/event/feed/http/HttpPolls.java     |  8 +--
 .../util/javalang/AtomicReferences.java         |  4 +-
 .../java/brooklyn/util/javalang/Providers.java  | 50 -------------
 .../java/brooklyn/util/math/MathFunctions.java  |  4 +-
 core/src/main/java/brooklyn/util/net/Urls.java  | 34 +++++++--
 .../brooklyn/event/feed/http/HttpFeedTest.java  | 19 +++--
 .../brooklyn/enricher/HttpLatencyDetector.java  | 62 ++++++++--------
 .../src/main/java/brooklyn/test/Asserts.java    | 66 ++++++++++++++++-
 .../main/java/brooklyn/test/TestUtils.groovy    | 74 ++++++++++----------
 10 files changed, 183 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
index 0c1806d..5872921 100644
--- a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
@@ -35,7 +35,6 @@ import brooklyn.event.feed.AttributePollHandler;
 import brooklyn.event.feed.DelegatingPollHandler;
 import brooklyn.event.feed.Poller;
 import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.net.Urls;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Supplier;
@@ -128,7 +127,7 @@ public class HttpFeed extends AbstractFeed {
             return this;
         }
         public Builder baseUrl(URL val) {
-            return baseUri(Urls.URI_FROM_STRING.apply(val.toString()));
+            return baseUri(URI.create(val.toString()));
         }
         public Builder baseUri(String val) {
             return baseUri(URI.create(val));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/core/src/main/java/brooklyn/event/feed/http/HttpPolls.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/http/HttpPolls.java b/core/src/main/java/brooklyn/event/feed/http/HttpPolls.java
index 009b459..e434b93 100644
--- a/core/src/main/java/brooklyn/event/feed/http/HttpPolls.java
+++ b/core/src/main/java/brooklyn/event/feed/http/HttpPolls.java
@@ -14,15 +14,13 @@ public class HttpPolls {
     public static HttpPollValue executeSimpleGet(URI uri) {
         DefaultHttpClient httpClient = new DefaultHttpClient();
         HttpGet httpGet = new HttpGet(uri);
-        HttpResponse httpResponse = null;
         try {
+            long startTime = System.currentTimeMillis();
+            HttpResponse httpResponse = httpClient.execute(httpGet);
             try {
-                long startTime = System.currentTimeMillis();
-                httpResponse = httpClient.execute(httpGet);
                 return new HttpPollValue(httpResponse, startTime);
             } finally {
-                if (httpResponse!=null)
-                    EntityUtils.consume(httpResponse.getEntity());
+                EntityUtils.consume(httpResponse.getEntity());
             }
         } catch (Exception e) {
             throw Exceptions.propagate(e);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java b/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
index 0555de9..fb03d91 100644
--- a/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
+++ b/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
@@ -22,8 +22,8 @@ public class AtomicReferences {
     public static <T> Supplier<T> supplier(final AtomicReference<T> ref) {
         Preconditions.checkNotNull(ref);
         return new Supplier<T>() {
-            public T get() { return ref.get(); }
+            @Override public T get() { return ref.get(); }
+            @Override public String toString() { return "AtomicRefSupplier"; }
         };
     }
-
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/core/src/main/java/brooklyn/util/javalang/Providers.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/javalang/Providers.java b/core/src/main/java/brooklyn/util/javalang/Providers.java
deleted file mode 100644
index aa3f13c..0000000
--- a/core/src/main/java/brooklyn/util/javalang/Providers.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package brooklyn.util.javalang;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-
-public class Providers {
-
-//    public static <T> Provider<T> constant(T value) {
-//        return new ConstantProvider<T>(value);
-//    }
-//    
-//    public static class ConstantProvider<T> implements Provider<T> {
-//        final T value;
-//        public ConstantProvider(T value) { this.value = value; }
-//        @Override public T get() { return value; }
-//        @Override public int hashCode() { return Objects.hashCode(value); }
-//        @Override public boolean equals(Object other) { 
-//            if (!(other instanceof ConstantProvider)) return false;
-//            return Objects.equal(value, ((ConstantProvider<?>)other).value); 
-//        }
-//    }
-// 
-//    public static <T> AtomicProvider<T> atomic(AtomicReference<T> ref) {
-//        return new AtomicProvider<T>(ref);
-//    }
-//
-//    public static class AtomicProvider<T> implements Provider<T> {
-//        final AtomicReference<T> ref;
-//        public AtomicProvider(AtomicReference<T> ref) { this.ref = ref; }
-//        @Override public T get() { return ref.get(); }
-//        public AtomicReference<T> getReference() { return ref; }
-//        @Override public int hashCode() { return Objects.hashCode(ref); }
-//        @Override public boolean equals(Object other) { 
-//            if (!(other instanceof AtomicProvider)) return false;
-//            return Objects.equal(ref, ((AtomicProvider<?>)other).ref); 
-//        }
-//    }
-//
-//    public static <A,B> Provider<B> transform(final Provider<A> val, final Function<A,B> f) {
-//        return new Provider<B>() {
-//            @Override
-//            public B get() {
-//                return f.apply(val.get());
-//            }
-//        };
-//    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/core/src/main/java/brooklyn/util/math/MathFunctions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/math/MathFunctions.java b/core/src/main/java/brooklyn/util/math/MathFunctions.java
index f682400..9128e96 100644
--- a/core/src/main/java/brooklyn/util/math/MathFunctions.java
+++ b/core/src/main/java/brooklyn/util/math/MathFunctions.java
@@ -6,11 +6,11 @@ import com.google.common.base.Function;
 
 public class MathFunctions {
 
-    public static Function<Number,Double> divide(final Number n, final double divisor) {
+    public static Function<Number,Double> divide(final double divisor) {
         return new Function<Number, Double>() {
             public Double apply(@Nullable Number input) {
                 if (input==null) return null;
-                return n.doubleValue() / divisor;
+                return input.doubleValue() / divisor;
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/core/src/main/java/brooklyn/util/net/Urls.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/net/Urls.java b/core/src/main/java/brooklyn/util/net/Urls.java
index 98d4eb6..aa8f088 100644
--- a/core/src/main/java/brooklyn/util/net/Urls.java
+++ b/core/src/main/java/brooklyn/util/net/Urls.java
@@ -12,13 +12,35 @@ import com.google.common.base.Throwables;
 
 public class Urls {
 
-    public static final Function<String,URI> URI_FROM_STRING = new Function<String,URI>() {
-        public URI apply(String input) { return toUri(input); } 
-    };
+    public static Function<String,URI> stringToUriFunction() {
+        return StringToUri.INSTANCE;
+    }
+    
+    public static Function<String,URL> stringToUrlFunction() {
+        return StringToUrl.INSTANCE;
+    }
+    
+    private static enum StringToUri implements Function<String,URI> {
+        INSTANCE;
+        @Override public URI apply(@Nullable String input) {
+            return toUri(input);
+        }
+        @Override
+        public String toString() {
+            return "StringToUri";
+        }
+    }
 
-    public static final Function<String,URL> URL_FROM_STRING = new Function<String,URL>() {
-        public URL apply(String input) { return toUrl(input); } 
-    };
+    private static enum StringToUrl implements Function<String,URL> {
+        INSTANCE;
+        @Override public URL apply(@Nullable String input) {
+            return toUrl(input);
+        }
+        @Override
+        public String toString() {
+            return "StringToUrl";
+        }
+    }
 
     /** creates a URL, preserving null and propagating exceptions *unchecked* */
     public static final URL toUrl(@Nullable String url) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
index 6b49b3c..a3dd3f1 100644
--- a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
+++ b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
@@ -2,6 +2,7 @@ package brooklyn.event.feed.http;
 
 import static brooklyn.test.TestUtils.executeUntilSucceeds;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
 
 import java.net.URL;
 import java.util.concurrent.Callable;
@@ -21,6 +22,7 @@ import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.BasicAttributeSensor;
 import brooklyn.location.Location;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.test.Asserts;
 import brooklyn.test.TestUtils;
 import brooklyn.test.entity.TestApplication;
 import brooklyn.test.entity.TestEntity;
@@ -124,14 +126,19 @@ public class HttpFeedTest {
                 .build();
         assertSensorEventually(SENSOR_INT, (Integer)200, TIMEOUT_MS);
         feed.suspend();
-        int countWhenSuspended = server.getRequestCount();
+        final int countWhenSuspended = server.getRequestCount();
+        
         Thread.sleep(500);
         if (server.getRequestCount() > countWhenSuspended+1)
             Assert.fail("Request count continued to increment while feed was suspended, from "+countWhenSuspended+" to "+server.getRequestCount());
+        
         feed.resume();
-        Thread.sleep(500);
-        if (server.getRequestCount() <= countWhenSuspended+1)
-            Assert.fail("Request count failed to increment when feed was resumed, from "+countWhenSuspended+", still at "+server.getRequestCount());        
+        TestUtils.executeUntilSucceeds(new Runnable() {
+            public void run() {
+                assertTrue(server.getRequestCount() > countWhenSuspended+1, 
+                        "Request count failed to increment when feed was resumed, from "+countWhenSuspended+", still at "+server.getRequestCount());        
+            }
+        });
     }
 
     @Test(groups="Integration")
@@ -148,11 +155,11 @@ public class HttpFeedTest {
                         .onSuccess(HttpValueFunctions.stringContentsFunction()))
                 .suspended()
                 .build();
-        TestUtils.assertContinuallyFromJava(MutableMap.of("timeout", 500),
+        Asserts.continually(MutableMap.of("timeout", 500),
                 Entities.supplier(entity, SENSOR_INT), Predicates.<Integer>equalTo(null));
         int countWhenSuspended = server.getRequestCount();
         feed.resume();
-        TestUtils.assertEventually(Entities.supplier(entity, SENSOR_INT), Predicates.<Integer>equalTo(200));
+        Asserts.eventually(Entities.supplier(entity, SENSOR_INT), Predicates.<Integer>equalTo(200));
         if (server.getRequestCount() <= countWhenSuspended)
             Assert.fail("Request count failed to increment when feed was resumed, from "+countWhenSuspended+", still at "+server.getRequestCount());
         log.info("RUN: "+countWhenSuspended+" - "+server.getRequestCount());

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/policy/src/main/java/brooklyn/enricher/HttpLatencyDetector.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/enricher/HttpLatencyDetector.java b/policy/src/main/java/brooklyn/enricher/HttpLatencyDetector.java
index b8c12e7..24d6f1a 100644
--- a/policy/src/main/java/brooklyn/enricher/HttpLatencyDetector.java
+++ b/policy/src/main/java/brooklyn/enricher/HttpLatencyDetector.java
@@ -53,15 +53,33 @@ public class HttpLatencyDetector extends AbstractEnricher {
                     "Request latency over time window, in seconds");
 
     HttpFeed httpFeed = null;
-    long periodMillis = 1000;
+    final long periodMillis;
     
-    boolean requireServiceUp = true; 
-    AtomicBoolean serviceUp = new AtomicBoolean(false);
+    final boolean requireServiceUp; 
+    final AtomicBoolean serviceUp = new AtomicBoolean(false);
     
-    AttributeSensor<String> urlSensor;
-    Function<String,String> urlPostProcessing = Functions.identity();
-    AtomicReference<String> url = new AtomicReference<String>(null);
-    TimeDuration rollupPeriod = LATENCY_WINDOW_DEFAULT_PERIOD;
+    final AttributeSensor<String> urlSensor;
+    final Function<String,String> urlPostProcessing;
+    final AtomicReference<String> url = new AtomicReference<String>(null);
+    final TimeDuration rollupWindowSize;
+    
+    protected HttpLatencyDetector(Builder builder) {
+        this.periodMillis = builder.periodMillis;
+        this.requireServiceUp = builder.requireServiceUp;
+        
+        if (builder.urlSensor != null) {
+            this.urlSensor = builder.urlSensor;
+            this.urlPostProcessing = builder.urlPostProcessing;
+            if (builder.url != null)
+                throw new IllegalStateException("Cannot set URL and UrlSensor");
+        } else {
+            this.url.set(builder.url);
+            this.urlSensor = null;
+            this.urlPostProcessing = null;
+        }
+
+        this.rollupWindowSize = builder.rollupWindowSize;
+    }
     
     @Override
     public void setEntity(EntityLocal entity) {
@@ -81,7 +99,7 @@ public class HttpLatencyDetector extends AbstractEnricher {
         httpFeed = HttpFeed.builder()
                 .entity(entity)
                 .period(periodMillis)
-                .baseUri(Suppliers.compose(Urls.URI_FROM_STRING, AtomicReferences.supplier(url)))
+                .baseUri(Suppliers.compose(Urls.stringToUriFunction(), AtomicReferences.supplier(url)))
                 .poll(new HttpPollConfig<Double>(REQUEST_LATENCY_IN_SECONDS_MOST_RECENT)
                         .onSuccess(MathFunctions.divide(HttpValueFunctions.latency(), 1000.0d))
                         .onError(Functions.constant((Double)null)))
@@ -116,10 +134,10 @@ public class HttpLatencyDetector extends AbstractEnricher {
     }
 
     protected void activateAdditionalEnrichers(EntityLocal entity) {
-        if (rollupPeriod!=null) {
+        if (rollupWindowSize!=null) {
             entity.addEnricher(new RollingTimeWindowMeanEnricher<Double>(entity,
                 REQUEST_LATENCY_IN_SECONDS_MOST_RECENT, REQUEST_LATENCY_IN_SECONDS_IN_WINDOW,
-                rollupPeriod.toMilliseconds()));
+                rollupWindowSize.toMilliseconds()));
         }
     }
 
@@ -148,11 +166,11 @@ public class HttpLatencyDetector extends AbstractEnricher {
     }
     
     public static class Builder {
-        Boolean requireServiceUp;
-        Long periodMillis;
+        boolean requireServiceUp = true;
+        long periodMillis = 1000;
         String url;
         AttributeSensor<String> urlSensor;
-        Function<String, String> urlPostProcessing;
+        Function<String, String> urlPostProcessing = Functions.identity();
         TimeDuration rollupWindowSize = LATENCY_WINDOW_DEFAULT_PERIOD;
         
         /** indicates that the HttpLatencyDetector should not require "service up";
@@ -204,23 +222,7 @@ public class HttpLatencyDetector extends AbstractEnricher {
         /** returns the detector. note that callers should then add this to the entity,
          * typically using {@link Entity#addEnricher(brooklyn.policy.Enricher)} */
         public HttpLatencyDetector build() {
-            HttpLatencyDetector result = new HttpLatencyDetector();
-            
-            if (periodMillis!=null) result.periodMillis = periodMillis;
-            if (requireServiceUp!=null) result.requireServiceUp = requireServiceUp;
-            
-            if (urlSensor!=null) {
-                result.urlSensor = urlSensor;
-                if (urlPostProcessing!=null) result.urlPostProcessing = urlPostProcessing;
-                if (url!=null)
-                    throw new IllegalStateException("Cannot set URL and UrlSensor");
-            } else {
-                result.url.set(url);
-            }
-
-            result.rollupPeriod = rollupWindowSize;
-            
-            return result;
+            return new HttpLatencyDetector(this);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/usage/test-support/src/main/java/brooklyn/test/Asserts.java
----------------------------------------------------------------------
diff --git a/usage/test-support/src/main/java/brooklyn/test/Asserts.java b/usage/test-support/src/main/java/brooklyn/test/Asserts.java
index 6cc6d9a..c5a4283 100644
--- a/usage/test-support/src/main/java/brooklyn/test/Asserts.java
+++ b/usage/test-support/src/main/java/brooklyn/test/Asserts.java
@@ -1,17 +1,79 @@
 package brooklyn.test;
 
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import groovy.time.TimeDuration;
+
+import java.util.Map;
+
+import com.google.common.annotations.Beta;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
 
+@Beta
 public class Asserts {
 
     public static <T> void eventually(Supplier<? extends T> supplier, Predicate<T> predicate) {
-        TestUtils.assertEventually(supplier, predicate);
+        eventually(ImmutableMap.<String,Object>of(), supplier, predicate);
+    }
+    
+    public static <T> void eventually(Map<String,?> flags, Supplier<? extends T> supplier, Predicate<T> predicate) {
+        eventually(flags, supplier, predicate, (String)null);
+    }
+    
+    public static <T> void eventually(Map<String,?> flags, Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
+        TimeDuration timeout = TestUtils.toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,1,0));
+        TimeDuration period = TestUtils.toTimeDuration(flags.get("period"), new TimeDuration(0,0,0,10));
+        long periodMs = period.toMilliseconds();
+        long startTime = System.currentTimeMillis();
+        long expireTime = startTime+timeout.toMilliseconds();
+        
+        boolean first = true;
+        T supplied = supplier.get();
+        while (first || System.currentTimeMillis() <= expireTime) {
+            supplied = supplier.get();
+            if (predicate.apply(supplied)) {
+                return;
+            }
+            first = false;
+            if (periodMs > 0) sleep(periodMs);
+        }
+        fail("supplied="+supplied+"; predicate="+predicate+(errMsg!=null?"; "+errMsg:""));
     }
     
     // TODO improve here -- these methods aren't very useful without timeouts
     public static <T> void continually(Supplier<? extends T> supplier, Predicate<T> predicate) {
-        TestUtils.assertContinuallyFromJava(supplier, predicate);
+        continually(ImmutableMap.<String,Object>of(), supplier, predicate);
     }
 
+    public static <T> void continually(Map<String,?> flags, Supplier<? extends T> supplier, Predicate<T> predicate) {
+        continually(flags, supplier, predicate, (String)null);
+    }
+
+    public static <T> void continually(Map<String,?> flags, Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
+        TimeDuration duration = TestUtils.toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,1,0));
+        TimeDuration period = TestUtils.toTimeDuration(flags.get("period"), new TimeDuration(0,0,0,10));
+        long periodMs = period.toMilliseconds();
+        long startTime = System.currentTimeMillis();
+        long expireTime = startTime+duration.toMilliseconds();
+        
+        boolean first = true;
+        while (first || System.currentTimeMillis() <= expireTime) {
+            assertTrue(predicate.apply(supplier.get()), "supplied="+supplier.get()+"; predicate="+predicate+(errMsg!=null?"; "+errMsg:""));
+            if (periodMs > 0) sleep(periodMs);
+            first = false;
+        }
+    }
+
+    private static void sleep(long periodMs) {
+        if (periodMs > 0) {
+            try {
+                Thread.sleep(periodMs);
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                throw new RuntimeException(e);
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9714edc3/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
----------------------------------------------------------------------
diff --git a/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy b/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
index 7aee3e5..54fc516 100644
--- a/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
+++ b/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
@@ -21,6 +21,8 @@ import com.google.common.collect.Iterables
 
 /**
  * Helper functions for tests of Tomcat, JBoss and others.
+ * 
+ * Note that methods will migrate from here to {@link Asserts} in future releases.
  */
 public class TestUtils {
     private static final Logger log = LoggerFactory.getLogger(TestUtils.class)
@@ -77,31 +79,22 @@ public class TestUtils {
         return HttpTestUtils.connectToUrl(url);
     }
     
-    // TODO see also Java variant: Asserts.eventually()
     // calling groovy from java doesn't cope with generics here; stripping them from here :-(
     //      <T> void assertEventually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate)
+    /**
+     * @deprecated since 0.5; use {@link Asserts.eventually(Map, Supplier, Predicate)}
+     */
+    @Deprecated
     public static void assertEventually(Map flags=[:], Supplier supplier, Predicate predicate) {
-        assertEventually(flags, supplier, predicate, (String)null);
+        Asserts.eventually(flags, supplier, predicate);
     }
     
+    /**
+     * @deprecated since 0.5; use {@link Asserts.eventually(Map, Supplier, Predicate, String)}
+     */
+    @Deprecated
     public static <T> void assertEventually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
-        TimeDuration timeout = toTimeDuration(flags.timeout) ?: new TimeDuration(0,0,1,0)
-        TimeDuration period = toTimeDuration(flags.period) ?: new TimeDuration(0,0,0,10)
-        long periodMs = period.toMilliseconds()
-        long startTime = System.currentTimeMillis()
-        long expireTime = startTime+timeout.toMilliseconds()
-        
-        boolean first = true;
-        T supplied = supplier.get();
-        while (first || System.currentTimeMillis() <= expireTime) {
-            supplied = supplier.get();
-            if (predicate.apply(supplied)) {
-                return;
-            }
-            first = false;
-            if (periodMs > 0) sleep(periodMs);
-        }
-        fail("supplied="+supplied+"; predicate="+predicate+(errMsg!=null?"; "+errMsg:""));
+        Asserts.eventually(flags, supplier, predicate, errMsg);
     }
     
     public static void assertEventually(Map flags=[:], Callable c) {
@@ -255,33 +248,38 @@ public class TestUtils {
         }
     }
     
-    // FIXME When calling from java, the generics declared in groovy messing things up! 
+    /**
+     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate)}
+     */
+    @Deprecated
+    // FIXME When calling from java, the generics declared in groovy messing things up!
     public static void assertContinuallyFromJava(Map flags=[:], Supplier<?> supplier, Predicate<?> predicate) {
-        assertContinually(flags, supplier, predicate, (String)null);
+        Asserts.continually(flags, supplier, predicate);
     }
     
+    /**
+     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate)}
+     */
+    @Deprecated
     public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate) {
-        assertContinually(flags, supplier, predicate, (String)null);
+        Asserts.continually(flags, supplier, predicate, (String)null);
     }
 
+    /**
+     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate, String)}
+     */
+    @Deprecated
     public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg, long durationMs) {
         flags.put("duration", toTimeDuration(durationMs));
-        assertContinually(flags, supplier, predicate, errMsg);
+        Asserts.continually(flags, supplier, predicate, errMsg);
     }
     
+    /**
+     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate, String)}
+     */
+    @Deprecated
     public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
-        TimeDuration duration = toTimeDuration(flags.timeout) ?: new TimeDuration(0,0,1,0)
-        TimeDuration period = toTimeDuration(flags.period) ?: new TimeDuration(0,0,0,10)
-        long periodMs = period.toMilliseconds()
-        long startTime = System.currentTimeMillis()
-        long expireTime = startTime+duration.toMilliseconds()
-        
-        boolean first = true;
-        while (first || System.currentTimeMillis() <= expireTime) {
-            assertTrue(predicate.apply(supplier.get()), "supplied="+supplier.get()+"; predicate="+predicate+(errMsg!=null?"; "+errMsg:""));
-            if (periodMs > 0) sleep(periodMs);
-            first = false;
-        }
+        Asserts.continually(flags, supplier, predicate, errMsg);
     }
     
     public static class BooleanWithMessage {
@@ -306,8 +304,12 @@ public class TestUtils {
     }
 
     public static TimeDuration toTimeDuration(Object duration) {
+        return toTimeDuration(duration, null);
+    }
+            
+    public static TimeDuration toTimeDuration(Object duration, TimeDuration defaultVal) {
         if (duration == null) {
-            return null
+            return defaultVal;
         } else if (duration instanceof TimeDuration) {
             return (TimeDuration) duration
         } else if (duration instanceof Number) {


[43/50] brooklyn-server git commit: Adds testInheritedConfigAvailableDeepInHierarchy

Posted by he...@apache.org.
Adds testInheritedConfigAvailableDeepInHierarchy

- Was added while trying to track down bug @grkvlt was seeing,
  but this wasn't the cause! A useful test to have though.


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

Branch: refs/heads/0.5.0
Commit: 6ea7b07ef541cb1c2359b00d6009fc5b3beb7781
Parents: 129bd9c
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 17 14:46:03 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 11:25:01 2013 +0100

----------------------------------------------------------------------
 .../entity/basic/EntityConfigMapUsageTest.java         | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6ea7b07e/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java b/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
index b5efd58..b2c99a2 100644
--- a/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
@@ -90,6 +90,19 @@ public class EntityConfigMapUsageTest {
     }
     
     @Test
+    public void testInheritedConfigAvailableDeepInHierarchy() throws Exception {
+        TestEntity parent = app.createAndManageChild(EntitySpecs.spec(TestEntity.class)
+                .configure(strKeyWithDefault, "customval"));
+        TestEntity entity = parent.createAndManageChild(EntitySpecs.spec(TestEntity.class));
+        TestEntity entity2 = entity.createAndManageChild(EntitySpecs.spec(TestEntity.class));
+        TestEntity entity3 = entity2.createAndManageChild(EntitySpecs.spec(TestEntity.class));
+        
+        assertEquals(entity.getConfig(strKeyWithDefault), "customval");
+        assertEquals(entity2.getConfig(strKeyWithDefault), "customval");
+        assertEquals(entity3.getConfig(strKeyWithDefault), "customval");
+    }
+    
+    @Test
     public void testConfigCanBeSetOnEntity() throws Exception {
         TestEntity entity = app.createChild(EntitySpecs.spec(TestEntity.class));
         ((EntityLocal)entity).setConfig(strKey, "aval");


[18/50] brooklyn-server git commit: resolves the issue with: java: brooklyn.entity.rebind.Rebindable cannot be inherited with different arguments: and <>

Posted by he...@apache.org.
resolves the issue with:
java: brooklyn.entity.rebind.Rebindable cannot be inherited with different arguments: <brooklyn.mementos.EntityMemento> and <>

This is done by dropping generics for the Rebindable, but relying on coveriant return types for getMementoSupport. Provides the same typesafety, at the price of a bit more code.


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

Branch: refs/heads/0.5.0
Commit: 32f5433ca6a86ae8d2fc54ac1fa7bcd014f54d74
Parents: 8df8852
Author: Peter Veentjer <al...@gmail.com>
Authored: Wed Apr 17 16:42:49 2013 +0300
Committer: Peter Veentjer <al...@gmail.com>
Committed: Wed Apr 17 16:42:49 2013 +0300

----------------------------------------------------------------------
 api/src/main/java/brooklyn/entity/Entity.java            | 6 +++++-
 api/src/main/java/brooklyn/entity/rebind/Rebindable.java | 4 ++--
 api/src/main/java/brooklyn/location/Location.java        | 6 +++++-
 api/src/main/java/brooklyn/policy/Policy.java            | 6 +++++-
 4 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/32f5433c/api/src/main/java/brooklyn/entity/Entity.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/Entity.java b/api/src/main/java/brooklyn/entity/Entity.java
index b267cb9..3c555e7 100644
--- a/api/src/main/java/brooklyn/entity/Entity.java
+++ b/api/src/main/java/brooklyn/entity/Entity.java
@@ -5,6 +5,7 @@ import java.util.Collection;
 import java.util.Map;
 
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.rebind.RebindSupport;
 import brooklyn.entity.rebind.Rebindable;
 import brooklyn.event.AttributeSensor;
 import brooklyn.location.Location;
@@ -27,7 +28,7 @@ import brooklyn.policy.Policy;
  * 
  * @see brooklyn.entity.basic.AbstractEntity
  */
-public interface Entity extends Serializable, Rebindable<EntityMemento> {
+public interface Entity extends Serializable, Rebindable {
     /**
      * The unique identifier for this entity.
      */
@@ -204,4 +205,7 @@ public interface Entity extends Serializable, Rebindable<EntityMemento> {
      * @return True if the policy enricher at this entity; false otherwise
      */
     boolean removeEnricher(Enricher enricher);
+
+    @Override
+    RebindSupport<EntityMemento> getRebindSupport();
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/32f5433c/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/Rebindable.java b/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
index cd63c9f..9ffbbba 100644
--- a/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
+++ b/api/src/main/java/brooklyn/entity/rebind/Rebindable.java
@@ -8,8 +8,8 @@ import brooklyn.mementos.Memento;
  * of the rebind is to reconstruct and reconnect the brooklyn objects, including
  * binding them to external resources.
  */
-public interface Rebindable<T extends Memento> {
+public interface Rebindable{
 
-    public RebindSupport<T> getRebindSupport();
+    public RebindSupport getRebindSupport();
     
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/32f5433c/api/src/main/java/brooklyn/location/Location.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/location/Location.java b/api/src/main/java/brooklyn/location/Location.java
index 2b9ae24..7cf1fb4 100644
--- a/api/src/main/java/brooklyn/location/Location.java
+++ b/api/src/main/java/brooklyn/location/Location.java
@@ -5,6 +5,7 @@ import java.util.Collection;
 import java.util.Map;
 
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.rebind.RebindSupport;
 import brooklyn.entity.rebind.Rebindable;
 import brooklyn.mementos.LocationMemento;
 
@@ -16,7 +17,7 @@ import brooklyn.mementos.LocationMemento;
  * 
  * Locations may not be {@link Serializable} in subsequent releases!
  */
-public interface Location extends Serializable, Rebindable<LocationMemento> {
+public interface Location extends Serializable, Rebindable {
 
     /**
      * A unique id for this location.
@@ -106,4 +107,7 @@ public interface Location extends Serializable, Rebindable<LocationMemento> {
      */
     @Deprecated
     Object findLocationProperty(String key);
+
+    @Override
+    RebindSupport<LocationMemento> getRebindSupport();
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/32f5433c/api/src/main/java/brooklyn/policy/Policy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/policy/Policy.java b/api/src/main/java/brooklyn/policy/Policy.java
index 5d34824..c03e3f8 100644
--- a/api/src/main/java/brooklyn/policy/Policy.java
+++ b/api/src/main/java/brooklyn/policy/Policy.java
@@ -3,6 +3,7 @@ package brooklyn.policy;
 import java.util.Map;
 
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.rebind.RebindSupport;
 import brooklyn.entity.rebind.Rebindable;
 import brooklyn.mementos.PolicyMemento;
 
@@ -12,7 +13,7 @@ import com.google.common.annotations.Beta;
  * Policies implement actions and thus must be suspendable; policies should continue to evaluate their sensors
  * and indicate their desired planned action even if they aren't invoking them
  */
-public interface Policy extends EntityAdjunct, Rebindable<PolicyMemento> {
+public interface Policy extends EntityAdjunct, Rebindable{
     /**
      * A unique id for this policy.
      */
@@ -51,4 +52,7 @@ public interface Policy extends EntityAdjunct, Rebindable<PolicyMemento> {
     <T> T setConfig(ConfigKey<T> key, T val);
     
     Map<ConfigKey<?>, Object> getAllConfig();
+
+    @Override
+    RebindSupport<PolicyMemento> getRebindSupport();
 }


[25/50] brooklyn-server git commit: Do not unpack ExecutionException when propagating Throwable

Posted by he...@apache.org.
Do not unpack ExecutionException when propagating Throwable


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

Branch: refs/heads/0.5.0
Commit: bba778be40a27473d6a62f8008992f744a6a6fa3
Parents: f7ac179
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Fri Apr 19 11:52:45 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Fri Apr 19 11:52:45 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/util/exceptions/Exceptions.java | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bba778be/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/exceptions/Exceptions.java b/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
index e4866c9..0775fba 100644
--- a/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
+++ b/core/src/main/java/brooklyn/util/exceptions/Exceptions.java
@@ -5,7 +5,6 @@ import static com.google.common.base.Throwables.getCausalChain;
 import static com.google.common.collect.Iterables.find;
 
 import java.util.NoSuchElementException;
-import java.util.concurrent.ExecutionException;
 
 import com.google.common.base.Throwables;
 
@@ -15,14 +14,11 @@ public class Exceptions {
      * Propagate a {@link Throwable} as a {@link RuntimeException}.
      * <p>
      * Like Guava {@link Throwables#propagate(Throwable)} but throws {@link RuntimeInterruptedException}
-     * to handle {@link InterruptedException}s and unpacks the {@link Exception#getCause() cause} and propagates
-     * it for {@link ExecutionException}s.
+     * to handle {@link InterruptedException}s.
      */
     public static RuntimeException propagate(Throwable throwable) {
         if (throwable instanceof InterruptedException)
             throw new RuntimeInterruptedException((InterruptedException) throwable);
-        if (throwable instanceof ExecutionException)
-            return Throwables.propagate(throwable.getCause());
         return Throwables.propagate(throwable);
     }
 
@@ -35,8 +31,6 @@ public class Exceptions {
     public static void propagateIfFatal(Throwable throwable) {
         if (throwable instanceof InterruptedException)
             throw new RuntimeInterruptedException((InterruptedException) throwable);
-        if (throwable instanceof ExecutionException)
-            propagateIfFatal(throwable.getCause());
         if (throwable instanceof Error)
             throw (Error) throwable;
     }


[03/50] brooklyn-server git commit: Move code from TestUtils to Asserts, and deprecate

Posted by he...@apache.org.
Move code from TestUtils to Asserts, and deprecate

- Deprecate code in TestUtils so we can delete it in 0.6
- Move code to Asserts
- Note: I've been lazy, and not updated uses of it!
  But this is just in test code, and I'll update everything
  first thing in 0.6 work.


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

Branch: refs/heads/0.5.0
Commit: b2471c284274259c8c6cc3a574c673667c2beea5
Parents: 9714edc
Author: Aled Sage <al...@gmail.com>
Authored: Thu Mar 28 10:37:14 2013 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Mar 29 09:47:46 2013 +0000

----------------------------------------------------------------------
 .../src/main/java/brooklyn/test/Asserts.java    | 262 ++++++++++++++++++-
 .../main/java/brooklyn/test/TestUtils.groovy    | 135 ++++++++--
 2 files changed, 376 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b2471c28/usage/test-support/src/main/java/brooklyn/test/Asserts.java
----------------------------------------------------------------------
diff --git a/usage/test-support/src/main/java/brooklyn/test/Asserts.java b/usage/test-support/src/main/java/brooklyn/test/Asserts.java
index c5a4283..d4261a9 100644
--- a/usage/test-support/src/main/java/brooklyn/test/Asserts.java
+++ b/usage/test-support/src/main/java/brooklyn/test/Asserts.java
@@ -2,18 +2,36 @@ package brooklyn.test;
 
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
+import groovy.lang.Closure;
 import groovy.time.TimeDuration;
 
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.test.TestUtils.BooleanWithMessage;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
 import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
 @Beta
 public class Asserts {
 
+    private static final Logger log = LoggerFactory.getLogger(Asserts.class);
+
+    private Asserts() {}
+    
     public static <T> void eventually(Supplier<? extends T> supplier, Predicate<T> predicate) {
         eventually(ImmutableMap.<String,Object>of(), supplier, predicate);
     }
@@ -23,8 +41,8 @@ public class Asserts {
     }
     
     public static <T> void eventually(Map<String,?> flags, Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
-        TimeDuration timeout = TestUtils.toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,1,0));
-        TimeDuration period = TestUtils.toTimeDuration(flags.get("period"), new TimeDuration(0,0,0,10));
+        TimeDuration timeout = toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,1,0));
+        TimeDuration period = toTimeDuration(flags.get("period"), new TimeDuration(0,0,0,10));
         long periodMs = period.toMilliseconds();
         long startTime = System.currentTimeMillis();
         long expireTime = startTime+timeout.toMilliseconds();
@@ -52,8 +70,8 @@ public class Asserts {
     }
 
     public static <T> void continually(Map<String,?> flags, Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
-        TimeDuration duration = TestUtils.toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,1,0));
-        TimeDuration period = TestUtils.toTimeDuration(flags.get("period"), new TimeDuration(0,0,0,10));
+        TimeDuration duration = toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,1,0));
+        TimeDuration period = toTimeDuration(flags.get("period"), new TimeDuration(0,0,0,10));
         long periodMs = period.toMilliseconds();
         long startTime = System.currentTimeMillis();
         long expireTime = startTime+duration.toMilliseconds();
@@ -66,14 +84,246 @@ public class Asserts {
         }
     }
 
+    
+    
+    public static void succeedsEventually(Runnable r) {
+        succeedsEventually(ImmutableMap.<String,Object>of(), r);
+    }
+
+    public static void succeedsEventually(Map<String,?> flags, Runnable r) {
+        succeedsEventually(flags, toCallable(r));
+    }
+    
+    public static void succeedsEventually(Callable<?> c) {
+        succeedsEventually(ImmutableMap.<String,Object>of(), c);
+    }
+    
+    /**
+     * Convenience method for cases where we need to test until something is true.
+     *
+     * The runnable will be invoked periodically until it succesfully concludes.
+     * <p>
+     * The following flags are supported:
+     * <ul>
+     * <li>abortOnError (boolean, default true)
+     * <li>abortOnException - (boolean, default false)
+     * <li>timeout - (a TimeDuration or an integer in millis, defaults to 30*SECONDS)
+     * <li>period - (a TimeDuration or an integer in millis, for fixed retry time; if not set, defaults to exponentially increasing from 1 to 500ms)
+     * <li>minPeriod - (a TimeDuration or an integer in millis; only used if period not explicitly set; the minimum period when exponentially increasing; defaults to 1ms)
+     * <li>maxPeriod - (a TimeDuration or an integer in millis; only used if period not explicitly set; the maximum period when exponentially increasing; defaults to 500ms)
+     * <li>maxAttempts - (integer, Integer.MAX_VALUE)
+     * </ul>
+     * 
+     * The following flags are deprecated:
+     * <ul>
+     * <li>useGroovyTruth - (defaults to false; any result code apart from 'false' will be treated as success including null; ignored for Runnables which aren't Callables)
+     * </ul>
+     * 
+     * @param flags, accepts the flags listed above
+     * @param r
+     * @param finallyBlock
+     */
+    public static void succeedsEventually(Map<String,?> flags, Callable<?> c) {
+        boolean abortOnException = get(flags, "abortOnException", false);
+        boolean abortOnError = get(flags, "abortOnError", false);
+        boolean useGroovyTruth = get(flags, "useGroovyTruth", false);
+        boolean logException = get(flags, "logException", true);
+
+        // To speed up tests, default is for the period to start small and increase...
+        TimeDuration duration = toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,30,0));
+        TimeDuration fixedPeriod = toTimeDuration(flags.get("period"), null);
+        TimeDuration minPeriod = (fixedPeriod != null) ? fixedPeriod : toTimeDuration(flags.get("minPeriod"), new TimeDuration(0,0,0,1));
+        TimeDuration maxPeriod = (fixedPeriod != null) ? fixedPeriod : toTimeDuration(flags.get("maxPeriod"), new TimeDuration(0,0,0,500));
+        int maxAttempts = get(flags, "maxAttempts", Integer.MAX_VALUE);
+        int attempt = 0;
+        long startTime = System.currentTimeMillis();
+        try {
+            Throwable lastException = null;
+            Object result = null;
+            long lastAttemptTime = 0;
+            long expireTime = startTime+duration.toMilliseconds();
+            long sleepTimeBetweenAttempts = minPeriod.toMilliseconds();
+            
+            while (attempt < maxAttempts && lastAttemptTime < expireTime) {
+                try {
+                    attempt++;
+                    lastAttemptTime = System.currentTimeMillis();
+                    result = c.call();
+                    if (log.isTraceEnabled()) log.trace("Attempt {} after {} ms: {}", new Object[] {attempt, System.currentTimeMillis() - startTime, result});
+                    if (useGroovyTruth) {
+                        if (groovyTruth(result)) return;
+                    } else if (Boolean.FALSE.equals(result)) {
+                        if (result instanceof BooleanWithMessage) 
+                            log.warn("Test returned an instance of BooleanWithMessage but useGroovyTruth is not set! " +
+                                     "The result of this probably isn't what you intended.");
+                        return;
+                    } else {
+                        return;
+                    }
+                    lastException = null;
+                } catch(Throwable e) {
+                    lastException = e;
+                    if (log.isTraceEnabled()) log.trace("Attempt {} after {} ms: {}", new Object[] {attempt, System.currentTimeMillis() - startTime, e.getMessage()});
+                    if (abortOnException) throw e;
+                    if (abortOnError && e instanceof Error) throw e;
+                }
+                long sleepTime = Math.min(sleepTimeBetweenAttempts, expireTime-System.currentTimeMillis());
+                if (sleepTime > 0) Thread.sleep(sleepTime);
+                sleepTimeBetweenAttempts = Math.min(sleepTimeBetweenAttempts*2, maxPeriod.toMilliseconds());
+            }
+            
+            log.debug("TestUtils.executeUntilSucceedsWithFinallyBlockInternal exceeded max attempts or timeout - {} attempts lasting {} ms", attempt, System.currentTimeMillis()-startTime);
+            if (lastException != null)
+                throw lastException;
+            fail("invalid result: "+result);
+        } catch (Throwable t) {
+            if (logException) log.info("failed succeeds-eventually, "+attempt+" attempts, "+
+                    (System.currentTimeMillis()-startTime)+"ms elapsed "+
+                    "(rethrowing): "+t);
+            throw propagate(t);
+        }
+    }
+
+    public static <T> void succeedsContinually(Runnable r) {
+        succeedsContinually(ImmutableMap.<String,Object>of(), r);
+    }
+    
+    public static <T> void succeedsContinually(Map<String,?> flags, Runnable r) {
+        succeedsContinually(flags, toCallable(r));
+    }
+
+    public static void succeedsContinually(Callable<?> c) {
+        succeedsContinually(ImmutableMap.<String,Object>of(), c);
+    }
+    
+    public static void succeedsContinually(Map<String,?> flags, Callable<?> job) {
+        TimeDuration duration = toTimeDuration(flags.get("timeout"), new TimeDuration(0,0,1,0));
+        TimeDuration period = toTimeDuration(flags.get("period"), new TimeDuration(0,0,0,10));
+        long periodMs = period.toMilliseconds();
+        long startTime = System.currentTimeMillis();
+        long expireTime = startTime+duration.toMilliseconds();
+        
+        boolean first = true;
+        while (first || System.currentTimeMillis() <= expireTime) {
+            try {
+                job.call();
+            } catch (Exception e) {
+                throw propagate(e);
+            }
+            if (periodMs > 0) sleep(periodMs);
+            first = false;
+        }
+    }
+    
+    private static TimeDuration toTimeDuration(Object duration) {
+        return toTimeDuration(duration, null);
+    }
+            
+    private static TimeDuration toTimeDuration(Object duration, TimeDuration defaultVal) {
+        if (duration == null) {
+            return defaultVal;
+        } else if (duration instanceof TimeDuration) {
+            return (TimeDuration) duration;
+        } else if (duration instanceof Number) {
+            return new TimeDuration(0,0,0,((Number) duration).intValue());
+            // TODO would be nice to have this, but we need to sort out utils / test-utils dependency
+//        } else if (duration instanceof String) {
+//            return Time.parseTimeString((String)duration);
+        } else {
+            throw new IllegalArgumentException("Cannot convert "+duration+" of type "+duration.getClass().getName()+" to a TimeDuration");
+        }
+    }
+    
+    public static void assertFails(Runnable c) {
+        assertFailsWith(c, Predicates.alwaysTrue());
+    }
+    
+    public static void assertFailsWith(Runnable c, final Closure<Boolean> exceptionChecker) {
+        assertFailsWith(c, new Predicate<Throwable>() {
+            public boolean apply(Throwable input) {
+                return exceptionChecker.call(input);
+            }
+        });
+    }
+    
+    public static void assertFailsWith(Runnable c, final Class<? extends Throwable> validException, final Class<? extends Throwable> ...otherValidExceptions) {
+        final List<Class> validExceptions = ImmutableList.<Class>builder()
+                .add(validException)
+                .addAll(ImmutableList.copyOf(otherValidExceptions))
+                .build();
+        
+        assertFailsWith(c, new Predicate<Throwable>() {
+            public boolean apply(Throwable e) {
+                for (Class<?> validException: validExceptions) {
+                    if (validException.isInstance(e)) return true;
+                }
+                fail("Test threw exception of unexpected type "+e.getClass()+"; expecting "+validExceptions);
+                return false;
+            }
+        });
+    }
+    
+    public static void assertFailsWith(Runnable c, Predicate<? super Throwable> exceptionChecker) {
+        boolean failed = false;
+        try {
+            c.run();
+        } catch (Throwable e) {
+            failed = true;
+            if (!exceptionChecker.apply(e)) {
+                log.debug("Test threw invalid exception (failing)", e);
+                fail("Test threw invalid exception: "+e);
+            }
+            log.debug("Test for exception successful ("+e+")");
+        }
+        if (!failed) fail("Test code should have thrown exception but did not");
+    }
+
+    private static boolean groovyTruth(Object o) {
+        // TODO Doesn't handle matchers (see http://docs.codehaus.org/display/GROOVY/Groovy+Truth)
+        if (o == null) {
+            return false;
+        } else if (o instanceof Boolean) {
+            return (Boolean)o;
+        } else if (o instanceof String) {
+            return !((String)o).isEmpty();
+        } else if (o instanceof Collection) {
+            return !((Collection)o).isEmpty();
+        } else if (o instanceof Map) {
+            return !((Map)o).isEmpty();
+        } else if (o instanceof Iterator) {
+            return ((Iterator)o).hasNext();
+        } else if (o instanceof Enumeration) {
+            return ((Enumeration)o).hasMoreElements();
+        } else {
+            return true;
+        }
+    }
+    
+    private static <T> T get(Map<String,?> map, String key, T defaultVal) {
+        Object val = map.get(key);
+        return (T) ((val == null) ? defaultVal : val);
+    }
+    
+    private static Callable<?> toCallable(Runnable r) {
+        return (r instanceof Callable) ? (Callable<?>)r : Executors.callable(r);
+    }
+    
     private static void sleep(long periodMs) {
         if (periodMs > 0) {
             try {
                 Thread.sleep(periodMs);
             } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                throw new RuntimeException(e);
+                throw propagate(e);
             }
         }
     }
+    
+    private static RuntimeException propagate(Throwable t) {
+        if (t instanceof InterruptedException) {
+            Thread.currentThread().interrupt();
+        }
+        if (t instanceof RuntimeException) throw (RuntimeException)t;
+        if (t instanceof Error) throw (Error)t;
+        throw new RuntimeException(t);
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b2471c28/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
----------------------------------------------------------------------
diff --git a/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy b/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
index 54fc516..ab81741 100644
--- a/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
+++ b/usage/test-support/src/main/java/brooklyn/test/TestUtils.groovy
@@ -29,7 +29,12 @@ public class TestUtils {
 
     private TestUtils() { }
 
-    /** True if two attempts to connect to the port succeed. */
+    /**
+     * True if two attempts to connect to the port succeed.
+     * 
+     * @deprecated since 0.5; use {@link brooklyn.util.NetworkUtils#isPortAvailable(int)}
+     */
+    @Deprecated
     public static boolean isPortInUse(int port, long retryAfterMillis=0) {
         try {
             def s = new Socket("localhost", port)
@@ -82,7 +87,7 @@ public class TestUtils {
     // calling groovy from java doesn't cope with generics here; stripping them from here :-(
     //      <T> void assertEventually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate)
     /**
-     * @deprecated since 0.5; use {@link Asserts.eventually(Map, Supplier, Predicate)}
+     * @deprecated since 0.5; use {@link Asserts#eventually(Map, Supplier, Predicate)}
      */
     @Deprecated
     public static void assertEventually(Map flags=[:], Supplier supplier, Predicate predicate) {
@@ -90,30 +95,49 @@ public class TestUtils {
     }
     
     /**
-     * @deprecated since 0.5; use {@link Asserts.eventually(Map, Supplier, Predicate, String)}
+     * @deprecated since 0.5; use {@link Asserts#eventually(Map, Supplier, Predicate, String)}
      */
     @Deprecated
     public static <T> void assertEventually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
         Asserts.eventually(flags, supplier, predicate, errMsg);
     }
-    
+
+    /**    
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(java.util.Map, Callable)}
+     */
+    @Deprecated
     public static void assertEventually(Map flags=[:], Callable c) {
         executeUntilSucceeds(flags, c);
     }
+    
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Runnable)}
+     */
+    @Deprecated
     public static void assertEventually(Map flags=[:], Runnable c) {
         executeUntilSucceeds(flags, c);
     }
 
-    //FIXME rename these to assertEventually, refactor to have boolean blockUntil in some other util class
-    //FIXME remove dupilcation with LanguageUtils.repeatUntilSuccess
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}
+     */
+    @Deprecated
     public static void executeUntilSucceeds(Map flags=[:], Closure c) {
-        executeUntilSucceedsWithFinallyBlock(flags, c) { }
+        Asserts.succeedsEventually(flags, c);
     }
 
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}
+     */
+    @Deprecated
     public static void executeUntilSucceeds(Map flags=[:], Callable c) {
-        executeUntilSucceedsWithFinallyBlock(flags, c) { }
+        Asserts.succeedsEventually(flags, c);
     }
     
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Runnable)}
+     */
+    @Deprecated
     public static void executeUntilSucceeds(Map flags=[:], Runnable r) {
         if (r in Callable) 
             executeUntilSucceedsWithFinallyBlock(flags, {return ((Callable)r).call();}, { })
@@ -123,6 +147,10 @@ public class TestUtils {
             executeUntilSucceedsWithFinallyBlock(flags, {r.run(); return true}, { })
     }
 
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
+     */
+    @Deprecated
     public static void executeUntilSucceedsElseShutdown(Map flags=[:], Entity entity, Closure c) {
         try { 
             executeUntilSucceedsWithFinallyBlock(flags, c) { }
@@ -132,11 +160,20 @@ public class TestUtils {
         }
     }
 
-    /** convenience for entities to ensure they shutdown afterwards */
+    /**
+     * convenience for entities to ensure they shutdown afterwards.
+     * 
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
+     */
+    @Deprecated
     public static void executeUntilSucceedsWithShutdown(Map flags=[:], Entity entity, Closure c) {
         executeUntilSucceedsWithFinallyBlock(flags, c) { entity.stop() }
     }
 
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
+     */
+    @Deprecated
     public static void executeUntilSucceedsWithFinallyBlock(Map flags=[:], Closure c, Closure finallyBlock={}) {
         executeUntilSucceedsWithFinallyBlockInternal(flags, c, finallyBlock)
     }
@@ -162,11 +199,20 @@ public class TestUtils {
      * @param flags, accepts the flags listed above
      * @param r
      * @param finallyBlock
+     * 
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
      */
+    @Deprecated
     public static void executeUntilSucceedsWithFinallyBlock(Map flags=[:], Callable<?> c, Closure finallyBlock={}) {
         executeUntilSucceedsWithFinallyBlockInternal(flags, c, finallyBlock);
     }
-    /** the "real" implementation, renamed to allow multiple entry points (depending whether closure cast to callable) */
+    
+    /**
+     * the "real" implementation, renamed to allow multiple entry points (depending whether closure cast to callable)
+     * 
+     * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
+     */
+    @Deprecated
     private static void executeUntilSucceedsWithFinallyBlockInternal(Map flags=[:], Callable<?> c, Closure finallyBlock={}) {
 //        log.trace "abortOnError = {}", flags.abortOnError
         boolean abortOnException = flags.abortOnException ?: false
@@ -229,11 +275,19 @@ public class TestUtils {
         }
     }
 
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsContinually(Map, Runnable)}
+     */
+    @Deprecated
     public static <T> void assertSucceedsContinually(Map flags=[:], Runnable job) {
         assertSucceedsContinually(flags, Executors.callable(job));
     }
     
-    public static <T> void assertSucceedsContinually(Map flags=[:], Callable<T> job) {
+    /**
+     * @deprecated since 0.5; use {@link Asserts#succeedsContinually(Map, Callable)}
+     */
+    @Deprecated
+    public static void assertSucceedsContinually(Map flags=[:], Callable<?> job) {
         TimeDuration duration = toTimeDuration(flags.timeout) ?: new TimeDuration(0,0,1,0)
         TimeDuration period = toTimeDuration(flags.period) ?: new TimeDuration(0,0,0,10)
         long periodMs = period.toMilliseconds()
@@ -249,7 +303,7 @@ public class TestUtils {
     }
     
     /**
-     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate)}
+     * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate)}
      */
     @Deprecated
     // FIXME When calling from java, the generics declared in groovy messing things up!
@@ -258,7 +312,7 @@ public class TestUtils {
     }
     
     /**
-     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate)}
+     * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate)}
      */
     @Deprecated
     public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate) {
@@ -266,7 +320,7 @@ public class TestUtils {
     }
 
     /**
-     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate, String)}
+     * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate, String)}
      */
     @Deprecated
     public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg, long durationMs) {
@@ -275,7 +329,7 @@ public class TestUtils {
     }
     
     /**
-     * @deprecated since 0.5; use {@link Asserts.continually(Map, Supplier, Predicate, String)}
+     * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate, String)}
      */
     @Deprecated
     public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
@@ -295,6 +349,10 @@ public class TestUtils {
         }
     }
     
+    /**
+     * @deprecated since 0.5; use {@link brooklyn.util.ResourceUtils}
+     */
+    @Deprecated
     public static File getResource(String path, ClassLoader loader) {
         URL resource = loader.getResource(path)
         if (resource==null)
@@ -303,10 +361,18 @@ public class TestUtils {
         return new File(resource.path)
     }
 
+    /**
+     * @deprecated since 0.5; use long and {@link TimeUnit}
+     */
+    @Deprecated
     public static TimeDuration toTimeDuration(Object duration) {
         return toTimeDuration(duration, null);
     }
             
+    /**
+     * @deprecated since 0.5; use long and {@link TimeUnit}
+     */
+    @Deprecated
     public static TimeDuration toTimeDuration(Object duration, TimeDuration defaultVal) {
         if (duration == null) {
             return defaultVal;
@@ -356,30 +422,56 @@ public class TestUtils {
         }
     }
 
+    /**
+     * @deprecated since 0.5; use {@link EntityTestUtils#assertAttributeEqualsEventually(Entity, AttributeSensor, Object)}
+     */
+    @Deprecated
     public static <T> void assertAttributeEventually(Entity entity, AttributeSensor<T> attribute, T expected) {
         executeUntilSucceeds() {
             assertEquals(entity.getAttribute(attribute), expected);
         }
     }
     
+    /**
+     * @deprecated since 0.5; use {@link EntityTestUtils#assertAttributeEqualsContinually(Entity, AttributeSensor, Object)}
+     */
+    @Deprecated
     public static <T> void assertAttributeContinually(Entity entity, AttributeSensor<T> attribute, T expected) {
         assertSucceedsContinually() {
             assertEquals(entity.getAttribute(attribute), expected);
         }
     }
     
+    /**
+     * @deprecated since 0.5; use {@link HttpTestUtils#assertHttpStatusCodeEquals(String, int)}
+     */
+    @Deprecated
     public static void assertUrlStatusCodeEventually(final String url, final int expected) {
         executeUntilSucceeds() {
             assertEquals(urlRespondsStatusCode(url), expected);
         }
     }
 
+    /**
+     * @deprecated since 0.5; use {@link Asserts#assertFails(Runnable)}
+     */
+    @Deprecated
     public static void assertFails(Runnable c) {
         assertFailsWith(c, (Predicate)null);
     }
+    
+    /**
+     * @deprecated since 0.5; use {@link Asserts#assertFailsWith(Closure)}
+     */
+    @Deprecated
     public static void assertFailsWith(Runnable c, Closure exceptionChecker) {
         assertFailsWith(c, exceptionChecker as Predicate);
     }
+    
+    /**
+     * @deprecated since 0.5; use {@link Asserts#assertFailsWith(Runnable, Class, Class...)}
+     */
+    @Deprecated
     public static void assertFailsWith(Runnable c, final Class<? extends Throwable> validException, final Class<? extends Throwable> ...otherValidExceptions) {
         assertFailsWith(c, { e -> 
             if (validException.isInstance(e)) return true;
@@ -389,6 +481,11 @@ public class TestUtils {
             fail("Test threw exception of unexpected type "+e.getClass()+"; expecting "+expectedTypes);             
         });
     }
+    
+    /**
+     * @deprecated since 0.5; use {@link Asserts#assertFailsWith(Runnable, Predicate)}
+     */
+    @Deprecated
     public static void assertFailsWith(Runnable c, Predicate<Throwable> exceptionChecker) {
         boolean failed = false;
         try {
@@ -413,11 +510,19 @@ public class TestUtils {
         if (!s.isEmpty()) fail("Second argument contains additional contents: "+s);
     }
     
+    /**
+     * @deprecated since 0.5; use {@code assertFalse(Iterables.isEmpty(c))}
+     */
+    @Deprecated
     public static <T> void assertNonEmpty(Iterable<T> c) {
         if (c.iterator().hasNext()) return;
         fail("Expected non-empty set");
     }
 
+    /**
+     * @deprecated since 0.5; use {@code assertEquals(Iterables.size(c), expectedSize)}
+     */
+    @Deprecated
     public static <T> void assertSize(Iterable<T> c, int expectedSize) {
         int actualSize = Iterables.size(c);
         if (actualSize==expectedSize) return;


[20/50] brooklyn-server git commit: Merge pull request #658 from aledsage/cherrypick/EntityManagementSupport-race

Posted by he...@apache.org.
Merge pull request #658 from aledsage/cherrypick/EntityManagementSupport-race

Fix EntityManagementSupport race for changeListener (0.5 branch)

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

Branch: refs/heads/0.5.0
Commit: a8f4c0fe1edb1b0f8477e879f716117e7795b20c
Parents: 32f5433 9fcdee9
Author: Peter Veentjer <al...@gmail.com>
Authored: Wed Apr 17 09:22:21 2013 -0700
Committer: Peter Veentjer <al...@gmail.com>
Committed: Wed Apr 17 09:22:21 2013 -0700

----------------------------------------------------------------------
 .../NonDeploymentManagementContext.java         | 70 ++++++++++++++++++--
 1 file changed, 65 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[21/50] brooklyn-server git commit: Removed cloud foundry module since it is broken

Posted by he...@apache.org.
Removed cloud foundry module since it is broken


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

Branch: refs/heads/0.5.0
Commit: 4ccaf5a334cd74341890b786f1a74e6822471b2b
Parents: a8f4c0f
Author: Peter Veentjer <al...@gmail.com>
Authored: Thu Apr 18 16:56:43 2013 +0300
Committer: Peter Veentjer <al...@gmail.com>
Committed: Thu Apr 18 16:56:43 2013 +0300

----------------------------------------------------------------------
 pom.xml                                         |   1 -
 systems/paas/cloudfoundry/pom.xml               |  39 --
 .../CloudFoundryJavaWebAppCluster.groovy        | 193 ---------
 .../cloudfoundry/CloudFoundryLocation.groovy    | 119 ------
 .../CloudFoundryVmcCliAccess.groovy             | 412 -------------------
 .../services/brooklyn.location.LocationResolver |   1 -
 .../CloudFoundryAccessIntegrationTest.groovy    |  82 ----
 .../CloudFoundryJavaClusterExample.groovy       |  72 ----
 ...FoundryJavaClusterFromLocationExample.groovy |  78 ----
 .../cloudfoundry/CloudFoundryParseTest.java     |  57 ---
 .../cloudfoundry/LocationResolvesTest.java      |  41 --
 .../src/test/resources/hello-world.war          | Bin 4606 -> 0 bytes
 12 files changed, 1095 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1e6aaa1..6da5302 100644
--- a/pom.xml
+++ b/pom.xml
@@ -602,7 +602,6 @@
                 <module>systems/whirr/base</module>
                 <module>systems/whirr/hadoop</module>
                 <module>systems/paas/openshift</module>
-                <module>systems/paas/cloudfoundry</module>
             </modules>
         </profile>
         <profile>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/pom.xml
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/pom.xml b/systems/paas/cloudfoundry/pom.xml
deleted file mode 100644
index 758c79c..0000000
--- a/systems/paas/cloudfoundry/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>brooklyn-systems-cloudfoundry</artifactId>
-    <packaging>bundle</packaging>
-    <name>Brooklyn CloudFoundry PaaS System Entities</name>
-    <description>
-		Brooklyn entities for CloudFoundry PaaS system (java web app)
-	</description>
-
-    <parent>
-        <groupId>io.brooklyn</groupId>
-        <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
-        <relativePath>../../../pom.xml</relativePath>
-    </parent>
-
-    <dependencies>
-        <dependency>
-            <groupId>io.brooklyn</groupId>
-            <artifactId>brooklyn-software-webapp</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>brooklyn-test-support</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>io.brooklyn</groupId>
-            <artifactId>brooklyn-core</artifactId>
-            <version>${project.version}</version>
-            <classifier>tests</classifier>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaWebAppCluster.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaWebAppCluster.groovy b/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaWebAppCluster.groovy
deleted file mode 100644
index 174d5fb..0000000
--- a/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaWebAppCluster.groovy
+++ /dev/null
@@ -1,193 +0,0 @@
-package brooklyn.extras.cloudfoundry
-
-
-import java.util.Collection
-import java.util.Map
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import brooklyn.entity.Entity
-import brooklyn.entity.basic.AbstractEntity
-import brooklyn.entity.basic.Attributes
-import brooklyn.entity.basic.BasicConfigurableEntityFactory
-import brooklyn.entity.basic.Lifecycle
-import brooklyn.entity.trait.Resizable
-import brooklyn.entity.trait.Startable
-import brooklyn.entity.webapp.ElasticJavaWebAppService
-import brooklyn.event.adapter.FunctionSensorAdapter
-import brooklyn.event.adapter.SensorRegistry
-import brooklyn.event.basic.BasicAttributeSensor
-import brooklyn.event.basic.BasicConfigKey
-import brooklyn.extras.cloudfoundry.CloudFoundryVmcCliAccess.AppRecord
-import brooklyn.extras.cloudfoundry.CloudFoundryVmcCliAccess.CloudFoundryAppStats
-import brooklyn.location.Location
-import brooklyn.util.StringUtils;
-import brooklyn.util.flags.SetFromFlag
-import brooklyn.util.mutex.MutexSupport
-import brooklyn.util.mutex.WithMutexes
-
-import com.google.common.base.Preconditions
-import com.google.common.collect.Iterables
-
-class CloudFoundryJavaWebAppCluster extends AbstractEntity implements ElasticJavaWebAppService, Startable, Resizable {
-    //Startable shouldn't have to be declared but sometimes it isn't picked up??!?!
-
-    private static final Logger log = LoggerFactory.getLogger(CloudFoundryJavaWebAppCluster.class)
-    
-    @SetFromFlag("appName")
-    public static final BasicConfigKey<String> APP_NAME = [ String, "cloudfoundry.app.name.uid", "Unique name for this app" ];
-    @SetFromFlag("url")
-    public static final BasicConfigKey<String> HOSTNAME_TO_USE_FOR_URL = [ String, "cloudfoundry.app.url", "URL to which the app should respond, if not the default" ];
-
-    public static final BasicAttributeSensor<String> APP_HOSTNAME = Attributes.HOSTNAME;
-    public static final BasicAttributeSensor<String> API_HOSTNAME = [ String, "cloudfoundry.api.host.name", "API host name" ];
-
-    //TODO allow url to be set
-    //disabled until we have access to a CF which allows setting the URL
-    //(see refs to getUrl and url in VmcCliAccess)
-    //(and note, this is different to ROOT_URL which _is_ exposed as a _sensor_)
-//    @SetFromFlag("url")            
-//    public static final BasicConfigKey<String> URL = [ String, "cloudfoundry.app.url", "URL this app should respond to" ]
-    
-    public static final SERVICE_STATE = Attributes.SERVICE_STATE
-    
-    public static final BasicAttributeSensor<Integer> SIZE = [ Integer, "cloudfoundry.instances.size", "Number of instances" ];
-    public static final BasicAttributeSensor<Double> CPU_USAGE = [ Double, "cloudfoundry.cpu.usage", "Average CPU utilisation (in [0..1], mean over number of instances and CPUs)" ];
-    public static final BasicAttributeSensor<Double> MEMORY_USED_FRACTION = [ Double, "cloudfoundry.memory.usage.fraction", "Average memory utilisation (in [0..1])" ];
-
-    public AppRecord appRecord;
-    protected transient SensorRegistry sensorRegistry;
-    
-    public CloudFoundryJavaWebAppCluster(Map flags=[:], Entity parent=null) {
-        super(flags, parent);
-        setAttribute(SERVICE_UP, false)
-        setAttribute(SERVICE_STATE, Lifecycle.CREATED);
-        sensorRegistry = new SensorRegistry(this);
-    }
-
-    public String getAppName() {
-        def appName = getConfig(APP_NAME);
-        if (appName) return appName;
-        return "brooklyn-"+getId();
-    }    
-    
-    public String getWar() {
-        return getConfig(ROOT_WAR);
-    }
-    
-    public void start(Collection<Location> locations) {
-        if (getConfig(APP_NAME)!=appName) setConfigEvenIfOwned(APP_NAME, appName);
-        startInLocation locations
-    }
-
-    public void startInLocation(Collection<? extends Location> locations) {
-        Preconditions.checkArgument locations.size() == 1
-        Location location = Iterables.getOnlyElement(locations)
-        startInLocation(location)
-    }
-
-    public void restart() {
-        stop()
-        start()
-    }
-    public void stop() {
-        setAttribute(SERVICE_STATE, Lifecycle.STOPPING);
-        setAttribute(SERVICE_UP, false);
-        cfAccess.stopApp();
-        setAttribute(SERVICE_STATE, Lifecycle.STOPPED);
-    }
-    
-    protected static WithMutexes cfMutex = new MutexSupport();
-     
-    private transient CloudFoundryVmcCliAccess _cfAccess;
-    public CloudFoundryVmcCliAccess getCfAccess() {
-        if (_cfAccess!=null) return _cfAccess;
-        _cfAccess = new CloudFoundryVmcCliAccess(
-            appName:getAppName(), war: war, context: this, mutexSupport:cfMutex)
-        _cfAccess.url = getConfig(HOSTNAME_TO_USE_FOR_URL);
-        return _cfAccess;
-    }
-    
-    public void startInLocation(CloudFoundryLocation ol) {
-        if (locations.isEmpty()) {
-            locations << ol
-        } else {
-            if (locations.contains(ol)) {
-                if (getAttribute(SERVICE_STATE) in [Lifecycle.STARTING, Lifecycle.RUNNING]) {
-                    log.warn("Entity $this already started; not starting again in same location");
-                    return;
-                }
-                //otherwise continue, we're just being told the location twice!
-            } else {
-                throw new IllegalStateException("Cannot start $this in $ol; it is already configured for $locations");
-            }
-        }
-        setAttribute(SERVICE_STATE, Lifecycle.STARTING);
-        
-        if (!war) throw new IllegalStateException("A WAR file is required to start ${this}")
-
-        useTarget(ol.getTarget());
-        appRecord = cfAccess.runAppWar();
-        log.info "{} app launched: {}", this, getAppName()
-
-        //add support for DynamicWebAppCluster.startInLocation(CloudFoundry)
-        connectSensors();
-        setAttribute(SERVICE_STATE, Lifecycle.RUNNING);
-        setAttribute(SERVICE_UP, true)
-    }
-    
-    protected void useTarget(String target) {
-        if (!target) return;
-        cfAccess.setTarget(target)
-    }
-    
-    public void connectSensors() {
-        String apiHostname = ((CloudFoundryLocation)Iterables.getOnlyElement(locations)).hostname;
-        setAttribute(API_HOSTNAME, apiHostname);
-        
-        String appHostname = StringUtils.removeStart(apiHostname, "api.");
-        appHostname = appRecord.appName+"."+appHostname;
-        setAttribute(APP_HOSTNAME, appHostname);
-        
-        String urlDomain = appRecord.url;
-        setAttribute(ROOT_URL, "http://"+urlDomain+"/");
-        
-        sensorRegistry.register(new FunctionSensorAdapter({cfAccess.stats()})).with {
-            poll(SIZE, { CloudFoundryAppStats stats -> stats.instances.size() });
-            poll(CPU_USAGE, { CloudFoundryAppStats stats -> stats.average.cpuUsage });
-            poll(MEMORY_USED_FRACTION, { CloudFoundryAppStats stats -> stats.average.memUsedFraction });
-        }
-    }
-
-    public String getWebAppAddress() {
-        return cfAccess.getUrl();
-    }
-    
-    public void destroy() {
-        log.info "{} destroying app {}", this, getAppName()
-        setAttribute(SERVICE_UP, false)
-        setAttribute(SERVICE_STATE, Lifecycle.STOPPING);
-        sensorRegistry.deactivateAdapters();
-        if (cfAccess.getAppRecord(getAppName(), true))
-            cfAccess.destroyApp();
-        setAttribute(SERVICE_STATE, Lifecycle.STOPPED);
-    }
-
-    @Override
-    public Integer resize(Integer desiredSize) {
-        cfAccess.resizeAbsolute(desiredSize);
-        //could block until SIZE sensor report achieved, or timeout;
-        //but it seems the command-line call is synchronous so not necessary
-    }
-
-    @Override
-    public Integer getCurrentSize() {
-        return getAttribute(SIZE);
-    }
-
-    
-    public static class Factory extends BasicConfigurableEntityFactory<CloudFoundryJavaWebAppCluster> {
-        public Factory(Map flags=[:]) { super(flags, CloudFoundryJavaWebAppCluster) }
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryLocation.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryLocation.groovy b/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryLocation.groovy
deleted file mode 100644
index 5027856..0000000
--- a/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryLocation.groovy
+++ /dev/null
@@ -1,119 +0,0 @@
-package brooklyn.extras.cloudfoundry
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import brooklyn.entity.basic.ConfigurableEntityFactory
-import brooklyn.entity.webapp.ElasticJavaWebAppService
-import brooklyn.entity.webapp.ElasticJavaWebAppService.ElasticJavaWebAppServiceAwareLocation
-import brooklyn.location.AddressableLocation
-import brooklyn.location.Location
-import brooklyn.location.LocationResolver
-import brooklyn.location.basic.AbstractLocation
-import brooklyn.location.geo.HostGeoInfo
-import brooklyn.util.NetworkUtils
-import brooklyn.util.StringUtils
-import brooklyn.util.flags.SetFromFlag
-import brooklyn.util.mutex.MutexSupport
-import brooklyn.util.mutex.WithMutexes
-
-
-/** defines a cloudfoundry location
- * <p>
- * this can be specified as 'cloudfoundry:api.cloudfoundry.com', 
- * or as 'cloudfoundry:https://api.aws.af.cm/' (required by `vmc` if target requires https)
- * or just 'cloudfoundry' (to use the default `vmc target`, in ~/.vmc_target)
- * <p>
- * username+password are not currently specifiable; 
- * we assume a token has been set up via `vmc login` (stored in ~/.vmc_token) */
-class CloudFoundryLocation extends AbstractLocation implements AddressableLocation, ElasticJavaWebAppServiceAwareLocation, WithMutexes {
-
-    public static final Logger log = LoggerFactory.getLogger(CloudFoundryLocation.class);
-            
-    @SetFromFlag
-    private String target;
-    
-    public CloudFoundryLocation(Map properties = [:]) {
-        super(properties);
-        if (!target) target="api.cloudfoundry.com";
-        if (!name) name="Cloud Foundry @ "+target;
-        if (getHostGeoInfo()==null) setHostGeoInfo(HostGeoInfo.fromLocation(this));
-    }
-    
-    public static class Resolver implements LocationResolver {
-        @Override
-        public String getPrefix() {
-            return "cloudfoundry";
-        }
-
-        @Override
-        public Location newLocationFromString(Map properties, String spec) {
-            if (spec.equals(getPrefix()))
-                return new CloudFoundryLocation();
-            String target = spec.substring(spec.indexOf(':')+1);
-            // target endpoint is allowed to be specified here as second part of spec
-            // default of null means to use whatever vmc is configured with
-            return new CloudFoundryLocation(target: target);
-        }
-    }
-
-    @Override
-    public ConfigurableEntityFactory<ElasticJavaWebAppService> newWebClusterFactory() {
-        return new CloudFoundryJavaWebAppCluster.Factory();
-    }
-
-    public String getTarget() {
-        return this.@target;
-    }
-
-    public String getHostname() {
-        if (!target) return null;
-        String hostname = target;
-        use (StringUtils) {
-            hostname = hostname.
-                removeStart("http://").
-                removeStart("https://").
-                replaceAll("/.*\$", "");
-        }
-        return hostname;
-    }
-    
-    @Override
-    public InetAddress getAddress() {
-        if (!target) return null;
-        if (hostname?.isEmpty())
-            throw new IllegalArgumentException("Cannot parse Cloud Foundry target '"+target+"' to determine address; expected in api.hostname.com or https://api.hostname.com/xxx format.")
-        try {
-            return NetworkUtils.getInetAddressWithFixedName(hostname);
-        } catch (Exception e) {
-            if (log.isDebugEnabled())
-                log.warn("unable to look up IP info for "+hostname+": "+e);
-            return null;
-        }
-    }
-
-    // make this a static because it has to be shared across all instances on a machine
-    // (using the command-line tool vmc)
-    static WithMutexes mutexSupport = new MutexSupport();
-    
-    @Override
-    public void acquireMutex(String mutexId, String description) throws InterruptedException {
-        mutexSupport.acquireMutex(mutexId, description);
-    }
-
-    @Override
-    public boolean tryAcquireMutex(String mutexId, String description) {
-        return mutexSupport.tryAcquireMutex(mutexId, description);
-    }
-
-    @Override
-    public void releaseMutex(String mutexId) {
-        mutexSupport.releaseMutex(mutexId);
-    }
-
-    @Override
-    public boolean hasMutex(String mutexId) {
-        return mutexSupport.hasMutex(mutexId);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryVmcCliAccess.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryVmcCliAccess.groovy b/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryVmcCliAccess.groovy
deleted file mode 100644
index 673fc2c..0000000
--- a/systems/paas/cloudfoundry/src/main/java/brooklyn/extras/cloudfoundry/CloudFoundryVmcCliAccess.groovy
+++ /dev/null
@@ -1,412 +0,0 @@
-package brooklyn.extras.cloudfoundry
-
-import groovy.transform.EqualsAndHashCode
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import brooklyn.entity.Entity
-import brooklyn.util.ResourceUtils
-import brooklyn.util.ShellUtils
-import brooklyn.util.mutex.WithMutexes
-import brooklyn.util.text.Identifiers;
-
-class CloudFoundryVmcCliAccess {
-    
-    private static final Logger log = LoggerFactory.getLogger(CloudFoundryVmcCliAccess.class)
-
-    /** optional user-supplied context object used for classloading context and
-     * inserting into toString to help with context */
-    protected Object context = this;
-    
-    String appName, war, url, target;
-    WithMutexes mutexSupport;
-    
-    String appPath;
-    public synchronized String getAppPath() {
-        if (this.@appPath) return this.@appPath;
-        if (context in Entity) {
-            appPath = "/tmp/brooklyn/apps/"+((Entity)context).application.id+"/staging/"+
-                "cloudfoundry/"+((Entity)context).id+"/";
-        } else {
-            appPath = "/tmp/brooklyn/cloudfoundry/"+Identifiers.makeRandomId(6)+"/"
-        }
-        return this.@appPath
-    }
-    
-    protected def requiredFields = [];
-    //    { requiredFields += ["target", "username", "password"] }
-
-    protected validate() {
-        requiredFields.each {
-            if (this."${it}"==null) throw new NullPointerException("Flag '${it}' must be passed to constructor for "+this.getClass().getSimpleName());
-        }
-    }
-
-    public String toString() {
-        if (context==this || context==null) return "brooklyn:"+getClass().getSimpleName();
-        return "CfVmc:"+context;
-    }
-    
-    /** returns lines of the form PATH=/usr/bin:/usr/local/bin:.
-     * for use passing to exec */
-    protected static String[] getDefaultEnvironmentForExec() {
-        System.getenv().collect { k,v -> "${k}=${v}" }         
-    }
-
-    protected String[] exec(String cmd) {
-        // 10min timeout
-        ShellUtils.exec(timeout: 10*60*1000, cmd, log, context);
-    }
-    protected String[] exec(String cmd, String input) {
-        ShellUtils.exec(timeout: 10*60*1000, cmd, input, log, context);
-    }
-
-    private Map<String,AppRecord> apps = null;
-    public synchronized Map<String,AppRecord> getApps(boolean refresh=false) {
-        if (refresh || apps==null) apps=_apps();
-        return apps;
-    }
-    public AppRecord getAppRecord(String appName, boolean refresh=false) {
-        getApps(refresh).get(appName);
-    }
-    public Collection<String> getAppNames(boolean refresh=false) {
-        getApps(refresh).keySet();
-    }
-    @EqualsAndHashCode
-    public static class AppRecord implements Serializable {
-        String appName, state, url;
-        int size;
-        List services = []
-        public static AppRecord parse(String line) {
-            def fields = line.split("\\|");
-            AppRecord result = new AppRecord(
-                appName: fields[1].trim(),
-                size: Integer.parseInt(fields[2].trim()),
-                state: fields[3].trim(),
-                url: fields[4].trim())
-            for (String svc : fields[5].trim().split("\\s+")) {
-                //add services (skip blank entries introduced by split)
-                if (svc) result.services << svc
-            }
-            return result
-        }
-    }
-    protected Map<String,AppRecord> _apps() {
-        validate();
-        Map result = [:]
-        useTarget(target, "lookup apps") {
-            String[] lines = exec("vmc apps");
-            //        +---------------+----+---------+--------------------------------+-------------+
-            //        | Application   | #  | Health  | URLS                           | Services    |
-            //        +---------------+----+---------+--------------------------------+-------------+
-            //        | hellobrooklyn | 1  | RUNNING | hellobrooklyn.cloudfoundry.com | mysql-8c1d0 |
-            //        | hellobrookly2 | 1  | RUNNING | hellobrookly2.cloudfoundry.com | mysql-8c1d0 |
-            //        +---------------+----+---------+--------------------------------+-------------+
-
-            def li = lines.iterator();
-            //skip 3 header lines; bail out if not enough (e.g. 'No Applications')
-            if (!li.hasNext()) return result; else li.next();
-            if (!li.hasNext()) return result; else li.next();
-            if (!li.hasNext()) return result; else li.next();
-            while (li.hasNext()) {
-                String line = li.next();
-                if (line.startsWith("+---"))
-                    continue;
-                def record = AppRecord.parse(line);
-                result.put(record.appName, record);
-            }
-        }
-        
-        result
-    }
-
-    public String getAppName(Map localFlags) {
-        String appName = localFlags.appName ?: this.@appName;
-        if (appName) return appName;
-        throw new NullPointerException("appName is required for ${context}"); 
-    }
-
-    public String getWar(Map localFlags) {
-        String war = localFlags.war ?: this.@war;
-        if (war) return war;
-        throw new NullPointerException("war is required for this operation on ${context}");
-    }
-
-    public String getUrl(Map localFlags=[:]) {
-        //not permitted on cloudfoundry.com; might work elsewhere
-        String url = localFlags.url ?: this.@url;
-        if (url) return url;
-        return getAppRecord(getAppName(localFlags))?.url
-    }
-
-    /** sets the target location that will be used, e.g. api.cloudfoundry.com
-     * <p>
-     * we assume vmc on the local system has already been configured to log in to that endpoint,
-     * so user+pass is not used. by default the last target set will be used.
-     * <p>
-     * this is not parallel-safe (if someone else switches target);
-     * we compensate for that by always calling setTarget(target),
-     * which is not safe by itself but if wrapped in a useTarget block
-     * is safe unless something outside brooklyn retargets vmc at the same time. 
-     * (a cleaner alternative would be to use a java API as described in issue #15.) 
-     */
-    public void setTarget(String target) {
-        this.target = target;
-        setTarget();
-    }
-    protected void setTarget() {
-        if (target) exec("vmc target ${target}")
-    }
-    
-    public Object useTarget(String target, String description, Closure code) {
-        boolean hasMutex = false;
-        try {
-            if (mutexSupport && !mutexSupport.hasMutex("vmc")) {
-                if (log.isDebugEnabled()) log.debug("acquiring vmc mutex for $target $description")
-                mutexSupport.acquireMutex("vmc", "Cloud Foundry vmc target ${target} - "+description);
-                if (log.isDebugEnabled()) log.debug("acquired vmc mutex for $target")
-                hasMutex = true;
-            }
-            setTarget();
-            return code.call();
-        } finally {
-            if (hasMutex) {
-                if (log.isDebugEnabled()) log.debug("releasing vmc mutex for $target")
-                mutexSupport.releaseMutex("vmc");
-            }
-        }
-    }
-    
-    public String getTarget() { target }
-    
-    /** flags appName and war (URL of deployable resource) required;
-     * memory (eg "512M") and url (target url) optional
-     */
-    public AppRecord runAppWar(Map flags=[:]) {
-        Collection apps = getAppNames();
-
-        String appName = getAppName(flags);
-        String appPath = getAppPath();
-        new File(appPath).mkdirs();
-        new File(appPath+"/root.war") << new ResourceUtils(context).getResourceFromUrl(getWar(flags));
-        
-        useTarget(target, "run ${appName} WAR") {
-            if (apps.contains(appName)) {
-                //update
-
-                //stop done implicitly on server
-                //            exec("vmc stop ${appName}")
-
-                if (flags.memory) exec("vmc mem ${appName} "+flags.memory);
-                if (flags.url) {
-                    url = getUrl(flags)
-                    exec("vmc map ${appName} "+url);
-                }
-
-                exec("vmc update ${appName} --path ${appPath}");
-
-                exec("vmc start ${appName}")
-            } else {
-                //create
-                String memory = flags.memory ?: "512M";
-                url = getUrl(flags)
-                exec("vmc push"+
-                        " ${appName}"+
-                        (url ? " --url ${url}" : "")+
-                        " --path ${appPath}"+
-                        //" --runtime java"+  //what is syntax here?  vmc runtimes shows java; frameworks shows java_web; all seem to prompt
-                        " --mem 512M",
-                        //need CR supplied twice (java prompt, and services prompt) since can't seem to get it specified on CLI;
-                        //and once more if url is default
-                        "\n\n"+(url?"":"\n"));
-            }
-
-            AppRecord result = this.getAppRecord(appName, true);
-            if (result==null)
-                throw new IllegalStateException("Failed to start $this");
-            url = result.url
-            return result
-        }
-    }
-
-    public void stopApp(Map flags=[:]) {
-        useTarget(target, "delete ${getAppName(flags)}") {
-            exec("vmc stop ${getAppName(flags)}");
-        }
-    }
-    
-    public void destroyApp(Map flags=[:]) {
-        useTarget(target, "delete ${getAppName(flags)}") {
-            exec("vmc delete ${getAppName(flags)}");
-        }
-    }
-
-    public void resizeAbsolute(Map flags=[:], int newSize) {
-        if (newSize<0) throw new IllegalArgumentException("newSize cannot be negative for ${context}")
-        useTarget(target, "resize ${getAppName(flags)} to ${newSize}") {
-            exec("vmc instances ${getAppName(flags)} "+newSize);
-        }
-    }
-    public void resizeDelta(Map flags=[:], int delta) {
-        useTarget(target, "resize ${getAppName(flags)} ${(delta>=0?"+"+delta:delta)}") {
-            exec("vmc instances ${getAppName(flags)} "+(delta>=0?"+"+delta:delta));
-        }
-    }
-
-    public static class CloudFoundryAppStats {
-        List<CloudFoundryAppStatLine> instances;
-        CloudFoundryAppStatLine average;
-        public int getSize() { instances.size() }
-        @Override
-        public String toString() {
-            return "CloudFoundryAppStats[size="+size+";average="+average+"]";
-        }
-    }
-    public static class CloudFoundryAppStatLine {
-        double cpuUsage;
-        int numCores;
-        double memUsedMB;
-        double memLimitMB;
-        double memUsedFraction;
-        
-        double diskUsedMB;
-        double diskLimitMB;
-        double diskUsedFraction;
-        
-        long uptimeSeconds;
-        
-        @Override
-        public String toString() {
-            return "CloudFoundryStats["+
-                "cpu="+cpuUsage+","+
-                "cores="+numCores+","+
-                "mem="+memUsedMB+"/"+memLimitMB+","+
-                "disk="+diskUsedMB+"/"+diskLimitMB+","+
-                "uptime="+uptimeSeconds+"]";
-        }
-        
-        public static CloudFoundryAppStatLine parse(String l) {
-            // | 0        | 0.0% (4)    | 116.6M (512M)  | 9.5M (2G)    | 0d:15h:41m:2s |
-            String[] fields = l.split("\\s+");
-            CloudFoundryAppStatLine result = new CloudFoundryAppStatLine();
-            int i=3;
-            result.cpuUsage = parseDouble(fields[i++]) / 100;
-            result.numCores = parseInt(fields[i++]);
-            i++
-            result.memUsedMB = parseSizeMB(fields[i++]);
-            result.memLimitMB = parseSizeMB(fields[i++]);
-            result.memUsedFraction = result.memUsedMB/result.memLimitMB;
-            i++
-            result.diskUsedMB = parseSizeMB(fields[i++]);
-            result.diskLimitMB = parseSizeMB(fields[i++]);
-            result.diskUsedFraction = result.diskUsedMB/result.diskLimitMB;
-            i++
-            result.uptimeSeconds = parseTime(fields[i]);
-            result
-        }
-        
-        public static double parseDouble(String word) {
-            if (word==null || word.length()==0) {
-                log.warn("empty word found in stats, using 0")
-                return 0;
-            }
-            if (word.startsWith("(")) word = word.substring(1);
-            if (word.endsWith(")")) word = word.substring(0, word.length()-1);
-            if (word.endsWith("%")) word = word.substring(0, word.length()-1);
-            if (word.equals("NA")) return 0;  //returned early in lifecycle
-            return Double.parseDouble(word);
-        }
-        public static int parseInt(String word) {
-            if (word==null || word.length()==0) {
-                log.warn("empty word found in stats, using 0")
-                return 0;
-            }
-            if (word.startsWith("(")) word = word.substring(1);
-            if (word.endsWith(")")) word = word.substring(0, word.length()-1);
-            if (word.endsWith("%")) word = word.substring(0, word.length()-1);
-            if (word.equals("NA")) return 0;  //returned early in lifecycle
-            return Integer.parseInt(word);
-        }        
-        public static double parseSizeMB(String word) {
-            if (word.startsWith("(")) word = word.substring(1, word.length()-1);
-            if ("NA".equals(word)) return 0;
-            double d = parseDouble(word.substring(0, word.length()-1));
-            char c = word.charAt(word.length()-1)
-            if (c=='M') return d;
-            if (c=='G') return d*1024;
-            if (c=='K') return d/1024.0;
-            if (c=='B') return d/1024.0/1024.0;
-            //perhaps one day:  :)
-            if (c=='T') return d*1024*1024;
-            if (c=='P') return d*1024*1024*1024;
-            throw new IllegalArgumentException("Unparseable size $word");
-        }
-        public static long parseTime(String word) {
-            if ("NA".equals(word)) return 0;
-            int split = word.indexOf(':');
-            String w = (split>=0 ? word.substring(0, split) : word);
-            long t = parseInt(w.substring(0, w.length()-1));
-            char c = w.charAt(w.length()-1);
-            switch (c) {
-                case 'd': t*=24;
-                case 'h': t*=60;
-                case 'm': t*=60;
-                case 's': break;
-                default: throw new IllegalArgumentException("Unparseable time $w"); 
-            }
-            if (split>=0) return t + parseTime(word.substring(split+1));
-            else return t;
-        }
-        
-        public static CloudFoundryAppStatLine average(Collection<CloudFoundryAppStatLine> stats) {
-            CloudFoundryAppStatLine result = new CloudFoundryAppStatLine();
-            for (CloudFoundryAppStatLine s: stats) {
-                result.cpuUsage += s.cpuUsage;
-                result.numCores += s.numCores;
-                result.memUsedMB += s.memUsedMB;
-                result.memLimitMB += s.memLimitMB;
-                result.diskUsedMB += s.diskUsedMB;
-                result.diskLimitMB += s.diskLimitMB;
-                result.uptimeSeconds += s.uptimeSeconds;
-            }
-            int count = stats.size();
-            if (count>0) {
-                result.cpuUsage /= count;
-                result.numCores /= count;
-                result.memUsedMB /= count;
-                result.memLimitMB /= count;
-                result.diskUsedMB /= count;
-                result.diskLimitMB /= count;
-                result.uptimeSeconds /= count;
-            }            
-            result.memUsedFraction = result.memUsedMB/result.memLimitMB;
-            result.diskUsedFraction = result.diskUsedMB/result.diskLimitMB;
-            result
-        }
-    }
-    
-    public CloudFoundryAppStats stats(Map flags=[:]) {
-        useTarget(target, "stats ${getAppName(flags)}") {
-            String[] lines = exec("vmc stats ${getAppName(flags)}");
-            //+----------+-------------+----------------+--------------+---------------+
-            //| Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime        |
-            //+----------+-------------+----------------+--------------+---------------+
-            //| 0        | 0.0% (4)    | 116.6M (512M)  | 9.5M (2G)    | 0d:15h:41m:2s |
-            //| 1        | 0.0% (4)    | 75.7M (512M)   | 9.4M (2G)    | 0d:9h:54m:44s |
-            //+----------+-------------+----------------+--------------+---------------+
-            List result = []
-
-            def li = lines.iterator();
-            3.times { if (li.hasNext()) li.next(); }  //skip 3 header lines
-            while (li.hasNext()) {
-                String line = li.next();
-                if (line.startsWith("+---"))
-                    continue;
-                result << CloudFoundryAppStatLine.parse(line)
-            }
-            return new CloudFoundryAppStats(instances: result, average: CloudFoundryAppStatLine.average(result));
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/main/resources/META-INF/services/brooklyn.location.LocationResolver
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/main/resources/META-INF/services/brooklyn.location.LocationResolver b/systems/paas/cloudfoundry/src/main/resources/META-INF/services/brooklyn.location.LocationResolver
deleted file mode 100644
index 50c88dc..0000000
--- a/systems/paas/cloudfoundry/src/main/resources/META-INF/services/brooklyn.location.LocationResolver
+++ /dev/null
@@ -1 +0,0 @@
-brooklyn.extras.cloudfoundry.CloudFoundryLocation$Resolver

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryAccessIntegrationTest.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryAccessIntegrationTest.groovy b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryAccessIntegrationTest.groovy
deleted file mode 100644
index 28d752a..0000000
--- a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryAccessIntegrationTest.groovy
+++ /dev/null
@@ -1,82 +0,0 @@
-package brooklyn.extras.cloudfoundry
-
-import static brooklyn.test.TestUtils.*
-import static org.testng.Assert.*
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-import org.testng.Assert
-import org.testng.annotations.Test
-
-import com.google.common.collect.Sets;
-
-import brooklyn.extras.cloudfoundry.CloudFoundryVmcCliAccess.AppRecord
-import brooklyn.extras.cloudfoundry.CloudFoundryVmcCliAccess.CloudFoundryAppStatLine
-import brooklyn.extras.cloudfoundry.CloudFoundryVmcCliAccess.CloudFoundryAppStats
-import brooklyn.util.text.Identifiers;
-
-
-/** requires vmc installed and configured */
-class CloudFoundryAccessIntegrationTest {
-    
-    static final Logger log = LoggerFactory.getLogger(CloudFoundryAccessIntegrationTest.class)
-    
-    @Test(groups = [ "Integration", "WIP" ])
-    public void testVmcInfo() {
-        List lines = new CloudFoundryVmcCliAccess().exec("vmc info") as List;
-        String user = lines.find({ it.startsWith("User:") })
-        String version = lines.find({ it.startsWith("Client:") })
-        Assert.assertNotNull(user, "expected User: in output");
-        user = user.substring(5).trim();
-        version = version.substring(7).trim()
-        log.info("vmc user is "+user+" and version is "+version);
-        Assert.assertTrue(user.indexOf('@')>0);
-    }
-
-    @Test(groups = [ "Integration", "WIP" ])
-    public void testVmcAppsList() {
-        Collection apps = new CloudFoundryVmcCliAccess().appNames;
-        log.info("vmc apps gives: "+apps)
-        //don't know anything is present, just assert no error
-    }
-
-    @Test(groups = [ "Integration", "WIP" ])
-    public void testVmcAppCreateRunUpdateScaleStats() {
-        String id = "brooklyn-"+Identifiers.makeRandomId(8).toLowerCase();
-        CloudFoundryVmcCliAccess access = new CloudFoundryVmcCliAccess(appName: id);
-        log.info("creating $id in ${access.appPath}");
-        Collection apps1 = access.getAppNames(true);
-        try {
-            //create
-            AppRecord record = access.runAppWar(war: "classpath://hello-world.war");
-            Collection apps2 = Sets.difference(access.getAppNames(true), apps1);
-            assertEquals(apps2, [ id ])
-            //check record
-            assertEquals(record.size, 1)
-            assertTrue(record.url.startsWith(id+"."), "url ${record.url} should start with ${id}.")
-            assertEquals(record.state, "RUNNING")
-            assertEquals(record.services, [])
-            AppRecord r2 = access.getAppRecord(id);
-            assertEquals(record, r2);
-            //update
-            access.runAppWar(war: "classpath://hello-world.war");
-            CloudFoundryAppStats stats = access.stats();
-            assertEquals(stats.size, 1)
-            //scale
-            access.resizeDelta(1);
-            stats = access.stats();
-            log.info("stats $stats")
-            assertEquals(stats.size, 2)
-//            //set url -- gives 702 not enabled
-//            AppRecord r3 = access.runAppWar(war: "classpath://hello-world.war", url: "foo.bar.com");
-//            assertEquals(r3, "foo.bar.com");
-        } finally {
-            log.info("destroying $id")
-            access.destroyApp();
-        }
-        Collection apps3 = access.getAppNames(true);
-        log.info("apps now $apps3")
-        assertEquals(apps3, apps1) 
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy
deleted file mode 100644
index 89db1bd..0000000
--- a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterExample.groovy
+++ /dev/null
@@ -1,72 +0,0 @@
-package brooklyn.extras.cloudfoundry
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import brooklyn.catalog.Catalog
-import brooklyn.entity.basic.AbstractApplication
-import brooklyn.entity.basic.Entities
-import brooklyn.location.basic.LocationRegistry
-
-/**
- * example app showing how to start an cloudfoundry java war
- *  
- * if this doesn't start, we may have too many apps, delete some using:
- * <pre>
- * {@code
- * vmc apps
- * vmc delete brooklyn-1234
- * }
- * </pre>
- * (or online at the cloudfoundry portal)
- * or
- * <pre>
- * {@code
- * for x in `vmc apps | grep brooklyn | awk '{ print $2 }'` ; do vmc delete $x ; done
- * }
- * </pre>
- * @author alex
- *
- */
-public class CloudFoundryJavaClusterExample extends AbstractApplication {
-
-    private static final Logger log = LoggerFactory.getLogger(CloudFoundryJavaClusterExample.class)
-    
-    public static final String WAR_FILE_URL = "classpath://hello-world.war";
-    
-    CloudFoundryJavaWebAppCluster cloudfoundry;
-    
-    @Override
-    public void init() {
-        cloudfoundry = new CloudFoundryJavaWebAppCluster(this, war: WAR_FILE_URL);
-    }
-    
-    // TODO a richer example which starts CloudFoundry alongside Tomcats in EC2 with geoscaling
-      
-    // ---- the code above is your app descriptor; code below runs it ----
-      
-    public static void main(String[] args) {
-        def app = new CloudFoundryJavaClusterExample();
-        def locations = new LocationRegistry().resolve([
-            "cloudfoundry"
-//            "cloudfoundry:https://api.your-stackato.example.com/"
-        ]);
-        
-        app.start(locations);
-        
-        log.info "should now be able to visit site (for 2m): {}", app.cloudfoundry.getWebAppAddress()
-        //should now be able to visit (assert?)
-        
-        for (int i=0; i<2*6; i++) {
-            //periodically print stats
-            Entities.dumpInfo(app.cloudfoundry);
-            Thread.sleep(10*1000);
-        }
-
-        //and kill
-        log.info "now cleaning up that app: {}", app.cloudfoundry.getWebAppAddress()
-        app.stop()
-        
-        log.info "finished, should terminate shortly"
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy
deleted file mode 100644
index 4f21441..0000000
--- a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryJavaClusterFromLocationExample.groovy
+++ /dev/null
@@ -1,78 +0,0 @@
-package brooklyn.extras.cloudfoundry
-
-import java.util.Collection
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import brooklyn.entity.basic.AbstractApplication
-import brooklyn.entity.basic.Entities
-import brooklyn.entity.webapp.ElasticJavaWebAppService
-import brooklyn.location.Location
-
-import com.google.common.collect.Iterables
-
-/**
- * example app showing how to start an cloudfoundry java war
- *  
- * if this doesn't start, we may have too many apps, delete some using:
- * <pre>
- * {@code
- * vmc apps 
- * vmc delete brooklyn-1234
- * }
- * </pre>
- * (or online at the cloudfoundry portal)
- * or
- * <pre>
- * {@code
- * for x in `vmc apps | grep brooklyn | awk '{ print $2 }'` ; do vmc delete $x ; done
- * }
- * </pre>
- * @author alex
- *
- */
-class CloudFoundryJavaClusterFromLocationExample extends AbstractApplication {
-
-    private static final Logger log = LoggerFactory.getLogger(CloudFoundryJavaClusterFromLocationExample.class)
-    
-    public static final String WAR_FILE_URL = "classpath://hello-world.war";
-                
-    ElasticJavaWebAppService svc;
-    
-    @Override
-    public void init() {
-        // no-op; see preStart
-    }
-
-    @Override
-    public void preStart(Collection<? extends Location> locations) {
-        svc = new ElasticJavaWebAppService.Factory().newFactoryForLocation( Iterables.getOnlyElement(locations) ).
-            newEntity(this, war: WAR_FILE_URL);
-    }  
-    
-    // the code above is your app descriptor; note, no mention of cloudfoundry
-    // code below runs it
-      
-      
-    public static void main(String[] args) {
-        def app = new CloudFoundryJavaClusterFromLocationExample();
-        
-        app.start([new CloudFoundryLocation(target: 'api.cloudfoundry.com')]);
-        
-        log.info "should now be able to visit site (for 2m): {}", app.svc.getAttribute(ElasticJavaWebAppService.ROOT_URL)
-        //should now be able to visit (assert?)
-        
-        for (int i=0; i<2*6; i++) {
-            //periodically print stats
-            Entities.dumpInfo(app);
-            Thread.sleep(10*1000);
-        }
-
-        //and kill
-        log.info "now cleaning up that app: {}", app
-        app.stop()
-        
-        log.info "finished, should terminate shortly"
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryParseTest.java
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryParseTest.java b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryParseTest.java
deleted file mode 100644
index 6738b0d..0000000
--- a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/CloudFoundryParseTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package brooklyn.extras.cloudfoundry;
-
-import java.util.Arrays;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.extras.cloudfoundry.CloudFoundryVmcCliAccess.CloudFoundryAppStatLine;
-import brooklyn.extras.cloudfoundry.CloudFoundryVmcCliAccess.CloudFoundryAppStats;
-
-public class CloudFoundryParseTest {
-
-    public static final Logger log = LoggerFactory.getLogger(CloudFoundryParseTest.class);
-    
-    @Test
-    public void testParseStatsLine() {
-        CloudFoundryAppStatLine stats = CloudFoundryAppStatLine.parse(
-                "| 0        | 0.0% (4)    | 116.6M (512M)  | 9.5M (2G)    | 0d:15h:41m:2s |");
-        log.info("stats: "+stats);
-        Assert.assertEquals(stats.getCpuUsage(), 0d);
-        Assert.assertEquals(stats.getNumCores(), 4);
-        Assert.assertEquals(stats.getMemUsedMB(), 116.6d, 0.0000001);
-        Assert.assertEquals(stats.getMemLimitMB(), 512d, 0.0000001);
-        Assert.assertEquals(stats.getMemUsedFraction(), 116.6d/512d, 0.0000001);
-        Assert.assertEquals(stats.getDiskUsedMB(), 9.5d, 0.0000001);
-        Assert.assertEquals(stats.getDiskLimitMB(), 2048d, 0.0000001);
-        Assert.assertEquals(stats.getDiskUsedFraction(), 9.5d/2048d, 0.0000001);
-        Assert.assertEquals(stats.getUptimeSeconds(), 60*(60*15+41)+2);
-    }
-
-    @Test
-    public void testParseStatsAverage() {
-        CloudFoundryAppStatLine stats1 = CloudFoundryAppStatLine.parse(
-                "| 0        | 0.0% (4)    | 116.6M (512M)  | 9.5M (2G)    | 0d:15h:41m:2s |");
-        CloudFoundryAppStatLine stats2 = CloudFoundryAppStatLine.parse(
-                "| 0        | 10.0% (4)    | 316.6M (512M)  | 29.5M (2G)    | 0d:13h:41m:2s |");
-        
-        CloudFoundryAppStats stats = new CloudFoundryAppStats();
-        stats.setInstances( Arrays.asList(stats1, stats2));
-        stats.setAverage(CloudFoundryAppStatLine.average(stats.getInstances()));
-        
-        CloudFoundryAppStatLine avg = stats.getAverage();
-        
-        Assert.assertEquals(avg.getCpuUsage(), 0.05d);
-        Assert.assertEquals(avg.getNumCores(), 4);
-        Assert.assertEquals(avg.getMemUsedMB(), 216.6d, 0.0000001);
-        Assert.assertEquals(avg.getMemLimitMB(), 512d, 0.0000001);
-        Assert.assertEquals(avg.getMemUsedFraction(), 216.6d/512d, 0.0000001);
-        Assert.assertEquals(avg.getDiskUsedMB(), 19.5d, 0.0000001);
-        Assert.assertEquals(avg.getDiskLimitMB(), 2048d, 0.0000001);
-        Assert.assertEquals(avg.getDiskUsedFraction(), 19.5d/2048d, 0.0000001);
-        Assert.assertEquals(avg.getUptimeSeconds(), 60*(60*14+41)+2);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/LocationResolvesTest.java
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/LocationResolvesTest.java b/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/LocationResolvesTest.java
deleted file mode 100644
index 6239ab4..0000000
--- a/systems/paas/cloudfoundry/src/test/java/brooklyn/extras/cloudfoundry/LocationResolvesTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package brooklyn.extras.cloudfoundry;
-
-import java.net.InetAddress;
-
-import brooklyn.config.BrooklynProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.location.AddressableLocation;
-import brooklyn.location.basic.LocationRegistry;
-
-public class LocationResolvesTest {
-    
-    public static final Logger log = LoggerFactory.getLogger(LocationResolvesTest.class);
-
-    BrooklynProperties properties;
-
-    @BeforeMethod
-    public void setUp(){
-       properties= BrooklynProperties.Factory.newDefault();
-    }
-
-    @Test
-    public void testCloudFoundryLocationResolves() {
-        //NB: if this test fails, make sure src/main/resources is on the classpath
-        //and META-INF/services/brooklyn.location.LocationResolver isn't being clobbered in a poorly shaded jar
-        Assert.assertNotNull(new LocationRegistry(properties).resolve("cloudfoundry"));
-    }
-    
-    @Test(groups="Integration")
-    public void testLocationAddress() {
-        log.info("lookup CF address");
-        InetAddress address = ((AddressableLocation)new LocationRegistry(properties).resolve("cloudfoundry")).getAddress();
-        log.info("done lookup of CF address, got "+address);
-        Assert.assertEquals("api.cloudfoundry.com", address.getHostName());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ccaf5a3/systems/paas/cloudfoundry/src/test/resources/hello-world.war
----------------------------------------------------------------------
diff --git a/systems/paas/cloudfoundry/src/test/resources/hello-world.war b/systems/paas/cloudfoundry/src/test/resources/hello-world.war
deleted file mode 100644
index 0a127e6..0000000
Binary files a/systems/paas/cloudfoundry/src/test/resources/hello-world.war and /dev/null differ


[42/50] brooklyn-server git commit: Expose FixedListMachineProvisioningLocation.getInUse

Posted by he...@apache.org.
Expose FixedListMachineProvisioningLocation.getInUse

- Useful for testing; and no harm exposing it as returns a copy
  so result can't be side-effected.


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

Branch: refs/heads/0.5.0
Commit: 129bd9ce8d9750a3be9eaa7ebc18f847ae797633
Parents: a253e39
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 17 14:42:30 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 11:24:55 2013 +0100

----------------------------------------------------------------------
 .../basic/FixedListMachineProvisioningLocation.java    | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/129bd9ce/core/src/main/java/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/FixedListMachineProvisioningLocation.java b/core/src/main/java/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
index 721d383..51bf5e3 100644
--- a/core/src/main/java/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
+++ b/core/src/main/java/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
@@ -14,10 +14,7 @@ import brooklyn.location.Location;
 import brooklyn.location.MachineLocation;
 import brooklyn.location.MachineProvisioningLocation;
 import brooklyn.location.NoMachinesAvailableException;
-import brooklyn.location.cloud.AbstractCloudMachineProvisioningLocation;
 import brooklyn.util.MutableMap;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.flags.SetFromFlag;
 import brooklyn.util.text.WildcardGlobs;
 import brooklyn.util.text.WildcardGlobs.PhraseTreatment;
@@ -41,7 +38,7 @@ implements MachineProvisioningLocation<T>, Closeable {
 
     // TODO Synchronization looks very wrong for accessing machines/inUse 
     // e.g. removeChildLocation doesn't synchronize when doing machines.remove(...),
-    // and getMachines() and getInUse() return the real sets risking 
+    // and getMachines() returns the real sets risking 
     // ConcurrentModificationException in the caller if it iterates over them etc.
     
     private Object lock;
@@ -123,16 +120,16 @@ implements MachineProvisioningLocation<T>, Closeable {
         return machines;
     }
     
-    protected Set<T> getInUse() {
-        return inUse;
-    }
-    
     public Set<T> getAvailable() {
         Set<T> a = Sets.newLinkedHashSet(machines);
         a.removeAll(inUse);
         return a;
     }   
      
+    public Set<T> getInUse() {
+        return Sets.newLinkedHashSet(inUse);
+    }   
+     
     public Set<T> getAllMachines() {
         return ImmutableSet.copyOf(machines);
     }   


[22/50] brooklyn-server git commit: Changes based on review comments, including: - Updating to use latest 0.5.0 APIs - Adding general Zookeeper entity interface - Make KafkaCluster implement Group

Posted by he...@apache.org.
Changes based on review comments, including:
- Updating to use latest 0.5.0 APIs
- Adding general Zookeeper entity interface
- Make KafkaCluster implement Group


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

Branch: refs/heads/0.5.0
Commit: ca1779716c0cb1be3c88788feff07577f4c24199
Parents: a8f4c0f
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Mon Apr 1 19:00:44 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Fri Apr 19 10:36:07 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/entity/basic/Entities.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ca177971/core/src/main/java/brooklyn/entity/basic/Entities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/Entities.java b/core/src/main/java/brooklyn/entity/basic/Entities.java
index d71c304..9c97195 100644
--- a/core/src/main/java/brooklyn/entity/basic/Entities.java
+++ b/core/src/main/java/brooklyn/entity/basic/Entities.java
@@ -569,6 +569,7 @@ public class Entities {
             ((EntityInternal)entity).getManagementContext().getEntityManager().unmanage(entity);
         }
     }
+
     public static <T> Supplier<T> supplier(final Entity entity, final AttributeSensor<T> sensor) {
         return new Supplier<T>() {
             public T get() { return entity.getAttribute(sensor); }


[33/50] brooklyn-server git commit: Significant upgrade to Brooklyn's Readme.

Posted by he...@apache.org.
Significant upgrade to Brooklyn's Readme.


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

Branch: refs/heads/0.5.0
Commit: d15890a539932eeb367176056ec49d63908ee8c4
Parents: 589bd26
Author: David Toy <d...@vidtoy.co.uk>
Authored: Fri Apr 12 14:20:11 2013 +0100
Committer: David Toy <d...@vidtoy.co.uk>
Committed: Mon Apr 22 12:52:47 2013 +0100

----------------------------------------------------------------------
 README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d15890a5/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..81a1a7a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,75 @@
+![**Brooklyn**](http://brooklyncentral.github.io/style/images/brooklyn.gif)
+
+# [Brooklyn 0.6.0-SNAPSHOT](http://brooklyncentral.github.com) <!-- BROOKLYN_VERSION -->
+
+Brooklyn is a library and control plane for deploying and managing distributed applications.
+
+See [brooklyncentral.github.com](http://brooklyncentral.github.com) for details and examples.
+
+## What?
+
+Brooklyn is a management tool for applications hosted in one or more clouds (or other locations).
+
+
+## Quick Start
+
+Three quick start options are available:
+
+* [Getting started guide](http://brooklyncentral.github.io/use/guide/quickstart/index.html)
+* [Download the latest release](https://github.com/brooklyncentral/brooklyn/tarball/master).
+* Clone the repo: `git clone git://github.com/brooklyncentral/brooklyn.git`.
+
+## Versioning
+
+For transparency and insight into our release cycle, and for striving to maintain backward compatibility, Brooklyn will be maintained under the [Semantic Versioning guidelines](http://semver.org/).
+
+Releases will be numbered with the following format:
+
+`<major>.<minor>.<patch>`
+
+And constructed with the following guidelines:
+
+* Breaking backward compatibility bumps the major (and resets the minor and patch)
+* New additions without breaking backward compatibility bumps the minor (and resets the patch)
+* Bug fixes and misc changes bumps the patch
+
+Milestone (`<major>.<minor>.<patch>-M<milestone>`) and Release Candidate (`<major>.<minor>.<patch>-rc.<candidate>`) are used in the release process.
+
+## Bug Tracker
+
+Have a bug or a feature request? [Please open a new issue](https://github.com/brooklyncentral/brooklyn/issues).
+
+## Community
+
+Keep track of development and community news.
+
+* Follow [@brooklyncentral on Twitter](http://twitter.com/brooklyncentral).
+* Have a question that's not a feature request or bug report? [Ask on the mailing list.](http://groups.google.com/group/brooklyn-dev)
+* Chat with us over IRC. On the `irc.freenode.net` server, in the `#brooklyncentral` channel.
+
+## Contributing
+
+Your input will be welcomed.
+
+See the [full guide to contributing](http://brooklyncentral.github.com/dev/how-to-contrib.html) on brooklyncentral.github.com.
+
+Thanks!
+
+
+## Copyright and License
+
+Copyright 2013 Cloudsoft Corporation, ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this work except in compliance with the License.
+You may obtain a copy of the License in the LICENSE file, or at:
+
+  [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+brooklyn is a registered trademark of Cloudsoft Corporation.


[45/50] brooklyn-server git commit: JmxFeed: decrease polling logging to trace

Posted by he...@apache.org.
JmxFeed: decrease polling logging to trace


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

Branch: refs/heads/0.5.0
Commit: 41c5bbd976e17e6f6744db1819c427eb5c44af28
Parents: bf2e4c3
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 24 10:57:49 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 11:25:12 2013 +0100

----------------------------------------------------------------------
 software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/41c5bbd9/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java b/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
index e3d9af3..684fbaa 100644
--- a/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
+++ b/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
@@ -256,7 +256,7 @@ public class JmxFeed extends AbstractFeed {
         getPoller().scheduleAtFixedRate(
                 new Callable<Object>() {
                     public Object call() throws Exception {
-                        if (log.isDebugEnabled()) log.debug("jmx attribute polling for {} sensors at {} -> {}", new Object[] {getEntity(), jmxUri, jmxAttributeName});
+                        if (log.isTraceEnabled()) log.trace("jmx attribute polling for {} sensors at {} -> {}", new Object[] {getEntity(), jmxUri, jmxAttributeName});
                         return helper.getAttribute(objectName, jmxAttributeName);
                     }
                 }, 


[31/50] brooklyn-server git commit: Will add better 'What' section later.

Posted by he...@apache.org.
Will add better 'What' section later.


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

Branch: refs/heads/0.5.0
Commit: acb0e7afad541534f417aa02dcd20469bdedeb5c
Parents: 494af33
Author: David Toy <d...@vidtoy.co.uk>
Authored: Fri Apr 12 16:31:53 2013 +0100
Committer: David Toy <d...@vidtoy.co.uk>
Committed: Mon Apr 22 12:52:47 2013 +0100

----------------------------------------------------------------------
 README.md | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/acb0e7af/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 85cc381..e5691b5 100644
--- a/README.md
+++ b/README.md
@@ -4,16 +4,11 @@ Brooklyn is a library and control plane for deploying and managing distributed a
 
 See [brooklyncentral.github.com](http://brooklyncentral.github.com) for details and examples.
 
-## What?
-
-Brooklyn is a management tool for applications hosted in one or more clouds (or other locations).
-
-
 ## Quick Start
 
 Three quick start options are available:
 
-* [Getting started guide](http://brooklyncentral.github.io/use/guide/quickstart/index.html)
+* Follow the [getting started guide](http://brooklyncentral.github.io/use/guide/quickstart/index.html)
 * [Download the latest release](https://github.com/brooklyncentral/brooklyn/tarball/master).
 * Clone the repo: `git clone git://github.com/brooklyncentral/brooklyn.git`.
 
@@ -31,7 +26,7 @@ And constructed with the following guidelines:
 * New additions without breaking backward compatibility bumps the minor (and resets the patch)
 * Bug fixes and misc changes bumps the patch
 
-Milestone (`<major>.<minor>.<patch>-M<milestone>`) and Release Candidate (`<major>.<minor>.<patch>-rc.<candidate>`) are used in the release process.
+Milestones (`<major>.<minor>.<patch>-M<milestone>`) and Release Candidates (`<major>.<minor>.<patch>-rc.<candidate>`) are used in the release process.
 
 ## Bug Tracker
 
@@ -62,7 +57,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this work except in compliance with the License.
 You may obtain a copy of the License in the LICENSE file, or at:
 
-  [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
+  [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,


[40/50] brooklyn-server git commit: Merge pull request #721 from aledsage/feature/geodns-recheck-members0.5

Posted by he...@apache.org.
Merge pull request #721 from aledsage/feature/geodns-recheck-members0.5

geo-dns: update member list of entity.hostname changes

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

Branch: refs/heads/0.5.0
Commit: 1a4101989de0e72ef2bb07561f6b799e70ae37f9
Parents: 39c08cb 187ffdb
Author: Aled Sage <al...@gmail.com>
Authored: Thu Apr 25 03:19:32 2013 -0700
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 03:19:32 2013 -0700

----------------------------------------------------------------------
 core/src/main/java/brooklyn/location/geo/HostGeoInfo.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[19/50] brooklyn-server git commit: Fix thread-safety in NonDeploymentManagementContext

Posted by he...@apache.org.
Fix thread-safety in NonDeploymentManagementContext

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

Branch: refs/heads/0.5.0
Commit: 9fcdee9eb93f43ae14cbdf3fac6e2deffbc69c01
Parents: 19938ce
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 17 14:57:25 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Apr 17 14:57:25 2013 +0100

----------------------------------------------------------------------
 .../management/internal/NonDeploymentManagementContext.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9fcdee9e/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
index 9b915aa..f5fcb03 100644
--- a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
@@ -1,6 +1,7 @@
 package brooklyn.management.internal;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
 
 import java.net.URL;
 import java.util.Collection;
@@ -48,13 +49,13 @@ public class NonDeploymentManagementContext implements ManagementContextInternal
     }
     
     private final AbstractEntity entity;
-    private NonDeploymentManagementContextMode mode;
-    private ManagementContextInternal initialManagementContext;
+    private volatile NonDeploymentManagementContextMode mode;
+    private volatile ManagementContextInternal initialManagementContext;
     
     private final QueueingSubscriptionManager qsm;
     private final BasicSubscriptionContext subscriptionContext;
     private final NonDeploymentExecutionContext executionContext;
-    private NonDeploymentEntityManager entityManager;
+    private volatile NonDeploymentEntityManager entityManager;
 
     public NonDeploymentManagementContext(AbstractEntity entity, NonDeploymentManagementContextMode mode) {
         this.entity = checkNotNull(entity, "entity");
@@ -66,6 +67,7 @@ public class NonDeploymentManagementContext implements ManagementContextInternal
     }
     
     public void setManagementContext(ManagementContextInternal val) {
+        checkState(initialManagementContext == null || initialManagementContext == val, "Must not change initialManagementContext from %s to %s", initialManagementContext, val);
         this.initialManagementContext = checkNotNull(val, "initialManagementContext");
         this.entityManager = new NonDeploymentEntityManager(val);
     }
@@ -78,6 +80,7 @@ public class NonDeploymentManagementContext implements ManagementContextInternal
     public void setMode(NonDeploymentManagementContextMode mode) {
         this.mode = checkNotNull(mode, "mode");
     }
+    
     public NonDeploymentManagementContextMode getMode() {
         return mode;
     }


[34/50] brooklyn-server git commit: Updates to wording of Deployment section.

Posted by he...@apache.org.
Updates to wording of Deployment section.


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

Branch: refs/heads/0.5.0
Commit: bfa0de2f08c26328e19eee64018c6025268d7d1f
Parents: 1e29159
Author: David Toy <d...@vidtoy.co.uk>
Authored: Thu Apr 18 17:05:07 2013 +0100
Committer: David Toy <d...@vidtoy.co.uk>
Committed: Mon Apr 22 12:52:48 2013 +0100

----------------------------------------------------------------------
 README.md | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bfa0de2f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 6072351..2cdc47a 100644
--- a/README.md
+++ b/README.md
@@ -8,18 +8,17 @@ Brooklyn's main emphasis is managing live applications (e.g auto-scaling, except
 
 ### Deployment
 
-Brooklyn enables single-click deployment of complex applications.
+Brooklyn enables single-click deployment of complex applications, while tying-in with other great tools, and reusing and complementing existing workflows.
 
+Use Brooklyn to create an Application Blueprint, instructing Brooklyn how to wire together your applications and components, customizing and extending them as needed. Share the blueprint with others (optionally using Brooklyn's Web Service Catalog) to allow them to single-click deploy your application onto the infrastructure of their choice.
 
 Brooklyn features:
 
-* out-of-the-box support for many common software entities.
+* out-of-the-box support for many common software components.
 * integration with jclouds, allowing deployment to the majority of public and private clouds, in addition to pools of fixed IP machines.
 * integration with Apache Whirr (and thereby Chef and Puppet), allowing deployment of well-known services such as Hadoop and elasticsearch (and you can still use POBS, plain-old-bash-scripts).
 * integration with PaaS's such as OpenShift, allowing use of PaaSes alongside self-built clusters, for maximum flexibility.
 
-Brooklyn works with and ties into other tools, adding the concepts of manageable clusters and fabrics.
-
 In DevOps fashion, Brooklyn allows applications and roll-outs to be version controlled, tested programatically, and reused across locations and contexts. Develop on localhost, then reuse the same application descriptor to deploy to QA, and then to your production environment.
 
 ### Management


[30/50] brooklyn-server git commit: Removed Brooklyn version, as is rendered on github.com.

Posted by he...@apache.org.
Removed Brooklyn version, as is rendered on github.com.


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

Branch: refs/heads/0.5.0
Commit: 494af3347aa8cda62ec8d99eeac2a277132c2958
Parents: d15890a
Author: David Toy <d...@vidtoy.co.uk>
Authored: Fri Apr 12 14:22:06 2013 +0100
Committer: David Toy <d...@vidtoy.co.uk>
Committed: Mon Apr 22 12:52:47 2013 +0100

----------------------------------------------------------------------
 README.md | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/494af334/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 81a1a7a..85cc381 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,4 @@
-![**Brooklyn**](http://brooklyncentral.github.io/style/images/brooklyn.gif)
-
-# [Brooklyn 0.6.0-SNAPSHOT](http://brooklyncentral.github.com) <!-- BROOKLYN_VERSION -->
+# [![**Brooklyn**](http://brooklyncentral.github.io/style/images/brooklyn.gif)](http://brooklyncentral.github.com)
 
 Brooklyn is a library and control plane for deploying and managing distributed applications.
 


[12/50] brooklyn-server git commit: extend timeout for integration test (http latency detector)

Posted by he...@apache.org.
extend timeout for integration test (http latency detector)


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

Branch: refs/heads/0.5.0
Commit: 3e164693b21a56c2c3b50abfc42041b07773aa00
Parents: 8b7985c
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Apr 2 06:48:34 2013 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Apr 2 06:49:27 2013 -0700

----------------------------------------------------------------------
 .../src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3e164693/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
index 1af5722..614104e 100644
--- a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
+++ b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
@@ -61,7 +61,7 @@ public class HttpLatencyDetectorTest {
                 Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
                 Predicates.notNull());
         log.info("Latency to "+entity.getAttribute(TEST_URL)+" is "+entity.getAttribute(HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT));
-        TestUtils.assertEventually(MutableMap.of("timeout", 4000), 
+        TestUtils.assertEventually(MutableMap.of("timeout", 10000), 
                 Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW), 
                 Predicates.notNull());
         log.info("Mean latency to "+entity.getAttribute(TEST_URL)+" is "+entity.getAttribute(HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW));


[29/50] brooklyn-server git commit: Merge pull request #673 from pveentjer/removecloudfoundry

Posted by he...@apache.org.
Merge pull request #673 from pveentjer/removecloudfoundry

Removed cloud foundry module since it is broken

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

Branch: refs/heads/0.5.0
Commit: 589bd26d3002c276de5b01ea55fedc43f078fe85
Parents: e366ed7 4ccaf5a
Author: Aled Sage <al...@gmail.com>
Authored: Mon Apr 22 03:00:12 2013 -0700
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Apr 22 03:00:12 2013 -0700

----------------------------------------------------------------------
 pom.xml                                         |   1 -
 systems/paas/cloudfoundry/pom.xml               |  39 --
 .../CloudFoundryJavaWebAppCluster.groovy        | 193 ---------
 .../cloudfoundry/CloudFoundryLocation.groovy    | 119 ------
 .../CloudFoundryVmcCliAccess.groovy             | 412 -------------------
 .../services/brooklyn.location.LocationResolver |   1 -
 .../CloudFoundryAccessIntegrationTest.groovy    |  82 ----
 .../CloudFoundryJavaClusterExample.groovy       |  72 ----
 ...FoundryJavaClusterFromLocationExample.groovy |  78 ----
 .../cloudfoundry/CloudFoundryParseTest.java     |  57 ---
 .../cloudfoundry/LocationResolvesTest.java      |  41 --
 .../src/test/resources/hello-world.war          | Bin 4606 -> 0 bytes
 12 files changed, 1095 deletions(-)
----------------------------------------------------------------------



[11/50] brooklyn-server git commit: extend timeout for integration test (http latency detector)

Posted by he...@apache.org.
extend timeout for integration test (http latency detector)


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

Branch: refs/heads/0.5.0
Commit: bb762104571de30708959b7e1ca36cec93fee8f0
Parents: 8b7985c
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Apr 2 06:48:34 2013 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Apr 2 06:48:34 2013 -0700

----------------------------------------------------------------------
 .../src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bb762104/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
index 1af5722..614104e 100644
--- a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
+++ b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
@@ -61,7 +61,7 @@ public class HttpLatencyDetectorTest {
                 Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
                 Predicates.notNull());
         log.info("Latency to "+entity.getAttribute(TEST_URL)+" is "+entity.getAttribute(HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT));
-        TestUtils.assertEventually(MutableMap.of("timeout", 4000), 
+        TestUtils.assertEventually(MutableMap.of("timeout", 10000), 
                 Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW), 
                 Predicates.notNull());
         log.info("Mean latency to "+entity.getAttribute(TEST_URL)+" is "+entity.getAttribute(HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW));


[16/50] brooklyn-server git commit: Fix memento/rebind of AbstractController

Posted by he...@apache.org.
Fix memento/rebind of AbstractController

- serverPoolTargets has entities as keys, so needed to fix
  MementoTransformer.transformIdsToEntities so it converted
  keys and values correctly.
- Can revisit this in the future for instead using serialised
  form of an entity-ref, rather than just String perhaps.


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

Branch: refs/heads/0.5.0
Commit: e5d2185546a40281d7f5117c85a82f4568a4d210
Parents: 64da3fc
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 10 13:01:17 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Apr 10 14:34:36 2013 +0100

----------------------------------------------------------------------
 .../entity/rebind/MementoTransformer.java       |  69 ++++++++----
 .../entity/rebind/MementoTransformerTest.java   | 107 +++++++++++++++++++
 2 files changed, 157 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e5d21855/core/src/main/java/brooklyn/entity/rebind/MementoTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/MementoTransformer.java b/core/src/main/java/brooklyn/entity/rebind/MementoTransformer.java
index 493b5c2..1706138 100644
--- a/core/src/main/java/brooklyn/entity/rebind/MementoTransformer.java
+++ b/core/src/main/java/brooklyn/entity/rebind/MementoTransformer.java
@@ -15,6 +15,7 @@ import brooklyn.location.Location;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import com.google.common.reflect.TypeToken;
 
 /**
  * Helpers for transforming references to locations into location ids, and vice versa.
@@ -99,29 +100,35 @@ public class MementoTransformer {
             throw new IllegalStateException("Cannot transform ids to locations of type "+requiredType);
         }
     }
-    
+
     public static <T> T transformIdsToEntities(RebindContext rebindContext, Object value, Class<T> requiredType, boolean removeDanglingRefs) {
+        return transformIdsToEntities(rebindContext, value, TypeToken.of(requiredType), removeDanglingRefs);
+    }
+    
+    public static <T> T transformIdsToEntities(RebindContext rebindContext, Object value, TypeToken<T> requiredType, boolean removeDanglingRefs) {
+        Class<? super T> requiredRawType = requiredType.getRawType();
+        
         if (value == null) {
             return null;
             
-        } else if (Entity.class.isAssignableFrom(requiredType)) {
+        } else if (Entity.class.isAssignableFrom(requiredRawType)) {
             Entity entity = rebindContext.getEntity((String)value);
             if (entity == null) {
                 if (removeDanglingRefs) {
-                    LOG.warn("No entity found for "+value+"; return null for "+requiredType.getSimpleName());
+                    LOG.warn("No entity found for "+value+"; return null for "+requiredRawType.getSimpleName());
                 } else {
                     throw new IllegalStateException("No entity found for "+value);
                 }
             }
             return (T) entity;
             
-        } else if (Iterable.class.isAssignableFrom(requiredType)) {
+        } else if (Iterable.class.isAssignableFrom(requiredRawType)) {
             Collection<Entity> result = Lists.newArrayList();
             for (String id : (Iterable<String>)value) {
                 Entity entity = rebindContext.getEntity(id);
                 if (entity == null) {
                     if (removeDanglingRefs) {
-                        LOG.warn("No entity found for "+id+"; discarding reference from "+requiredType.getSimpleName());
+                        LOG.warn("No entity found for "+id+"; discarding reference from "+requiredRawType.getSimpleName());
                     } else {
                         throw new IllegalStateException("No entity found for "+id);
                     }
@@ -130,7 +137,7 @@ public class MementoTransformer {
                 }
             }
 
-            if (Set.class.isAssignableFrom(requiredType)) {
+            if (Set.class.isAssignableFrom(requiredRawType)) {
                 result = Sets.newLinkedHashSet(result);
             }
             if (!requiredType.isAssignableFrom(result.getClass())) {
@@ -139,19 +146,41 @@ public class MementoTransformer {
             return (T) result;
                 
         } else if (value instanceof Map) {
-            Map<Object,Entity> result = Maps.newLinkedHashMap();
-            for (Map.Entry<?, String> entry : ((Map<?,String>)value).entrySet()) {
-                String id = entry.getValue();
-                Entity entity = rebindContext.getEntity(id);
-                if (entity == null) {
-                    if (removeDanglingRefs) {
-                        LOG.warn("No entity found for "+id+"; discarding reference from "+requiredType.getSimpleName());
-                    } else {
-                        throw new IllegalStateException("No entity found for "+id);
+            // If told explicitly the generics, then use that; but otherwise default to the value being of type Entity
+            TypeToken<?> keyType = requiredType.resolveType(Map.class.getTypeParameters()[0]);
+            TypeToken<?> valueType = requiredType.resolveType(Map.class.getTypeParameters()[1]);
+            boolean keyIsEntity = Entity.class.isAssignableFrom(keyType.getRawType());
+            boolean valueIsEntity = Entity.class.isAssignableFrom(valueType.getRawType()) || !keyIsEntity;
+            
+            Map<Object,Object> result = Maps.newLinkedHashMap();
+            for (Map.Entry<?, ?> entry : ((Map<?,?>)value).entrySet()) {
+                Object key = entry.getKey();
+                Object val = entry.getValue();
+                
+                if (keyIsEntity) {
+                    key = rebindContext.getEntity((String)key);
+                    if (key == null) {
+                        if (removeDanglingRefs) {
+                            LOG.warn("No entity found for "+entry.getKey()+"; discarding reference from "+requiredRawType.getSimpleName());
+                            continue;
+                        } else {
+                            throw new IllegalStateException("No entity found for "+entry.getKey());
+                        }
                     }
-                } else {
-                    result.put(entry.getKey(), entity);
                 }
+                if (valueIsEntity) {
+                    val = rebindContext.getEntity((String)val);
+                    if (val == null) {
+                        if (removeDanglingRefs) {
+                            LOG.warn("No entity found for "+entry.getValue()+"; discarding reference from "+requiredRawType.getSimpleName());
+                            continue;
+                        } else {
+                            throw new IllegalStateException("No entity found for "+entry.getValue());
+                        }
+                    }
+                }
+                
+                result.put(key, val);
             }
             
             if (!requiredType.isAssignableFrom(LinkedHashMap.class)) {
@@ -232,13 +261,15 @@ public class MementoTransformer {
     }
 
     private static Map<?,?> transformEntitiesToIds(Map<?,?> vs) {
-        if (containsType(vs.values(), Entity.class)) {
+        if (containsType(vs.values(), Entity.class) || containsType(vs.keySet(), Entity.class)) {
             // requires transforming for serialization
             Map<Object,Object> result = Maps.newLinkedHashMap();
             for (Map.Entry<?,?> entry : vs.entrySet()) {
                 Object k = entry.getKey();
                 Object v = entry.getValue();
-                result.put(k, ((Entity)v).getId());
+                Object k2 = (k instanceof Entity) ? ((Entity)k).getId() : k;
+                Object v2 = (v instanceof Entity) ? ((Entity)v).getId() : v;
+                result.put(k2, v2);
             }
             return result;
         } else {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e5d21855/core/src/test/java/brooklyn/entity/rebind/MementoTransformerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/MementoTransformerTest.java b/core/src/test/java/brooklyn/entity/rebind/MementoTransformerTest.java
new file mode 100644
index 0000000..3a2237b
--- /dev/null
+++ b/core/src/test/java/brooklyn/entity/rebind/MementoTransformerTest.java
@@ -0,0 +1,107 @@
+package brooklyn.entity.rebind;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Entity;
+import brooklyn.location.Location;
+import brooklyn.location.basic.SshMachineLocation;
+import brooklyn.test.entity.TestEntityImpl;
+import brooklyn.util.MutableMap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.TypeToken;
+
+public class MementoTransformerTest {
+
+    private Entity entity;
+    private RebindContextImpl rebindContext;
+    private SshMachineLocation location;
+    
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception {
+        location = new SshMachineLocation(MutableMap.of("address", "localhost"));
+        entity = new TestEntityImpl();
+        rebindContext = new RebindContextImpl(MementoTransformerTest.class.getClassLoader());
+        rebindContext.registerLocation(location.getId(), location);
+        rebindContext.registerEntity(entity.getId(), entity);
+    }
+    
+    @Test
+    public void testTransformLocation() throws Exception {
+        assertTransformsLocationIds(location, Location.class);
+    }
+    
+    @Test
+    public void testTransformLocationSet() throws Exception {
+        assertTransformsLocationIds(ImmutableSet.of(location), Set.class);
+    }
+    
+    @Test
+    public void testTransformLocationList() throws Exception {
+        assertTransformsLocationIds(ImmutableList.of(location), List.class);
+    }
+    
+    @Test
+    public void testTransformLocationMaop() throws Exception {
+        assertTransformsLocationIds(ImmutableMap.of("a", location), Map.class);
+    }
+    
+    @Test
+    public void testTransformEntity() throws Exception {
+        assertTransformsEntityIds(entity, Entity.class);
+    }
+    
+    @Test
+    public void testTransformEntitySet() throws Exception {
+        assertTransformsEntityIds(ImmutableSet.of(entity), Set.class);
+    }
+    
+    @Test
+    public void testTransformEntityList() throws Exception {
+        assertTransformsEntityIds(ImmutableList.of(entity), List.class);
+    }
+    
+    @Test
+    public void testTransformMapWithEntityValueUsingClazz() throws Exception {
+        assertTransformsEntityIds(ImmutableMap.of("a", entity), Map.class);
+    }
+    
+    @SuppressWarnings("serial")
+    @Test
+    public void testTransformMapWithEntityValueUsingTypeToken() throws Exception {
+        assertTransformsEntityIds(ImmutableMap.of("a", entity), new TypeToken<Map<String,Entity>>() {});
+    }
+    
+    @SuppressWarnings("serial")
+    @Test
+    public void testTransformMapWithEntityKey() throws Exception {
+        assertTransformsEntityIds(ImmutableMap.of(entity, "a"), new TypeToken<Map<Entity,String>>() {});
+    }
+    
+    private void assertTransformsLocationIds(Object orig, Class<?> type) throws Exception {
+        Object transformed = MementoTransformer.transformLocationsToIds(orig);
+        Object result = MementoTransformer.transformIdsToLocations(rebindContext, transformed, type, true);
+        assertEquals(result, orig, "transformed="+transformed);
+    }
+    
+    private void assertTransformsEntityIds(Object orig, Class<?> type) throws Exception {
+        Object transformed = MementoTransformer.transformEntitiesToIds(orig);
+        Object result = MementoTransformer.transformIdsToEntities(rebindContext, transformed, type, true);
+        assertEquals(result, orig, "transformed="+transformed);
+    }
+    
+    private void assertTransformsEntityIds(Object orig, TypeToken<?> type) throws Exception {
+        Object transformed = MementoTransformer.transformEntitiesToIds(orig);
+        Object result = MementoTransformer.transformIdsToEntities(rebindContext, transformed, type, true);
+        assertEquals(result, orig, "transformed="+transformed);
+    }
+}


[26/50] brooklyn-server git commit: cherrypicked a01940fac58d397b384b709631921810d95606cd Merge pull request #639 from ahgittin/fix/addChild-with-spec-on-interface onto 0.5

Posted by he...@apache.org.
cherrypicked a01940fac58d397b384b709631921810d95606cd Merge pull request #639 from ahgittin/fix/addChild-with-spec-on-interface onto 0.5


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

Branch: refs/heads/0.5.0
Commit: 5d79bc1340679bdc65378cd615c5e9d19bf38e4d
Parents: bba778b
Author: Andrea Turli <an...@gmail.com>
Authored: Fri Apr 19 15:11:28 2013 +0200
Committer: Andrea Turli <an...@gmail.com>
Committed: Fri Apr 19 15:56:30 2013 +0200

----------------------------------------------------------------------
 api/src/main/java/brooklyn/entity/Entity.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5d79bc13/api/src/main/java/brooklyn/entity/Entity.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/Entity.java b/api/src/main/java/brooklyn/entity/Entity.java
index 3c555e7..7211821 100644
--- a/api/src/main/java/brooklyn/entity/Entity.java
+++ b/api/src/main/java/brooklyn/entity/Entity.java
@@ -5,12 +5,14 @@ import java.util.Collection;
 import java.util.Map;
 
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.rebind.RebindSupport;
 import brooklyn.entity.rebind.Rebindable;
 import brooklyn.event.AttributeSensor;
 import brooklyn.location.Location;
 import brooklyn.management.Task;
 import brooklyn.mementos.EntityMemento;
+import brooklyn.mementos.PolicyMemento;
 import brooklyn.policy.Enricher;
 import brooklyn.policy.Policy;
 
@@ -91,11 +93,16 @@ public interface Entity extends Serializable, Rebindable {
      * 
      * TODO Signature will change to {@code <T extends Entity> T addChild(T child)}, but
      * that currently breaks groovy AbstractEntity subclasses sometimes so deferring that
-     * until (hopefully) the next release.
+     * until (hopefully) the next release. For now use addChild(EntitySpec).
      */
     Entity addChild(Entity child);
     
     /** 
+     * Creates an {@link Entity} from the given spec and adds it, setting this entity as the parent,
+     * returning the added child. */
+    <T extends Entity> T addChild(EntitySpec<T> spec);
+    
+    /** 
      * Removes the specified child {@link Entity}; its parent will be set to null.
      * 
      * @return True if the given entity was contained in the set of children


[14/50] brooklyn-server git commit: Fix HttpFeed so again reuses polls

Posted by he...@apache.org.
Fix HttpFeed so again reuses polls

- If two sensors make the same http request (with just
  different post-processing on the result) then just poll
  once and pass the result to each.

  Was broken by switching to Supplier<URI> instead of just
  a simple URI, so hashcode/equals failed.

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

Branch: refs/heads/0.5.0
Commit: 0ea1a02443cd1dc54a934967d81169897dfb08eb
Parents: 64da3fc
Author: Aled Sage <al...@gmail.com>
Authored: Tue Apr 9 14:26:10 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Apr 9 14:26:10 2013 +0100

----------------------------------------------------------------------
 .../java/brooklyn/event/feed/http/HttpFeed.java |  6 +--
 .../brooklyn/event/feed/http/HttpFeedTest.java  | 39 +++++++++++++++++++-
 2 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0ea1a024/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
index 5872921..4133b58 100644
--- a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
@@ -34,11 +34,11 @@ import brooklyn.event.feed.AbstractFeed;
 import brooklyn.event.feed.AttributePollHandler;
 import brooklyn.event.feed.DelegatingPollHandler;
 import brooklyn.event.feed.Poller;
+import brooklyn.util.Suppliers2;
 import brooklyn.util.exceptions.Exceptions;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
@@ -187,7 +187,7 @@ public class HttpFeed extends AbstractFeed {
         final byte[] body;
 
         private HttpPollIdentifier(String method, URI uri, Map<String,String> headers, byte[] body) {
-            this(method, Suppliers.ofInstance(uri), headers, body);
+            this(method, Suppliers2.ofInstance(uri), headers, body);
         }
         private HttpPollIdentifier(String method, Supplier<URI> uriProvider, Map<String,String> headers, byte[] body) {
             this.method = checkNotNull(method, "method").toLowerCase();
@@ -242,7 +242,7 @@ public class HttpFeed extends AbstractFeed {
                     throw new IllegalStateException("Not permitted to supply baseUri and baseUriProvider");
                 Map<String,String> baseUriVars = ImmutableMap.copyOf(checkNotNull(builder.baseUriVars, "baseUriVars"));
                 URI uri = config.buildUri(builder.baseUri, baseUriVars);
-                baseUriProvider = Suppliers.ofInstance(uri);
+                baseUriProvider = Suppliers2.ofInstance(uri);
             } else if (!builder.baseUriVars.isEmpty()) {
                 throw new IllegalStateException("Not permitted to supply URI vars when using a URI provider");
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0ea1a024/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
index 5da0893..d1eeab7 100644
--- a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
+++ b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
@@ -46,7 +46,10 @@ public class HttpFeedTest {
     
     private MockWebServer server;
     private URL baseUrl;
-    
+
+    private MockWebServer server2;
+    private URL baseUrl2;
+
     private Location loc;
     private TestApplication app;
     private EntityLocal entity;
@@ -61,6 +64,13 @@ public class HttpFeedTest {
         server.play();
         baseUrl = server.getUrl("/");
 
+        server2 = new MockWebServer();
+        for (int i = 0; i < 100; i++) {
+            server2.enqueue(new MockResponse().setResponseCode(200).addHeader("content-type: application/json").setBody(""+i));
+        }
+        server2.play();
+        baseUrl2 = server2.getUrl("/");
+
         loc = new LocalhostMachineProvisioningLocation();
         app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
@@ -71,6 +81,7 @@ public class HttpFeedTest {
     public void tearDown() throws Exception {
         if (feed != null) feed.stop();
         if (server != null) server.shutdown();
+        if (server2 != null) server2.shutdown();
         if (app != null) Entities.destroyAll(app);
         feed = null;
     }
@@ -204,4 +215,30 @@ public class HttpFeedTest {
                 return null;
             }});
     }
+    
+    @Test
+    public void testPollSharedByMultipleSensors() throws Exception {
+        long bigPeriod = 60*1000;
+        final BasicAttributeSensor<String> attribute1 = new BasicAttributeSensor<String>(String.class, "attrib1", "");
+        final BasicAttributeSensor<String> attribute2 = new BasicAttributeSensor<String>(String.class, "attrib2", "");
+
+        feed = HttpFeed.builder()
+                .entity(entity)
+                .baseUrl(baseUrl2)
+                .period(bigPeriod)
+                .poll(new HttpPollConfig<String>(attribute1)
+                        .onSuccess(HttpValueFunctions.stringContentsFunction()))
+                .poll(new HttpPollConfig<String>(attribute2)
+                        .onSuccess(HttpValueFunctions.stringContentsFunction()))
+                .build();
+        
+        Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
+           public void run() {
+               String val1 = entity.getAttribute(attribute1);
+               String val2 = entity.getAttribute(attribute2);
+               assertEquals(val1, "0", "attrib1="+val1+"; attrib2="+val2);
+               assertEquals(val2, "0", "attrib1="+val1+"; attrib2="+val2);
+           }
+        });
+    }
 }


[49/50] brooklyn-server git commit: Fix SoftwareProcess.connectServiceUpIsRunning

Posted by he...@apache.org.
Fix SoftwareProcess.connectServiceUpIsRunning

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

Branch: refs/heads/0.5.0
Commit: 7a931fc03a4cf09717471020bb7fbe7077df432d
Parents: 755d1ed
Author: Aled Sage <al...@gmail.com>
Authored: Thu May 2 11:30:48 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu May 2 11:30:48 2013 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/entity/basic/SoftwareProcessImpl.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7a931fc0/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
index 8a02ca9..48982a7 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
@@ -55,6 +55,9 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
 	private transient SoftwareProcessDriver driver;
 	protected transient SensorRegistry sensorRegistry;
 
+    /** @see #connectServiceUpIsRunning() */
+    private volatile FunctionFeed serviceUp;
+
 	public SoftwareProcessImpl() {
         super(MutableMap.of(), null);
     }
@@ -111,9 +114,6 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
     protected void connectSensors() {
     }
 
-    /** @see #connectServiceUpIsRunning() */
-    private volatile FunctionFeed serviceUp;
-
     /**
      * For connecting the {@link #SERVICE_UP} sensor to the value of the {@code getDriver().isRunning()} expression.
      * <p>
@@ -122,7 +122,7 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
      * @see #disconnectServiceUpIsRunning()
      */
     protected void connectServiceUpIsRunning() {
-        FunctionFeed serviceUp = FunctionFeed.builder()
+        serviceUp = FunctionFeed.builder()
                 .entity(this)
                 .period(5000)
                 .poll(new FunctionPollConfig<Boolean, Boolean>(SERVICE_UP)


[35/50] brooklyn-server git commit: Typo: "logic groupings" -> "logical groupings"

Posted by he...@apache.org.
Typo: "logic groupings" -> "logical groupings"


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

Branch: refs/heads/0.5.0
Commit: 0136a416888dd5c47161a6bf22a9aa759eed8e2e
Parents: bfa0de2
Author: David Toy <d...@vidtoy.co.uk>
Authored: Thu Apr 18 19:52:26 2013 +0100
Committer: David Toy <d...@vidtoy.co.uk>
Committed: Mon Apr 22 12:52:48 2013 +0100

----------------------------------------------------------------------
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0136a416/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 2cdc47a..35bfb06 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ In DevOps fashion, Brooklyn allows applications and roll-outs to be version cont
 
 Brooklyn enables [autonomic management](http://en.wikipedia.org/wiki/Autonomic_computing) of applications. (i.e. many small, local, distributed control loops).
 
-Management policies can be attached to every component part in an application, and to logic groupings of components (clusters, fabrics). Policies can implement both technical and non-technical (business) requirements.
+Management policies can be attached to every component part in an application, and to logical groupings of components (clusters, fabrics). Policies can implement both technical and non-technical (business) requirements.
 
 At runtime, policies have access to all aspects of the deployment, including deployment topology (hierarchical) and locations (machines, PaaSes, and jurisdictions), as well as scripts, instrumentation, and operational goals and constraints. This means that once the application is launched, the policies are all set to keep the application running optimally, based on whatever optimally means in that context.
 


[10/50] brooklyn-server git commit: minor logging fixes

Posted by he...@apache.org.
minor logging fixes


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

Branch: refs/heads/0.5.0
Commit: 8b7985ce2371ca510dc417eb0bf08ee7c572867b
Parents: 02339d9
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Apr 2 06:59:39 2013 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Apr 2 07:02:15 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/event/feed/http/HttpPollValue.java | 6 ++++--
 .../brooklyn/management/internal/BrooklynGarbageCollector.java | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8b7985ce/core/src/main/java/brooklyn/event/feed/http/HttpPollValue.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/http/HttpPollValue.java b/core/src/main/java/brooklyn/event/feed/http/HttpPollValue.java
index 0abad63..faecdd6 100644
--- a/core/src/main/java/brooklyn/event/feed/http/HttpPollValue.java
+++ b/core/src/main/java/brooklyn/event/feed/http/HttpPollValue.java
@@ -13,6 +13,8 @@ import org.apache.http.HttpResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import brooklyn.util.Time;
+
 import com.google.common.base.Throwables;
 import com.google.common.collect.Maps;
 import com.google.common.io.ByteStreams;
@@ -51,8 +53,8 @@ public class HttpPollValue {
             
             response.getEntity().getContentLength();
             durationMillisOfFullContent = System.currentTimeMillis() - startTime;
-            if (log.isDebugEnabled())
-                log.debug("latency detector detected "+durationMillisOfFirstResponse+" / "+durationMillisOfFullContent+" latency");
+            if (log.isTraceEnabled())
+                log.trace("HttpPollValue latency "+Time.makeTimeString(durationMillisOfFirstResponse)+" / "+Time.makeTimeString(durationMillisOfFullContent)+", content size "+content.length);
         } catch (IOException e) {
             throw Throwables.propagate(e);
         }        

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8b7985ce/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
index 01241ae..0243021 100644
--- a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
+++ b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
@@ -124,7 +124,7 @@ public class BrooklynGarbageCollector {
                 Strings.makeSizeString(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())+" / "+
                 Strings.makeSizeString(Runtime.getRuntime().totalMemory()) + " memory; "+
                 "tasks: " +
-                executionManager.getNumActiveTasks()+" active,"+
+                executionManager.getNumActiveTasks()+" active, "+
                 executionManager.getNumInMemoryTasks()+" in memory "+
                 "("+executionManager.getNumIncompleteTasks()+" incomplete and "+
                 executionManager.getTotalTasksSubmitted()+" total submitted)"


[38/50] brooklyn-server git commit: SensorPropagatingEnricher: support propagating as different sensor

Posted by he...@apache.org.
SensorPropagatingEnricher: support propagating as different sensor


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

Branch: refs/heads/0.5.0
Commit: 39c08cb5c1f233a347fcbe629bc85b3648cb01e9
Parents: 7358417
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 24 10:54:04 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 11:15:19 2013 +0100

----------------------------------------------------------------------
 .../basic/SensorPropagatingEnricher.java        | 56 ++++++++---
 .../SensorPropagatingEnricherTest.groovy        | 41 --------
 .../enricher/SensorPropagatingEnricherTest.java | 98 ++++++++++++++++++++
 3 files changed, 141 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/39c08cb5/core/src/main/java/brooklyn/enricher/basic/SensorPropagatingEnricher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/enricher/basic/SensorPropagatingEnricher.java b/core/src/main/java/brooklyn/enricher/basic/SensorPropagatingEnricher.java
index 899dc61..068cc9a 100644
--- a/core/src/main/java/brooklyn/enricher/basic/SensorPropagatingEnricher.java
+++ b/core/src/main/java/brooklyn/enricher/basic/SensorPropagatingEnricher.java
@@ -1,7 +1,7 @@
 package brooklyn.enricher.basic;
 
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.Map;
 import java.util.Set;
 
 import org.slf4j.Logger;
@@ -14,6 +14,8 @@ import brooklyn.event.Sensor;
 import brooklyn.event.SensorEvent;
 import brooklyn.event.SensorEventListener;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 
@@ -24,9 +26,13 @@ public class SensorPropagatingEnricher extends AbstractEnricher implements Senso
         
     /** the entity to listen to */
     private final Entity source;
-    /** the sensors to listen to */
-    private final Set<Sensor<?>> sensors = Sets.newLinkedHashSet();
     
+    /** the sensors to listen to */
+    private final Set<Sensor<?>> sensors;
+
+    /** the sensors to listen to */
+    private final Map<Sensor<?>, Sensor<?>> sensorAlternatives;
+
     public static SensorPropagatingEnricher newInstanceListeningToAllSensors(Entity source) {
         return newInstanceListeningToAllSensorsBut(source);
     }
@@ -44,12 +50,24 @@ public class SensorPropagatingEnricher extends AbstractEnricher implements Senso
         return new SensorPropagatingEnricher(source, includes);
     }
 
+    public static SensorPropagatingEnricher newInstanceListeningTo(Entity source, Map<? extends Sensor<?>, ? extends Sensor<?>> sensors) {
+        return new SensorPropagatingEnricher(source, sensors);
+    }
+
     public SensorPropagatingEnricher(Entity source, Sensor<?>... sensors) {
-        this(source, Arrays.asList(sensors));
+        this(source, ImmutableList.copyOf(sensors));
     }
+    
     public SensorPropagatingEnricher(Entity source, Collection<Sensor<?>> sensors) {
         this.source = source;
-        this.sensors.addAll(sensors);
+        this.sensors = ImmutableSet.copyOf(sensors);
+        this.sensorAlternatives = ImmutableMap.of();
+    }
+    
+    public SensorPropagatingEnricher(Entity source, Map<? extends Sensor<?>, ? extends Sensor<?>> sensors) {
+        this.source = source;
+        this.sensors = ImmutableSet.copyOf(sensors.keySet());
+        this.sensorAlternatives = ImmutableMap.copyOf(sensors);
     }
     
     public void setEntity(EntityLocal entity) {
@@ -59,16 +77,23 @@ public class SensorPropagatingEnricher extends AbstractEnricher implements Senso
         }
     }
     
-    public void onEvent(SensorEvent event) {
-        if (log.isTraceEnabled()) log.trace("policy {} got {}, propagating via {}", new Object[] {this, event, entity});
-        //just propagate upwards
+    @Override
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public void onEvent(SensorEvent<Object> event) {
+        // propagate upwards
+        Sensor<?> sourceSensor = event.getSensor();
+        Sensor<?> destinationSensor = getDestinationSensor(sourceSensor);
+        
+        if (log.isTraceEnabled()) log.trace("policy {} got {}, propagating via {}{}", 
+                new Object[] {this, event, entity, (sourceSensor == destinationSensor ? "" : " (as "+destinationSensor+")")});
+        
         if (event.getSensor() instanceof AttributeSensor) {
-            entity.setAttribute((AttributeSensor)event.getSensor(), event.getValue());
+            entity.setAttribute((AttributeSensor)destinationSensor, event.getValue());
         } else {
-            entity.emit(event.getSensor(), event.getValue());
+            entity.emit((Sensor)destinationSensor, event.getValue());
         }       
     }
-    
+
     /** useful post-addition to emit current values */
     public void emitAllAttributes() {
         emitAllAttributes(false);
@@ -77,8 +102,9 @@ public class SensorPropagatingEnricher extends AbstractEnricher implements Senso
     public void emitAllAttributes(boolean includeNullValues) {
         for (Sensor s: sensors) {
             if (s instanceof AttributeSensor) {
+                AttributeSensor destinationSensor = (AttributeSensor<?>) getDestinationSensor(s);
                 Object v = source.getAttribute((AttributeSensor)s);
-                if (v!=null || includeNullValues) entity.setAttribute((AttributeSensor)s, v);
+                if (v != null || includeNullValues) entity.setAttribute(destinationSensor, v);
             }
         }
     }
@@ -88,5 +114,9 @@ public class SensorPropagatingEnricher extends AbstractEnricher implements Senso
         host.addEnricher(this);
         emitAllAttributes();
         return this;
-    }    
+    }
+    
+    private Sensor<?> getDestinationSensor(Sensor<?> sourceSensor) {
+        return sensorAlternatives.containsKey(sourceSensor) ? sensorAlternatives.get(sourceSensor): sourceSensor;
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/39c08cb5/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy b/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy
deleted file mode 100644
index c4615d9..0000000
--- a/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy
+++ /dev/null
@@ -1,41 +0,0 @@
-package brooklyn.enricher
-
-import org.testng.Assert
-import org.testng.annotations.Test
-
-import brooklyn.enricher.basic.SensorPropagatingEnricher
-import brooklyn.entity.basic.ApplicationBuilder
-import brooklyn.entity.proxying.EntitySpecs
-import brooklyn.event.SensorEvent
-import brooklyn.event.SensorEventListener
-import brooklyn.test.TestUtils
-import brooklyn.test.entity.TestApplication
-import brooklyn.test.entity.TestEntity
-
-class SensorPropagatingEnricherTest {
-
-    @Test
-    public void testPropagation() {
-        TestApplication app = ApplicationBuilder.newManagedApp(TestApplication.class);
-        TestEntity entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
-        
-        app.addEnricher(SensorPropagatingEnricher.newInstanceListeningToAllSensorsBut(entity, TestEntity.SEQUENCE)) 
-
-        //name propagated
-        entity.setAttribute(TestEntity.NAME, "foo")
-        TestUtils.executeUntilSucceeds { Assert.assertEquals(app.getAttribute(TestEntity.NAME), "foo") }
-        
-        //sequence not picked up
-        entity.setAttribute(TestEntity.SEQUENCE, 2)
-        Thread.sleep(100)                       
-        Assert.assertEquals(app.getAttribute(TestEntity.SEQUENCE), null)
-        
-        //notif propagated
-        int notif = 0;
-        app.subscribe(app, TestEntity.MY_NOTIF, { SensorEvent evt -> notif = evt.value } as SensorEventListener)
-        entity.emit(TestEntity.MY_NOTIF, 7)
-        TestUtils.executeUntilSucceeds { Assert.assertEquals(notif, 7) }
-    }
-    
-    
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/39c08cb5/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.java b/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.java
new file mode 100644
index 0000000..27cb601
--- /dev/null
+++ b/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.java
@@ -0,0 +1,98 @@
+package brooklyn.enricher;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.enricher.basic.SensorPropagatingEnricher;
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.proxying.EntitySpecs;
+import brooklyn.event.SensorEvent;
+import brooklyn.event.SensorEventListener;
+import brooklyn.event.basic.BasicAttributeSensor;
+import brooklyn.test.Asserts;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.test.entity.TestApplication;
+import brooklyn.test.entity.TestEntity;
+import brooklyn.util.MutableMap;
+import brooklyn.util.javalang.AtomicReferences;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+
+public class SensorPropagatingEnricherTest {
+
+    private TestApplication app;
+    private TestEntity entity;
+
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception {
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
+        entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app);
+    }
+    
+    @Test
+    public void testPropagatesSpecificSensor() {
+        app.addEnricher(SensorPropagatingEnricher.newInstanceListeningTo(entity, TestEntity.NAME));
+
+        // name propagated
+        entity.setAttribute(TestEntity.NAME, "foo");
+        EntityTestUtils.assertAttributeEqualsEventually(app, TestEntity.NAME, "foo");
+        
+        // sequence not propagated
+        entity.setAttribute(TestEntity.SEQUENCE, 2);
+        EntityTestUtils.assertAttributeEqualsContinually(MutableMap.of("timeout", 100), app, TestEntity.SEQUENCE, null);
+    }
+    
+    @Test
+    public void testPropagatesAllSensors() {
+        app.addEnricher(SensorPropagatingEnricher.newInstanceListeningToAllSensors(entity));
+
+        // all attributes propagated
+        entity.setAttribute(TestEntity.NAME, "foo");
+        entity.setAttribute(TestEntity.SEQUENCE, 2);
+        
+        EntityTestUtils.assertAttributeEqualsEventually(app, TestEntity.NAME, "foo");
+        EntityTestUtils.assertAttributeEqualsEventually(app, TestEntity.SEQUENCE, 2);
+        
+        // notification-sensor propagated
+        final AtomicReference<Integer> notif = new AtomicReference<Integer>();
+        app.subscribe(app, TestEntity.MY_NOTIF, new SensorEventListener<Integer>() {
+                @Override public void onEvent(SensorEvent<Integer> event) {
+                    notif.set(event.getValue());
+                }});
+        entity.emit(TestEntity.MY_NOTIF, 7);
+        Asserts.eventually(AtomicReferences.supplier(notif), Predicates.equalTo(7));
+    }
+    
+    @Test
+    public void testPropagatesAllBut() {
+        app.addEnricher(SensorPropagatingEnricher.newInstanceListeningToAllSensorsBut(entity, TestEntity.SEQUENCE)) ;
+
+        // name propagated
+        entity.setAttribute(TestEntity.NAME, "foo");
+        EntityTestUtils.assertAttributeEqualsEventually(app, TestEntity.NAME, "foo");
+        
+        // sequence not propagated
+        entity.setAttribute(TestEntity.SEQUENCE, 2);
+        EntityTestUtils.assertAttributeEqualsContinually(MutableMap.of("timeout", 100), app, TestEntity.SEQUENCE, null);
+    }
+    
+    @Test
+    public void testPropagatingAsDifferentSensor() {
+        final BasicAttributeSensor<String> ANOTHER_ATTRIBUTE = new BasicAttributeSensor<String>(String.class, "another.attribute", "");
+        app.addEnricher(SensorPropagatingEnricher.newInstanceListeningTo(entity, ImmutableMap.of(TestEntity.NAME, ANOTHER_ATTRIBUTE)));
+
+        // name propagated as different attribute
+        entity.setAttribute(TestEntity.NAME, "foo");
+        EntityTestUtils.assertAttributeEqualsEventually(app, ANOTHER_ATTRIBUTE, "foo");
+    }
+}


[44/50] brooklyn-server git commit: Fix AtomicReference.setIfDifferent

Posted by he...@apache.org.
Fix AtomicReference.setIfDifferent

- was using != instead of .equals for object equality


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

Branch: refs/heads/0.5.0
Commit: bf2e4c36f7ab4dc193d911dcb436e9211447e9da
Parents: 6ea7b07
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 24 10:54:48 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Apr 25 11:25:06 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/util/javalang/AtomicReferences.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bf2e4c36/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java b/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
index fb03d91..ed10d28 100644
--- a/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
+++ b/core/src/main/java/brooklyn/util/javalang/AtomicReferences.java
@@ -3,6 +3,7 @@ package brooklyn.util.javalang;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
+import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Supplier;
 
@@ -15,7 +16,7 @@ public class AtomicReferences {
 
     /** sets the atomic reference to the given value, and returns whether there is any change */
     public static <T> boolean setIfDifferent(AtomicReference<T> ref, T value) {
-        return ref.getAndSet(value) != value;
+        return !Objects.equal(ref.getAndSet(value), value);
     }
     
     /** returns the given atomic as a Supplier */


[24/50] brooklyn-server git commit: Tidy up the Entities class - Rename supplier to attributeSupplier - Add newDownloader method to get DownloadResolver for a driver - Better javadoc

Posted by he...@apache.org.
Tidy up the Entities class
- Rename supplier to attributeSupplier
- Add newDownloader method to get DownloadResolver for a driver
- Better javadoc


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

Branch: refs/heads/0.5.0
Commit: b3a1b05048e5550c0bdffe7e0df24240701560f6
Parents: ca17797
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Wed Apr 3 23:13:48 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Fri Apr 19 10:37:17 2013 +0100

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/Entities.java    | 271 ++++++++++---------
 .../java/brooklyn/event/feed/http/HttpFeed.java |   2 +-
 .../brooklyn/event/feed/http/HttpFeedTest.java  |   4 +-
 .../enricher/HttpLatencyDetectorTest.java       |   6 +-
 4 files changed, 150 insertions(+), 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b3a1b050/core/src/main/java/brooklyn/entity/basic/Entities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/Entities.java b/core/src/main/java/brooklyn/entity/basic/Entities.java
index 9c97195..774ee0a 100644
--- a/core/src/main/java/brooklyn/entity/basic/Entities.java
+++ b/core/src/main/java/brooklyn/entity/basic/Entities.java
@@ -25,7 +25,10 @@ import brooklyn.entity.Application;
 import brooklyn.entity.Effector;
 import brooklyn.entity.Entity;
 import brooklyn.entity.Group;
+import brooklyn.entity.drivers.EntityDriver;
+import brooklyn.entity.drivers.downloads.DownloadResolver;
 import brooklyn.entity.trait.Startable;
+import brooklyn.entity.trait.StartableMethods;
 import brooklyn.event.AttributeSensor;
 import brooklyn.event.Sensor;
 import brooklyn.location.Location;
@@ -49,14 +52,16 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
-
-/** Convenience methods for working with entities. 
- * Also see the various *Methods classes for traits 
- * (eg StartableMethods for Startable implementations). */
+/**
+ * Convenience methods for working with entities.
+ * <p>
+ * Also see the various {@code *Methods} classes for traits,
+ * such as {@link StartableMethods} for {@link Startable} implementations.
+ */
 public class Entities {
 
     private static final Logger log = LoggerFactory.getLogger(Entities.class);
-    
+
     /**
      * Names that, if they appear anywhere in an attribute/config/field indicates that it
      * may be private, so should not be logged etc.
@@ -69,63 +74,70 @@ public class Entities {
             "private",
             "access.cert",
             "access.key");
-    
-	/** invokes the given effector with the given named arguments on the entitiesToCall, from the calling context of the callingEntity;
-	 * intended for use only from the callingEntity.
-	 * @return ParallelTask containing a results from each invocation; calling get() on the result will block until all complete,
-	 * and throw error if any threw error   
-	 */
-	public static <T> Task<List<T>> invokeEffectorList(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall, 
-	        final Effector<T> effector, final Map<String,?> parameters) {
+
+    /**
+     * Invokes an {@link Effector} on multiple entities, with the named arguments from the parameters {@link Map}
+     * using the context of the provided {@link Entity}.
+     * <p>
+     * Intended for use only from the callingEntity.
+     * <p>
+     * Returns a {@link ParallelTask} containing the results from each tasks invocation. Calling
+     * {@link java.util.concurrent.Future#get() get()} on this will block until all tasks are complete,
+     * and will throw an exception if any task resulted in an error.
+     *
+     * @return {@link ParallelTask} containing results from each invocation
+     */
+    public static <T> Task<List<T>> invokeEffectorList(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall,
+            final Effector<T> effector, final Map<String,?> parameters) {
         // formulation is complicated, but it is building up a list of tasks, without blocking on them initially,
         // but ensuring that when the parallel task is gotten it does block on all of them
-	    // TODO why not just get list of tasks with `entity.invoke(effector, parameters))`?
-	    //      What is advantage of invoking in callingEntity's context?
-        
-		if (entitiesToCall == null || Iterables.isEmpty(entitiesToCall)) return null;
-		List<Task<T>> tasks = Lists.newArrayList();
-		
-		for (final Entity entity : entitiesToCall) {
-		    tasks.add(new BasicTask<T>(
-		            MutableMap.of("displayName", "invoke", "description", "invoke effector \""+effector.getName()+"\" on entity "+entity), 
-		            new Callable<T>() {
-        		        public T call() throws Exception {
-        		            return entity.invoke(effector, parameters).get();
-        		        }
-    		        }));
-		}
-	    ParallelTask<T> invoke = new ParallelTask<T>(
-	            MutableMap.of(
-	                    "displayName", "compound-invoke", 
-	                    "description", "invoke effector \""+effector.getName()+"\" on "+tasks.size()+(tasks.size() == 1 ? " entity" : " entities")), 
-	            tasks);
-	    ((EntityInternal)callingEntity).getManagementSupport().getExecutionContext().submit(invoke);
-	    return invoke;
-	}
-    public static <T> Task<List<T>> invokeEffectorListWithMap(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall, 
+        // TODO why not just get list of tasks with `entity.invoke(effector, parameters))`?
+        //      What is advantage of invoking in callingEntity's context?
+
+        if (entitiesToCall == null || Iterables.isEmpty(entitiesToCall)) return null;
+        List<Task<T>> tasks = Lists.newArrayList();
+
+        for (final Entity entity : entitiesToCall) {
+            tasks.add(new BasicTask<T>(
+                    MutableMap.of("displayName", "invoke", "description", "invoke effector \""+effector.getName()+"\" on entity "+entity),
+                    new Callable<T>() {
+                        public T call() throws Exception {
+                            return entity.invoke(effector, parameters).get();
+                        }
+                    }));
+        }
+        ParallelTask<T> invoke = new ParallelTask<T>(
+                MutableMap.of(
+                        "displayName", "compound-invoke",
+                        "description", "invoke effector \""+effector.getName()+"\" on "+tasks.size()+(tasks.size() == 1 ? " entity" : " entities")),
+                tasks);
+        ((EntityInternal)callingEntity).getManagementSupport().getExecutionContext().submit(invoke);
+        return invoke;
+    }
+    public static <T> Task<List<T>> invokeEffectorListWithMap(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall,
             final Effector<T> effector, final Map<String,?> parameters) {
         return invokeEffectorList(callingEntity, entitiesToCall, effector, parameters);
     }
     @SuppressWarnings("unchecked")
-    public static <T> Task<List<T>> invokeEffectorListWithArgs(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall, 
+    public static <T> Task<List<T>> invokeEffectorListWithArgs(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall,
             final Effector<T> effector, Object ...args) {
         return invokeEffectorListWithMap(callingEntity, entitiesToCall, effector,
                 // putting into a map, unnecessarily, as it ends up being the array again...
                 EffectorUtils.prepareArgsForEffectorAsMapFromArray(effector, args));
     }
-    public static <T> Task<List<T>> invokeEffectorList(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall, 
+    public static <T> Task<List<T>> invokeEffectorList(EntityLocal callingEntity, Iterable<? extends Entity> entitiesToCall,
             final Effector<T> effector) {
         return invokeEffectorList(callingEntity, entitiesToCall, effector, Collections.<String,Object>emptyMap());
     }
-    public static <T> Task<List<T>> invokeEffectorWithMap(EntityLocal callingEntity, Entity entityToCall, 
+    public static <T> Task<List<T>> invokeEffectorWithMap(EntityLocal callingEntity, Entity entityToCall,
             final Effector<T> effector, final Map<String,?> parameters) {
         return invokeEffectorList(callingEntity, ImmutableList.of(entityToCall), effector, parameters);
     }
-    public static <T> Task<List<T>> invokeEffectorWithArgs(EntityLocal callingEntity, Entity entityToCall, 
+    public static <T> Task<List<T>> invokeEffectorWithArgs(EntityLocal callingEntity, Entity entityToCall,
             final Effector<T> effector, Object ...args) {
-        return invokeEffectorListWithArgs(callingEntity, ImmutableList.of(entityToCall), effector, args); 
+        return invokeEffectorListWithArgs(callingEntity, ImmutableList.of(entityToCall), effector, args);
     }
-    public static <T> Task<List<T>> invokeEffector(EntityLocal callingEntity, Entity entityToCall, 
+    public static <T> Task<List<T>> invokeEffector(EntityLocal callingEntity, Entity entityToCall,
             final Effector<T> effector) {
         return invokeEffectorWithMap(callingEntity, entityToCall, effector, Collections.<String,Object>emptyMap());
     }
@@ -143,7 +155,7 @@ public class Entities {
                 (v instanceof Collection && ((Collection<?>)v).isEmpty()) ||
                 (v instanceof CharSequence&& ((CharSequence)v).length() == 0);
     }
-    
+
     public static <K> Map<K,Object> sanitize(Map<K,?> input) {
         Map<K,Object> result = Maps.newLinkedHashMap();
         for (Map.Entry<K,?> e: input.entrySet()) {
@@ -158,7 +170,7 @@ public class Entities {
             dumpInfo(e);
         }
     }
-    
+
     public static void dumpInfo(Entity e) {
         try {
             dumpInfo(e, new PrintWriter(System.out), "", "  ");
@@ -173,12 +185,12 @@ public class Entities {
     public static void dumpInfo(Entity e, String currentIndentation, String tab) throws IOException {
         dumpInfo(e, new PrintWriter(System.out), currentIndentation, tab);
     }
-	public static void dumpInfo(Entity e, Writer out, String currentIndentation, String tab) throws IOException {
-		out.append(currentIndentation+e.toString()+"\n");
-		
+    public static void dumpInfo(Entity e, Writer out, String currentIndentation, String tab) throws IOException {
+        out.append(currentIndentation+e.toString()+"\n");
+
         out.append(currentIndentation+tab+tab+"locations = "+e.getLocations()+"\n");
 
-		for (ConfigKey<?> it : sortConfigKeys(e.getEntityType().getConfigKeys())) {
+        for (ConfigKey<?> it : sortConfigKeys(e.getEntityType().getConfigKeys())) {
             Object v = ((EntityInternal)e).getConfigMap().getRawConfig(it);
             if (!isTrivial(v)) {
                 out.append(currentIndentation+tab+tab+it.getName());
@@ -200,10 +212,10 @@ public class Entities {
                 } else out.append(""+v);
                 out.append("\n");
             }
-		}
-		
-		for (Sensor<?> it : sortSensors(e.getEntityType().getSensors())) {
-			if (it instanceof AttributeSensor) {
+        }
+
+        for (Sensor<?> it : sortSensors(e.getEntityType().getSensors())) {
+            if (it instanceof AttributeSensor) {
                 Object v = e.getAttribute((AttributeSensor<?>)it);
                 if (!isTrivial(v)) {
                     out.append(currentIndentation+tab+tab+it.getName());
@@ -212,28 +224,28 @@ public class Entities {
                     else out.append(""+v);
                     out.append("\n");
                 }
-			}
-		}
-		
-		if (e instanceof Group) {
-		    StringBuilder members = new StringBuilder();
-    		for (Entity it : ((Group)e).getMembers()) {
+            }
+        }
+
+        if (e instanceof Group) {
+            StringBuilder members = new StringBuilder();
+            for (Entity it : ((Group)e).getMembers()) {
                 members.append(it.getId()+", ");
             }
-    		out.append(currentIndentation+tab+tab+"Members: "+members.toString()+"\n");
-		}
-		
-		out.append(currentIndentation+tab+tab+"Policies:\n");
+            out.append(currentIndentation+tab+tab+"Members: "+members.toString()+"\n");
+        }
+
+        out.append(currentIndentation+tab+tab+"Policies:\n");
         for (Policy policy : e.getPolicies()) {
             dumpInfo(policy, out, currentIndentation+tab+tab+tab, tab);
         }
-        
-		for (Entity it : e.getChildren()) {
-			dumpInfo(it, out, currentIndentation+tab, tab);
-		}
-		
-		out.flush();
-	}
+
+        for (Entity it : e.getChildren()) {
+            dumpInfo(it, out, currentIndentation+tab, tab);
+        }
+
+        out.flush();
+    }
 
     public static void dumpInfo(Location loc) {
         try {
@@ -252,11 +264,11 @@ public class Entities {
     @SuppressWarnings("rawtypes")
     public static void dumpInfo(Location loc, Writer out, String currentIndentation, String tab) throws IOException {
         out.append(currentIndentation+loc.toString()+"\n");
-        
+
         for (Object entryO : loc.getAllConfig().entrySet()) {
             Map.Entry entry = (Map.Entry)entryO;
             Object keyO = entry.getKey();
-            String key = 
+            String key =
                     keyO instanceof HasConfigKey ? ((HasConfigKey)keyO).getConfigKey().getName() :
                     keyO instanceof ConfigKey ? ((ConfigKey)keyO).getName() :
                     keyO == null ? null :
@@ -270,8 +282,8 @@ public class Entities {
                 out.append("\n");
             }
         }
-        
-        
+
+
         for (Map.Entry<String,?> entry : sortMap(FlagUtils.getFieldsWithFlags(loc)).entrySet()) {
             String key = entry.getKey();
             Object val = entry.getValue();
@@ -283,11 +295,11 @@ public class Entities {
                 out.append("\n");
             }
         }
-        
+
         for (Location it : loc.getChildLocations()) {
             dumpInfo(it, out, currentIndentation+tab, tab);
         }
-        
+
         out.flush();
     }
 
@@ -307,7 +319,7 @@ public class Entities {
     }
     public static void dumpInfo(Policy pol, Writer out, String currentIndentation, String tab) throws IOException {
         out.append(currentIndentation+pol.toString()+"\n");
-        
+
         for (ConfigKey<?> key : sortConfigKeys(pol.getPolicyType().getConfigKeys())) {
             Object val = ((AbstractPolicy)pol).getConfigMap().getRawConfig(key);
             if (!isTrivial(val)) {
@@ -318,23 +330,23 @@ public class Entities {
                 out.append("\n");
             }
         }
-        
+
         out.flush();
     }
 
-	@SuppressWarnings({ "rawtypes", "unchecked" })
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     public static List<Sensor<?>> sortSensors(Set<Sensor<?>> sensors) {
-	    List result = new ArrayList(sensors);
-	    Collections.sort(result, new Comparator<Sensor>() {
+        List result = new ArrayList(sensors);
+        Collections.sort(result, new Comparator<Sensor>() {
                     @Override
                     public int compare(Sensor arg0, Sensor arg1) {
                         return arg0.getName().compareTo(arg1.getName());
                     }
-	        
-	    });
-	    return result;
+
+        });
+        return result;
     }
-	
+
     @SuppressWarnings({ "rawtypes", "unchecked" })
     public static List<ConfigKey<?>> sortConfigKeys(Set<ConfigKey<?>> configs) {
         List result = new ArrayList(configs);
@@ -343,53 +355,53 @@ public class Entities {
                     public int compare(ConfigKey arg0, ConfigKey arg1) {
                         return arg0.getName().compareTo(arg1.getName());
                     }
-            
+
         });
         return result;
     }
-    
+
     public static <T> Map<String, T> sortMap(Map<String, T> map) {
         Map<String,T> result = Maps.newLinkedHashMap();
         List<String> order = Lists.newArrayList(map.keySet());
         Collections.sort(order, String.CASE_INSENSITIVE_ORDER);
-        
+
         for (String key : order) {
             result.put(key, map.get(key));
         }
         return result;
     }
-    
+
     public static boolean isAncestor(Entity descendant, Entity potentialAncestor) {
-		Entity ancestor = descendant.getParent();
-		while (ancestor != null) {
-			if (ancestor.equals(potentialAncestor)) return true;
-			ancestor = ancestor.getParent();
-		}
-		return false;
-	}
-
-	/** note, it is usually preferred to use isAncestor() and swap the order, it is a cheaper method */
-	public static boolean isDescendant(Entity ancestor, Entity potentialDescendant) {
-		Set<Entity> inspected = Sets.newLinkedHashSet();
-		Stack<Entity> toinspect = new Stack<Entity>();
-		toinspect.add(ancestor);
-		
-		while (!toinspect.isEmpty()) {
-			Entity e = toinspect.pop();
-			if (e.getChildren().contains(potentialDescendant)) {
-				return true;
-			}
-			inspected.add(e);
-			toinspect.addAll(e.getChildren());
-			toinspect.removeAll(inspected);
-		}
-		
-		return false;
-	}
+        Entity ancestor = descendant.getParent();
+        while (ancestor != null) {
+            if (ancestor.equals(potentialAncestor)) return true;
+            ancestor = ancestor.getParent();
+        }
+        return false;
+    }
+
+    /** note, it is usually preferred to use isAncestor() and swap the order, it is a cheaper method */
+    public static boolean isDescendant(Entity ancestor, Entity potentialDescendant) {
+        Set<Entity> inspected = Sets.newLinkedHashSet();
+        Stack<Entity> toinspect = new Stack<Entity>();
+        toinspect.add(ancestor);
+
+        while (!toinspect.isEmpty()) {
+            Entity e = toinspect.pop();
+            if (e.getChildren().contains(potentialDescendant)) {
+                return true;
+            }
+            inspected.add(e);
+            toinspect.addAll(e.getChildren());
+            toinspect.removeAll(inspected);
+        }
+
+        return false;
+    }
 
     private static final List<Entity> entitiesToStopOnShutdown = Lists.newArrayList();
     private static final AtomicBoolean isShutdownHookRegistered = new AtomicBoolean();
-    
+
     public static void invokeStopOnShutdown(Entity entity) {
         if (isShutdownHookRegistered.compareAndSet(false, true)) {
             ResourceUtils.addShutdownHook(new Runnable() {
@@ -405,9 +417,9 @@ public class Entities {
                                 log.debug("stopOnShutdown of "+entity+" returned error: "+exc, exc);
                             }
                         }
-                        for (Task t: stops) { 
+                        for (Task t: stops) {
                             try {
-                                log.debug("stopOnShutdown of {} completed: {}", t, t.get()); 
+                                log.debug("stopOnShutdown of {} completed: {}", t, t.get());
                             } catch (Exception exc) {
                                 log.debug("stopOnShutdown of "+t+" returned error: "+exc, exc);
                             }
@@ -472,10 +484,10 @@ public class Entities {
     public static boolean isManaged(Entity e) {
         return ((EntityInternal)e).getManagementSupport().isDeployed() && ((EntityInternal)e).getManagementContext().isRunning();
     }
-    
+
     /** brings this entity under management iff its ancestor is managed, returns true in that case;
      * otherwise returns false in the expectation that the ancestor will become managed,
-     * or throws exception if it has no parent or a non-application root 
+     * or throws exception if it has no parent or a non-application root
      * (will throw if e is an Application; see also {@link #startManagement(Entity)} ) */
     public static boolean manage(Entity e) {
         Entity o = e.getParent();
@@ -498,7 +510,7 @@ public class Entities {
      * (assuming root is an application).
      * returns existing management context if there is one (non-deployment),
      * or new local mgmt context if not,
-     * or throwing exception if root is not an application 
+     * or throwing exception if root is not an application
      * <p>
      * callers are recommended to use {@link #manage(Entity)} instead unless they know
      * a plain-vanilla non-root management context is sufficient (e.g. in tests)
@@ -526,7 +538,7 @@ public class Entities {
 
     /**
      * Starts managing the given (unmanaged) app, using the given management context.
-     * 
+     *
      * @see startManagement(Entity)
      */
     public static ManagementContext startManagement(Application app, ManagementContext mgmt) {
@@ -536,11 +548,11 @@ public class Entities {
         mgmt.getEntityManager().manage(app);
         return mgmt;
     }
-    
+
     /**
      * Starts managing the given (unmanaged) app, setting the given brooklyn properties on the new
      * management context.
-     * 
+     *
      * @see startManagement(Entity)
      */
     public static ManagementContext startManagement(Application app, BrooklynProperties props) {
@@ -551,11 +563,11 @@ public class Entities {
         mgmt.getEntityManager().manage(app);
         return mgmt;
     }
-    
+
     public static ManagementContext newManagementContext() {
         return new LocalManagementContext();
     }
-    
+
     public static ManagementContext newManagementContext(BrooklynProperties props) {
         return new LocalManagementContext(props);
     }
@@ -570,7 +582,12 @@ public class Entities {
         }
     }
 
-    public static <T> Supplier<T> supplier(final Entity entity, final AttributeSensor<T> sensor) {
+    public static DownloadResolver newDownloader(EntityDriver driver) {
+        EntityInternal internal = (EntityInternal) driver.getEntity();
+        return internal.getManagementContext().getEntityDownloadsManager().newDownloader(driver);
+    }
+
+    public static <T> Supplier<T> attributeSupplier(final Entity entity, final AttributeSensor<T> sensor) {
         return new Supplier<T>() {
             public T get() { return entity.getAttribute(sensor); }
         };

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b3a1b050/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
index 4133b58..06081a6 100644
--- a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
@@ -81,7 +81,7 @@ import com.google.common.collect.Sets;
  * <p>
  *  
  * This also supports giving a Supplier for the URL 
- * (e.g. {@link Entities#supplier(brooklyn.entity.Entity, brooklyn.event.AttributeSensor)})
+ * (e.g. {@link Entities#attributeSupplier(brooklyn.entity.Entity, brooklyn.event.AttributeSensor)})
  * from a sensor.  Note however that if a Supplier-based sensor is *https*,
  * https-specific initialization may not occur if the URL is not available at start time,
  * and it may report errors if that sensor is not available.

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b3a1b050/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
index d1eeab7..d438571 100644
--- a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
+++ b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
@@ -167,10 +167,10 @@ public class HttpFeedTest {
                 .suspended()
                 .build();
         Asserts.continually(MutableMap.of("timeout", 500),
-                Entities.supplier(entity, SENSOR_INT), Predicates.<Integer>equalTo(null));
+                Entities.attributeSupplier(entity, SENSOR_INT), Predicates.<Integer>equalTo(null));
         int countWhenSuspended = server.getRequestCount();
         feed.resume();
-        Asserts.eventually(Entities.supplier(entity, SENSOR_INT), Predicates.<Integer>equalTo(200));
+        Asserts.eventually(Entities.attributeSupplier(entity, SENSOR_INT), Predicates.<Integer>equalTo(200));
         if (server.getRequestCount() <= countWhenSuspended)
             Assert.fail("Request count failed to increment when feed was resumed, from "+countWhenSuspended+", still at "+server.getRequestCount());
         log.info("RUN: "+countWhenSuspended+" - "+server.getRequestCount());

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b3a1b050/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
index df9fdb0..5b92252 100644
--- a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
+++ b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
@@ -54,15 +54,15 @@ public class HttpLatencyDetectorTest {
                 build());
         // nothing until url is set
         TestUtils.assertContinuallyFromJava(MutableMap.of("timeout", 200), 
-                Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
+                Entities.attributeSupplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
                 Predicates.equalTo(null));
         entity.setAttribute(TEST_URL, "http://www.google.com");
         TestUtils.assertEventually(MutableMap.of("timeout", 10000), 
-                Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
+                Entities.attributeSupplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT), 
                 Predicates.notNull());
         log.info("Latency to "+entity.getAttribute(TEST_URL)+" is "+entity.getAttribute(HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_MOST_RECENT));
         TestUtils.assertEventually(MutableMap.of("timeout", 10000), 
-                Entities.supplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW), 
+                Entities.attributeSupplier(entity, HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW), 
                 Predicates.notNull());
         log.info("Mean latency to "+entity.getAttribute(TEST_URL)+" is "+entity.getAttribute(HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW));
     }


[28/50] brooklyn-server git commit: Merge pull request #688 from grkvlt/0.5-test-readme-location

Posted by he...@apache.org.
Merge pull request #688 from grkvlt/0.5-test-readme-location

Fix SshMachineLocationTest reference to README file

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

Branch: refs/heads/0.5.0
Commit: e366ed7b0580e0c09fa0cb66395ef1064890bd27
Parents: 5d79bc1 ab5b473
Author: Aled Sage <al...@gmail.com>
Authored: Fri Apr 19 09:00:22 2013 -0700
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Apr 19 09:00:22 2013 -0700

----------------------------------------------------------------------
 .../java/brooklyn/location/basic/SshMachineLocationTest.groovy   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[15/50] brooklyn-server git commit: Fix EntityManagementSupport race for changeListener

Posted by he...@apache.org.
Fix EntityManagementSupport race for changeListener

- Fixes race where effector called post-exec listener concurrent
  with app.stop(), which unmanaged the app.
  Caused exception, and thus test's tearDown to fail.


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

Branch: refs/heads/0.5.0
Commit: 19938ce8833b40c7b6ea990fcd77d04de3544cc9
Parents: 64da3fc
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 10 11:08:50 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Apr 10 14:29:57 2013 +0100

----------------------------------------------------------------------
 .../NonDeploymentManagementContext.java         | 61 +++++++++++++++++++-
 1 file changed, 59 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/19938ce8/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
index aed0dbb..9b915aa 100644
--- a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
@@ -5,9 +5,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import brooklyn.catalog.BrooklynCatalog;
 import brooklyn.config.StringConfigMap;
@@ -17,6 +20,7 @@ import brooklyn.entity.Entity;
 import brooklyn.entity.basic.AbstractEntity;
 import brooklyn.entity.drivers.EntityDriverManager;
 import brooklyn.entity.drivers.downloads.DownloadResolverManager;
+import brooklyn.entity.rebind.ChangeListener;
 import brooklyn.entity.rebind.RebindManager;
 import brooklyn.location.LocationRegistry;
 import brooklyn.management.EntityManager;
@@ -24,6 +28,8 @@ import brooklyn.management.ExecutionContext;
 import brooklyn.management.ExecutionManager;
 import brooklyn.management.SubscriptionContext;
 import brooklyn.management.Task;
+import brooklyn.mementos.BrooklynMemento;
+import brooklyn.mementos.BrooklynMementoPersister;
 import brooklyn.util.task.AbstractExecutionContext;
 
 public class NonDeploymentManagementContext implements ManagementContextInternal {
@@ -140,8 +146,16 @@ public class NonDeploymentManagementContext implements ManagementContextInternal
 
     @Override
     public RebindManager getRebindManager() {
-        checkInitialManagementContextReal();
-        return initialManagementContext.getRebindManager();
+        // There was a race where EffectorUtils on invoking an effector calls:
+        //     mgmtSupport.getEntityChangeListener().onEffectorCompleted(eff);
+        // but where the entity/app may be being unmanaged concurrently (e.g. calling app.stop()).
+        // So now we allow the change-listener to be called.
+        
+        if (isInitialManagementContextReal()) {
+            return initialManagementContext.getRebindManager();
+        } else {
+            return new NonDeploymentRebindManager();
+        }
     }
 
     @Override
@@ -265,4 +279,47 @@ public class NonDeploymentManagementContext implements ManagementContextInternal
             throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
         }
     }
+    
+    /**
+     * For when the initial management context is not "real"; the changeListener is a no-op, but everything else forbidden.
+     * 
+     * @author aled
+     */
+    private class NonDeploymentRebindManager implements RebindManager {
+
+        @Override
+        public ChangeListener getChangeListener() {
+            return ChangeListener.NOOP;
+        }
+
+        @Override
+        public void setPersister(BrooklynMementoPersister persister) {
+            throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
+        }
+
+        @Override
+        public BrooklynMementoPersister getPersister() {
+            throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
+        }
+
+        @Override
+        public List<Application> rebind(BrooklynMemento memento) {
+            throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
+        }
+
+        @Override
+        public List<Application> rebind(BrooklynMemento memento, ClassLoader classLoader) {
+            throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
+        }
+
+        @Override
+        public void stop() {
+            throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
+        }
+
+        @Override
+        public void waitForPendingComplete(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
+            throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
+        }
+    }
 }


[50/50] brooklyn-server git commit: Changed version to 0.5.0

Posted by he...@apache.org.
Changed version to 0.5.0


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

Branch: refs/heads/0.5.0
Commit: 8ebab0b2fd784a5df232a40f320df93b087a3981
Parents: 7a931fc
Author: David Toy <d...@vidtoy.co.uk>
Authored: Wed May 8 19:39:51 2013 +0100
Committer: David Toy <d...@vidtoy.co.uk>
Committed: Wed May 8 19:39:51 2013 +0100

----------------------------------------------------------------------
 api/pom.xml                                                      | 2 +-
 core/pom.xml                                                     | 2 +-
 locations/jclouds/pom.xml                                        | 2 +-
 policy/pom.xml                                                   | 2 +-
 pom.xml                                                          | 4 ++--
 software/base/pom.xml                                            | 2 +-
 .../base/src/main/java/brooklyn/entity/java/JmxmpSslSupport.java | 2 +-
 systems/paas/openshift/pom.xml                                   | 2 +-
 systems/whirr/base/pom.xml                                       | 2 +-
 systems/whirr/hadoop/pom.xml                                     | 2 +-
 usage/cli/pom.xml                                                | 2 +-
 usage/launcher/pom.xml                                           | 2 +-
 usage/logback-xml/pom.xml                                        | 2 +-
 usage/rest/pom.xml                                               | 2 +-
 usage/test-support/pom.xml                                       | 2 +-
 util/jmx/jmxmp-ssl-agent/pom.xml                                 | 2 +-
 util/jmx/jmxrmi-agent/pom.xml                                    | 2 +-
 17 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/api/pom.xml
----------------------------------------------------------------------
diff --git a/api/pom.xml b/api/pom.xml
index 91efb82..3d0ece5 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -13,7 +13,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 111b8ac..decf058 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -12,7 +12,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/locations/jclouds/pom.xml
----------------------------------------------------------------------
diff --git a/locations/jclouds/pom.xml b/locations/jclouds/pom.xml
index 9e07e01..317c9a1 100644
--- a/locations/jclouds/pom.xml
+++ b/locations/jclouds/pom.xml
@@ -11,7 +11,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/policy/pom.xml
----------------------------------------------------------------------
diff --git a/policy/pom.xml b/policy/pom.xml
index 281a96e..2075a91 100644
--- a/policy/pom.xml
+++ b/policy/pom.xml
@@ -11,7 +11,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6da5302..2b81323 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
 
     <groupId>io.brooklyn</groupId>
     <artifactId>brooklyn-parent</artifactId>
-    <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+    <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
 
     <name>Brooklyn Parent Project</name>
     <description>
@@ -70,7 +70,7 @@
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <brooklyn.version>0.5.0-SNAPSHOT</brooklyn.version>  <!-- BROOKLYN_VERSION -->
+        <brooklyn.version>0.5.0</brooklyn.version>  <!-- BROOKLYN_VERSION -->
 
         <cobertura.version>1.9.4.1</cobertura.version>
         <surefire.version>2.13</surefire.version>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/software/base/pom.xml
----------------------------------------------------------------------
diff --git a/software/base/pom.xml b/software/base/pom.xml
index 1083374..4dbc8d0 100644
--- a/software/base/pom.xml
+++ b/software/base/pom.xml
@@ -12,7 +12,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/software/base/src/main/java/brooklyn/entity/java/JmxmpSslSupport.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/java/JmxmpSslSupport.java b/software/base/src/main/java/brooklyn/entity/java/JmxmpSslSupport.java
index b5cae8a..6c7c5df 100644
--- a/software/base/src/main/java/brooklyn/entity/java/JmxmpSslSupport.java
+++ b/software/base/src/main/java/brooklyn/entity/java/JmxmpSslSupport.java
@@ -20,7 +20,7 @@ import brooklyn.util.jmx.jmxmp.JmxmpAgent;
 
 public class JmxmpSslSupport {
 
-    final static String BROOKLYN_VERSION = "0.5.0-SNAPSHOT";  // BROOKLYN_VERSION (updated by script)
+    final static String BROOKLYN_VERSION = "0.5.0";  // BROOKLYN_VERSION (updated by script)
     
     protected final JavaSoftwareProcessSshDriver driver;
     

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/systems/paas/openshift/pom.xml
----------------------------------------------------------------------
diff --git a/systems/paas/openshift/pom.xml b/systems/paas/openshift/pom.xml
index c0a8709..4935762 100644
--- a/systems/paas/openshift/pom.xml
+++ b/systems/paas/openshift/pom.xml
@@ -10,7 +10,7 @@
 	<parent>
 		<groupId>io.brooklyn</groupId>
 		<artifactId>brooklyn-parent</artifactId>
-		<version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+		<version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
 		<relativePath>../../../pom.xml</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/systems/whirr/base/pom.xml
----------------------------------------------------------------------
diff --git a/systems/whirr/base/pom.xml b/systems/whirr/base/pom.xml
index 6ecaef5..acd802b 100644
--- a/systems/whirr/base/pom.xml
+++ b/systems/whirr/base/pom.xml
@@ -11,7 +11,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/systems/whirr/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/systems/whirr/hadoop/pom.xml b/systems/whirr/hadoop/pom.xml
index 6f4421a..3e1e5c1 100644
--- a/systems/whirr/hadoop/pom.xml
+++ b/systems/whirr/hadoop/pom.xml
@@ -10,7 +10,7 @@
 	<parent>
 		<groupId>io.brooklyn</groupId>
 		<artifactId>brooklyn-parent</artifactId>
-		<version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+		<version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
 		<relativePath>../../../pom.xml</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/usage/cli/pom.xml
----------------------------------------------------------------------
diff --git a/usage/cli/pom.xml b/usage/cli/pom.xml
index 78c5e92..aab84b7 100644
--- a/usage/cli/pom.xml
+++ b/usage/cli/pom.xml
@@ -13,7 +13,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/usage/launcher/pom.xml
----------------------------------------------------------------------
diff --git a/usage/launcher/pom.xml b/usage/launcher/pom.xml
index 05b19ea..410b621 100644
--- a/usage/launcher/pom.xml
+++ b/usage/launcher/pom.xml
@@ -14,7 +14,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/usage/logback-xml/pom.xml
----------------------------------------------------------------------
diff --git a/usage/logback-xml/pom.xml b/usage/logback-xml/pom.xml
index 5c610a6..ad9de5e 100644
--- a/usage/logback-xml/pom.xml
+++ b/usage/logback-xml/pom.xml
@@ -16,7 +16,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/usage/rest/pom.xml
----------------------------------------------------------------------
diff --git a/usage/rest/pom.xml b/usage/rest/pom.xml
index 1aa22dd..9a8f908 100644
--- a/usage/rest/pom.xml
+++ b/usage/rest/pom.xml
@@ -11,7 +11,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version><!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version><!-- BROOKLYN_VERSION -->
         <relativePath>../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/usage/test-support/pom.xml
----------------------------------------------------------------------
diff --git a/usage/test-support/pom.xml b/usage/test-support/pom.xml
index 25da9ad..f037ee1 100644
--- a/usage/test-support/pom.xml
+++ b/usage/test-support/pom.xml
@@ -10,7 +10,7 @@
 	<parent>
 		<groupId>io.brooklyn</groupId>
 		<artifactId>brooklyn-parent</artifactId>
-		<version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+		<version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
 		<relativePath>../../pom.xml</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/util/jmx/jmxmp-ssl-agent/pom.xml
----------------------------------------------------------------------
diff --git a/util/jmx/jmxmp-ssl-agent/pom.xml b/util/jmx/jmxmp-ssl-agent/pom.xml
index 82abbae..d4bc283 100644
--- a/util/jmx/jmxmp-ssl-agent/pom.xml
+++ b/util/jmx/jmxmp-ssl-agent/pom.xml
@@ -14,7 +14,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../../pom.xml</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8ebab0b2/util/jmx/jmxrmi-agent/pom.xml
----------------------------------------------------------------------
diff --git a/util/jmx/jmxrmi-agent/pom.xml b/util/jmx/jmxrmi-agent/pom.xml
index 30455c7..f35e9e2 100644
--- a/util/jmx/jmxrmi-agent/pom.xml
+++ b/util/jmx/jmxrmi-agent/pom.xml
@@ -14,7 +14,7 @@
     <parent>
         <groupId>io.brooklyn</groupId>
         <artifactId>brooklyn-parent</artifactId>
-        <version>0.5.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <version>0.5.0</version>  <!-- BROOKLYN_VERSION -->
         <relativePath>../../../pom.xml</relativePath>
     </parent>
 


[09/50] brooklyn-server git commit: Deletes ApplicationBuilder.Builder

Posted by he...@apache.org.
Deletes ApplicationBuilder.Builder

- Removes the Builder
- Adds ApplicationBuilder.newManagedApp(...) for use
  by tests.


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

Branch: refs/heads/0.5.0
Commit: f19185a6ce420d51c2758e0af2483c9e126eaef2
Parents: 7dbfb88
Author: Aled Sage <al...@gmail.com>
Authored: Thu Mar 28 16:12:39 2013 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Apr 1 12:41:41 2013 +0100

----------------------------------------------------------------------
 .../entity/basic/ApplicationBuilder.java        | 140 ++++---------------
 .../enricher/CombiningEnricherTest.groovy       |   2 +-
 .../CustomAggregatingEnricherTest.groovy        |   2 +-
 .../SensorPropagatingEnricherTest.groovy        |   2 +-
 .../enricher/TransformingEnricherTest.groovy    |   2 +-
 .../entity/EntityPreManagementTest.java         |   2 +-
 .../entity/basic/AbstractEntityLegacyTest.java  |   6 +-
 .../entity/basic/DynamicGroupTest.groovy        |   2 +-
 .../entity/basic/EffectorBasicTest.java         |   2 +-
 .../entity/basic/EntityConfigMapUsageTest.java  |   2 +-
 .../entity/basic/EntitySubscriptionTest.groovy  |   2 +-
 .../brooklyn/entity/basic/EntityTypeTest.java   |   2 +-
 ...apListAndOtherStructuredConfigKeyTest.groovy |   2 +-
 .../entity/basic/PolicyRegistrationTest.java    |   2 +-
 .../downloads/BasicDownloadsRegistryTest.java   |   2 +-
 .../DownloadProducerFromLocalRepoTest.java      |   2 +-
 .../DownloadProducerFromPropertiesTest.java     |   2 +-
 .../downloads/DownloadSubstitutersTest.java     |   2 +-
 .../entity/group/DynamicClusterTest.groovy      |   2 +-
 .../entity/group/DynamicFabricTest.groovy       |   2 +-
 .../group/MembershipTrackingPolicyTest.java     |   2 +-
 .../ApplicationBuilderBuildingTest.java         | 137 ------------------
 .../entity/proxying/EntityManagerTest.java      |   2 +-
 .../entity/proxying/EntityProxyTest.java        |   2 +-
 .../event/feed/function/FunctionFeedTest.java   |   2 +-
 .../feed/http/HttpFeedSslIntegrationTest.java   |   2 +-
 .../brooklyn/event/feed/http/HttpFeedTest.java  |   2 +-
 .../feed/shell/ShellFeedIntegrationTest.java    |   2 +-
 .../event/feed/ssh/SshFeedIntegrationTest.java  |   2 +-
 ...stMachineProvisioningLocationRebindTest.java |   2 +-
 .../basic/TestPortSupplierLocation.groovy       |   2 +-
 .../internal/EntityExecutionManagerTest.groovy  |  12 +-
 .../internal/LocalSubscriptionManagerTest.java  |   2 +-
 .../policy/basic/PolicyConfigMapUsageTest.java  |   2 +-
 .../policy/basic/PolicySubscriptionTest.groovy  |   2 +-
 .../location/jclouds/CloudMachineNamerTest.java |   2 +-
 .../enricher/HttpLatencyDetectorTest.java       |   2 +-
 .../enricher/TimeFractionDeltaEnricherTest.java |   2 +-
 .../entity/brooklyn/BrooklynMetricsTest.groovy  |   2 +-
 .../autoscaling/AutoScalerPolicyMetricTest.java |   2 +-
 .../AutoScalerPolicyReconfigurationTest.java    |   2 +-
 .../ha/MemberFailureDetectionPolicyTest.java    |   2 +-
 .../brooklyn/entity/AbstractEc2LiveTest.java    |   2 +-
 .../basic/SoftwareProcessEntityTest.groovy      |   2 +-
 .../hadoop/WhirrHadoopClusterLiveTest.java      |   2 +-
 .../rest/util/BrooklynRestResourceUtils.java    |  32 ++---
 .../brooklyn/rest/domain/SensorSummaryTest.java |   2 +-
 47 files changed, 92 insertions(+), 319 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java b/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
index 522a3d0..6164b31 100644
--- a/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
+++ b/core/src/main/java/brooklyn/entity/basic/ApplicationBuilder.java
@@ -2,15 +2,12 @@ package brooklyn.entity.basic;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
-import java.lang.reflect.Modifier;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.entity.Application;
 import brooklyn.entity.Entity;
 import brooklyn.entity.proxying.BasicEntitySpec;
 import brooklyn.entity.proxying.EntitySpec;
@@ -18,16 +15,9 @@ import brooklyn.entity.proxying.EntitySpecs;
 import brooklyn.management.EntityManager;
 import brooklyn.management.ManagementContext;
 
-import com.google.common.collect.Lists;
-
 /**
- * For building an application. There are two ways to use this:
- * <ul>
- *   <li>By sub-classing and overriding doBuild(), putting the logic for creating and wiring 
- *       together entities in there.
- *   <li>As a conventional builder, using ApplicationBuilder.build().
- *       This is simpler to use, but less powerful for injecting configuration of one entity into other entities.
- * </ul>
+ * For building an application. Users can sub-class and override doBuild(), putting the logic for  
+ * creating and wiring together entities in there.
  * 
  * The builder is mutable; a given instance should be used to build only a single application.
  * Once {@link manage()} has been called, the application will be built and no additional configuration
@@ -45,15 +35,6 @@ import com.google.common.collect.Lists;
  *   }.manage();
  * </code>
  * 
- * And example code for using the builder:
- * 
- * <code>
- *   app = ApplicationBuilder.builder()
- *           .child(EntitySpecs.spec(MySqlNode.class))
- *           .child(EntitySpecs.spec(JBoss7Server.class))
- *           .manage();
- * </code>
- * 
  * @author aled
  */
 public abstract class ApplicationBuilder {
@@ -61,110 +42,39 @@ public abstract class ApplicationBuilder {
     @SuppressWarnings("unused")
     private static final Logger LOG = LoggerFactory.getLogger(ApplicationBuilder.class);
 
-    /**
-     * @deprecated since 0.5.0-rc.1 (added in 0.5.0-M2)
-     */
-    public static <T extends StartableApplication> BasicEntitySpec<StartableApplication, ?> newAppSpec(Class<? extends T> type) {
-        return EntitySpecs.appSpec(type);
+    @SuppressWarnings("unchecked")
+    public static <T extends StartableApplication> T newManagedApp(Class<T> type) {
+        return (T) newManagedApp(EntitySpecs.appSpec(type));
     }
 
-    public static Builder<StartableApplication> builder() {
-        return new Builder<StartableApplication>().app(EntitySpecs.spec(BasicApplication.class));
+    @SuppressWarnings("unchecked")
+    public static <T extends StartableApplication> T newManagedApp(EntitySpec<T> spec) {
+        return (T) new ApplicationBuilder(spec) {
+            @Override protected void doBuild() {
+            }
+        }.manage();
     }
 
-    public static <T extends Application> Builder<T> builder(EntitySpec<T> appSpec) {
-        return new Builder<T>().app(appSpec);
+    @SuppressWarnings("unchecked")
+    public static <T extends StartableApplication> T newManagedApp(Class<T> type, ManagementContext managementContext) {
+        return (T) newManagedApp(EntitySpecs.appSpec(type), managementContext);
     }
 
-    /** smart builder factory method which takes an interface type _or_ an implementation type */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    public static <T extends Application,U extends T> Builder<T> builder(Class<? extends T> type) {
-        // TODO Don't think we want to handle abstract classes like this; it's not an interface so can't be
-        // used for proxying
-        if (type.isInterface() || ((type.getModifiers() & Modifier.ABSTRACT)!=0))
-            // is interface or abstract
-            return new Builder<T>().app(type);
-        else {
-            // is implementation
-            Class interfaceType = (StartableApplication.class.isAssignableFrom(type)) ? StartableApplication.class : Application.class;
-            Class<?>[] additionalInterfaceClazzes = type.getInterfaces();
-            EntitySpec<T> spec = EntitySpecs.spec((Class<T>)interfaceType, (Class<U>)type)
-                    .additionalInterfaces(additionalInterfaceClazzes);
-            return new Builder<T>().app(spec);
-        }
+    @SuppressWarnings("unchecked")
+    public static <T extends StartableApplication> T newManagedApp(EntitySpec<T> spec, ManagementContext managementContext) {
+        return (T) new ApplicationBuilder(spec) {
+            @Override protected void doBuild() {
+            }
+        }.manage(managementContext);
     }
 
-    public static <T extends Application> Builder<T> builder(Class<T> interfaceType, Class<T> implType) {
-        return new Builder<T>().app(EntitySpecs.spec(interfaceType, implType));
+    /**
+     * @deprecated since 0.5.0-rc.1 (added in 0.5.0-M2)
+     */
+    public static <T extends StartableApplication> BasicEntitySpec<StartableApplication, ?> newAppSpec(Class<? extends T> type) {
+        return EntitySpecs.appSpec(type);
     }
 
-    public static class Builder<T extends Application> {
-        protected volatile boolean managed = false;
-        private BasicEntitySpec<T, ?> appSpec;
-        private List<EntitySpec<?>> childSpecs = Lists.newArrayList();
-        
-        // Use static builder methods
-        protected Builder() {}
-        
-        // Use static builder methods
-        protected Builder<T> app(EntitySpec<? extends T> val) {
-            checkNotManaged();
-            this.appSpec = EntitySpecs.wrapSpec(val); 
-            return this;
-        }
-        
-        // Use static builder methods
-        @SuppressWarnings("unchecked")
-        protected Builder<T> app(Class<? extends T> type) {
-            checkNotManaged();
-            this.appSpec = EntitySpecs.spec((Class<T>)type); 
-            return this;
-        }
-        
-        public Builder<T> appImpl(Class<? extends T> val) {
-            checkNotManaged();
-            appSpec.impl(val);
-            return this;
-        }
-        
-        public Builder<T> displayName(String val) {
-            checkNotManaged();
-            appSpec.displayName(val);
-            return this;
-        }
-        
-        public final Builder<T> configure(Map<?,?> config) {
-            appSpec.configure(config);
-            return this;
-        }
-
-        public Builder<T> child(EntitySpec<?> val) {
-            checkNotManaged();
-            childSpecs.add(val);
-            return this;
-        }
-        
-        public final T manage() {
-            return manage(Entities.newManagementContext());
-        }
-        
-        public final T manage(ManagementContext managementContext) {
-            checkNotManaged();
-            managed = true;
-            T app = managementContext.getEntityManager().createEntity(appSpec);
-            for (EntitySpec<?> childSpec : childSpecs) {
-                Entity child = managementContext.getEntityManager().createEntity(childSpec);
-                app.addChild(child);
-            }
-            Entities.startManagement(app, managementContext);
-            return app;
-        }
-        
-        protected void checkNotManaged() {
-            if (managed) throw new IllegalStateException("Builder already managed; cannot perform operation after call to manage()");
-        }
-    }
-    
     protected volatile boolean managed = false;
     protected final AtomicBoolean inManage = new AtomicBoolean(false);
     private BasicEntitySpec<? extends StartableApplication, ?> appSpec;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/enricher/CombiningEnricherTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/enricher/CombiningEnricherTest.groovy b/core/src/test/java/brooklyn/enricher/CombiningEnricherTest.groovy
index 00d78cd..f9fc81a 100644
--- a/core/src/test/java/brooklyn/enricher/CombiningEnricherTest.groovy
+++ b/core/src/test/java/brooklyn/enricher/CombiningEnricherTest.groovy
@@ -32,7 +32,7 @@ class CombiningEnricherTest {
 
     @BeforeMethod(alwaysRun=true)
     public void before() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         producer = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         intSensorA = new BasicAttributeSensor<Integer>(Integer.class, "int.sensor.a");
         intSensorB = new BasicAttributeSensor<Integer>(Integer.class, "int.sensor.b");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/enricher/CustomAggregatingEnricherTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/enricher/CustomAggregatingEnricherTest.groovy b/core/src/test/java/brooklyn/enricher/CustomAggregatingEnricherTest.groovy
index b840c4b..dcb8eaf 100644
--- a/core/src/test/java/brooklyn/enricher/CustomAggregatingEnricherTest.groovy
+++ b/core/src/test/java/brooklyn/enricher/CustomAggregatingEnricherTest.groovy
@@ -38,7 +38,7 @@ class CustomAggregatingEnricherTest {
 
     @BeforeMethod(alwaysRun=true)
     public void before() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         producer = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor")
         target = new BasicAttributeSensor<Integer>(Long.class, "target sensor")

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy b/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy
index 53fc9d5..c4615d9 100644
--- a/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy
+++ b/core/src/test/java/brooklyn/enricher/SensorPropagatingEnricherTest.groovy
@@ -16,7 +16,7 @@ class SensorPropagatingEnricherTest {
 
     @Test
     public void testPropagation() {
-        TestApplication app = ApplicationBuilder.builder(TestApplication.class).manage();
+        TestApplication app = ApplicationBuilder.newManagedApp(TestApplication.class);
         TestEntity entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         
         app.addEnricher(SensorPropagatingEnricher.newInstanceListeningToAllSensorsBut(entity, TestEntity.SEQUENCE)) 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/enricher/TransformingEnricherTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/enricher/TransformingEnricherTest.groovy b/core/src/test/java/brooklyn/enricher/TransformingEnricherTest.groovy
index d3dfa2b..a0f074d 100644
--- a/core/src/test/java/brooklyn/enricher/TransformingEnricherTest.groovy
+++ b/core/src/test/java/brooklyn/enricher/TransformingEnricherTest.groovy
@@ -35,7 +35,7 @@ public class TransformingEnricherTest {
 
     @BeforeMethod()
     public void before() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         producer = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         intSensorA = new BasicAttributeSensor<Integer>(Integer.class, "int.sensor.a");
         target = new BasicAttributeSensor<Long>(Long.class, "long.sensor.target");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/EntityPreManagementTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/EntityPreManagementTest.java b/core/src/test/java/brooklyn/entity/EntityPreManagementTest.java
index 10ade62..47b2f3e 100644
--- a/core/src/test/java/brooklyn/entity/EntityPreManagementTest.java
+++ b/core/src/test/java/brooklyn/entity/EntityPreManagementTest.java
@@ -80,7 +80,7 @@ public class EntityPreManagementTest {
         if (!events.isEmpty()) Assert.fail("Shouldn't have events yet: "+events);
         Assert.assertFalse(e.getManagementSupport().isManagementContextReal());
         
-        TestApplication app = ApplicationBuilder.builder(TestApplication.class).manage(managementContext);
+        TestApplication app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
         e.setParent(app);
         Entities.manage(e);
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java b/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
index 7d9a411..fa5d8ed 100644
--- a/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
@@ -91,7 +91,7 @@ public class AbstractEntityLegacyTest {
     
     @Test
     public void testNewStyleCallsConfigureAfterConstruction() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         MyEntity entity = app.createChild(EntitySpecs.spec(MyEntity.class));
         
         assertEquals(entity.getConfigureCount(), 1);
@@ -122,7 +122,7 @@ public class AbstractEntityLegacyTest {
     
     @Test
     public void testNewStyleSetsDefaultDisplayName() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         MyEntity entity = app.createChild(EntitySpecs.spec(MyEntity.class));
         
         assertTrue(entity.getDisplayName().startsWith("MyEntity:"+entity.getId().substring(0,4)), "displayName="+entity.getDisplayName());
@@ -130,7 +130,7 @@ public class AbstractEntityLegacyTest {
     
     @Test
     public void testNewStyleUsesCustomDisplayName() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).displayName("appname").manage();
+        app = ApplicationBuilder.newManagedApp(EntitySpecs.spec(TestApplication.class).displayName("appname"));
         MyEntity entity = app.createChild(EntitySpecs.spec(MyEntity.class).displayName("entityname"));
         
         assertEquals(app.getDisplayName(), "appname");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/DynamicGroupTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/DynamicGroupTest.groovy b/core/src/test/java/brooklyn/entity/basic/DynamicGroupTest.groovy
index e1245d1..45110fb 100644
--- a/core/src/test/java/brooklyn/entity/basic/DynamicGroupTest.groovy
+++ b/core/src/test/java/brooklyn/entity/basic/DynamicGroupTest.groovy
@@ -42,7 +42,7 @@ public class DynamicGroupTest {
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         group = app.createAndManageChild(EntitySpecs.spec(DynamicGroup.class));
         e1 = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         e2 = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/EffectorBasicTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/EffectorBasicTest.java b/core/src/test/java/brooklyn/entity/basic/EffectorBasicTest.java
index ec0c4b8..454b677 100644
--- a/core/src/test/java/brooklyn/entity/basic/EffectorBasicTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/EffectorBasicTest.java
@@ -33,7 +33,7 @@ public class EffectorBasicTest {
     
     @BeforeMethod(alwaysRun=true)
     public void setup() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         locs = ImmutableList.of(new SimulatedLocation());
     }
     

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java b/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
index 4e21039..b5efd58 100644
--- a/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/EntityConfigMapUsageTest.java
@@ -41,7 +41,7 @@ public class EntityConfigMapUsageTest {
     
     @BeforeMethod
     public void setUp() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         locs = ImmutableList.of(new SimulatedLocation());
     }
     

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/EntitySubscriptionTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/EntitySubscriptionTest.groovy b/core/src/test/java/brooklyn/entity/basic/EntitySubscriptionTest.groovy
index 625cfb0..d44205e 100644
--- a/core/src/test/java/brooklyn/entity/basic/EntitySubscriptionTest.groovy
+++ b/core/src/test/java/brooklyn/entity/basic/EntitySubscriptionTest.groovy
@@ -38,7 +38,7 @@ public class EntitySubscriptionTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
         loc = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         observedEntity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         observedChildEntity = observedEntity.createAndManageChild(EntitySpecs.spec(TestEntity.class));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/EntityTypeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/EntityTypeTest.java b/core/src/test/java/brooklyn/entity/basic/EntityTypeTest.java
index 715d333..4e444e6 100644
--- a/core/src/test/java/brooklyn/entity/basic/EntityTypeTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/EntityTypeTest.java
@@ -35,7 +35,7 @@ public class EntityTypeTest {
     
     @BeforeMethod
     public void setUpTestEntity() throws Exception{
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = new AbstractEntity(app) {};
         Entities.startManagement(entity);
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/MapListAndOtherStructuredConfigKeyTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/MapListAndOtherStructuredConfigKeyTest.groovy b/core/src/test/java/brooklyn/entity/basic/MapListAndOtherStructuredConfigKeyTest.groovy
index 27979e2..4a1061f 100644
--- a/core/src/test/java/brooklyn/entity/basic/MapListAndOtherStructuredConfigKeyTest.groovy
+++ b/core/src/test/java/brooklyn/entity/basic/MapListAndOtherStructuredConfigKeyTest.groovy
@@ -28,7 +28,7 @@ public class MapListAndOtherStructuredConfigKeyTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
         locs = ImmutableList.of(new SimulatedLocation());
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/basic/PolicyRegistrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/PolicyRegistrationTest.java b/core/src/test/java/brooklyn/entity/basic/PolicyRegistrationTest.java
index 84cf141..207388e 100644
--- a/core/src/test/java/brooklyn/entity/basic/PolicyRegistrationTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/PolicyRegistrationTest.java
@@ -38,7 +38,7 @@ public class PolicyRegistrationTest {
 
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         policy1 = new AbstractPolicy() {};
         policy2 = new AbstractPolicy() {};

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/drivers/downloads/BasicDownloadsRegistryTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/drivers/downloads/BasicDownloadsRegistryTest.java b/core/src/test/java/brooklyn/entity/drivers/downloads/BasicDownloadsRegistryTest.java
index a86b05e..9977831 100644
--- a/core/src/test/java/brooklyn/entity/drivers/downloads/BasicDownloadsRegistryTest.java
+++ b/core/src/test/java/brooklyn/entity/drivers/downloads/BasicDownloadsRegistryTest.java
@@ -37,7 +37,7 @@ public class BasicDownloadsRegistryTest {
         managementContext = new LocalManagementContext(brooklynProperties);
 
         loc = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage(managementContext);
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         driver = new MyEntityDriver(entity, loc);
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java b/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
index 025e076..bc2dc2b 100644
--- a/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
+++ b/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
@@ -41,7 +41,7 @@ public class DownloadProducerFromLocalRepoTest {
         managementContext = new LocalManagementContext(brooklynProperties);
         
         loc = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage(managementContext);
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         driver = new MyEntityDriver(entity, loc);
         entitySimpleType = TestEntity.class.getSimpleName();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java b/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
index 9b0e71d..2afb619 100644
--- a/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
+++ b/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
@@ -41,7 +41,7 @@ public class DownloadProducerFromPropertiesTest {
         managementContext = new LocalManagementContext(brooklynProperties);
         
         loc = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage(managementContext);
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         driver = new MyEntityDriver(entity, loc);
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadSubstitutersTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadSubstitutersTest.java b/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadSubstitutersTest.java
index 3eb4731..467c312 100644
--- a/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadSubstitutersTest.java
+++ b/core/src/test/java/brooklyn/entity/drivers/downloads/DownloadSubstitutersTest.java
@@ -33,7 +33,7 @@ public class DownloadSubstitutersTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         loc = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         driver = new MyEntityDriver(entity, loc);
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy b/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
index 11d2373..0d138ad 100644
--- a/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
+++ b/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
@@ -46,7 +46,7 @@ class DynamicClusterTest {
     
     @BeforeMethod
     public void setUp() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         loc = new SimulatedLocation()
         loc2 = new SimulatedLocation()
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.groovy b/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.groovy
index b914e3d..b693b50 100644
--- a/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.groovy
+++ b/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.groovy
@@ -51,7 +51,7 @@ class DynamicFabricTest {
         loc1 = new SimulatedLocation()
         loc2 = new SimulatedLocation()
         loc3 = new SimulatedLocation()
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java b/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
index ab60ebb..a2d2257 100644
--- a/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
+++ b/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
@@ -39,7 +39,7 @@ public class MembershipTrackingPolicyTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
         loc = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entityManager = app.getManagementContext().getEntityManager();
         
         group = app.createAndManageChild(EntitySpecs.spec(BasicGroup.class)

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/proxying/ApplicationBuilderBuildingTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/proxying/ApplicationBuilderBuildingTest.java b/core/src/test/java/brooklyn/entity/proxying/ApplicationBuilderBuildingTest.java
deleted file mode 100644
index f334115..0000000
--- a/core/src/test/java/brooklyn/entity/proxying/ApplicationBuilderBuildingTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package brooklyn.entity.proxying;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.AbstractEntity;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.BasicApplication;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.EntityInternal;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.injava.ExampleJavaPolicy;
-import brooklyn.management.ManagementContext;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.test.entity.TestEntity;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-public class ApplicationBuilderBuildingTest {
-
-    private Application app;
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() {
-        if (app != null) Entities.destroy(app);
-        app = null;
-    }
-
-    @Test
-    public void testUsesDefaultBasicApplicationClass() {
-        app = ApplicationBuilder.builder().manage();
-        
-        assertEquals(app.getEntityType().getName(), BasicApplication.class.getCanonicalName());
-        assertIsProxy(app);
-    }
-    
-    @Test
-    public void testUsesSuppliedApplicationClass() {
-        app = ApplicationBuilder.builder(EntitySpecs.spec(TestApplication.class)).manage();
-        
-        assertEquals(app.getEntityType().getName(), TestApplication.class.getName());
-    }
-
-    @Test
-    public void testUsesSuppliedManagementContext() {
-        ManagementContext managementContext = Entities.newManagementContext();
-        app = ApplicationBuilder.builder().manage(managementContext);
-        
-        assertEquals(app.getManagementContext(), managementContext);
-    }
-
-    @Test
-    public void testCreatesChildEntity() {
-        app = ApplicationBuilder.builder()
-                .child(TestEntity.Spec.newInstance())
-                .manage();
-        Entity child = Iterables.getOnlyElement(app.getChildren());
-        
-        assertIsProxy(child);
-        assertEquals(child.getParent(), app);
-        assertTrue(child instanceof TestEntity, "child="+child);
-    }
-
-    @Test
-    public void testCreatesEntityWithPolicy() {
-        ExampleJavaPolicy policy = new ExampleJavaPolicy();
-        app = ApplicationBuilder.builder()
-                .child(TestEntity.Spec.newInstance().policy(policy))
-                .manage();
-        Entity child = Iterables.getOnlyElement(app.getChildren());
-        
-        assertEquals(ImmutableList.copyOf(child.getPolicies()), ImmutableList.of(policy));
-    }
-
-    @Test
-    public void testAppHierarchyIsManaged() {
-        app = ApplicationBuilder.builder()
-                .child(TestEntity.Spec.newInstance())
-                .manage();
-        
-        assertIsManaged(app);
-        assertIsManaged(Iterables.getOnlyElement(app.getChildren()));
-    }
-
-    @Test
-    public void testCreateAppFromImplClass() {
-        app = ApplicationBuilder.builder(MyApplicationImpl.class).manage();
-        
-        assertTrue(app instanceof EntityProxy);
-        assertTrue(app instanceof MyInterface);
-        assertFalse(app instanceof MyApplicationImpl);
-        assertEquals(app.getEntityType().getName(), MyApplicationImpl.class.getCanonicalName());
-    }
-
-    @Test
-    public void testCreateAppSpecUsingInterface() {
-        BasicEntitySpec<StartableApplication, ?> spec = EntitySpecs.appSpec(TestApplication.class);
-        app = ApplicationBuilder.builder(spec).manage();
-        
-        assertEquals(app.getEntityType().getName(), TestApplication.class.getCanonicalName());
-    }
-    
-    @Test
-    public void testCreatesAppSpecUsingImplClass() {
-        BasicEntitySpec<StartableApplication, ?> spec = EntitySpecs.appSpec(MyApplicationImpl.class);
-        app = ApplicationBuilder.builder(spec).manage();
-        
-        assertTrue(app instanceof EntityProxy);
-        assertTrue(app instanceof MyInterface);
-        assertFalse(app instanceof MyApplicationImpl);
-        assertEquals(app.getEntityType().getName(), MyApplicationImpl.class.getCanonicalName());
-    }
-    
-    private void assertIsProxy(Entity e) {
-        assertFalse(e instanceof AbstractEntity, "e="+e+";e.class="+e.getClass());
-        assertTrue(e instanceof EntityProxy, "e="+e+";e.class="+e.getClass());
-    }
-    
-    private void assertIsManaged(Entity e) {
-        assertTrue(((EntityInternal)e).getManagementSupport().isDeployed(), "e="+e);
-    }
-    
-    public interface MyInterface {
-    }
-    
-    public static class MyApplicationImpl extends AbstractApplication implements MyInterface {
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/proxying/EntityManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/proxying/EntityManagerTest.java b/core/src/test/java/brooklyn/entity/proxying/EntityManagerTest.java
index 6ae5dd4..f30f518 100644
--- a/core/src/test/java/brooklyn/entity/proxying/EntityManagerTest.java
+++ b/core/src/test/java/brooklyn/entity/proxying/EntityManagerTest.java
@@ -25,7 +25,7 @@ public class EntityManagerTest {
 
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
     }
     
     @AfterMethod(alwaysRun=true)

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/entity/proxying/EntityProxyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/proxying/EntityProxyTest.java b/core/src/test/java/brooklyn/entity/proxying/EntityProxyTest.java
index 2ef81b5..cff2c6e 100644
--- a/core/src/test/java/brooklyn/entity/proxying/EntityProxyTest.java
+++ b/core/src/test/java/brooklyn/entity/proxying/EntityProxyTest.java
@@ -37,7 +37,7 @@ public class EntityProxyTest {
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(TestEntity.Spec.newInstance());
         managementContext = app.getManagementContext();
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/event/feed/function/FunctionFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/function/FunctionFeedTest.java b/core/src/test/java/brooklyn/event/feed/function/FunctionFeedTest.java
index fb03cae..49c5fb8 100644
--- a/core/src/test/java/brooklyn/event/feed/function/FunctionFeedTest.java
+++ b/core/src/test/java/brooklyn/event/feed/function/FunctionFeedTest.java
@@ -46,7 +46,7 @@ public class FunctionFeedTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         loc = new LocalhostMachineProvisioningLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         app.start(ImmutableList.of(loc));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/event/feed/http/HttpFeedSslIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/http/HttpFeedSslIntegrationTest.java b/core/src/test/java/brooklyn/event/feed/http/HttpFeedSslIntegrationTest.java
index 834a638..7b367cc 100644
--- a/core/src/test/java/brooklyn/event/feed/http/HttpFeedSslIntegrationTest.java
+++ b/core/src/test/java/brooklyn/event/feed/http/HttpFeedSslIntegrationTest.java
@@ -47,7 +47,7 @@ public class HttpFeedSslIntegrationTest {
         baseUrl = new URI(httpService.getUrl());
 
         loc = new LocalhostMachineProvisioningLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         app.start(ImmutableList.of(loc));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
index a3dd3f1..5da0893 100644
--- a/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
+++ b/core/src/test/java/brooklyn/event/feed/http/HttpFeedTest.java
@@ -62,7 +62,7 @@ public class HttpFeedTest {
         baseUrl = server.getUrl("/");
 
         loc = new LocalhostMachineProvisioningLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         app.start(ImmutableList.of(loc));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/event/feed/shell/ShellFeedIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/shell/ShellFeedIntegrationTest.java b/core/src/test/java/brooklyn/event/feed/shell/ShellFeedIntegrationTest.java
index 184bfcf..817c860 100644
--- a/core/src/test/java/brooklyn/event/feed/shell/ShellFeedIntegrationTest.java
+++ b/core/src/test/java/brooklyn/event/feed/shell/ShellFeedIntegrationTest.java
@@ -43,7 +43,7 @@ public class ShellFeedIntegrationTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         loc = new LocalhostMachineProvisioningLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         app.start(ImmutableList.of(loc));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java b/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
index 6040332..80dd7b8 100644
--- a/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
+++ b/core/src/test/java/brooklyn/event/feed/ssh/SshFeedIntegrationTest.java
@@ -38,7 +38,7 @@ public class SshFeedIntegrationTest {
     public void setUp() throws Exception {
         loc = new LocalhostMachineProvisioningLocation();
         machine = loc.obtain();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         app.start(ImmutableList.of(loc));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/location/basic/FixedListMachineProvisioningLocationRebindTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/FixedListMachineProvisioningLocationRebindTest.java b/core/src/test/java/brooklyn/location/basic/FixedListMachineProvisioningLocationRebindTest.java
index 4001471..3862f11 100644
--- a/core/src/test/java/brooklyn/location/basic/FixedListMachineProvisioningLocationRebindTest.java
+++ b/core/src/test/java/brooklyn/location/basic/FixedListMachineProvisioningLocationRebindTest.java
@@ -43,7 +43,7 @@ public class FixedListMachineProvisioningLocationRebindTest {
     			.keyData("myKeyData")
     			.keyPassphrase("myKeyPassphrase")
     			.build();
-        origApp = ApplicationBuilder.builder(TestApplication.class).manage(managementContext);
+        origApp = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
     	origApp.start(ImmutableList.of(origLoc));
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.groovy b/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.groovy
index 8a59b09..ee909a9 100644
--- a/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.groovy
+++ b/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.groovy
@@ -20,7 +20,7 @@ public class TestPortSupplierLocation {
     @BeforeMethod
     public void setup() {
         l = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         e = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         app.start([l]);
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.groovy b/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.groovy
index f7fe579..536b806 100644
--- a/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.groovy
+++ b/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.groovy
@@ -47,7 +47,7 @@ class EntityExecutionManagerTest {
 
     @Test
     public void testGetTasksOfEntity() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         e = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         
         CountDownLatch latch = new CountDownLatch(1)
@@ -60,7 +60,7 @@ class EntityExecutionManagerTest {
     
     @Test
     public void testUnmanagedEntityCanBeGcedEvenIfPreviouslyTagged() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         e = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         String eId = e.getId();
         
@@ -86,7 +86,7 @@ class EntityExecutionManagerTest {
     
     @Test(groups="Integration")
     public void testUnmanagedEntityGcedOnUnmanageEvenIfEffectorInvoked() throws Exception {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         
         BasicAttributeSensor byteArrayAttrib = new BasicAttributeSensor(Object.class, "test.byteArray", "");
 
@@ -115,7 +115,7 @@ class EntityExecutionManagerTest {
         brooklynProperties.put(BrooklynGarbageCollector.GC_PERIOD, 1);
         brooklynProperties.put(BrooklynGarbageCollector.MAX_TASKS_PER_TAG, 2);
         
-        app = ApplicationBuilder.builder(TestApplication.class).manage(Entities.newManagementContext(brooklynProperties));
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, Entities.newManagementContext(brooklynProperties));
         TestEntity entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         
         for (int i = 0; i < 1000; i++) {
@@ -139,7 +139,7 @@ class EntityExecutionManagerTest {
         brooklynProperties.put(BrooklynGarbageCollector.GC_PERIOD, 1000);
         brooklynProperties.put(BrooklynGarbageCollector.MAX_TASKS_PER_TAG, 2);
         
-        app = ApplicationBuilder.builder(TestApplication.class).manage(Entities.newManagementContext(brooklynProperties));
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, Entities.newManagementContext(brooklynProperties));
         TestEntity entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         
         List<Task<?>> tasks = Lists.newArrayList();
@@ -171,7 +171,7 @@ class EntityExecutionManagerTest {
         brooklynProperties.put(BrooklynGarbageCollector.GC_PERIOD, 1);
         brooklynProperties.put(BrooklynGarbageCollector.MAX_TASK_AGE, maxTaskAge);
         
-        app = ApplicationBuilder.builder(TestApplication.class).manage(Entities.newManagementContext(brooklynProperties));
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, Entities.newManagementContext(brooklynProperties));
         TestEntity entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         
         Stopwatch stopwatch = new Stopwatch().start();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java b/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java
index e4e518e..9817f47 100644
--- a/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java
+++ b/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java
@@ -36,7 +36,7 @@ public class LocalSubscriptionManagerTest {
     
     @BeforeMethod(alwaysRun=true)
     public void setup() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/policy/basic/PolicyConfigMapUsageTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/policy/basic/PolicyConfigMapUsageTest.java b/core/src/test/java/brooklyn/policy/basic/PolicyConfigMapUsageTest.java
index 2b45f12..631bc71 100644
--- a/core/src/test/java/brooklyn/policy/basic/PolicyConfigMapUsageTest.java
+++ b/core/src/test/java/brooklyn/policy/basic/PolicyConfigMapUsageTest.java
@@ -55,7 +55,7 @@ public class PolicyConfigMapUsageTest {
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
     }
     
     @AfterMethod(alwaysRun=true)

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.groovy b/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.groovy
index bedd4ac..3619070 100644
--- a/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.groovy
+++ b/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.groovy
@@ -35,7 +35,7 @@ public class PolicySubscriptionTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
         loc = new SimulatedLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         entity2 = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         listener = new RecordingSensorEventListener();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/locations/jclouds/src/test/java/brooklyn/location/jclouds/CloudMachineNamerTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/brooklyn/location/jclouds/CloudMachineNamerTest.java b/locations/jclouds/src/test/java/brooklyn/location/jclouds/CloudMachineNamerTest.java
index 2213b4b..40fe4c3 100644
--- a/locations/jclouds/src/test/java/brooklyn/location/jclouds/CloudMachineNamerTest.java
+++ b/locations/jclouds/src/test/java/brooklyn/location/jclouds/CloudMachineNamerTest.java
@@ -37,7 +37,7 @@ public class CloudMachineNamerTest {
 
     @Test
     public void testGenerateGroupIdWithEntity() {
-        TestApplication app = ApplicationBuilder.builder(TestApplication.class).displayName("TistApp").manage();
+        TestApplication app = ApplicationBuilder.newManagedApp(EntitySpecs.spec(TestApplication.class).displayName("TistApp"));
         TestEntity child = app.createAndManageChild(EntitySpecs.spec(TestEntity.class).displayName("TestEnt"));
         try {
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
index 184d611..1af5722 100644
--- a/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
+++ b/policy/src/test/java/brooklyn/enricher/HttpLatencyDetectorTest.java
@@ -34,7 +34,7 @@ public class HttpLatencyDetectorTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         loc = new LocalhostMachineProvisioningLocation();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         app.start(ImmutableList.of(loc));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/policy/src/test/java/brooklyn/enricher/TimeFractionDeltaEnricherTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/enricher/TimeFractionDeltaEnricherTest.java b/policy/src/test/java/brooklyn/enricher/TimeFractionDeltaEnricherTest.java
index 615f9b6..c39220b 100644
--- a/policy/src/test/java/brooklyn/enricher/TimeFractionDeltaEnricherTest.java
+++ b/policy/src/test/java/brooklyn/enricher/TimeFractionDeltaEnricherTest.java
@@ -33,7 +33,7 @@ public class TimeFractionDeltaEnricherTest {
     
     @BeforeMethod(alwaysRun=true)
     public void before() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         producer = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         
         intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/policy/src/test/java/brooklyn/entity/brooklyn/BrooklynMetricsTest.groovy
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/entity/brooklyn/BrooklynMetricsTest.groovy b/policy/src/test/java/brooklyn/entity/brooklyn/BrooklynMetricsTest.groovy
index 793bf3d..0b348c6 100644
--- a/policy/src/test/java/brooklyn/entity/brooklyn/BrooklynMetricsTest.groovy
+++ b/policy/src/test/java/brooklyn/entity/brooklyn/BrooklynMetricsTest.groovy
@@ -26,7 +26,7 @@ class BrooklynMetricsTest {
     
     @BeforeMethod
     public void setUp() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         loc = new SimulatedLocation()
         brooklynMetrics = new BrooklynMetrics(updatePeriod:10L, parent:app)
         Entities.manage(brooklynMetrics);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyMetricTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyMetricTest.java b/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyMetricTest.java
index e93a34a..3ae05da 100644
--- a/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyMetricTest.java
+++ b/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyMetricTest.java
@@ -36,7 +36,7 @@ public class AutoScalerPolicyMetricTest {
     
     @BeforeMethod()
     public void before() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         tc = app.createAndManageChild(EntitySpecs.spec(TestCluster.class)
                 .configure("initialSize", 1));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyReconfigurationTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyReconfigurationTest.java b/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyReconfigurationTest.java
index 5a67a2c..2223b90 100644
--- a/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyReconfigurationTest.java
+++ b/policy/src/test/java/brooklyn/policy/autoscaling/AutoScalerPolicyReconfigurationTest.java
@@ -24,7 +24,7 @@ public class AutoScalerPolicyReconfigurationTest {
     
     @BeforeMethod()
     public void before() {
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         tc = app.createAndManageChild(EntitySpecs.spec(TestCluster.class)
                 .configure("initialSize", 1));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java b/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java
index b434b57..e8c0fdd 100644
--- a/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java
+++ b/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java
@@ -41,7 +41,7 @@ public class MemberFailureDetectionPolicyTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         events = new CopyOnWriteArrayList<SensorEvent<FailureDescriptor>>();
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         group = app.createAndManageChild(EntitySpecs.spec(BasicGroup.class)
                 .configure("childrenAsMembers", true));
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java b/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
index 42aaed1..582d2ad 100644
--- a/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
+++ b/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
@@ -56,7 +56,7 @@ public abstract class AbstractEc2LiveTest {
         brooklynProperties.remove("brooklyn.ssh.config.scriptHeader");
         
         ctx = new LocalManagementContext(brooklynProperties);
-        app = ApplicationBuilder.builder(TestApplication.class).manage(ctx);
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, ctx);
     }
 
     @AfterMethod(alwaysRun=true)

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.groovy
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.groovy b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.groovy
index aa4c771..2fe1e3d 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.groovy
+++ b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.groovy
@@ -33,7 +33,7 @@ public class SoftwareProcessEntityTest {
     public void setUp() throws Exception {
         machine = new SshMachineLocation(address:"localhost");
         loc = new FixedListMachineProvisioningLocation<MachineLocation>(machines:[machine]);
-        app = ApplicationBuilder.builder(TestApplication.class).manage();
+        app = ApplicationBuilder.newManagedApp(TestApplication.class);
         //entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
         MyService entity = new MyService(app)
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/systems/whirr/hadoop/src/test/java/brooklyn/extras/whirr/hadoop/WhirrHadoopClusterLiveTest.java
----------------------------------------------------------------------
diff --git a/systems/whirr/hadoop/src/test/java/brooklyn/extras/whirr/hadoop/WhirrHadoopClusterLiveTest.java b/systems/whirr/hadoop/src/test/java/brooklyn/extras/whirr/hadoop/WhirrHadoopClusterLiveTest.java
index 394f788..155e96c 100644
--- a/systems/whirr/hadoop/src/test/java/brooklyn/extras/whirr/hadoop/WhirrHadoopClusterLiveTest.java
+++ b/systems/whirr/hadoop/src/test/java/brooklyn/extras/whirr/hadoop/WhirrHadoopClusterLiveTest.java
@@ -32,7 +32,7 @@ public class WhirrHadoopClusterLiveTest {
     public void setUp() throws Exception {
         brooklynProperties = BrooklynProperties.Factory.newDefault();
         ctx = new LocalManagementContext(brooklynProperties);
-        app = ApplicationBuilder.builder(TestApplication.class).manage(ctx);
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, ctx);
     }
 
     @AfterMethod(alwaysRun=true)

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
----------------------------------------------------------------------
diff --git a/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java b/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
index eea5da0..54e4a94 100644
--- a/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
+++ b/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
@@ -24,7 +24,6 @@ import brooklyn.entity.Application;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.AbstractEntity;
 import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.ApplicationBuilder.Builder;
 import brooklyn.entity.basic.BasicApplication;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.EntityInternal;
@@ -165,10 +164,10 @@ public class BrooklynRestResourceUtils {
     public Application create(ApplicationSpec spec) {
         log.debug("REST creating application instance for {}", spec);
         
-        String type = spec.getType();
-        String name = spec.getName();
-        Map<String,String> configO = spec.getConfig();
-        Set<EntitySpec> entities = (spec.getEntities() == null) ? ImmutableSet.<EntitySpec>of() : spec.getEntities();
+        final String type = spec.getType();
+        final String name = spec.getName();
+        final Map<String,String> configO = spec.getConfig();
+        final Set<EntitySpec> entities = (spec.getEntities() == null) ? ImmutableSet.<EntitySpec>of() : spec.getEntities();
         
         final Application instance;
 
@@ -204,27 +203,28 @@ public class BrooklynRestResourceUtils {
                 instance = appBuilder.manage(mgmt);
                 
             } else if (Application.class.isAssignableFrom(clazz)) {
-                brooklyn.entity.proxying.EntitySpec<? extends Application> coreSpec = 
-                        (brooklyn.entity.proxying.EntitySpec<? extends Application>) toCoreEntitySpec(clazz, name, configO);
-                Builder<? extends Application> builder = ApplicationBuilder.builder(coreSpec);
+                brooklyn.entity.proxying.EntitySpec<?> coreSpec = toCoreEntitySpec(clazz, name, configO);
+                instance = (Application) mgmt.getEntityManager().createEntity(coreSpec);
                 for (EntitySpec entitySpec : entities) {
                     log.info("REST creating instance for entity {}", entitySpec.getType());
-                    builder.child(toCoreEntitySpec(entitySpec));
+                    instance.addChild(mgmt.getEntityManager().createEntity(toCoreEntitySpec(entitySpec)));
                 }
                 
                 log.info("REST placing '{}' under management", spec.getName());
-                instance = builder.manage(mgmt);
+                Entities.startManagement(instance, mgmt);
                 
             } else if (Entity.class.isAssignableFrom(clazz)) {
-                final Class<? extends Entity> eclazz = getCatalog().loadClassByType(spec.getType(), Entity.class);
-                Builder<? extends Application> builder = ApplicationBuilder.builder()
-                        .configure(configO)
-                        .child(toCoreEntitySpec(eclazz, spec.getName(), spec.getConfig()));
                 if (entities.size() > 0) log.warn("Cannot supply additional entities when using a non-application entity; ignoring in spec {}", spec);
                 
+                brooklyn.entity.proxying.EntitySpec<?> coreSpec = toCoreEntitySpec(BasicApplication.class, name, configO);
+                instance = (Application) mgmt.getEntityManager().createEntity(coreSpec);
+                
+                final Class<? extends Entity> eclazz = getCatalog().loadClassByType(spec.getType(), Entity.class);
+                instance.addChild(mgmt.getEntityManager().createEntity(toCoreEntitySpec(eclazz, name, configO)));
+                
                 log.info("REST placing '{}' under management", spec.getName());
-                instance = builder.manage(mgmt);
-                    
+                Entities.startManagement(instance, mgmt);
+                
             } else {
                 throw new IllegalArgumentException("Class "+clazz+" must extend one of ApplicationBuilder, Application or Entity");
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f19185a6/usage/rest/src/test/java/brooklyn/rest/domain/SensorSummaryTest.java
----------------------------------------------------------------------
diff --git a/usage/rest/src/test/java/brooklyn/rest/domain/SensorSummaryTest.java b/usage/rest/src/test/java/brooklyn/rest/domain/SensorSummaryTest.java
index f76e0dd..3cf971a 100644
--- a/usage/rest/src/test/java/brooklyn/rest/domain/SensorSummaryTest.java
+++ b/usage/rest/src/test/java/brooklyn/rest/domain/SensorSummaryTest.java
@@ -35,7 +35,7 @@ public class SensorSummaryTest {
   
   @BeforeMethod(alwaysRun=true)
   public void setUp() throws Exception {
-      app = ApplicationBuilder.builder(TestApplication.class).manage();
+      app = ApplicationBuilder.newManagedApp(TestApplication.class);
       entity = app.createAndManageChild(EntitySpecs.spec(TestEntity.class));
   }
   


[07/50] brooklyn-server git commit: converting postConstruct to init

Posted by he...@apache.org.
converting postConstruct to init


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

Branch: refs/heads/0.5.0
Commit: 02339d92cd09806d4dc131f0e541502c12e5459e
Parents: bd2256f
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Apr 1 12:30:26 2013 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Apr 1 12:41:41 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/02339d92/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
index 5f4117f..c9ff73a 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.groovy
@@ -78,7 +78,7 @@ import com.google.common.collect.Maps
  *       to this entity (except for drivers/policies that are attached to the entity, which can be  
  *       given a reference to this entity itself).
  *   <li>Call {@link #configure(Map)} and then {@link #setConfig(ConfigKey, Object)}
- *   <li>Call {@link #postConstruct()}
+ *   <li>Call {@link #init()}
  *   <li>Call {@link #addPolicy()} (for any policies defined in the {@link EntitySpec})
  *   <li>Call {@link #setParent(Entity)}, if a parent is specified in the {@link EntitySpec}
  * </ol>


[05/50] brooklyn-server git commit: Deprecate Attributes.VERSION

Posted by he...@apache.org.
Deprecate Attributes.VERSION

- USe ConfigKeys.SUGGESTED_VERSION instead

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

Branch: refs/heads/0.5.0
Commit: 8c3bfdd56726fb536b9bee2f2cd984589666e411
Parents: d2ed034
Author: Aled Sage <al...@gmail.com>
Authored: Sun Mar 31 20:44:31 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sun Mar 31 20:44:31 2013 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/entity/basic/Attributes.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8c3bfdd5/core/src/main/java/brooklyn/entity/basic/Attributes.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/Attributes.java b/core/src/main/java/brooklyn/entity/basic/Attributes.java
index bb60238..682f9d2 100644
--- a/core/src/main/java/brooklyn/entity/basic/Attributes.java
+++ b/core/src/main/java/brooklyn/entity/basic/Attributes.java
@@ -21,10 +21,12 @@ public interface Attributes {
             Void.class, "entity.locationChanged", "Indicates that an entity's location has been changed");
 
 
-    /*
+    /**
      * Application information sensors.
-     * @see SoftwareProcessEntities.SUGGESTED_VERSION
+     * 
+     * @deprecated since 0.5; see {@link ConfigKeys#SUGGESTED_VERSION}
      */
+    @Deprecated
     BasicAttributeSensor<String> VERSION = new BasicAttributeSensor<String>(String.class, "version", "Version information");
 
     BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new BasicAttributeSensorAndConfigKey<String>(


[47/50] brooklyn-server git commit: MembershipTrackingPolicy: support configuring sensors to track

Posted by he...@apache.org.
MembershipTrackingPolicy: support configuring sensors to track


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

Branch: refs/heads/0.5.0
Commit: 24c3a4cea85e9e08bca772d7841bff10d9b433bd
Parents: 1bdb182
Author: Aled Sage <al...@gmail.com>
Authored: Wed Apr 17 14:39:28 2013 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Apr 26 14:40:05 2013 +0100

----------------------------------------------------------------------
 .../group/AbstractMembershipTrackingPolicy.java | 19 +++++++++++++++++++
 .../group/MembershipTrackingPolicyTest.java     | 20 +++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/24c3a4ce/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java b/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
index c42ec71..d345bc5 100644
--- a/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
+++ b/core/src/main/java/brooklyn/entity/group/AbstractMembershipTrackingPolicy.java
@@ -2,6 +2,7 @@ package brooklyn.entity.group;
 
 import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -10,11 +11,14 @@ import brooklyn.entity.Entity;
 import brooklyn.entity.Group;
 import brooklyn.entity.basic.DynamicGroup;
 import brooklyn.entity.trait.Startable;
+import brooklyn.event.Sensor;
 import brooklyn.event.SensorEvent;
 import brooklyn.event.SensorEventListener;
 import brooklyn.policy.basic.AbstractPolicy;
+import brooklyn.util.flags.SetFromFlag;
 
 import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
 
 /** abstract class which helps track membership of a group, invoking (empty) methods in this class on MEMBER{ADDED,REMOVED} events, as well as SERVICE_UP {true,false} for those members. */
 public abstract class AbstractMembershipTrackingPolicy extends AbstractPolicy {
@@ -22,9 +26,14 @@ public abstract class AbstractMembershipTrackingPolicy extends AbstractPolicy {
     
     private Group group;
     
+    @SetFromFlag
+    private Set<Sensor<?>> sensorsToTrack;
+    
     public AbstractMembershipTrackingPolicy(Map flags) {
         super(flags);
+        if (sensorsToTrack == null)  sensorsToTrack = Sets.newLinkedHashSet();
     }
+    
     public AbstractMembershipTrackingPolicy() {
         this(Collections.emptyMap());
     }
@@ -67,6 +76,8 @@ public abstract class AbstractMembershipTrackingPolicy extends AbstractPolicy {
     protected void subscribeToGroup() {
         Preconditions.checkNotNull(group, "The group cannot be null");
 
+        LOG.debug("Subscribing to group "+group+", for memberAdded, memberRemoved, serviceUp, and {}", sensorsToTrack);
+        
         subscribe(group, DynamicGroup.MEMBER_ADDED, new SensorEventListener<Entity>() {
             @Override public void onEvent(SensorEvent<Entity> event) {
                 onEntityAdded(event.getValue());
@@ -83,6 +94,14 @@ public abstract class AbstractMembershipTrackingPolicy extends AbstractPolicy {
                 onEntityChange(event.getSource());
             }
         });
+        for (Sensor<?> sensor : sensorsToTrack) {
+            subscribeToMembers(group, sensor, new SensorEventListener<Object>() {
+                @Override public void onEvent(SensorEvent<Object> event) {
+                    onEntityChange(event.getSource());
+                }
+            });
+        }
+        
         for (Entity it : group.getMembers()) { onEntityAdded(it); }
         
         // FIXME cluster may be remote, we need to make this retrieve the remote values, or store members in local mgmt node, or use children

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/24c3a4ce/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java b/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
index a2d2257..a8f20e6 100644
--- a/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
+++ b/core/src/test/java/brooklyn/entity/group/MembershipTrackingPolicyTest.java
@@ -25,6 +25,7 @@ import brooklyn.util.MutableMap;
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 
 public class MembershipTrackingPolicyTest {
 
@@ -115,7 +116,24 @@ public class MembershipTrackingPolicyTest {
         assertRecordsEventually(Record.newAdded(e1));
     }
 
+    @Test
+    public void testNotifiedOfExtraTrackedSensors() throws Exception {
+        TestEntity e1 = createAndManageChildOf(group);
+
+        RecordingMembershipTrackingPolicy policy2 = new RecordingMembershipTrackingPolicy(MutableMap.of("group", group, "sensorsToTrack", ImmutableSet.of(TestEntity.NAME)));
+        group.addPolicy(policy2);
+        policy2.setGroup(group);
+
+        e1.setAttribute(TestEntity.NAME, "myname");
+        
+        assertRecordsEventually(policy2, Record.newAdded(e1), Record.newChanged(e1));
+    }
+
     private void assertRecordsEventually(final Record... expected) {
+        assertRecordsEventually(policy, expected);
+    }
+    
+    private void assertRecordsEventually(final RecordingMembershipTrackingPolicy policy, final Record... expected) {
         TestUtils.assertEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
             public void run() {
                 assertEquals(policy.records, ImmutableList.copyOf(expected), "actual="+policy.records);
@@ -132,7 +150,7 @@ public class MembershipTrackingPolicyTest {
     static class RecordingMembershipTrackingPolicy extends AbstractMembershipTrackingPolicy {
         final List<Record> records = new CopyOnWriteArrayList<Record>();
         
-        public RecordingMembershipTrackingPolicy(MutableMap<String, BasicGroup> flags) {
+        public RecordingMembershipTrackingPolicy(MutableMap<String, ?> flags) {
             super(flags);
         }
 


[27/50] brooklyn-server git commit: Fix SshMachineLocationTest reference to README file

Posted by he...@apache.org.
Fix SshMachineLocationTest reference to README file


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

Branch: refs/heads/0.5.0
Commit: ab5b473a26882ceee59cfc0aae3213efeb7a0706
Parents: bba778b
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Fri Apr 19 16:20:38 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Fri Apr 19 16:57:32 2013 +0100

----------------------------------------------------------------------
 .../java/brooklyn/location/basic/SshMachineLocationTest.groovy   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ab5b473a/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.groovy b/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.groovy
index b23bf6f..afb15a7 100644
--- a/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.groovy
+++ b/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.groovy
@@ -101,9 +101,9 @@ public class SshMachineLocationTest {
         File dest = new File(System.getProperty("java.io.tmpdir")+"/"+"sssMachineLocationTest_dir/");
         dest.mkdir();
         try {
-            int result = host.installTo(null, "http://github.com/brooklyncentral/brooklyn/raw/master/README.rst", dest.getCanonicalPath()+"/");
+            int result = host.installTo(null, "https://raw.github.com/brooklyncentral/brooklyn/master/README.md", dest.getCanonicalPath()+"/");
             assertEquals(result, 0);
-            String contents = ResourceUtils.readFullyString(new FileInputStream(new File(dest, "README.rst")));
+            String contents = ResourceUtils.readFullyString(new FileInputStream(new File(dest, "README.md")));
             assertTrue(contents.contains("http://brooklyncentral.github.com"), "contents missing expected phrase; contains:\n"+contents);
         } finally {
             dest.delete()


[46/50] brooklyn-server git commit: Check class loader for entity if not in catalog

Posted by he...@apache.org.
Check class loader for entity if not in catalog


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

Branch: refs/heads/0.5.0
Commit: 1bdb1821d61b3ea88026cb3d6019ac1e49efded7
Parents: 41c5bbd
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Thu Apr 25 18:00:36 2013 +0100
Committer: Andrew Kennedy <an...@cloudsoftcorp.com>
Committed: Thu Apr 25 18:00:36 2013 +0100

----------------------------------------------------------------------
 .../rest/util/BrooklynRestResourceUtils.java        | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1bdb1821/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
----------------------------------------------------------------------
diff --git a/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java b/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
index 54e4a94..93b3b29 100644
--- a/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
+++ b/usage/rest/src/main/java/brooklyn/rest/util/BrooklynRestResourceUtils.java
@@ -256,8 +256,20 @@ public class BrooklynRestResourceUtils {
         String type = spec.getType();
         String name = spec.getName();
         Map<String, String> config = (spec.getConfig() == null) ? Maps.<String,String>newLinkedHashMap() : Maps.newLinkedHashMap(spec.getConfig());
-        
-        final Class<? extends Entity> clazz = getCatalog().loadClassByType(type, Entity.class);
+
+        Class<? extends Entity> tempclazz;
+        try {
+            tempclazz = getCatalog().loadClassByType(type, Entity.class);
+        } catch (NoSuchElementException e) {
+            try {
+                tempclazz = (Class<? extends Entity>) getCatalog().getRootClassLoader().loadClass(type);
+                log.info("Catalog does not contain item for type {}; loaded class directly instead", type);
+            } catch (ClassNotFoundException e2) {
+                log.warn("No catalog item for type {}, and could not load class directly; rethrowing", type);
+                throw e;
+            }
+        }
+        final Class<? extends Entity> clazz = tempclazz;
         BasicEntitySpec<? extends Entity, ?> result;
         if (clazz.isInterface()) {
             result = EntitySpecs.spec(clazz);