updating partitions kubernetes cluster ids on network partition deployment
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2ebca69e Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2ebca69e Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2ebca69e Branch: refs/heads/4.1.0-beta-deployment-policy-fix Commit: 2ebca69e08ee0e6caff59081a195da9c0f4da7a5 Parents: c04e42b Author: R-Rajkumar <[email protected]> Authored: Thu Feb 19 13:57:36 2015 +0530 Committer: R-Rajkumar <[email protected]> Committed: Thu Feb 19 13:57:36 2015 +0530 ---------------------------------------------------------------------- .../impl/CloudControllerServiceImpl.java | 3 +++ .../impl/CloudControllerServiceUtil.java | 25 ++++++++++++++++++++ 2 files changed, 28 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/2ebca69e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java index 792a013..7ce221f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java @@ -1537,6 +1537,9 @@ public class CloudControllerServiceImpl implements CloudControllerService { } } + // overwrites partitions' kubernetes cluster ids with network partition's kubernetes cluster id + CloudControllerServiceUtil.overwritesPartitionsKubernetesClusterIdsWithNetworkPartitionKubernetesClusterId(networkPartition); + // adding network partition to CC-Context CloudControllerContext.getInstance().addNetworkPartition(networkPartition); // persisting CC-Context http://git-wip-us.apache.org/repos/asf/stratos/blob/2ebca69e/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java index 76374f3..7cc8bed 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java @@ -19,10 +19,12 @@ package org.apache.stratos.cloud.controller.services.impl; +import java.util.List; import java.util.Properties; import com.google.common.net.InetAddresses; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.context.CloudControllerContext; @@ -234,4 +236,27 @@ public class CloudControllerServiceUtil { } } } + + /** + * Overwrites partition's kubernetes cluster ids with network partition's kubernetes cluster ids. + * @param networkPartitions + */ + public static void overwritesPartitionsKubernetesClusterIdsWithNetworkPartitionKubernetesClusterId(NetworkPartition networkPartition) { + + if(StringUtils.isNotBlank(networkPartition.getKubernetesClusterId())) { + Partition[] partitions = networkPartition.getPartitions(); + if(partitions != null) { + for(Partition partition : partitions) { + if(partition != null) { + if(log.isInfoEnabled()) { + log.info(String.format("Overwriting partition's kubernetes cluster id: " + + "[network-partition-id] %s [partition-id] %s [kubernetes-cluster-id] %s", + networkPartition.getId(), partition.getId(), networkPartition.getKubernetesClusterId())); + } + partition.setKubernetesClusterId(networkPartition.getKubernetesClusterId()); + } + } + } + } + } }
