Repository: stratos Updated Branches: refs/heads/docker-grouping-merge 2d490c1c9 -> c63d0552c
fixing merging issue Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c63d0552 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c63d0552 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c63d0552 Branch: refs/heads/docker-grouping-merge Commit: c63d0552c8a005390dafdd86166cfc8b62ab43ac Parents: 2d490c1 Author: reka <[email protected]> Authored: Tue Nov 4 11:53:01 2014 +0530 Committer: reka <[email protected]> Committed: Tue Nov 4 11:53:01 2014 +0530 ---------------------------------------------------------------------- .../impl/CloudControllerServiceImpl.java | 83 ++++++++------------ .../pojo/ApplicationClusterContextDTO.java | 5 +- .../cloud/controller/pojo/ClusterContext.java | 6 +- 3 files changed, 35 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/c63d0552/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index d7d9400..fd4f172 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -45,7 +45,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.util.PodActivationWatcher; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; -import org.apache.stratos.common.Property; +import org.apache.stratos.common.*; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.kubernetes.client.KubernetesApiClient; import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException; @@ -69,6 +69,7 @@ import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; import java.util.Map.Entry; +import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -1063,11 +1064,12 @@ public class CloudControllerServiceImpl implements CloudControllerService { String property = props.getProperty(Constants.IS_LOAD_BALANCER); boolean isLb = property != null ? Boolean.parseBoolean(property) : false; - ClusterContext ctxt = null;//TODO buildClusterContext(cartridge, clusterId, - //payload, hostName, props, isLb, registrant.getPersistence()); + //TODO fix the properties issue + /*ClusterContext ctxt = buildClusterContext(cartridge, clusterId, + payload, hostName, props, isLb, registrant.getPersistence()); - dataHolder.addClusterContext(ctxt); + dataHolder.addClusterContext(ctxt);*/ TopologyBuilder.handleClusterCreated(registrant, isLb); persist(); @@ -1080,13 +1082,12 @@ public class CloudControllerServiceImpl implements CloudControllerService { private ClusterContext buildClusterContext(Cartridge cartridge, String clusterId, String payload, String hostName, org.apache.stratos.common.Properties props, boolean isLb, Persistence persistence) { - - //TODO - /*// initialize ClusterContext + //TODO fix properties issue + // initialize ClusterContext ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, hostName, isLb, props); - String property; + /*String property; property = props.get(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); long timeout = property != null ? Long.parseLong(property) : 30000; @@ -1102,7 +1103,8 @@ public class CloudControllerServiceImpl implements CloudControllerService { ctxt.setVolumeRequired(false); } ctxt.setTimeoutInMillis(timeout); - return ctxt;*/ + return ctxt; + ;*/ return null; } @@ -1498,7 +1500,14 @@ public class CloudControllerServiceImpl implements CloudControllerService { kubApi.createService(service); // set host port and update - ctxt.addProperty(StratosConstants.ALLOCATED_SERVICE_HOST_PORT, service.getPort()); + //TODO to clean the impl of properties + Property[] properties = new Property[1]; + Property property = new Property(StratosConstants.ALLOCATED_SERVICE_HOST_PORT, + String.valueOf(service.getPort())); + org.apache.stratos.common.Properties properties1 = new org.apache.stratos.common.Properties(); + properties1.setProperties(properties); + + ctxt.setProperties(properties1); dataHolder.addClusterContext(ctxt); if (LOG.isDebugEnabled()) { @@ -1897,7 +1906,8 @@ public class CloudControllerServiceImpl implements CloudControllerService { } } - public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts) throws + @Override + public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException { // Create a Cluster Context obj. for each of the Clusters in the Application @@ -1906,25 +1916,27 @@ public class CloudControllerServiceImpl implements CloudControllerService { LOG.error(errorMsg); throw new ApplicationClusterRegistrationException(errorMsg); } + List<Cluster> clusters = new ArrayList<Cluster>(); - //TODO - /*for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { - dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { - /* TODO dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), + dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())) - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); + appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); // create Cluster objects Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(), appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); newCluster.setLbCluster(false); - newCluster.setTenantRange("*"); + newCluster.setTenantRange(appClusterCtxt.getTenantRange()); newCluster.setStatus(ClusterStatus.Created); newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); - clusters.add(newCluster);*/ + Cartridge cartridge = dataHolder.getCartridge(appClusterCtxt.getCartridgeType()); + if(cartridge.getDeployerType().equals(StratosConstants.KUBERNETES_DEPLOYER_TYPE)) { + newCluster.setKubernetesCluster(true); + } + clusters.add(newCluster); } + } // public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { // @@ -1950,39 +1962,6 @@ public class CloudControllerServiceImpl implements CloudControllerService { // //TopologyBuilder.handleApplicationUndeployed(applicationId); // } - public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts) throws - ApplicationClusterRegistrationException { - - // Create a Cluster Context obj. for each of the Clusters in the Application - if (appClustersContexts == null || appClustersContexts.length == 0) { - String errorMsg = "No application cluster information found, unable to create clusters" ; - LOG.error(errorMsg); - throw new ApplicationClusterRegistrationException(errorMsg); - } - - List<Cluster> clusters = new ArrayList<Cluster>(); - - for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { - // add the context data - //TODO - /*dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), - appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties()));*/ - // create Cluster objects - Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(), - appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); - newCluster.setLbCluster(false); - newCluster.setTenantRange("*"); - newCluster.setStatus(ClusterStatus.Created); - newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); - //newCluster.setProperties(appClusterCtxt.getProperties()); - clusters.add(newCluster); - } - - TopologyBuilder.handleApplicationClustersCreated(appId, clusters); - - persist(); - } // public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { // http://git-wip-us.apache.org/repos/asf/stratos/blob/c63d0552/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java index cbf1a2b..9e3d046 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java @@ -34,8 +34,6 @@ public class ApplicationClusterContextDTO { private String hostName; // flag to indicate LB cluster private boolean isLbCluster; - // flag to indicate Kubernetes cluster - private boolean isKubernetesCluster; // autoscaling policy private String autoscalePolicyName; // deployment policy @@ -45,8 +43,6 @@ public class ApplicationClusterContextDTO { // propertis private Properties properties; - public ApplicationClusterContextDTO () { - } public ApplicationClusterContextDTO () { } @@ -143,4 +139,5 @@ public class ApplicationClusterContextDTO { public void setProperties(Properties properties) { this.properties = properties; } + } http://git-wip-us.apache.org/repos/asf/stratos/blob/c63d0552/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java index cb48739..5e0eebd 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java @@ -19,9 +19,9 @@ package org.apache.stratos.cloud.controller.pojo; import java.io.Serializable; -import java.util.Properties; import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Properties; /** * Holds runtime data of a Cluster. @@ -122,11 +122,11 @@ public class ClusterContext implements Serializable{ this.properties = properties; } - public void addProperty(String key, int value) { + /*public void addProperty(String key, int value) { this.properties.put(key, value); } public void addProperty(String key, String value) { this.properties.put(key, value); - } + }*/ }
