You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/06/29 15:36:15 UTC

[33/50] [abbrv] brooklyn-server git commit: Fix openshift config so location config is used

Fix openshift config so location config is used


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

Branch: refs/heads/master
Commit: 2ed4290854ac22a89d9677ce28ae0db83d4655c2
Parents: a334e0f
Author: graeme.miller <gr...@cloudsoftcorp.com>
Authored: Tue May 23 17:35:08 2017 +0100
Committer: graeme.miller <gr...@cloudsoftcorp.com>
Committed: Tue May 23 17:35:08 2017 +0100

----------------------------------------------------------------------
 .../location/kubernetes/KubernetesLocation.java | 28 ++++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2ed42908/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
index 75164e3..65973d9 100644
--- a/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
+++ b/brooklyn-server/locations/container/src/main/java/org/apache/brooklyn/container/location/kubernetes/KubernetesLocation.java
@@ -122,6 +122,8 @@ import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
 
+import javax.annotation.Nullable;
+
 public class KubernetesLocation extends AbstractLocation implements MachineProvisioningLocation<KubernetesMachineLocation>, KubernetesLocationConfig {
 
     /*
@@ -999,22 +1001,32 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi
         throw new UnsupportedOperationException();
     }
 
-    /**
-     * @see {@link #lookup(ConfigKey, Entity, ConfigBag, Object)}
-     */
+    /** @see {@link #lookup(ConfigKey, Entity, ConfigBag, Object)} */
     public <T> T lookup(ConfigKey<T> config, Entity entity, ConfigBag setup) {
-        return lookup(config, entity, setup, null);
+        return lookup(config, entity, setup, config.getDefaultValue());
     }
 
     /**
      * Looks up {@link ConfigKey configuration} with the entity value taking precedence over the
      * location, and returning a default value (normally {@literal null}) if neither is present.
      */
-    public <T> T lookup(ConfigKey<T> config, Entity entity, ConfigBag setup, T defaultValue) {
-        Optional<T> entityValue = Optional.fromNullable(entity.config().get(config));
-        Optional<T> locationValue = Optional.fromNullable(setup.get(config));
+    public <T> T lookup(final ConfigKey<T> config, Entity entity, ConfigBag setup, T defaultValue) {
+        boolean entityConfigPresent = !entity.config().findKeysPresent(new Predicate<ConfigKey<?>>() {
+            @Override
+            public boolean apply(@Nullable ConfigKey<?> configKey) {
+                return config.equals(configKey);
+            }
+        }).isEmpty();
+
+        boolean setupBagConfigPresent = setup.containsKey(config);
+
+        if (entityConfigPresent) {
+            return entity.config().get(config);
+        } else if (setupBagConfigPresent) {
+            return setup.get(config);
+        }
 
-        return Iterables.getFirst(Optional.presentInstances(Arrays.asList(entityValue, locationValue)), defaultValue);
+        return defaultValue;
     }
 
     public void waitForExitCondition(ExitCondition exitCondition) {