You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by an...@apache.org on 2015/02/06 17:58:22 UTC

[1/5] incubator-brooklyn git commit: Transformer enricher: tidy import

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 92e9d0bcc -> 21d9a91fc


Transformer enricher: tidy import

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

Branch: refs/heads/master
Commit: c9693fee94f3b1469c54f4d65c809d2b22a15a75
Parents: 92e9d0b
Author: Aled Sage <al...@gmail.com>
Authored: Fri Feb 6 15:06:00 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Feb 6 15:06:00 2015 +0000

----------------------------------------------------------------------
 core/src/main/java/brooklyn/enricher/basic/Transformer.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c9693fee/core/src/main/java/brooklyn/enricher/basic/Transformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/enricher/basic/Transformer.java b/core/src/main/java/brooklyn/enricher/basic/Transformer.java
index d8244c3..47b0a24 100644
--- a/core/src/main/java/brooklyn/enricher/basic/Transformer.java
+++ b/core/src/main/java/brooklyn/enricher/basic/Transformer.java
@@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkArgument;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.catalog.Catalog;
 import brooklyn.config.ConfigKey;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.ConfigKeys;


[5/5] incubator-brooklyn git commit: This closes #507

Posted by an...@apache.org.
This closes #507


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

Branch: refs/heads/master
Commit: 21d9a91fc31bb4b4b93cc77800cbe6643642cb01
Parents: 92e9d0b 8d015a8
Author: Andrea Turli <an...@gmail.com>
Authored: Fri Feb 6 17:58:08 2015 +0100
Committer: Andrea Turli <an...@gmail.com>
Committed: Fri Feb 6 17:58:08 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/enricher/basic/Transformer.java    |  1 -
 .../java/brooklyn/entity/basic/Entities.java    | 62 ++++++++++++++------
 .../entity/basic/EntityAndAttribute.java        | 11 +++-
 .../blueprints/AbstractBlueprintTest.java       | 19 ++++--
 4 files changed, 66 insertions(+), 27 deletions(-)
----------------------------------------------------------------------



[3/5] incubator-brooklyn git commit: Adds EntityAndAttribute.create(...)

Posted by an...@apache.org.
Adds EntityAndAttribute.create(...)

It’s nicer to use than the constructor because you don’t need to
specify generics and don’t get warned about it. However, not everyone
is used to such static methods so leaving the constructor as well
for ease of discovery.

Deprecates the old supplier() method, which should really have been 
called create().

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

Branch: refs/heads/master
Commit: 83aa2d62da59401672940fc5542c9721f1b11ffb
Parents: 0ecf677
Author: Aled Sage <al...@gmail.com>
Authored: Fri Feb 6 15:07:40 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Feb 6 15:07:40 2015 +0000

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/EntityAndAttribute.java   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/83aa2d62/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java b/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
index 71dd822..a7d5a5a 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
@@ -26,7 +26,7 @@ import com.google.common.base.Objects;
 import com.google.common.base.Supplier;
 
 /**
- * A tuple containing an {@link Entity} and an {@link Attribute}, which is assumed to be present on the entity.
+ * A tuple containing an {@link Entity} and an {@link AttributeSensor}, which is assumed to be present on the entity.
  * <p>
  * Allows retrieval of the attribute {@link #getValue() value} or can be used instead where a {@link Supplier} for
  * the attribute value is required.
@@ -36,10 +36,17 @@ public class EntityAndAttribute<T> implements Supplier<T> {
     private final Entity entity;
     private final AttributeSensor<T> attribute;
 
-    public static <T> EntityAndAttribute<T> supplier(Entity entity, AttributeSensor<T> attribute) {
+    public static <T> EntityAndAttribute<T> create(Entity entity, AttributeSensor<T> attribute) {
         return new EntityAndAttribute<T>(entity, attribute);
     }
 
+    /**
+     * @deprecated since 0.7.0; use {@link #create(Entity, AttributeSensor)}; this does not relate to {@link Supplier}
+     */
+    public static <T> EntityAndAttribute<T> supplier(Entity entity, AttributeSensor<T> attribute) {
+        return create(entity, attribute);
+    }
+
     public EntityAndAttribute(Entity entity, AttributeSensor<T> attribute) {
         this.entity = checkNotNull(entity, "entity");
         this.attribute = checkNotNull(attribute, "attribute");


[4/5] incubator-brooklyn git commit: AbstractBlueprintTest: make fields/methods protected

Posted by an...@apache.org.
AbstractBlueprintTest: make fields/methods protected

Make it more useful for sub-classing in downstream projects.

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

Branch: refs/heads/master
Commit: 8d015a8f31147a4a03b043806d52d9f6a4f1aef8
Parents: 83aa2d6
Author: Aled Sage <al...@gmail.com>
Authored: Fri Feb 6 15:08:12 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Feb 6 15:08:12 2015 +0000

----------------------------------------------------------------------
 .../blueprints/AbstractBlueprintTest.java        | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8d015a8f/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
index e9df79c..ec084e9 100644
--- a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
+++ b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
@@ -54,12 +54,12 @@ public abstract class AbstractBlueprintTest {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractBlueprintTest.class);
     
-    private File mementoDir;
-    private ClassLoader classLoader = AbstractBlueprintTest.class.getClassLoader();
+    protected File mementoDir;
+    protected ClassLoader classLoader = AbstractBlueprintTest.class.getClassLoader();
     
-    private ManagementContext mgmt;
-    private SimpleYamlLauncherForTests launcher;
-    private BrooklynLauncher viewer;
+    protected ManagementContext mgmt;
+    protected SimpleYamlLauncherForTests launcher;
+    protected BrooklynLauncher viewer;
 
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
@@ -117,6 +117,15 @@ public abstract class AbstractBlueprintTest {
         assertNoFires(newApp);
     }
     
+    protected void runTest(Reader yaml) throws Exception {
+        final Application app = launcher.launchAppYaml(yaml);
+        
+        assertNoFires(app);
+        
+        Application newApp = rebind();
+        assertNoFires(newApp);
+    }
+    
     protected void assertNoFires(final Entity app) {
         EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true);
         EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);


