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:35:50 UTC

[08/50] [abbrv] brooklyn-server git commit: Filter out empty KubernetesEmptyMachineLocation for KubernetesPod compatibility

Filter out empty KubernetesEmptyMachineLocation for KubernetesPod compatibility


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

Branch: refs/heads/master
Commit: 272e25a1e9ffb422193ca43de186c64ec4e19fa1
Parents: ca876ce
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Fri Feb 3 04:52:34 2017 +0000
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Fri May 19 14:01:20 2017 +0100

----------------------------------------------------------------------
 .../kubernetes/entity/KubernetesPodImpl.java    | 25 +++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/272e25a1/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPodImpl.java
----------------------------------------------------------------------
diff --git a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPodImpl.java b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPodImpl.java
index 79f1d97..637bd75 100644
--- a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPodImpl.java
+++ b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPodImpl.java
@@ -1,6 +1,20 @@
 package io.cloudsoft.amp.containerservice.kubernetes.entity;
 
+import static com.google.common.base.Predicates.and;
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.base.Predicates.not;
+import static org.apache.brooklyn.core.location.LocationPredicates.configEqualTo;
+
+import java.util.Collection;
+
+import org.apache.brooklyn.api.location.Location;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
 import io.cloudsoft.amp.containerservice.dockercontainer.DockerContainerImpl;
+import io.cloudsoft.amp.containerservice.kubernetes.location.machine.KubernetesEmptyMachineLocation;
+import io.cloudsoft.amp.containerservice.kubernetes.location.machine.KubernetesMachineLocation;
 
 public class KubernetesPodImpl extends DockerContainerImpl implements KubernetesPod {
 
@@ -9,8 +23,17 @@ public class KubernetesPodImpl extends DockerContainerImpl implements Kubernetes
         super.init();
 
         if (config().get(IMAGE_NAME) == null && config().get(INBOUND_TCP_PORTS) == null) {
-            config().set(CHILDREN_STARTABLE_MODE, ChildStartableMode.BACKGROUND);
+            config().set(CHILDREN_STARTABLE_MODE, ChildStartableMode.BACKGROUND_LATE);
         }
     }
 
+    // FIXME I hate myself...
+    @Override
+    public Collection<Location> getLocations() {
+        // TODO Remove this filtering once backwards compatible KubernetesPod usage is deprecated
+        return ImmutableSet.copyOf(Iterables.filter(super.getLocations(),
+                not(and(instanceOf(KubernetesEmptyMachineLocation.class),
+                        configEqualTo(KubernetesMachineLocation.KUBERNETES_RESOURCE_TYPE, KubernetesPod.EMPTY)))));
+    }
+
 }