brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [6/8] incubator-brooklyn git commit: better comments for config key and better coercion tests (code review of previous commits)
Date Sat, 15 Nov 2014 17:07:14 GMT
better comments for config key and better coercion tests (code review of previous commits)


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

Branch: refs/heads/master
Commit: 7789158063686315374d9d2fe8c5e2498b5503be
Parents: 7f00d67
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Sat Nov 15 17:05:02 2014 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Sat Nov 15 17:05:02 2014 +0000

----------------------------------------------------------------------
 .../java/brooklyn/entity/rebind/dto/BasicEntityMemento.java  | 8 ++++----
 core/src/main/java/brooklyn/location/basic/Locations.java    | 1 +
 .../brooklyn/location/jclouds/JcloudsLocationResolver.java   | 4 ++--
 .../entity/software/MachineLifecycleEffectorTasks.java       | 4 +---
 4 files changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77891580/core/src/main/java/brooklyn/entity/rebind/dto/BasicEntityMemento.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/dto/BasicEntityMemento.java b/core/src/main/java/brooklyn/entity/rebind/dto/BasicEntityMemento.java
index 0ef27e1..2d36ee8 100644
--- a/core/src/main/java/brooklyn/entity/rebind/dto/BasicEntityMemento.java
+++ b/core/src/main/java/brooklyn/entity/rebind/dto/BasicEntityMemento.java
@@ -197,9 +197,10 @@ public class BasicEntityMemento extends AbstractTreeNodeMemento implements
Entit
         }
         ConfigKey<?> resultStatic = getStaticConfigKeys().get(key);
         if (resultStatic!=null) return resultStatic;
-        // if it was a legacy key, if it is added back, drop the legacy reference
         if (result!=null) return result;
-        // can happen on rebind if a key has gone away; it will not be declared in the file
or in the 
+        // can come here on rebind if a key has gone away in the class, so create a generic
one; 
+        // but if it was previously found to a legacy key (below) which is added back after
a regind, 
+        // gnore the legacy description (several lines above) and add the key back from static
(code just above)
         log.warn("Config key "+key+": "+LEGACY_KEY_DESCRIPTION);
         return ConfigKeys.newConfigKey(Object.class, key, LEGACY_KEY_DESCRIPTION);
     }
@@ -222,9 +223,8 @@ public class BasicEntityMemento extends AbstractTreeNodeMemento implements
Entit
         }
         AttributeSensor<?> resultStatic = (AttributeSensor<?>) getStaticSensorKeys().get(key);
         if (resultStatic!=null) return resultStatic;
-        // if it was a legacy key, if it is added back, drop the legacy reference
         if (result!=null) return result;
-        // can happen on rebind if a key has gone away; it will not be declared in the file
or in the 
+        // see notes on legacy config key
         log.warn("Sensor "+key+": "+LEGACY_KEY_DESCRIPTION);
         return Sensors.newSensor(Object.class, key, LEGACY_KEY_DESCRIPTION);
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77891580/core/src/main/java/brooklyn/location/basic/Locations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/Locations.java b/core/src/main/java/brooklyn/location/basic/Locations.java
index 09cef7c..5fadd26 100644
--- a/core/src/main/java/brooklyn/location/basic/Locations.java
+++ b/core/src/main/java/brooklyn/location/basic/Locations.java
@@ -141,6 +141,7 @@ public class Locations {
     }
     
     public static Collection<? extends Location> coerceToCollection(ManagementContext
mgmt, Object rawO) {
+        if (rawO==null) return null;
         Object raw = rawO;
         if (raw instanceof Collection) {
             List<Location> result = MutableList.<Location>of();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77891580/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationResolver.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationResolver.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationResolver.java
index f71a81b..5d42da3 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationResolver.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationResolver.java
@@ -183,12 +183,12 @@ public class JcloudsLocationResolver implements LocationResolver {
                 // providers from ServiceLoader take a location (endpoint already configured),
and optionally a region name
                 // NB blank might be supplied if spec string is "mycloud:" -- that should
be respected, 
                 // whereas no parameter/regionName ie null value -- "mycloud" -- means don't
set
-                if (regionOrEndpoint!=null && Strings.isBlank(Strings.toString(jcloudsProperties.get(JcloudsLocationConfig.CLOUD_REGION_ID.getName()))))
+                if (Strings.isBlank(Strings.toString(jcloudsProperties.get(JcloudsLocationConfig.CLOUD_REGION_ID.getName()))))
                     jcloudsProperties.put(JcloudsLocationConfig.CLOUD_REGION_ID.getName(),
regionOrEndpoint);
             } else {
                 // other "providers" are APIs so take an _endpoint_ (but not a location);
                 // see note above re null here
-                if (regionOrEndpoint!=null && Strings.isBlank(Strings.toString(jcloudsProperties.get(JcloudsLocationConfig.CLOUD_ENDPOINT.getName()))))
+                if (Strings.isBlank(Strings.toString(jcloudsProperties.get(JcloudsLocationConfig.CLOUD_ENDPOINT.getName()))))
                     jcloudsProperties.put(JcloudsLocationConfig.CLOUD_ENDPOINT.getName(),
regionOrEndpoint);
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77891580/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
index 8381e99..2168693 100644
--- a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
@@ -155,9 +155,7 @@ public abstract class MachineLifecycleEffectorTasks {
                 Collection<? extends Location> locations  = null;
 
                 Object locationsRaw = parameters.getStringKey(LOCATIONS.getName());
-                if (locationsRaw != null) {
-                    locations = Locations.coerceToCollection(entity().getManagementContext(),
locationsRaw);
-                }
+                locations = Locations.coerceToCollection(entity().getManagementContext(),
locationsRaw);
 
                 if (locations==null) {
                     // null/empty will mean to inherit from parent


Mime
View raw message