[2/5] incubator-brooklyn git commit: Entities.destroyAll: stop apps concurrently

Posted by an...@apache.org.
Entities.destroyAll: stop apps concurrently

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

Branch: refs/heads/master
Commit: 0ecf677ee8fd26b2fc4d35187421bd155c7b8c11
Parents: c9693fe
Author: Aled Sage <al...@gmail.com>
Authored: Fri Feb 6 15:06:16 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Feb 6 15:06:16 2015 +0000

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/Entities.java    | 62 ++++++++++++++------
 1 file changed, 43 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0ecf677e/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 7736d50..68b7912 100644
--- a/core/src/main/java/brooklyn/entity/basic/Entities.java
+++ b/core/src/main/java/brooklyn/entity/basic/Entities.java
@@ -34,6 +34,7 @@ import java.util.Set;
 import java.util.Stack;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
@@ -106,6 +107,11 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.reflect.TypeToken;
+import com.google.common.util.concurrent.Atomics;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 
 /**
  * Convenience methods for working with entities.
@@ -716,36 +722,54 @@ public class Entities {
 
     /**
      * Stops, destroys, and unmanages all apps in the given context, and then terminates the management context.
+     * 
+     * Apps will be stopped+destroyed+unmanaged concurrently, waiting for all to complete.
      */
-    public static void destroyAll(ManagementContext mgmt) {
-        Exception error = null;
+    public static void destroyAll(final ManagementContext mgmt) {
         if (mgmt instanceof NonDeploymentManagementContext) {
             // log here because it is easy for tests to destroyAll(app.getMgmtContext())
             // which will *not* destroy the mgmt context if the app has been stopped!
             log.warn("Entities.destroyAll invoked on non-deployment "+mgmt+" - not likely to have much effect! " +
-                    "(This usually means the mgmt context has been taken from entity has been destroyed. " +
+                    "(This usually means the mgmt context has been taken from an entity that has been destroyed. " +
                     "To destroy other things on the management context ensure you keep a handle to the context " +
                     "before the entity is destroyed, such as by creating the management context first.)");
         }
         if (!mgmt.isRunning()) return;
-        log.debug("destroying all apps in "+mgmt+": "+mgmt.getApplications());
-        for (Application app: mgmt.getApplications()) {
-            log.debug("destroying app "+app+" (managed? "+isManaged(app)+"; mgmt is "+mgmt+")");
-            try {
-                destroy(app);
-                log.debug("destroyed app "+app+"; mgmt now "+mgmt);
-            } catch (Exception e) {
-                log.warn("problems destroying app "+app+" (mgmt now "+mgmt+", will rethrow at least one exception): "+e);
-                if (error==null) error = e;
+        
+        ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
+        List<ListenableFuture<?>> futures = Lists.newArrayList();
+        final AtomicReference<Exception> error = Atomics.newReference();
+        try {
+            log.debug("destroying all apps in "+mgmt+": "+mgmt.getApplications());
+            for (final Application app: mgmt.getApplications()) {
+                futures.add(executor.submit(new Runnable() {
+                    public void run() {
+                        log.debug("destroying app "+app+" (managed? "+isManaged(app)+"; mgmt is "+mgmt+")");
+                        try {
+                            destroy(app);
+                            log.debug("destroyed app "+app+"; mgmt now "+mgmt);
+                        } catch (Exception e) {
+                            log.warn("problems destroying app "+app+" (mgmt now "+mgmt+", will rethrow at least one exception): "+e);
+                            error.compareAndSet(null, e);
+                        }
+                    }}));
             }
+            Futures.allAsList(futures).get();
+            
+            for (Location loc : mgmt.getLocationManager().getLocations()) {
+                destroyCatching(loc);
+            }
+            if (mgmt instanceof ManagementContextInternal) {
+                ((ManagementContextInternal)mgmt).terminate();
+            }
+            if (error.get() != null) throw Exceptions.propagate(error.get());
+        } catch (InterruptedException e) {
+            throw Exceptions.propagate(e);
+        } catch (ExecutionException e) {
+            throw Exceptions.propagate(e);
+        } finally {
+            executor.shutdownNow();
         }
-        for (Location loc : mgmt.getLocationManager().getLocations()) {
-            destroyCatching(loc);
-        }
-        if (mgmt instanceof ManagementContextInternal) {
-            ((ManagementContextInternal)mgmt).terminate();
-        }
-        if (error!=null) throw Exceptions.propagate(error);
     }
 
     /** Same as {@link #destroyAll(ManagementContext)} but catching all errors */