brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [4/9] incubator-brooklyn git commit: Use {location, policy, enricher}.config(), instead of newly deprecated methods
Date Wed, 18 Feb 2015 11:32:09 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73c49852/usage/cli/src/main/java/brooklyn/cli/CloudExplorer.java
----------------------------------------------------------------------
diff --git a/usage/cli/src/main/java/brooklyn/cli/CloudExplorer.java b/usage/cli/src/main/java/brooklyn/cli/CloudExplorer.java
index 8f2f375..3dd8462 100644
--- a/usage/cli/src/main/java/brooklyn/cli/CloudExplorer.java
+++ b/usage/cli/src/main/java/brooklyn/cli/CloudExplorer.java
@@ -245,7 +245,7 @@ public class CloudExplorer {
             failIfArguments();
             ComputeService computeService = loc.getComputeService();
             
-            Template template = loc.buildTemplate(computeService, loc.getAllConfigBag());
+            Template template = loc.buildTemplate(computeService, loc.config().getBag());
             Image image = template.getImage();
             Hardware hardware = template.getHardware();
             org.jclouds.domain.Location location = template.getLocation();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73c49852/usage/qa/src/test/java/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/java/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java
b/usage/qa/src/test/java/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java
index 0d4d9fd..392b976 100644
--- a/usage/qa/src/test/java/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java
+++ b/usage/qa/src/test/java/brooklyn/qa/longevity/webcluster/SinusoidalLoadGenerator.java
@@ -57,10 +57,10 @@ public class SinusoidalLoadGenerator extends AbstractEnricher {
     }
     
     public SinusoidalLoadGenerator(AttributeSensor<Double> target, long publishPeriodMs,
long sinPeriodMs, double sinAmplitude) {
-        setConfig(TARGET, target);
-        setConfig(PUBLISH_PERIOD_MS, publishPeriodMs);
-        setConfig(SIN_PERIOD_MS, sinPeriodMs);
-        setConfig(SIN_AMPLITUDE, sinAmplitude);
+        config().set(TARGET, target);
+        config().set(PUBLISH_PERIOD_MS, publishPeriodMs);
+        config().set(SIN_PERIOD_MS, sinPeriodMs);
+        config().set(SIN_AMPLITUDE, sinAmplitude);
         this.executor = Executors.newSingleThreadScheduledExecutor();
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73c49852/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
index 5c2a1ba..842be53 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/PolicyConfigResource.java
@@ -23,6 +23,7 @@ import java.util.Map;
 
 import javax.ws.rs.core.Response;
 
+import brooklyn.basic.BrooklynObjectInternal;
 import brooklyn.config.ConfigKey;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.EntityLocal;
@@ -59,10 +60,10 @@ public class PolicyConfigResource extends AbstractBrooklynRestResource
implement
     public Map<String, Object> batchConfigRead(String application, String entityToken,
String policyToken) {
         // TODO: add test
         Policy policy = brooklyn().getPolicy(application, entityToken, policyToken);
-        Map<ConfigKey<?>, Object> source = policy.getAllConfig();
+        Map<String, Object> source = ((BrooklynObjectInternal)policy).config().getBag().getAllConfig();
         Map<String, Object> result = Maps.newLinkedHashMap();
-        for (Map.Entry<ConfigKey<?>, Object> ek : source.entrySet()) {
-            result.put(ek.getKey().getName(), getStringValueForDisplay(brooklyn(), policy,
ek.getValue()));
+        for (Map.Entry<String, Object> ek : source.entrySet()) {
+            result.put(ek.getKey(), getStringValueForDisplay(brooklyn(), policy, ek.getValue()));
         }
         return result;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73c49852/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
index a77e386..accb59a 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java
@@ -57,14 +57,14 @@ public class LocationTransformer {
         if (mgmt != null && (level==LocationDetailLevel.FULL_EXCLUDING_SECRET ||
level==LocationDetailLevel.FULL_INCLUDING_SECRET)) {
             LocationDefinition ld = new BasicLocationDefinition(id, locationSpec.getName(),
locationSpec.getSpec(), locationSpec.getConfig());
             Location ll = mgmt.getLocationRegistry().resolve(ld, false, null).orNull();
-            if (ll!=null) config = ll.getAllConfig(true);
+            if (ll!=null) config = ((LocationInternal)ll).config().getBag().getAllConfig();
         } else if (level==LocationDetailLevel.LOCAL_EXCLUDING_SECRET) {
             // get displayName
             if (!config.containsKey(LocationConfigKeys.DISPLAY_NAME.getName()) &&
mgmt!=null) {
                 LocationDefinition ld = new BasicLocationDefinition(id, locationSpec.getName(),
locationSpec.getSpec(), locationSpec.getConfig());
                 Location ll = mgmt.getLocationRegistry().resolve(ld, false, null).orNull();
                 if (ll!=null) {
-                    Map<String, Object> configExtra = ll.getAllConfig(true);
+                    Map<String, Object> configExtra = ((LocationInternal)ll).config().getBag().getAllConfig();
                     if (configExtra.containsKey(LocationConfigKeys.DISPLAY_NAME.getName()))
{
                         ConfigBag configNew = ConfigBag.newInstance(config);
                         configNew.configure(LocationConfigKeys.DISPLAY_NAME, (String)configExtra.get(LocationConfigKeys.DISPLAY_NAME.getName()));
@@ -93,13 +93,13 @@ public class LocationTransformer {
         Map<String, Object> config = l.getConfig();
         if (mgmt != null && (level==LocationDetailLevel.FULL_EXCLUDING_SECRET ||
level==LocationDetailLevel.FULL_INCLUDING_SECRET)) {
             Location ll = mgmt.getLocationRegistry().resolve(l, false, null).orNull();
-            if (ll!=null) config = ll.getAllConfig(true);
+            if (ll!=null) config = ((LocationInternal)ll).config().getBag().getAllConfig();
         } else if (level==LocationDetailLevel.LOCAL_EXCLUDING_SECRET) {
             // get displayName
             if (mgmt != null && !config.containsKey(LocationConfigKeys.DISPLAY_NAME.getName()))
{
                 Location ll = mgmt.getLocationRegistry().resolve(l, false, null).orNull();
                 if (ll!=null) {
-                    Map<String, Object> configExtra = ll.getAllConfig(true);
+                    Map<String, Object> configExtra = ((LocationInternal)ll).config().getBag().getAllConfig();
                     if (configExtra.containsKey(LocationConfigKeys.DISPLAY_NAME.getName()))
{
                         ConfigBag configNew = ConfigBag.newInstance(config);
                         configNew.configure(LocationConfigKeys.DISPLAY_NAME, (String)configExtra.get(LocationConfigKeys.DISPLAY_NAME.getName()));
@@ -137,8 +137,9 @@ public class LocationTransformer {
         while (lp!=null && (spec==null || specId==null)) {
             // walk parent locations
             // TODO not sure this is the best strategy, or if it's needed, as the spec config
is inherited anyway... 
-            if (spec==null)
-                spec = Strings.toString( lp.getAllConfig(true).get(LocationInternal.ORIGINAL_SPEC.getName())
);
+            if (spec==null) {
+                spec = Strings.toString( ((LocationInternal)lp).config().getRaw(LocationInternal.ORIGINAL_SPEC)
);
+            }
             if (specId==null) {
                 LocationDefinition ld = null;
                 // prefer looking it up by name as this loads the canonical definition
@@ -159,11 +160,16 @@ public class LocationTransformer {
             if (ll!=null) specId = ll.getId();
         }
         
-        Map<String, Object> configOrig = l.getAllConfig(level!=LocationDetailLevel.LOCAL_EXCLUDING_SECRET);
+        Map<String, Object> configOrig;
+        if (level == LocationDetailLevel.LOCAL_EXCLUDING_SECRET) {
+            configOrig = MutableMap.copyOf(((LocationInternal)l).config().getLocalBag().getAllConfig());
+        } else {
+            configOrig = MutableMap.copyOf(((LocationInternal)l).config().getBag().getAllConfig());
+        }
         if (level==LocationDetailLevel.LOCAL_EXCLUDING_SECRET) {
             // for LOCAL, also get the display name
             if (!configOrig.containsKey(LocationConfigKeys.DISPLAY_NAME.getName())) {
-                Map<String, Object> configExtra = l.getAllConfig(true);
+                Map<String, Object> configExtra = ((LocationInternal)l).config().getBag().getAllConfig();
                 if (configExtra.containsKey(LocationConfigKeys.DISPLAY_NAME.getName()))
                     configOrig.put(LocationConfigKeys.DISPLAY_NAME.getName(), configExtra.get(LocationConfigKeys.DISPLAY_NAME.getName()));
             }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73c49852/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
index a6c26ab..21d9bac 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
@@ -45,9 +45,9 @@ import brooklyn.entity.basic.BasicEntity;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.EntityFunctions;
 import brooklyn.entity.basic.Lifecycle;
-import brooklyn.location.Location;
 import brooklyn.location.basic.AbstractLocation;
 import brooklyn.location.basic.LocationConfigKeys;
+import brooklyn.location.basic.LocationInternal;
 import brooklyn.location.geo.HostGeoInfo;
 import brooklyn.rest.domain.ApiError;
 import brooklyn.rest.domain.ApplicationSpec;
@@ -533,8 +533,8 @@ public class ApplicationResourceTest extends BrooklynRestResourceTest
{
         log.info("starting testLocatedLocations");
         testListApplications();
 
-        Location l = getManagementContext().getApplications().iterator().next().getLocations().iterator().next();
-        if (!l.hasConfig(LocationConfigKeys.LATITUDE, false)) {
+        LocationInternal l = (LocationInternal) getManagementContext().getApplications().iterator().next().getLocations().iterator().next();
+        if (l.config().getLocalRaw(LocationConfigKeys.LATITUDE).isAbsent()) {
             log.info("Supplying fake locations for localhost because could not be autodetected");
             ((AbstractLocation) l).setHostGeoInfo(new HostGeoInfo("localhost", "localhost",
50, 0));
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73c49852/usage/rest-server/src/test/java/brooklyn/rest/util/EntityLocationUtilsTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/util/EntityLocationUtilsTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/util/EntityLocationUtilsTest.java
index 10d1a99..8a6d212 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/util/EntityLocationUtilsTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/util/EntityLocationUtilsTest.java
@@ -34,6 +34,7 @@ import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.location.Location;
 import brooklyn.location.basic.AbstractLocation;
+import brooklyn.location.basic.LocationInternal;
 import brooklyn.location.geo.HostGeoInfo;
 import brooklyn.rest.testing.mocks.RestMockSimpleEntity;
 
@@ -63,7 +64,7 @@ public class EntityLocationUtilsTest extends BrooklynAppUnitTestSupport
{
         Entities.dumpInfo(app);
 
         log.info("r2loc: "+r2.getLocations());
-        log.info("props: "+r2.getLocations().iterator().next().getAllConfig(false));
+        log.info("props: "+((LocationInternal)r2.getLocations().iterator().next()).config().getBag().getAllConfig());
 
         Map<Location, Integer> counts = new EntityLocationUtils(mgmt).countLeafEntitiesByLocatedLocations();
         log.info("count: "+counts);


Mime
View raw message