brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [4/5] git commit: minor tidies of location leaks, for code review
Date Thu, 16 Oct 2014 16:44:24 GMT
minor tidies of location leaks, for code review


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

Branch: refs/heads/master
Commit: 72d8dd374a45d9978d5b0c7b42a2773aa277e592
Parents: 1ad4218
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Oct 16 17:42:37 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Oct 16 17:42:52 2014 +0100

----------------------------------------------------------------------
 api/src/main/java/brooklyn/location/LocationRegistry.java   | 6 +++++-
 .../persister/BrooklynMementoPersisterToObjectStore.java    | 2 +-
 .../java/brooklyn/location/basic/BasicLocationRegistry.java | 9 +++++----
 .../brooklyn/management/internal/LocalLocationManager.java  | 2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/72d8dd37/api/src/main/java/brooklyn/location/LocationRegistry.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/location/LocationRegistry.java b/api/src/main/java/brooklyn/location/LocationRegistry.java
index e5b8cf3..eea5ce4 100644
--- a/api/src/main/java/brooklyn/location/LocationRegistry.java
+++ b/api/src/main/java/brooklyn/location/LocationRegistry.java
@@ -52,7 +52,11 @@ public interface LocationRegistry {
     public void removeDefinedLocation(String id);
 
     /** Returns a fully populated (config etc) location from the given definition, with optional
add'l flags.
-     * the location will be managed by default, unless the manage parameter is false or the
CREATE_UNMANAGED flag is set.
+     * the location will be managed by default, unless the manage parameter is false, 
+     * or the manage parameter is null and the CREATE_UNMANAGED flag is set.
+     * <p>
+     * The manage parameter is {@link Boolean} so that null can be used to say rely on anything
in the flags.
+     * 
      * @since 0.7.0, but beta and likely to change as the semantics of this class are tuned
*/
     @Beta
     public Maybe<Location> resolve(LocationDefinition ld, Boolean manage, Map locationFlags);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/72d8dd37/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
index dfc0676..98fff36 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
@@ -524,7 +524,7 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
         
         if (LOG.isDebugEnabled()) LOG.debug("Checkpointed delta of memento in {}: "
                 + "updated {} entities, {} locations, {} policies, {} enrichers, {} catalog
items; "
-                + "removed {} entities, {} locations, {} policies, {} enrichers {} catalog
items",
+                + "removed {} entities, {} locations, {} policies, {} enrichers, {} catalog
items",
                     new Object[] {Time.makeTimeStringRounded(stopwatch),
                         delta.entities().size(), delta.locations().size(), delta.policies().size(),
delta.enrichers().size(), delta.catalogItems().size(),
                         delta.removedEntityIds().size(), delta.removedLocationIds().size(),
delta.removedPolicyIds().size(), delta.removedEnricherIds().size(), delta.removedCatalogItemIds().size()});

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/72d8dd37/core/src/main/java/brooklyn/location/basic/BasicLocationRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/BasicLocationRegistry.java b/core/src/main/java/brooklyn/location/basic/BasicLocationRegistry.java
index a2cc245..09f69e7 100644
--- a/core/src/main/java/brooklyn/location/basic/BasicLocationRegistry.java
+++ b/core/src/main/java/brooklyn/location/basic/BasicLocationRegistry.java
@@ -187,6 +187,7 @@ public class BasicLocationRegistry implements LocationRegistry {
     }
     
     // TODO save / serialize
+    // (we persist live locations, ie those in the LocationManager, but not "catalog" locations,
ie those in this Registry)
     
     @VisibleForTesting
     void disablePersistence() {
@@ -194,7 +195,7 @@ public class BasicLocationRegistry implements LocationRegistry {
         // defining the format and file etc)
     }
 
-    static BasicLocationDefinition localhost(String id) {
+    protected static BasicLocationDefinition localhost(String id) {
         return new BasicLocationDefinition(id, "localhost", "localhost", null);
     }
     
@@ -218,13 +219,13 @@ public class BasicLocationRegistry implements LocationRegistry {
     }
     
     @Deprecated /** since 0.7.0 not used */
-    public Maybe<Location> resolve(String spec, boolean manage) {
+    public final Maybe<Location> resolve(String spec, boolean manage) {
         return resolve(spec, manage, null);
     }
     
     public Maybe<Location> resolve(String spec, Boolean manage, Map locationFlags)
{
         try {
-            if (locationFlags==null) locationFlags = MutableMap.of();
+            locationFlags = MutableMap.copyOf(locationFlags);
             if (manage!=null) {
                 locationFlags.put(LocalLocationManager.CREATE_UNMANAGED, !manage);
             }
@@ -281,7 +282,7 @@ public class BasicLocationRegistry implements LocationRegistry {
     }
 
     @Override
-    public Location resolve(String spec, Map locationFlags) {
+    public final Location resolve(String spec, Map locationFlags) {
         return resolve(spec, null, locationFlags).get();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/72d8dd37/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java b/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
index f57b5df..3fe711e 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
@@ -206,9 +206,9 @@ public class LocalLocationManager implements LocationManagerInternal {
             throw new IllegalStateException("Access controller forbids management of "+loc+":
"+access.getMsg());
         }
 
+        long count = LOCATION_CNT.incrementAndGet();
         if (log.isDebugEnabled()) {
             String msg = "Managing location " + loc + " ("+initialMode+"), from " + Tasks.current()+"
/ "+Entitlements.getEntitlementContext();
-            long count = LOCATION_CNT.incrementAndGet();
             if (count % 100 == 0) {
                 // include trace periodically in case we get leaks or too much location management
                 log.debug(msg, new Exception("Informational stack trace of call to manage
location "+loc+" ("+count+" calls; "+getLocations().size()+" currently managed)"));


Mime
View raw message