remove a bunch of deprecated config methods
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/914982ea Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/914982ea Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/914982ea Branch: refs/heads/master Commit: 914982ea3ce7d9bad2d8ec59a7d33783570a79c1 Parents: e8d44d5 Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com> Authored: Tue Sep 20 16:23:36 2016 +0100 Committer: Alex Heneveld <alex.henev...@cloudsoftcorp.com> Committed: Wed Sep 21 16:06:07 2016 +0100 ---------------------------------------------------------------------- .../org/apache/brooklyn/api/entity/Entity.java | 18 ------- .../catalog/internal/CatalogInitialization.java | 2 +- .../core/effector/ssh/SshEffectorTasks.java | 2 +- .../brooklyn/core/entity/AbstractEntity.java | 56 -------------------- .../brooklyn/core/entity/EntityInternal.java | 41 -------------- .../internal/EntityTransientCopyInternal.java | 9 ---- .../core/location/AbstractLocation.java | 4 +- .../mgmt/rebind/BasicEntityRebindSupport.java | 4 +- .../mgmt/rebind/BasicLocationRebindSupport.java | 4 +- .../mgmt/rebind/dto/MementosGenerators.java | 6 +-- .../AbstractConfigurationSupportInternal.java | 10 ++-- .../core/objs/BrooklynObjectInternal.java | 11 ++-- .../FixedListMachineProvisioningLocation.java | 11 ++-- .../config/MapConfigKeyAndFriendsMoreTest.java | 56 ++++++++++---------- .../brooklyn/core/entity/EntityConfigTest.java | 54 ++++++++++--------- .../core/mgmt/rebind/RebindEntityTest.java | 5 +- .../RebindManagerExceptionHandlerTest.java | 9 +++- .../jclouds/JcloudsByonLocationResolver.java | 2 +- .../location/jclouds/JcloudsLocation.java | 2 +- .../jclouds/JcloudsSshMachineLocation.java | 4 +- .../loadbalancing/LoadBalancingPolicy.java | 14 ++--- .../BrooklynNodeUpgradeEffectorBody.java | 2 +- .../entity/chef/ChefLifecycleEffectorTasks.java | 4 +- .../apache/brooklyn/entity/java/JmxSupport.java | 2 +- .../base/AbstractSoftwareProcessSshDriver.java | 2 +- .../base/VanillaSoftwareProcessSshDriver.java | 3 +- .../base/SoftwareProcessEntityTest.java | 30 +++++------ .../org/apache/brooklyn/config/ConfigMap.java | 2 +- 28 files changed, 129 insertions(+), 240 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java b/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java index 14d3c23..5faf19c 100644 --- a/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java +++ b/api/src/main/java/org/apache/brooklyn/api/entity/Entity.java @@ -223,24 +223,6 @@ public interface Entity extends BrooklynObject { <T> T getConfig(HasConfigKey<T> key); /** - * Returns the uncoerced value for this config key as set on this entity, if available, - * not following any inheritance chains and not taking any default. - * - * @deprecated since 0.7.0; use {@code ((EntityInternal)entity).config().getRaw()} or - * {@code ((EntityInternal)entity).config().getLocalRaw()} - */ - @Deprecated - Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean includeInherited); - - /** - * @see {@link #getConfigRaw(ConfigKey, boolean)}. - * - * @deprecated since 0.7.0 - */ - @Deprecated - Maybe<Object> getConfigRaw(HasConfigKey<?> key, boolean includeInherited); - - /** * Invokes the given effector, with the given parameters to that effector. */ <T> Task<T> invoke(Effector<T> eff, Map<String,?> parameters); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java index 8083921..95e593f 100644 --- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java +++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java @@ -393,7 +393,7 @@ public class CatalogInitialization implements ManagementContextInjectable { synchronized (setFromCLMMutex) { if (setFromCatalogLoadMode) return; setFromCatalogLoadMode = true; - Maybe<Object> clmm = ((ManagementContextInternal)managementContext).getConfig().getConfigRaw(BrooklynServerConfig.CATALOG_LOAD_MODE, false); + Maybe<Object> clmm = ((ManagementContextInternal)managementContext).getConfig().getConfigLocalRaw(BrooklynServerConfig.CATALOG_LOAD_MODE); if (clmm.isAbsent()) return; org.apache.brooklyn.core.catalog.CatalogLoadMode clm = TypeCoercions.coerce(clmm.get(), org.apache.brooklyn.core.catalog.CatalogLoadMode.class); log.warn("Legacy CatalogLoadMode "+clm+" set: applying, but this should be changed to use new CLI --catalogXxx commands"); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/effector/ssh/SshEffectorTasks.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/effector/ssh/SshEffectorTasks.java b/core/src/main/java/org/apache/brooklyn/core/effector/ssh/SshEffectorTasks.java index a8e427c..29c1480 100644 --- a/core/src/main/java/org/apache/brooklyn/core/effector/ssh/SshEffectorTasks.java +++ b/core/src/main/java/org/apache/brooklyn/core/effector/ssh/SshEffectorTasks.java @@ -299,7 +299,7 @@ public class SshEffectorTasks { if (optionalLocation!=null) allConfig.putAll(((LocationInternal)optionalLocation).config().getBag()); - allConfig.putAll(((EntityInternal)entity).getAllConfig()); + allConfig.putAll(((EntityInternal)entity).config().getBag()); Map<String, Object> result = Maps.newLinkedHashMap(); for (String keyS : allConfig.getAllConfig().keySet()) { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java index fe65cff..8ba1bc3 100644 --- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java +++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java @@ -1273,18 +1273,6 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E if (result==null) return defaultValue; return result; } - - @Override - @Deprecated - public Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean includeInherited) { - return (includeInherited) ? config().getRaw(key) : config().getLocalRaw(key); - } - - @Override - @Deprecated - public Maybe<Object> getConfigRaw(HasConfigKey<?> key, boolean includeInherited) { - return (includeInherited) ? config().getRaw(key) : config().getLocalRaw(key); - } @Override @Deprecated @@ -1336,50 +1324,6 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E protected void setConfigIfValNonNull(HasConfigKey key, Object val) { if (val != null) config().set(key, val); } - - /** - * @deprecated since 0.7.0; see {@code config().refreshInheritedConfig()} - */ - @Override - @Deprecated - public void refreshInheritedConfig() { - config().refreshInheritedConfig(); - } - - /** - * @deprecated since 0.7.0; see {@code config().refreshInheritedConfigOfChildren()} - */ - @Deprecated - void refreshInheritedConfigOfChildren() { - config().refreshInheritedConfigOfChildren(); - } - - @Override - @Deprecated - public EntityConfigMap getConfigMap() { - return configsInternal; - } - - @Override - @Deprecated - public Map<ConfigKey<?>,Object> getAllConfig() { - return configsInternal.getAllConfig(); - } - - @Beta - @Override - @Deprecated - public ConfigBag getAllConfigBag() { - return config().getBag(); - } - - @Beta - @Override - @Deprecated - public ConfigBag getLocalConfigBag() { - return config().getLocalBag(); - } - // -------- SUBSCRIPTIONS -------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java b/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java index 1f627ac..5610903 100644 --- a/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java +++ b/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java @@ -63,40 +63,6 @@ public interface EntityInternal extends BrooklynObjectInternal, EntityLocal, Reb <T> T setAttributeWithoutPublishing(AttributeSensor<T> sensor, T val); /** - * @deprecated since 0.7.0; instead just use methods on {@link ConfigurationSupportInternal} returned by {@link #config()} - */ - @Deprecated - EntityConfigMap getConfigMap(); - - /** - * @return a read-only copy of all the config key/value pairs on this entity. - * - * @deprecated since 0.7.0; instead just use methods on {@link ConfigurationSupportInternal} returned by {@link #config()}, - * e.g. getBag().getAllConfigAsConfigKeyMap(). - */ - @Deprecated - @Beta - Map<ConfigKey<?>,Object> getAllConfig(); - - /** - * Returns a read-only view of all the config key/value pairs on this entity, backed by a string-based map, - * including config names that did not match anything on this entity. - * - * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().getBag()} - */ - @Deprecated - ConfigBag getAllConfigBag(); - - /** - * Returns a read-only view of the local (i.e. not inherited) config key/value pairs on this entity, - * backed by a string-based map, including config names that did not match anything on this entity. - * - * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().getLocalBag()} - */ - @Deprecated - ConfigBag getLocalConfigBag(); - - /** * @deprecated since 0.8.0; use {@link SensorSupportInternal#getAll()} via code like {@code sensors().getAll()}. */ @Beta @@ -109,13 +75,6 @@ public interface EntityInternal extends BrooklynObjectInternal, EntityLocal, Reb void removeAttribute(AttributeSensor<?> attribute); /** - * - * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().refreshInheritedConfig()} - */ - @Deprecated - void refreshInheritedConfig(); - - /** * Must be called before the entity is started. * * @return this entity (i.e. itself) http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java index c462728..548f159 100644 --- a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java +++ b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java @@ -43,8 +43,6 @@ import org.apache.brooklyn.core.entity.EntityInternal; import org.apache.brooklyn.core.entity.EntityInternal.FeedSupport; import org.apache.brooklyn.core.mgmt.internal.EntityManagementSupport; import org.apache.brooklyn.core.objs.proxy.EntityProxyImpl; -import org.apache.brooklyn.util.core.config.ConfigBag; -import org.apache.brooklyn.util.guava.Maybe; import com.google.common.annotations.Beta; @@ -79,18 +77,11 @@ public interface EntityTransientCopyInternal { <T> T getAttribute(AttributeSensor<T> sensor); <T> T getConfig(ConfigKey<T> key); <T> T getConfig(HasConfigKey<T> key); - Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean includeInherited); - Maybe<Object> getConfigRaw(HasConfigKey<?> key, boolean includeInherited); TagSupport tags(); String getCatalogItemId(); // from EntityInternal: - @Deprecated EntityConfigMap getConfigMap(); - @Deprecated Map<ConfigKey<?>,Object> getAllConfig(); - // for rebind mainly: - @Deprecated ConfigBag getAllConfigBag(); - @Deprecated ConfigBag getLocalConfigBag(); @SuppressWarnings("rawtypes") Map<AttributeSensor, Object> getAllAttributes(); EntityManagementSupport getManagementSupport(); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java b/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java index 12253b6..9d82704 100644 --- a/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java +++ b/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java @@ -245,14 +245,14 @@ public abstract class AbstractLocation extends AbstractBrooklynObject implements boolean firstTime = !configured.getAndSet(true); - config().addToLocalBag(properties); + config().set(properties); if (properties.containsKey(PARENT_LOCATION.getName())) { // need to ensure parent's list of children is also updated setParent(config().get(PARENT_LOCATION)); // don't include parentLocation in configBag, as breaks rebind - config().removeFromLocalBag(PARENT_LOCATION); + config().removeKey(PARENT_LOCATION); } // NB: flag-setting done here must also be done in BasicLocationRebindSupport http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java index a233067..c576663 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java @@ -114,8 +114,8 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor } } - ((EntityInternal)entity).getConfigMap().addToLocalBag(memento.getConfigUnmatched()); - ((EntityInternal)entity).refreshInheritedConfig(); + ((EntityInternal)entity).config().set(memento.getConfigUnmatched()); + ((EntityInternal)entity).config().refreshInheritedConfig(); } @Override http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java index 9036e36..5273c65 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java @@ -70,7 +70,7 @@ public class BasicLocationRebindSupport extends AbstractBrooklynObjectRebindSupp // Note that the flags have been set in the constructor // Sept 2016 - now ignores unused and config description - location.config().addToLocalBag(memento.getLocationConfig()); + location.config().set(memento.getLocationConfig()); for (Map.Entry<String, Object> entry : memento.getLocationConfig().entrySet()) { String flagName = entry.getKey(); @@ -90,7 +90,7 @@ public class BasicLocationRebindSupport extends AbstractBrooklynObjectRebindSupp } else { value = TypeCoercions.coerce(entry.getValue(), fieldType); if (value != null) { - location.config().addToLocalBag(MutableMap.of(flagName, value)); + location.config().set(MutableMap.of(flagName, value)); FlagUtils.setFieldFromFlag(location, flagName, value); } } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java index 266ed07..a13dc91 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java @@ -178,14 +178,14 @@ public class MementosGenerators { builder.isTopLevelApp = (entity instanceof Application && entity.getParent() == null); - Map<ConfigKey<?>, Object> localConfig = entity.getConfigMap().getLocalConfig(); - for (Map.Entry<ConfigKey<?>, Object> entry : localConfig.entrySet()) { + Map<ConfigKey<?>, ?> localConfig = entity.config().getAllLocalRaw(); + for (Map.Entry<ConfigKey<?>, ?> entry : localConfig.entrySet()) { ConfigKey<?> key = checkNotNull(entry.getKey(), localConfig); Object value = configValueToPersistable(entry.getValue(), entityRaw, key.getName()); builder.config.put(key, value); } - Map<String, Object> localConfigUnmatched = MutableMap.copyOf(entity.getConfigMap().getLocalConfigBag().getAllConfig()); + Map<String, Object> localConfigUnmatched = MutableMap.copyOf(entity.config().getLocalBag().getAllConfig()); for (ConfigKey<?> key : localConfig.keySet()) { localConfigUnmatched.remove(key.getName()); } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java index 2e18fc0..c1b1942 100644 --- a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java +++ b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java @@ -201,17 +201,17 @@ public abstract class AbstractConfigurationSupportInternal implements BrooklynOb } @Override - public void addToLocalBag(Map<?, ?> vals) { + public void set(Map<?, ?> vals) { getConfigsInternal().addToLocalBag(vals); } @Override - public void removeFromLocalBag(String key) { + public void removeKey(String key) { getConfigsInternal().removeFromLocalBag(key); } @Override - public void removeFromLocalBag(ConfigKey<?> key) { + public void removeKey(ConfigKey<?> key) { getConfigsInternal().removeFromLocalBag(key); } @@ -225,6 +225,10 @@ public abstract class AbstractConfigurationSupportInternal implements BrooklynOb return getConfigsInternal(); } + public Map<ConfigKey<?>,Object> getAllLocalRaw() { + return getConfigsInternal().getAllConfigLocalRaw(); + } + @Override // TODO deprecate because key inheritance not respected public ConfigBag getBag() { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java b/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java index 566f957..7a46cfe 100644 --- a/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java +++ b/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java @@ -64,6 +64,7 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable { * and callers should be advised this beta method may be removed. */ @Beta + // TODO deprecate ConfigBag getBag(); /** @@ -71,7 +72,11 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable { * backed by a string-based map, including config names that did not match anything on this entity. */ @Beta + // TODO deprecate ConfigBag getLocalBag(); + + /** Returns all config defined here, in {@link #getLocalRaw(ConfigKey)} format */ + Map<ConfigKey<?>,Object> getAllLocalRaw(); /** * Returns the uncoerced value for this config key, if available, not taking any default. @@ -126,13 +131,13 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable { /** Adds keys or strings, making anonymous keys from strings; throws on other keys */ @Beta - void addToLocalBag(Map<?, ?> vals); + void set(Map<?, ?> vals); @Beta - void removeFromLocalBag(String key); + void removeKey(String key); @Beta - void removeFromLocalBag(ConfigKey<?> key); + void removeKey(ConfigKey<?> key); @Beta void refreshInheritedConfig(); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java b/core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java index 72d462f..1cabfc5 100644 --- a/core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java +++ b/core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java @@ -146,7 +146,7 @@ implements MachineProvisioningLocation<T>, Closeable { public FixedListMachineProvisioningLocation() { this(Maps.newLinkedHashMap()); } - public FixedListMachineProvisioningLocation(Map properties) { + public FixedListMachineProvisioningLocation(Map<?,?> properties) { super(properties); if (isLegacyConstruction()) { @@ -220,7 +220,7 @@ implements MachineProvisioningLocation<T>, Closeable { // TODO shouldn't have to copy config bag as it should be inherited (but currently it is not used inherited everywhere; just most places) return getManagementContext().getLocationManager().createLocation(LocationSpec.create(getClass()) .parent(this) - .configure(config().getLocalBag().getAllConfig()) // FIXME Should this just be inherited? + .configure(config().getAllLocalRaw()) // FIXME Should this just be inherited? .configure(newFlags)); } @@ -309,6 +309,7 @@ implements MachineProvisioningLocation<T>, Closeable { return obtain(Maps.<String,Object>newLinkedHashMap()); } + @SuppressWarnings("unchecked") @Override public T obtain(Map<?,?> flags) throws NoMachinesAvailableException { T machine; @@ -384,7 +385,7 @@ implements MachineProvisioningLocation<T>, Closeable { origConfigs.put(machine, origConfig); requestPersist(); - ((ConfigurationSupportInternal)machine.config()).addToLocalBag(strFlags); + ((ConfigurationSupportInternal)machine.config()).set(strFlags); } protected void restoreMachineConfig(MachineLocation machine) { @@ -399,9 +400,9 @@ implements MachineProvisioningLocation<T>, Closeable { Set<String> currentKeys = ((ConfigurationSupportInternal)machine.config()).getLocalBag().getAllConfig().keySet(); Set<String> newKeys = Sets.difference(currentKeys, origConfig.entrySet()); for (String key : newKeys) { - ((ConfigurationSupportInternal)machine.config()).removeFromLocalBag(key); + ((ConfigurationSupportInternal)machine.config()).removeKey(key); } - ((ConfigurationSupportInternal)machine.config()).addToLocalBag(origConfig); + ((ConfigurationSupportInternal)machine.config()).set(origConfig); } @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java b/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java index f8bbfd1..322f928 100644 --- a/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java @@ -21,8 +21,6 @@ package org.apache.brooklyn.core.config; import java.util.List; import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.core.config.SetConfigKey; -import org.apache.brooklyn.core.config.SubElementConfigKey; import org.apache.brooklyn.core.config.ListConfigKey.ListModifications; import org.apache.brooklyn.core.config.MapConfigKey.MapModifications; import org.apache.brooklyn.core.config.SetConfigKey.SetModifications; @@ -65,25 +63,25 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { public void testMapModUsage() throws Exception { entity.config().set(TestEntity.CONF_MAP_OBJ_THING, MapModifications.add(MutableMap.<String,Object>of("a", 1))); - log.info("Map-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Map-Mod: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_OBJ_THING), ImmutableMap.<String,Object>of("a", 1)); } public void testMapSubkeyUsage() throws Exception { entity.config().set(TestEntity.CONF_MAP_OBJ_THING.subKey("a"), 1); - log.info("Map-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Map-SubKey: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_OBJ_THING), ImmutableMap.<String,Object>of("a", 1)); } public void testMapDirectUsage() throws Exception { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_OBJ_THING.getName()), ImmutableMap.<String,Object>of("a", 1)); - log.info("Map-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Map-Direct: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_OBJ_THING), ImmutableMap.<String,Object>of("a", 1)); } public void testMapDotExtensionUsage() throws Exception { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_OBJ_THING.getName()+".a"), 1); - log.info("Map-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Map-DotExt: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_OBJ_THING), ImmutableMap.<String,Object>of("a", 1)); } @@ -92,42 +90,42 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_OBJ_THING.getName()+".dotext"), 1); entity.config().set(TestEntity.CONF_MAP_OBJ_THING.subKey("subkey"), 1); - log.info("Map-ManyWays: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Map-ManyWays: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_OBJ_THING), ImmutableMap.<String,Object>of("map", 1, "subkey", 1, "dotext", 1)); } @SuppressWarnings({ "unchecked", "rawtypes" }) public void testMapEmpty() throws Exception { // ensure it is null before we pass something in, and passing an empty collection makes it be empty - log.info("Map-Empty-1: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Map-Empty-1: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), null); entity.config().set((MapConfigKey)TestEntity.CONF_MAP_THING, MutableMap.of()); - log.info("Map-Empty-2: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Map-Empty-2: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), ImmutableMap.of()); } public void testSetModUsage() throws Exception { entity.config().set(TestEntity.CONF_SET_THING, SetModifications.addItem("x")); - log.info("Set-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-Mod: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } public void testSetSubKeyUsage() throws Exception { entity.config().set(TestEntity.CONF_SET_THING.subKey(), "x"); - log.info("Set-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-SubKey: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } public void testSetPutDirectUsage() throws Exception { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()), ImmutableSet.of("x")); - log.info("Set-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-Direct: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } public void testSetDotExtensionUsage() throws Exception { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()+".a"), "x"); - log.info("Set-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-DotExt: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } @@ -136,7 +134,7 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()+".dotext"), "dotextX"); entity.config().set(TestEntity.CONF_SET_THING.subKey(), "subkeyX"); - log.info("Set-ManyWays: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-ManyWays: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("directX", "subkeyX", "dotextX")); } @@ -151,7 +149,7 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { entity.config().set(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem("z")); entity.config().set(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem(MutableSet.of("c", "d"))); entity.config().set(TestEntity.CONF_SET_OBJ_THING, MutableSet.of(MutableSet.of("e", "f"))); - log.info("Set-Coll: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-Coll: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_OBJ_THING), ImmutableSet.of( "a", "b", "w", "x", "y", "z", ImmutableSet.of("c", "d"), ImmutableSet.of("e", "f"))); } @@ -159,37 +157,37 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { @SuppressWarnings({ "unchecked", "rawtypes" }) public void testSetEmpty() throws Exception { // ensure it is null before we pass something in, and passing an empty collection makes it be empty - log.info("Set-Empty-1: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-Empty-1: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), null); entity.config().set((SetConfigKey)TestEntity.CONF_SET_THING, MutableSet.of()); - log.info("Set-Empty-2: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("Set-Empty-2: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of()); } public void testListModUsage() throws Exception { entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.add("x", "x")); - log.info("List-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-Mod: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } public void testListSubKeyUsage() throws Exception { entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); - log.info("List-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-SubKey: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } public void testListPutDirectUsage() throws Exception { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x", "x")); - log.info("List-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-Direct: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } public void testListDotExtensionUsage() throws Exception { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".a"), "x"); entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".b"), "x"); - log.info("List-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-DotExt: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } @@ -199,7 +197,7 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { @Test(enabled=false) public void testListModUsageMultiValues() throws Exception { entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.add("x", "w", "x")); - log.info("List-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-Mod: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @@ -208,14 +206,14 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "w"); entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); - log.info("List-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-SubKey: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @Test(enabled=false) public void testListPutDirectUsageMultiValues() throws Exception { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x", "w", "x")); - log.info("List-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-Direct: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @@ -224,7 +222,7 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".a"), "x"); entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".c"), "w"); entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".b"), "x"); - log.info("List-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-DotExt: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @@ -236,7 +234,7 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x3"); entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "w3"); - log.info("List-ManyWays: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-ManyWays: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x1", "w1", "x2", "x2", "x3", "w3")); } @@ -251,7 +249,7 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { entity.config().set(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem("z")); entity.config().set(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem(MutableList.of("c", "d"))); entity.config().set(TestEntity.CONF_LIST_OBJ_THING, MutableList.of(MutableList.of("e", "f"))); - log.info("List-Coll: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-Coll: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); List<? extends Object> list = entity.getConfig(TestEntity.CONF_LIST_OBJ_THING); Assert.assertEquals(list.size(), 8, "list is: "+list); // "a", "b", "w", "x", "y", "z", ImmutableList.of("c", "d"), ImmutableList.of("e", "f")) @@ -260,10 +258,10 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { @SuppressWarnings({ "unchecked", "rawtypes" }) public void testListEmpty() throws Exception { // ensure it is null before we pass something in, and passing an empty collection makes it be empty - log.info("List-Empty-1: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-Empty-1: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), null); entity.config().set((ListConfigKey)TestEntity.CONF_LIST_THING, MutableList.of()); - log.info("List-Empty-2: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); + log.info("List-Empty-2: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of()); } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java index 5f02d55..af5e816 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java @@ -87,9 +87,9 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { .configure("myentity.myconfig", "myval1") .configure("myentity.myconfigwithflagname", "myval2")); - assertEquals(entity.getAllConfig(), ImmutableMap.of(MyEntity.MY_CONFIG, "myval1", MyEntity.MY_CONFIG_WITH_FLAGNAME, "myval2")); - assertEquals(entity.getAllConfigBag().getAllConfig(), ImmutableMap.of("myentity.myconfig", "myval1", "myentity.myconfigwithflagname", "myval2")); - assertEquals(entity.getLocalConfigBag().getAllConfig(), ImmutableMap.of("myentity.myconfig", "myval1", "myentity.myconfigwithflagname", "myval2")); + assertEquals(entity.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyEntity.MY_CONFIG, "myval1", MyEntity.MY_CONFIG_WITH_FLAGNAME, "myval2")); + assertEquals(entity.config().getBag().getAllConfig(), ImmutableMap.of("myentity.myconfig", "myval1", "myentity.myconfigwithflagname", "myval2")); + assertEquals(entity.config().getLocalBag().getAllConfig(), ImmutableMap.of("myentity.myconfig", "myval1", "myentity.myconfigwithflagname", "myval2")); } @Test @@ -98,19 +98,19 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { EntityInternal entity = mgmt.getEntityManager().createEntity(EntitySpec.create(MyEntity.class) .configure("myconfigflagname", "myval")); - assertEquals(entity.getAllConfig(), ImmutableMap.of(MyEntity.MY_CONFIG_WITH_FLAGNAME, "myval")); - assertEquals(entity.getAllConfigBag().getAllConfig(), ImmutableMap.of("myentity.myconfigwithflagname", "myval")); - assertEquals(entity.getLocalConfigBag().getAllConfig(), ImmutableMap.of("myentity.myconfigwithflagname", "myval")); + assertEquals(entity.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyEntity.MY_CONFIG_WITH_FLAGNAME, "myval")); + assertEquals(entity.config().getBag().getAllConfig(), ImmutableMap.of("myentity.myconfigwithflagname", "myval")); + assertEquals(entity.config().getLocalBag().getAllConfig(), ImmutableMap.of("myentity.myconfigwithflagname", "myval")); } - // TODO Which way round should it be?! + // config key name takes priority @Test(enabled=false) public void testPrefersFlagNameOverConfigKeyName() throws Exception { EntityInternal entity = mgmt.getEntityManager().createEntity(EntitySpec.create(MyEntity.class) .configure("myconfigflagname", "myval") .configure("myentity.myconfigwithflagname", "shouldIgnoreAndPreferFlagName")); - assertEquals(entity.getAllConfig(), ImmutableMap.of(MyEntity.MY_CONFIG_WITH_FLAGNAME, "myval")); + assertEquals(entity.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyEntity.MY_CONFIG_WITH_FLAGNAME, "myval")); } @Test @@ -118,9 +118,9 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { EntityInternal entity = mgmt.getEntityManager().createEntity(EntitySpec.create(MyEntity.class) .configure("notThere", "notThereVal")); - assertEquals(entity.getAllConfig(), ImmutableMap.of(ConfigKeys.newConfigKey(Object.class, "notThere"), "notThereVal")); - assertEquals(entity.getAllConfigBag().getAllConfig(), ImmutableMap.of("notThere", "notThereVal")); - assertEquals(entity.getLocalConfigBag().getAllConfig(), ImmutableMap.of("notThere", "notThereVal")); + assertEquals(entity.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(ConfigKeys.newConfigKey(Object.class, "notThere"), "notThereVal")); + assertEquals(entity.config().getBag().getAllConfig(), ImmutableMap.of("notThere", "notThereVal")); + assertEquals(entity.config().getLocalBag().getAllConfig(), ImmutableMap.of("notThere", "notThereVal")); } @Test @@ -133,11 +133,11 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { EntityInternal child = mgmt.getEntityManager().createEntity(EntitySpec.create(MyChildEntity.class) .parent(entity)); - assertEquals(child.getAllConfig(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG, "myval1", + assertEquals(child.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG, "myval1", ConfigKeys.newConfigKey(Object.class, "mychildconfigflagname"), "myval2", ConfigKeys.newConfigKey(Object.class, "notThere"), "notThereVal")); - assertEquals(child.getAllConfigBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfig", "myval1", "mychildconfigflagname", "myval2", "notThere", "notThereVal")); - assertEquals(child.getLocalConfigBag().getAllConfig(), ImmutableMap.of()); + assertEquals(child.config().getBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfig", "myval1", "mychildconfigflagname", "myval2", "notThere", "notThereVal")); + assertEquals(child.config().getLocalBag().getAllConfig(), ImmutableMap.of()); } @Test @@ -148,9 +148,9 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { EntityInternal child = mgmt.getEntityManager().createEntity(EntitySpec.create(MyChildEntity.class) .parent(entity)); - assertEquals(child.getAllConfig(), ImmutableMap.of(MyEntity.MY_CONFIG, "myval1")); - assertEquals(child.getAllConfigBag().getAllConfig(), ImmutableMap.of("myentity.myconfig", "myval1")); - assertEquals(child.getLocalConfigBag().getAllConfig(), ImmutableMap.of()); + assertEquals(child.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyEntity.MY_CONFIG, "myval1")); + assertEquals(child.config().getBag().getAllConfig(), ImmutableMap.of("myentity.myconfig", "myval1")); + assertEquals(child.config().getLocalBag().getAllConfig(), ImmutableMap.of()); } @Test @@ -164,25 +164,25 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { .configure("mychildentity.myconfigwithflagname", "overrideMyval") .configure("notThere", "overrideNotThereVal")); - assertEquals(child.getAllConfig(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG_WITH_FLAGNAME, "overrideMyval", + assertEquals(child.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG_WITH_FLAGNAME, "overrideMyval", ConfigKeys.newConfigKey(Object.class, "notThere"), "overrideNotThereVal")); - assertEquals(child.getAllConfigBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval", "notThere", "overrideNotThereVal")); - assertEquals(child.getLocalConfigBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval", "notThere", "overrideNotThereVal")); + assertEquals(child.config().getBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval", "notThere", "overrideNotThereVal")); + assertEquals(child.config().getLocalBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval", "notThere", "overrideNotThereVal")); } @Test public void testChildCanOverrideConfigUsingFlagName() throws Exception { EntityInternal entity = mgmt.getEntityManager().createEntity(EntitySpec.create(MyEntity.class) .configure(MyChildEntity.MY_CHILD_CONFIG_WITH_FLAGNAME, "myval")); - assertEquals(entity.getAllConfig(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG_WITH_FLAGNAME, "myval")); + assertEquals(entity.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG_WITH_FLAGNAME, "myval")); EntityInternal child = mgmt.getEntityManager().createEntity(EntitySpec.create(MyChildEntity.class) .parent(entity) .configure("mychildconfigflagname", "overrideMyval")); - assertEquals(child.getAllConfig(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG_WITH_FLAGNAME, "overrideMyval")); - assertEquals(child.getAllConfigBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval")); - assertEquals(child.getLocalConfigBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval")); + assertEquals(child.config().getBag().getAllConfigAsConfigKeyMap(), ImmutableMap.of(MyChildEntity.MY_CHILD_CONFIG_WITH_FLAGNAME, "overrideMyval")); + assertEquals(child.config().getBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval")); + assertEquals(child.config().getLocalBag().getAllConfig(), ImmutableMap.of("mychildentity.myconfigwithflagname", "overrideMyval")); } @Test @@ -332,11 +332,12 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { MySubEntity entity = app.addChild(EntitySpec.create(MySubEntity.class)); entity.config().set(MyBaseEntity.SUPER_KEY_1, "s1"); entity.config().set(MySubEntity.SUB_KEY_2, "s2"); - ConfigMap sub = entity.getConfigMap().submap(ConfigPredicates.nameMatchesGlob("sup*")); + ConfigMap sub = entity.config().getInternalConfigMap().submap(ConfigPredicates.nameMatchesGlob("sup*")); Assert.assertEquals(sub.getConfigRaw(MyBaseEntity.SUPER_KEY_1, true).get(), "s1"); Assert.assertFalse(sub.getConfigRaw(MySubEntity.SUB_KEY_2, true).isPresent()); } + @SuppressWarnings({ "rawtypes", "unchecked" }) @Test(expectedExceptions=IllegalArgumentException.class) public void testFailFastOnInvalidConfigKeyCoercion() throws Exception { MyOtherEntity entity = app.addChild(EntitySpec.create(MyOtherEntity.class)); @@ -344,6 +345,7 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { entity.config().set((ConfigKey)key, "thisisnotanint"); } + @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testGetConfigWithDeferredSupplierReturnsSupplied() throws Exception { DeferredSupplier<Integer> supplier = new DeferredSupplier<Integer>() { @@ -360,6 +362,7 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { assertEquals(entity.getConfig(MyOtherEntity.INT_KEY), Integer.valueOf(1)); } + @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testGetConfigWithFutureWaitsForResult() throws Exception { LatchingCallable<String> work = new LatchingCallable<String>("abc"); @@ -445,6 +448,7 @@ public class EntityConfigTest extends BrooklynAppUnitTestSupport { } @ImplementedBy(MyOtherEntityImpl.class) + @SuppressWarnings("rawtypes") public interface MyOtherEntity extends Entity { public static final ConfigKey<Integer> INT_KEY = ConfigKeys.newIntegerConfigKey("intKey", "int key", 1); public static final ConfigKey<String> STRING_KEY = ConfigKeys.newStringConfigKey("stringKey", "string key", null); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java index c6c2790..62aed5e 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java @@ -55,6 +55,7 @@ import org.apache.brooklyn.core.config.BasicConfigKey; import org.apache.brooklyn.core.entity.AbstractEntity; import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.entity.EntityAsserts; +import org.apache.brooklyn.core.entity.EntityInternal; import org.apache.brooklyn.core.entity.EntityPredicates; import org.apache.brooklyn.core.entity.trait.Resizable; import org.apache.brooklyn.core.entity.trait.Startable; @@ -556,13 +557,13 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { MyEntity origE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)); assertNull(origE.getConfig(MyEntity.MY_CONFIG)); - assertEquals(origE.getConfigRaw(MyEntity.MY_CONFIG, true).or("mydefault"), "mydefault"); + assertEquals(((EntityInternal)origE).config().getRaw(MyEntity.MY_CONFIG).or("mydefault"), "mydefault"); newApp = rebind(); MyEntity newE = (MyEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity.class)); assertNull(newE.getConfig(MyEntity.MY_CONFIG)); - assertEquals(newE.getConfigRaw(MyEntity.MY_CONFIG, true).or("mydefault"), "mydefault"); + assertEquals(((EntityInternal)newE).config().getRaw(MyEntity.MY_CONFIG).or("mydefault"), "mydefault"); } @Test http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java index 7ac31df..14b2a16 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java @@ -36,7 +36,9 @@ public class RebindManagerExceptionHandlerTest extends RebindTestFixtureWithApp @Test public void testAddConfigFailure() throws Throwable { origApp.createAndManageChild(EntitySpec.create(TestEntity.class) - .configure("test.confMapThing", ImmutableMap.of("keyWithMapValue", ImmutableMap.of("minRam", 4)))); + .configure(TestEntity.CONF_MAP_THING.getName(), + ImmutableMap.of("keyWithMapValue", ImmutableMap.of("minRam", 4)))); + // above misconfigured, should be a string key, but forced above so failure won't be enforced until persist/rebind try { RebindTestUtils.waitForPersisted(origApp); @@ -53,9 +55,12 @@ public class RebindManagerExceptionHandlerTest extends RebindTestFixtureWithApp @Test public void testAddConfigContinue() throws Throwable { ManagementContext m = createManagementContextWithAddConfigContinue(); + // configured above to continue on error + origApp = m.getEntityManager().createEntity(EntitySpec.create(TestApplication.class, TestApplicationNoEnrichersImpl.class)); origApp.createAndManageChild(EntitySpec.create(TestEntity.class) - .configure("test.confMapThing", ImmutableMap.of("keyWithMapValue", ImmutableMap.of("minRam", 4)))); + .configure(TestEntity.CONF_MAP_THING.getName(), + ImmutableMap.of("keyWithMapValue", ImmutableMap.of("minRam", 4)))); RebindTestUtils.waitForPersisted(origApp); RebindOptions rebindOptions = RebindOptions.create(); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java index f9a75be..7bd0381 100644 --- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java +++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolver.java @@ -154,7 +154,7 @@ public class JcloudsByonLocationResolver extends AbstractLocationResolver implem JcloudsLocation jcloudsLocation = (JcloudsLocation) managementContext.getLocationManager().createLocation(jcloudsLocationSpec.get()); for (Map<?,?> machineFlags : machinesFlags) { try { - jcloudsLocation.config().addToLocalBag(machineFlags); + jcloudsLocation.config().set(machineFlags); JcloudsMachineLocation machine = jcloudsLocation.registerMachine(jcloudsLocation.config().getBag()); result.add(machine); } catch (NoMachinesAvailableException e) { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java index 65ea8ec..f6f31a8 100644 --- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java +++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java @@ -249,7 +249,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im if (config().getLocalBag().containsKey("providerLocationId")) { LOG.warn("Using deprecated 'providerLocationId' key in "+this); if (!config().getLocalBag().containsKey(CLOUD_REGION_ID)) - config().addToLocalBag(MutableMap.of(CLOUD_REGION_ID.getName(), (String)config().getLocalBag().getStringKey("providerLocationId"))); + config().set(MutableMap.of(CLOUD_REGION_ID.getName(), (String)config().getLocalBag().getStringKey("providerLocationId"))); } if (isDisplayNameAutoGenerated() || !groovyTruth(getDisplayName())) { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java index 6d3553b..714fda4 100644 --- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java +++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java @@ -203,7 +203,7 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements Jcl protected void setNode(NodeMetadata node) { this.node = null; - config().removeFromLocalBag("node"); + config().removeKey("node"); nodeId = node.getId(); imageId = node.getImageId(); privateAddresses = node.getPrivateAddresses(); @@ -213,7 +213,7 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements Jcl protected void setTemplate(Template template) { this.template = null; - config().removeFromLocalBag("template"); + config().removeKey("template"); _template = Optional.of(template); _image = Optional.fromNullable(template.getImage()); } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java ---------------------------------------------------------------------- diff --git a/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java b/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java index 4b6afd8..f0e94ba 100644 --- a/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java +++ b/policy/src/main/java/org/apache/brooklyn/policy/loadbalancing/LoadBalancingPolicy.java @@ -36,6 +36,7 @@ import org.apache.brooklyn.api.sensor.Sensor; import org.apache.brooklyn.api.sensor.SensorEvent; import org.apache.brooklyn.api.sensor.SensorEventListener; import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; import org.apache.brooklyn.core.entity.EntityInternal; import org.apache.brooklyn.core.policy.AbstractPolicy; import org.slf4j.Logger; @@ -278,8 +279,8 @@ public class LoadBalancingPolicy<NodeType extends Entity, ItemType extends Movab if (LOG.isTraceEnabled()) LOG.trace("{} recording addition of container {}", this, newContainer); // Low and high thresholds for the metric we're interested in are assumed to be present // in the container's configuration. - Number lowThreshold = (Number) findConfigValue(newContainer, lowThresholdConfigKeyName); - Number highThreshold = (Number) findConfigValue(newContainer, highThresholdConfigKeyName); + Number lowThreshold = newContainer.getConfig(ConfigKeys.newConfigKey(Number.class, lowThresholdConfigKeyName)); + Number highThreshold = newContainer.getConfig(ConfigKeys.newConfigKey(Number.class, highThresholdConfigKeyName)); if (lowThreshold == null || highThreshold == null) { LOG.warn( "Balanceable container '"+newContainer+"' does not define low- and high- threshold configuration keys: '"+ @@ -295,15 +296,10 @@ public class LoadBalancingPolicy<NodeType extends Entity, ItemType extends Movab if (rebalanceNow) scheduleRebalance(); } - private static Object findConfigValue(Entity entity, String configKeyName) { - Map<ConfigKey<?>, Object> config = ((EntityInternal)entity).getAllConfig(); - for (Entry<ConfigKey<?>, Object> entry : config.entrySet()) { - if (configKeyName.equals(entry.getKey().getName())) - return entry.getValue(); - } + private Number findConfigValue(NodeType newContainer, String lowThresholdConfigKeyName2) { return null; } - + // TODO Receiving duplicates of onContainerRemoved (e.g. when running LoadBalancingInmemorySoakTest) private void onContainerRemoved(NodeType oldContainer, boolean rebalanceNow) { if (LOG.isTraceEnabled()) LOG.trace("{} recording removal of container {}", this, oldContainer); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/software/base/src/main/java/org/apache/brooklyn/entity/brooklynnode/effector/BrooklynNodeUpgradeEffectorBody.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/brooklynnode/effector/BrooklynNodeUpgradeEffectorBody.java b/software/base/src/main/java/org/apache/brooklyn/entity/brooklynnode/effector/BrooklynNodeUpgradeEffectorBody.java index 4e75121..67128c1 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/brooklynnode/effector/BrooklynNodeUpgradeEffectorBody.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/brooklynnode/effector/BrooklynNodeUpgradeEffectorBody.java @@ -145,7 +145,7 @@ public class BrooklynNodeUpgradeEffectorBody extends EffectorBody<Void> { DynamicTasks.waitForLast(); ((EntityInternal)entity()).sensors().set(SoftwareProcess.INSTALL_DIR, (String)null); entity().config().set(SoftwareProcess.INSTALL_UNIQUE_LABEL, (String)null); - entity().getConfigMap().addToLocalBag(parameters.getAllConfig()); + entity().config().set(parameters.getAllConfig()); entity().sensors().set(BrooklynNode.DOWNLOAD_URL, entity().getConfig(DOWNLOAD_URL)); // Setting SUGGESTED_VERSION will result in an new empty INSTALL_FOLDER, but clear it http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefLifecycleEffectorTasks.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefLifecycleEffectorTasks.java b/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefLifecycleEffectorTasks.java index 96d692f..78eb094 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefLifecycleEffectorTasks.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefLifecycleEffectorTasks.java @@ -183,7 +183,7 @@ public class ChefLifecycleEffectorTasks extends MachineLifecycleEffectorTasks im Navigator<MutableMap<Object, Object>> attrs = Jsonya.newInstancePrimitive().at("brooklyn"); if (Strings.isNonBlank(primary)) attrs.at(primary); attrs.at("config"); - attrs.put( entity().getAllConfigBag().getAllConfig() ); + attrs.put( entity().config().getBag().getAllConfig() ); // and put launch attrs at root try { attrs.root().put((Map<?,?>)Tasks.resolveDeepValue(entity().getConfig(CHEF_LAUNCH_ATTRIBUTES), Object.class, entity().getExecutionContext())); @@ -215,7 +215,7 @@ public class ChefLifecycleEffectorTasks extends MachineLifecycleEffectorTasks im Navigator<MutableMap<Object, Object>> attrs = Jsonya.newInstancePrimitive().at("brooklyn"); if (Strings.isNonBlank(primary)) attrs.at(primary); attrs.at("config"); - attrs.put( entity().getAllConfigBag().getAllConfig() ); + attrs.put( entity().config().getBag().getAllConfig() ); // and put launch attrs at root try { attrs.root().put((Map<?,?>)Tasks.resolveDeepValue(entity().getConfig(CHEF_LAUNCH_ATTRIBUTES), Object.class, entity().getExecutionContext())); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/software/base/src/main/java/org/apache/brooklyn/entity/java/JmxSupport.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/java/JmxSupport.java b/software/base/src/main/java/org/apache/brooklyn/entity/java/JmxSupport.java index 86c211e..eeafbcb 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/java/JmxSupport.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/java/JmxSupport.java @@ -346,7 +346,7 @@ public class JmxSupport implements UsesJmx { */ public void recommendJmxRmiCustomAgent() { // set JMX_RMI because the registry is needed (i think) - Maybe<Object> jmx = entity.getConfigRaw(UsesJmx.JMX_AGENT_MODE, true); + Maybe<Object> jmx = ((EntityInternal)entity).config().getRaw(UsesJmx.JMX_AGENT_MODE); if (!jmx.isPresentAndNonNull()) { setConfig(UsesJmx.JMX_AGENT_MODE, JmxAgentModes.JMX_RMI_CUSTOM_AGENT); } else if (jmx.get()!=JmxAgentModes.JMX_RMI_CUSTOM_AGENT) { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java index a1f2f87..53ccbec 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java @@ -154,7 +154,7 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP } protected void setInstallLabel() { - if (getEntity().getConfigRaw(SoftwareProcess.INSTALL_UNIQUE_LABEL, false).isPresentAndNonNull()) return; + if (((EntityInternal)getEntity()).config().getLocalRaw(SoftwareProcess.INSTALL_UNIQUE_LABEL).isPresentAndNonNull()) return; getEntity().config().set(SoftwareProcess.INSTALL_UNIQUE_LABEL, getEntity().getEntityType().getSimpleName()+ (Strings.isNonBlank(getVersion()) ? "_"+getVersion() : "")+ http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java index 4e9bfdd..f2287ab 100644 --- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java +++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java @@ -26,6 +26,7 @@ import org.apache.brooklyn.api.entity.EntityLocal; import org.apache.brooklyn.api.entity.drivers.downloads.DownloadResolver; import org.apache.brooklyn.config.ConfigKey; import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.entity.EntityInternal; import org.apache.brooklyn.core.objs.BrooklynObjectInternal.ConfigurationSupportInternal; import org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper; import org.apache.brooklyn.location.ssh.SshMachineLocation; @@ -82,7 +83,7 @@ public class VanillaSoftwareProcessSshDriver extends AbstractSoftwareProcessSshD @Override public void install() { - Maybe<Object> url = getEntity().getConfigRaw(SoftwareProcess.DOWNLOAD_URL, true); + Maybe<Object> url = ((EntityInternal)getEntity()).config().getRaw(SoftwareProcess.DOWNLOAD_URL); if (url.isPresentAndNonNull()) { DownloadResolver resolver = Entities.newDownloader(this); List<String> urls = resolver.getTargets(); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java ---------------------------------------------------------------------- diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java index 18f7ff2..b1564e9 100644 --- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java +++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java @@ -30,21 +30,6 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -import org.jclouds.util.Throwables2; - import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.entity.EntityLocal; import org.apache.brooklyn.api.entity.EntitySpec; @@ -92,6 +77,19 @@ import org.apache.brooklyn.util.net.UserAndHostAndPort; import org.apache.brooklyn.util.os.Os; import org.apache.brooklyn.util.text.Strings; import org.apache.brooklyn.util.time.Duration; +import org.jclouds.util.Throwables2; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport { @@ -768,7 +766,7 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport { @Override protected String getInstallLabelExtraSalt() { - return (String)getEntity().getConfigRaw(ConfigKeys.newStringConfigKey("salt"), true).or((String)null); + return (String)((EntityInternal)getEntity()).config().getRaw(ConfigKeys.newStringConfigKey("salt")).or((String)null); } } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/914982ea/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java ---------------------------------------------------------------------- diff --git a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java index 933e0e7..2cc5068 100644 --- a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java +++ b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java @@ -75,10 +75,10 @@ public interface ConfigMap { * @param key key to look up * @return raw, unresolved, uncoerced value of key explicitly in map */ - // TODO deprecate other methods? getRaw won't be able to merge for instance public Maybe<Object> getConfigLocalRaw(ConfigKey<?> key); /** returns a map of all config keys to their raw (unresolved+uncoerced) contents */ + // TODO deprecate public Map<ConfigKey<?>,Object> getAllConfig(); /** returns submap matching the given filter predicate; see ConfigPredicates for common predicates */