brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [2/5] incubator-brooklyn git commit: Change back to ConfigKey with inheritance disabled
Date Tue, 24 Mar 2015 19:57:09 GMT
Change back to ConfigKey with inheritance disabled


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

Branch: refs/heads/master
Commit: 6fa675f71174ade80abf065796bc2d4208376987
Parents: 927556f
Author: Andrew Kennedy <grkvlt@apache.org>
Authored: Tue Mar 24 18:33:19 2015 +0000
Committer: Andrew Kennedy <grkvlt@apache.org>
Committed: Tue Mar 24 18:33:19 2015 +0000

----------------------------------------------------------------------
 .../camp/brooklyn/BrooklynCampConstants.java    | 22 +++++++++++---------
 .../BrooklynComponentTemplateResolver.java      |  4 ++--
 .../brooklyn/spi/dsl/methods/DslComponent.java  |  2 +-
 .../brooklyn/VanillaBashNetcatYamlTest.java     |  2 +-
 4 files changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6fa675f7/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
index 7dc472a..c8d3d1d 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
@@ -23,24 +23,26 @@ import io.brooklyn.camp.CampPlatform;
 import java.util.Set;
 
 import brooklyn.config.BrooklynServerConfig;
+import brooklyn.config.ConfigInheritance;
 import brooklyn.config.ConfigKey;
-import brooklyn.event.basic.AttributeSensorAndConfigKey;
-import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
+import brooklyn.entity.basic.ConfigKeys;
 
 import com.google.common.collect.ImmutableSet;
 
 public class BrooklynCampConstants {
 
-    /* These are only advertised as ConfigKeys currently, as they are not automatically set
as sensors. 
-     * To fix if EntitySpec allows us to specify sensor values, or there is an automatic
way they get converted from config. */
-    
     public static final String PLAN_ID_FLAG = "planId";
-    public static final AttributeSensorAndConfigKey<String,String> PLAN_ID = new BasicAttributeSensorAndConfigKey<String>(String.class,
"camp.plan.id", 
-        "Identifier supplied in the deployment plan for component to which this entity corresponds
"
-        + "(human-readable, for correlating across plan, template, and instance)");
 
-    public static final AttributeSensorAndConfigKey<String,String> TEMPLATE_ID = new
BasicAttributeSensorAndConfigKey<String>(String.class, "camp.template.id", 
-        "UID of the component in the CAMP template from which this entity was created");
+    public static final ConfigKey<String> PLAN_ID = ConfigKeys.builder(String.class,
"camp.plan.id")
+            .description("Identifier supplied in the deployment plan for component to which
this entity corresponds "
+                        + "(human-readable, for correlating across plan, template, and instance)")
+            .inheritance(ConfigInheritance.NONE)
+            .build();
+
+    public static final ConfigKey<String> TEMPLATE_ID = ConfigKeys.builder(String.class,
"camp.template.id")
+            .description("UID of the component in the CAMP template from which this entity
was created")
+            .inheritance(ConfigInheritance.NONE)
+            .build();
 
     public static final ConfigKey<CampPlatform> CAMP_PLATFORM = BrooklynServerConfig.CAMP_PLATFORM;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6fa675f7/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
index 89ec2b0..da6e395 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
@@ -322,9 +322,9 @@ public class BrooklynComponentTemplateResolver {
         InternalEntityFactory entityFactory = ((ManagementContextInternal)mgmt).getEntityFactory();
         T entity = entityFactory.constructEntity(entityImpl, spec);
 
-        String planId = (String)spec.getConfig().get(BrooklynCampConstants.PLAN_ID.getConfigKey());
+        String planId = (String)spec.getConfig().get(BrooklynCampConstants.PLAN_ID);
         if (planId != null) {
-            ((EntityInternal)entity).setAttribute(BrooklynCampConstants.PLAN_ID, planId);
+            entity.config().set(BrooklynCampConstants.PLAN_ID, planId);
         }
         
         if (spec.getLocations().size() > 0) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6fa675f7/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
index ca6c2bd..21e8afc 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
@@ -123,7 +123,7 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity>
{
                     throw new IllegalStateException("Unexpected scope "+scope);
             }
             
-            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, EntityPredicates.attributeEqualTo(BrooklynCampConstants.PLAN_ID,
componentId));
+            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID,
componentId));
             
             if (result.isPresent())
                 return result.get();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6fa675f7/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/VanillaBashNetcatYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/VanillaBashNetcatYamlTest.java
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/VanillaBashNetcatYamlTest.java
index 242e5ed..dd1b647 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/VanillaBashNetcatYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/VanillaBashNetcatYamlTest.java
@@ -63,7 +63,7 @@ public class VanillaBashNetcatYamlTest extends AbstractYamlTest {
         Assert.assertEquals(app.getDisplayName(), "Simple Netcat with Client");
         
         // comparing by plan ID is one common way
-        Iterable<Entity> netcatI = Iterables.filter(app.getChildren(), EntityPredicates.attributeEqualTo(BrooklynCampConstants.PLAN_ID,
"netcat-server"));
+        Iterable<Entity> netcatI = Iterables.filter(app.getChildren(), EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID,
"netcat-server"));
         Assert.assertTrue(netcatI.iterator().hasNext(), "no 'netcat-server' child of app:
"+app.getChildren());
         Entity netcat = Iterables.getOnlyElement(netcatI);
         


Mime
View raw message