brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [11/15] git commit: address @sjcorbett review comments
Date Wed, 01 Oct 2014 18:03:11 GMT
address @sjcorbett review comments


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

Branch: refs/heads/master
Commit: 6d58882f9e6a33b870609017abc1433ae7611884
Parents: 32c926b
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Oct 1 16:17:33 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Oct 1 17:01:52 2014 +0100

----------------------------------------------------------------------
 api/src/main/java/brooklyn/entity/Entity.java         | 11 +++++++++--
 .../java/brooklyn/entity/rebind/RebindManager.java    |  4 ++--
 .../java/brooklyn/management/ManagementContext.java   |  7 ++++---
 .../brooklyn/management/ha/ManagementNodeState.java   | 14 +++++++-------
 .../java/brooklyn/entity/basic/AbstractEntity.java    |  4 ++--
 .../src/main/java/brooklyn/entity/basic/Entities.java | 11 +++++++----
 .../internal/AbstractManagementContext.java           |  2 +-
 .../internal/NonDeploymentManagementContext.java      |  2 +-
 8 files changed, 33 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/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 8e32dcd..dba9a28 100644
--- a/api/src/main/java/brooklyn/entity/Entity.java
+++ b/api/src/main/java/brooklyn/entity/Entity.java
@@ -122,13 +122,20 @@ public interface Entity extends BrooklynObject {
     /** 
      * Add a child {@link Entity}, and set this entity as its parent,
      * returning the added child.
+     * <p>
+     * As with {@link #addChild(EntitySpec)} the child is <b>not</b> brought
under management
+     * as part of this call.  It should not be managed prior to this call either.
      */
     <T extends Entity> T addChild(T child);
     
     /** 
      * Creates an {@link Entity} from the given spec and adds it, setting this entity as
the parent,
-     * returning the added child. The added child is not yet managed, even if the parent
is managed,
-     * so if adding post-management an explicit call to manage the child will be needed.
*/
+     * returning the added child.
+     * <p>
+     * The added child is <b>not</b> managed as part of this call, even if the
parent is managed,
+     * so if adding post-management an explicit call to manage the child will be needed;
+     * see the convenience method <code>Entities.manage(...)</code>. 
+     * */
     <T extends Entity> T addChild(EntitySpec<T> spec);
     
     /** 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java b/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
index 9e62fa4..5f9ccf8 100644
--- a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
+++ b/api/src/main/java/brooklyn/entity/rebind/RebindManager.java
@@ -65,7 +65,7 @@ public interface RebindManager {
     public List<Application> rebind(ClassLoader classLoader);
     /** @deprecated since 0.7; use {@link #rebind(ClassLoader, RebindExceptionHandler, ManagementNodeState)}
*/ @Deprecated
     public List<Application> rebind(ClassLoader classLoader, RebindExceptionHandler
exceptionHandler);
-    /** causes this management context to rebind, loading data from the given backing store.
+    /** Causes this management context to rebind, loading data from the given backing store.
      * use wisely, as this can cause local entities to be completely lost, or will throw
in many other situations.
      * in general it may be invoked for a new node becoming {@link ManagementNodeState#MASTER}

      * or periodically for a node in {@link ManagementNodeState#HOT_STANDBY}. */
@@ -110,7 +110,7 @@ public interface RebindManager {
     /** waits for any needed or pending writes to complete */
     @VisibleForTesting
     public void waitForPendingComplete(Duration duration) throws InterruptedException, TimeoutException;
-    /** forcibly performs persistence, in the foreground */
+    /** Forcibly performs persistence, in the foreground */
     @VisibleForTesting
     public void forcePersistNow();
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/api/src/main/java/brooklyn/management/ManagementContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/management/ManagementContext.java b/api/src/main/java/brooklyn/management/ManagementContext.java
index 6e3a3b1..26024b0 100644
--- a/api/src/main/java/brooklyn/management/ManagementContext.java
+++ b/api/src/main/java/brooklyn/management/ManagementContext.java
@@ -214,10 +214,11 @@ public interface ManagementContext {
     EntitlementManager getEntitlementManager();
  
 
-    /** as {@link #lookup(String, Class)} but not constraining the return type */
+    /** As {@link #lookup(String, Class)} but not constraining the return type */
     public BrooklynObject lookup(String id);
-    /** finds an entity with the given ID known at this management context */
+    
+    /** Finds an entity with the given ID known at this management context */
     // TODO in future support policies etc
-    public <T> T lookup(String id, Class<T> type); 
+    public <T extends BrooklynObject> T lookup(String id, Class<T> type); 
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java b/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
index d3b0508..c8a90f1 100644
--- a/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
+++ b/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
@@ -19,23 +19,23 @@
 package brooklyn.management.ha;
 
 public enum ManagementNodeState {
-    /** @deprecated since 0.7.0 synonym for maintenance (plus, it should have been UK english!)
*/
+    /** @deprecated since 0.7.0 synonym for maintenance (plus, it should have been US English!)
*/
     UNINITIALISED,
-    /** node is either coming online, or is in some kind of recovery/transitioning mode */
+    /** Node is either coming online, or is in some kind of recovery/transitioning mode */
     INITIALIZING,
     
-    /** node is in "lukewarm standby" mode, where it is available to be promoted to master,
+    /** Node is in "lukewarm standby" mode, where it is available to be promoted to master,
      * but does not have entities loaded and will require some effort to be promoted */
     STANDBY,
-    /** node is acting as read-only proxy */
+    /** Node is acting as read-only proxy */
     HOT_STANDBY,
-    /** node is running as primary/master, able to manage entities and create new ones */
+    /** Node is running as primary/master, able to manage entities and create new ones */
     // the semantics are intended to support multi-master here; we could have multiple master
nodes,
     // but we need to look up who is master for any given entity
     MASTER,
 
-    /** node has failed and requires maintenance attention */
+    /** Node has failed and requires maintenance attention */
     FAILED,
-    /** node has gone away; maintenance not possible */
+    /** Node has gone away; maintenance not possible */
     TERMINATED;
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
index de00c8a..e1429e9 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
@@ -686,8 +686,8 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements
E
     @Override
     public ManagementContext getManagementContext() {
         // NB Sept 2014 - removed synch keyword above due to deadlock;
-        // it also synchs in ManagementSupport..getManagementContext();
-        // no apparent reason why it was here also.  @aledsage can you review?
+        // it also synchs in ManagementSupport.getManagementContext();
+        // no apparent reason why it was here also
         return getManagementSupport().getManagementContext();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/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 aa669db..d32afa6 100644
--- a/core/src/main/java/brooklyn/entity/basic/Entities.java
+++ b/core/src/main/java/brooklyn/entity/basic/Entities.java
@@ -658,13 +658,16 @@ public class Entities {
      */
     public static void destroy(Entity e) {
         if (isManaged(e)) {
-            if (!isReadOnly(e)) {
+            if (isReadOnly(e)) {
+                unmanage(e);
+                log.debug("destroyed and unmanaged read-only copy of "+e);
+            } else {
                 if (e instanceof Startable) Entities.invokeEffector((EntityLocal)e, e, Startable.STOP).getUnchecked();
                 if (e instanceof EntityInternal) ((EntityInternal)e).destroy();
-            }
-            unmanage(e);
-            log.debug("destroyed and unmanaged "+e+"; mgmt now "+
+                unmanage(e);
+                log.debug("destroyed and unmanaged "+e+"; mgmt now "+
                     (e.getApplicationId()==null ? "(no app)" : e.getApplication().getManagementContext())+"
- managed? "+isManaged(e));
+            }
         } else {
             log.debug("skipping destroy of "+e+": not managed");
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
b/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
index 4c6d7d9..ee4e518 100644
--- a/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/AbstractManagementContext.java
@@ -413,7 +413,7 @@ public abstract class AbstractManagementContext implements ManagementContextInte
     }
     
     @SuppressWarnings("unchecked")
-    public <T> T lookup(String id, Class<T> type) {
+    public <T extends BrooklynObject> T lookup(String id, Class<T> type) {
         Object result;
         result = getEntityManager().getEntity(id);
         if (result!=null && type.isInstance(result)) return (T)result;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d58882f/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 46e3f97..7f07f14 100644
--- a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
@@ -424,7 +424,7 @@ public class NonDeploymentManagementContext implements ManagementContextInternal
     }
 
     @Override
-    public <T> T lookup(String id, Class<T> type) {
+    public <T extends BrooklynObject> T lookup(String id, Class<T> type) {
         checkInitialManagementContextReal();
         return initialManagementContext.lookup(id, type);
     }


Mime
View raw message