Repository: stratos Updated Branches: refs/heads/master 48ef59a93 -> 98872dbb3
Fixing deployment polocy related issues in manager backend client Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/98872dbb Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/98872dbb Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/98872dbb Branch: refs/heads/master Commit: 98872dbb3d5404c11463c8b955814a91b1e09e30 Parents: 48ef59a Author: Lahiru Sandaruwan <[email protected]> Authored: Sun Nov 30 14:28:07 2014 +0530 Committer: Lahiru Sandaruwan <[email protected]> Committed: Sun Nov 30 14:28:07 2014 +0530 ---------------------------------------------------------------------- .../manager/client/AutoscalerServiceClient.java | 49 ++- .../multitenant/lb/DefaultLBService.java | 12 +- .../multitenant/lb/ServiceAwareLBService.java | 14 +- .../deployer/DefaultServiceGroupDeployer.java | 2 + .../category/DefaultLoadBalancerCategory.java | 12 +- .../ServiceLevelLoadBalancerCategory.java | 14 +- .../manager/CartridgeSubscriptionManager.java | 2 +- .../utils/CartridgeSubscriptionUtils.java | 429 ++++++++++--------- .../rest/endpoint/api/StratosApiV40Utils.java | 2 +- .../rest/endpoint/api/StratosApiV41Utils.java | 2 +- .../bean/util/converter/PojoConverter.java | 4 +- .../pom.xml | 1 + 12 files changed, 275 insertions(+), 268 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java index 4211b0b..a220323 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java @@ -24,6 +24,7 @@ import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.stub.deployment.partition.ApplicationLevelNetworkPartition; import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext; import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; import org.apache.stratos.autoscaler.stub.*; @@ -121,13 +122,15 @@ public class AutoscalerServiceClient { // return partitions; // } - public org.apache.stratos.autoscaler.stub.partition.PartitionGroup[] getPartitionGroups( + public ApplicationLevelNetworkPartition[] getApplicationLevelNetworkPartition( String deploymentPolicyId) throws RemoteException { - org.apache.stratos.autoscaler.stub.partition.PartitionGroup[] partitionGroups; - partitionGroups = stub.getPartitionGroups(deploymentPolicyId); + ApplicationLevelNetworkPartition[] partitionGroups; +// partitionGroups = stub.getPartitionGroups(deploymentPolicyId); - return partitionGroups; +// return partitionGroups; + //FIXME add a method to autoscaler to return Application Level NetworkPartitions + return null; } public org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy[] getAutoScalePolicies() @@ -167,19 +170,19 @@ public class AutoscalerServiceClient { return deploymentPolicies; } - public void checkLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) throws RemoteException, - AutoScalerServiceNonExistingLBExceptionException { - stub.checkLBExistenceAgainstPolicy(clusterId, deploymentPolicyId); - } - - public boolean checkDefaultLBExistenceAgainstPolicy( - String deploymentPolicyId) throws RemoteException { - return stub.checkDefaultLBExistenceAgainstPolicy(deploymentPolicyId); - } - - public boolean checkServiceLBExistenceAgainstPolicy(String serviceName, String deploymentPolicyId) throws RemoteException { - return stub.checkServiceLBExistenceAgainstPolicy(serviceName, deploymentPolicyId); - } +// public void checkLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) throws RemoteException, +// AutoScalerServiceNonExistingLBExceptionException { +// stub.checkLBExistenceAgainstPolicy(clusterId, deploymentPolicyId); +// } +// +// public boolean checkDefaultLBExistenceAgainstPolicy( +// String deploymentPolicyId) throws RemoteException { +// return stub.checkDefaultLBExistenceAgainstPolicy(deploymentPolicyId); +// } +// +// public boolean checkServiceLBExistenceAgainstPolicy(String serviceName, String deploymentPolicyId) throws RemoteException { +// return stub.checkServiceLBExistenceAgainstPolicy(serviceName, deploymentPolicyId); +// } public org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy getDeploymentPolicy(String deploymentPolicyId) throws RemoteException { @@ -222,9 +225,9 @@ public class AutoscalerServiceClient { // // } - public String getDefaultLBClusterId(String deploymentPolicy) throws RemoteException { - return stub.getDefaultLBClusterId(deploymentPolicy); - } +// public String getDefaultLBClusterId(String deploymentPolicy) throws RemoteException { +// return stub.getDefaultLBClusterId(deploymentPolicy); +// } public ServiceGroup getServiceGroup(String serviceGroupDefinitionName) throws RemoteException { @@ -250,9 +253,9 @@ public class AutoscalerServiceClient { } - public String getServiceLBClusterId(String serviceType, String deploymentPolicy) throws RemoteException { - return stub.getServiceLBClusterId(serviceType, deploymentPolicy); - } +// public String getServiceLBClusterId(String serviceType, String deploymentPolicy) throws RemoteException { +// return stub.getServiceLBClusterId(serviceType, deploymentPolicy); +// } public boolean deployKubernetesGroup(KubernetesGroup kubernetesGroup) throws RemoteException, AutoScalerServiceInvalidKubernetesGroupExceptionException { http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java index 4892c8f..66175e3 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java @@ -55,12 +55,12 @@ public class DefaultLBService extends LBService { // call the relevant method to get the cluster id, using deployment policy String clusterId = null; - try { - clusterId = AutoscalerServiceClient.getServiceClient().getDefaultLBClusterId(getDeploymentPolicyName()); - } catch (Exception e) { - log.error("Error occurred in retrieving default LB cluster id" + e.getMessage()); - throw new ADCException(e); - } +// try { +// clusterId = AutoscalerServiceClient.getServiceClient().getDefaultLBClusterId(getDeploymentPolicyName()); +// } catch (Exception e) { +// log.error("Error occurred in retrieving default LB cluster id" + e.getMessage()); +// throw new ADCException(e); +// } if (clusterId != null) { //set the cluster id to Cluster object http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java index c83879a..96111bf 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java @@ -59,13 +59,13 @@ public class ServiceAwareLBService extends LBService { // call the relevant method to get the cluster id, using deployment policy and type String clusterId = null; - try { - clusterId = AutoscalerServiceClient.getServiceClient().getServiceLBClusterId(getLoadBalancedServiceType(), getDeploymentPolicyName()); - - } catch (Exception e) { - log.error("Error occurred in retrieving Service LB cluster id" + e.getMessage()); - throw new ADCException(e); - } +// try { +// clusterId = AutoscalerServiceClient.getServiceClient().getServiceLBClusterId(getLoadBalancedServiceType(), getDeploymentPolicyName()); +// +// } catch (Exception e) { +// log.error("Error occurred in retrieving Service LB cluster id" + e.getMessage()); +// throw new ADCException(e); +// } if (clusterId != null) { http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java index 83c82b5..8a6235f 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java @@ -22,6 +22,8 @@ package org.apache.stratos.manager.grouping.deployer; import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.stub.AutoScalerServiceAutoScalerExceptionException; +import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidServiceGroupExceptionException; import org.apache.stratos.autoscaler.stub.pojo.Dependencies; import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; import org.apache.stratos.autoscaler.stub.exception.*; http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java index b6bf7ce..10f249c 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java @@ -50,12 +50,12 @@ public class DefaultLoadBalancerCategory extends LoadBalancerCategory { // call the relevant method to get the cluster id, using deployment policy String clusterId = null; - try { - clusterId = AutoscalerServiceClient.getServiceClient().getDefaultLBClusterId(getDeploymentPolicyName()); - } catch (Exception e) { - log.error("Error occurred in retrieving default LB cluster id" + e.getMessage()); - throw new ADCException(e); - } +// try { +// clusterId = AutoscalerServiceClient.getServiceClient().getDefaultLBClusterId(getDeploymentPolicyName()); +// } catch (Exception e) { +// log.error("Error occurred in retrieving default LB cluster id" + e.getMessage()); +// throw new ADCException(e); +// } if (clusterId != null) { //set the cluster id to Cluster object http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java index 1b8b61b..fae0ede 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java @@ -51,13 +51,13 @@ public class ServiceLevelLoadBalancerCategory extends LoadBalancerCategory { // call the relevant method to get the cluster id, using deployment policy and type String clusterId = null; - try { - clusterId = AutoscalerServiceClient.getServiceClient().getServiceLBClusterId(getLoadBalancedServiceType(), getDeploymentPolicyName()); - - } catch (Exception e) { - log.error("Error occurred in retrieving Service LB cluster id" + e.getMessage()); - throw new ADCException(e); - } +// try { +// clusterId = AutoscalerServiceClient.getServiceClient().getServiceLBClusterId(getLoadBalancedServiceType(), getDeploymentPolicyName()); +// +// } catch (Exception e) { +// log.error("Error occurred in retrieving Service LB cluster id" + e.getMessage()); +// throw new ADCException(e); +// } if (clusterId != null) { http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java index 2c4f466..f49a48e 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java @@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.domain.Persistence; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -import org.apache.stratos.cloud.controller.stub.pojo.*; +//import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.common.Properties; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java index 2f8be77..9fc90bb 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java @@ -260,221 +260,222 @@ public class CartridgeSubscriptionUtils { public static LBDataContext getLoadBalancerDataContext(int tenantId, String serviceType, String deploymentPolicyName, LoadbalancerConfig lbConfig) throws UnregisteredCartridgeException, ADCException { - String lbCartridgeType = lbConfig.getType(); - - LBDataContext lbDataCtxt = new LBDataContext(); - // set tenant Id - lbDataCtxt.setTenantId(tenantId); - - Properties lbReferenceProperties = lbConfig.getProperties(); - - Property lbRefProperty = new Property(); - lbRefProperty.setName(StratosConstants.LOAD_BALANCER_REF); - - for (Property prop : lbReferenceProperties.getProperties()) { - - String name = prop.getName(); - String value = prop.getValue(); - - // TODO make following a chain of responsibility pattern - if (StratosConstants.NO_LOAD_BALANCER.equals(name)) { - - if ("true".equals(value)) { - lbDataCtxt.setLbCategory(StratosConstants.NO_LOAD_BALANCER); - - if (log.isDebugEnabled()) { - log.debug("This cartridge does not require a load balancer. " + "[Type] " + serviceType); - } - lbRefProperty.setValue(name); - lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); - break; - } - } else if (StratosConstants.EXISTING_LOAD_BALANCERS.equals(name)) { - - lbDataCtxt.setLbCategory(StratosConstants.EXISTING_LOAD_BALANCERS); - - String clusterIdsVal = value; - if (log.isDebugEnabled()) { - log.debug("This cartridge refers to existing load balancers. " + "[Type] " + serviceType + "[Referenced Cluster Ids] " + clusterIdsVal); - } - - String[] clusterIds = clusterIdsVal.split(","); - - for (String clusterId : clusterIds) { - try { - AutoscalerServiceClient.getServiceClient().checkLBExistenceAgainstPolicy(clusterId, deploymentPolicyName); - } catch (Exception ex) { - // we don't need to throw the error here. - log.error(ex.getMessage(), ex); - } - } - - lbRefProperty.setValue(name); - lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); - break; - - } else if (StratosConstants.DEFAULT_LOAD_BALANCER.equals(name)) { - - if ("true".equals(value)) { - - lbDataCtxt.setLbCategory(StratosConstants.DEFAULT_LOAD_BALANCER); - - lbRefProperty.setValue(name); - - CartridgeInfo lbCartridgeInfo; - - try { - lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType); - - } catch (Exception e) { - String message = "Error getting info for " + lbCartridgeType; - log.error(message, e); - throw new ADCException(message, e); - } - - if (lbCartridgeInfo == null) { - String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " + - StratosConstants.DEFAULT_LOAD_BALANCER; - log.error(msg); - throw new ADCException(msg); - } - - lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo); - - if (log.isDebugEnabled()) { - log.debug("This cartridge uses default load balancer. " + "[Type] " + serviceType); - } - - try { - // get the valid policies for lb cartridge - DeploymentPolicy[] lbCartridgeDepPolicies = - getAutoscalerServiceClient().getDeploymentPolicies(lbCartridgeType); - // traverse deployment policies of lb cartridge - for (DeploymentPolicy policy : lbCartridgeDepPolicies) { - - // check existence of the subscribed policy - if (deploymentPolicyName.equals(policy.getId())) { - - if (!getAutoscalerServiceClient().checkDefaultLBExistenceAgainstPolicy(deploymentPolicyName)) { - if (log.isDebugEnabled()) { - log.debug(" Default LB doesn't exist for deployment policy [" + deploymentPolicyName + "] "); - } - - Properties lbProperties = new Properties(); - - // if LB cartridge definition has properties as well, combine - if (lbCartridgeInfo.getProperties() != null && lbCartridgeInfo.getProperties().length > 0) { - if (log.isDebugEnabled()) { - log.debug(" Combining LB properties "); - } - lbProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{lbRefProperty})); - } else { - lbProperties.setProperties(new Property[]{lbRefProperty}); - } - - lbDataCtxt.addLBProperties(lbProperties); - } - } - } - - } catch (Exception ex) { - // we don't need to throw the error here. - log.error(ex.getMessage(), ex); - } - - // set deployment and autoscaling policies - lbDataCtxt.setDeploymentPolicy(deploymentPolicyName); - lbDataCtxt.setAutoscalePolicy(lbCartridgeInfo.getDefaultAutoscalingPolicy()); - - lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); - break; - } - - } else if (StratosConstants.SERVICE_AWARE_LOAD_BALANCER.equals(name)) { - - if ("true".equals(value)) { - - lbDataCtxt.setLbCategory(StratosConstants.SERVICE_AWARE_LOAD_BALANCER); - - lbRefProperty.setValue(name); - - CartridgeInfo lbCartridgeInfo; - - try { - lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType); - - } catch (Exception e) { - String message = "Error getting info for " + lbCartridgeType; - log.error(message, e); - throw new ADCException(message, e); - } - - if (lbCartridgeInfo == null) { - String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " + - StratosConstants.SERVICE_AWARE_LOAD_BALANCER; - log.error(msg); - throw new ADCException(msg); - } - - lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo); - - // add a property for the service type - Property loadBalancedServiceTypeProperty = new Property(); - loadBalancedServiceTypeProperty.setName(StratosConstants.LOAD_BALANCED_SERVICE_TYPE); - // set the load balanced service type - loadBalancedServiceTypeProperty.setValue(serviceType); - - if (log.isDebugEnabled()) { - log.debug("This cartridge uses a service aware load balancer. [Type] " + serviceType); - } - - try { - - // get the valid policies for lb cartridge - DeploymentPolicy[] lbCartridgeDepPolicies = getAutoscalerServiceClient().getDeploymentPolicies(lbCartridgeType); - // traverse deployment policies of lb cartridge - for (DeploymentPolicy policy : lbCartridgeDepPolicies) { - // check existence of the subscribed policy - if (deploymentPolicyName.equals(policy.getId())) { - - if (!getAutoscalerServiceClient().checkServiceLBExistenceAgainstPolicy(serviceType, deploymentPolicyName)) { - - Properties lbProperties = new Properties(); - - // if LB cartridge definition has properties as well, combine - if (lbCartridgeInfo.getProperties() != null && lbCartridgeInfo.getProperties().length > 0) { - lbProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{lbRefProperty, loadBalancedServiceTypeProperty})); - - } else { - lbProperties.setProperties(new Property[]{lbRefProperty, loadBalancedServiceTypeProperty}); - } - - // set a payload property for load balanced service type - Property payloadProperty = new Property(); - payloadProperty.setName("LOAD_BALANCED_SERVICE_TYPE"); //TODO: refactor hardcoded name - payloadProperty.setValue(serviceType); - - lbDataCtxt.addLBProperties(lbProperties); - } - } - } - - } catch (Exception ex) { - // we don't need to throw the error here. - log.error(ex.getMessage(), ex); - } - - // set deployment and autoscaling policies - lbDataCtxt.setDeploymentPolicy(deploymentPolicyName); - lbDataCtxt.setAutoscalePolicy(lbCartridgeInfo.getDefaultAutoscalingPolicy()); - - lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); - break; - } - } - } +// String lbCartridgeType = lbConfig.getType(); +// +// LBDataContext lbDataCtxt = new LBDataContext(); +// // set tenant Id +// lbDataCtxt.setTenantId(tenantId); +// +// Properties lbReferenceProperties = lbConfig.getProperties(); +// +// Property lbRefProperty = new Property(); +// lbRefProperty.setName(StratosConstants.LOAD_BALANCER_REF); +// +// for (Property prop : lbReferenceProperties.getProperties()) { +// +// String name = prop.getName(); +// String value = prop.getValue(); +// +// // TODO make following a chain of responsibility pattern +// if (StratosConstants.NO_LOAD_BALANCER.equals(name)) { +// +// if ("true".equals(value)) { +// lbDataCtxt.setLbCategory(StratosConstants.NO_LOAD_BALANCER); +// +// if (log.isDebugEnabled()) { +// log.debug("This cartridge does not require a load balancer. " + "[Type] " + serviceType); +// } +// lbRefProperty.setValue(name); +// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); +// break; +// } +// } else if (StratosConstants.EXISTING_LOAD_BALANCERS.equals(name)) { +// +// lbDataCtxt.setLbCategory(StratosConstants.EXISTING_LOAD_BALANCERS); +// +// String clusterIdsVal = value; +// if (log.isDebugEnabled()) { +// log.debug("This cartridge refers to existing load balancers. " + "[Type] " + serviceType + "[Referenced Cluster Ids] " + clusterIdsVal); +// } +// +// String[] clusterIds = clusterIdsVal.split(","); +// +//// for (String clusterId : clusterIds) { +//// try { +//// AutoscalerServiceClient.getServiceClient().checkLBExistenceAgainstPolicy(clusterId, deploymentPolicyName); +//// } catch (Exception ex) { +//// // we don't need to throw the error here. +//// log.error(ex.getMessage(), ex); +//// } +//// } +// +// lbRefProperty.setValue(name); +// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); +// break; +// +// } else if (StratosConstants.DEFAULT_LOAD_BALANCER.equals(name)) { +// +// if ("true".equals(value)) { +// +// lbDataCtxt.setLbCategory(StratosConstants.DEFAULT_LOAD_BALANCER); +// +// lbRefProperty.setValue(name); +// +// CartridgeInfo lbCartridgeInfo; +// +// try { +// lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType); +// +// } catch (Exception e) { +// String message = "Error getting info for " + lbCartridgeType; +// log.error(message, e); +// throw new ADCException(message, e); +// } +// +// if (lbCartridgeInfo == null) { +// String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " + +// StratosConstants.DEFAULT_LOAD_BALANCER; +// log.error(msg); +// throw new ADCException(msg); +// } +// +// lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo); +// +// if (log.isDebugEnabled()) { +// log.debug("This cartridge uses default load balancer. " + "[Type] " + serviceType); +// } +// +// try { +// // get the valid policies for lb cartridge +// DeploymentPolicy[] lbCartridgeDepPolicies = +// getAutoscalerServiceClient().getDeploymentPolicies(lbCartridgeType); +// // traverse deployment policies of lb cartridge +// for (DeploymentPolicy policy : lbCartridgeDepPolicies) { +// +// // check existence of the subscribed policy +// if (deploymentPolicyName.equals(policy.getId())) { +// +// if (!getAutoscalerServiceClient().checkDefaultLBExistenceAgainstPolicy(deploymentPolicyName)) { +// if (log.isDebugEnabled()) { +// log.debug(" Default LB doesn't exist for deployment policy [" + deploymentPolicyName + "] "); +// } +// +// Properties lbProperties = new Properties(); +// +// // if LB cartridge definition has properties as well, combine +// if (lbCartridgeInfo.getProperties() != null && lbCartridgeInfo.getProperties().length > 0) { +// if (log.isDebugEnabled()) { +// log.debug(" Combining LB properties "); +// } +// lbProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{lbRefProperty})); +// } else { +// lbProperties.setProperties(new Property[]{lbRefProperty}); +// } +// +// lbDataCtxt.addLBProperties(lbProperties); +// } +// } +// } +// +// } catch (Exception ex) { +// // we don't need to throw the error here. +// log.error(ex.getMessage(), ex); +// } +// +// // set deployment and autoscaling policies +// lbDataCtxt.setDeploymentPolicy(deploymentPolicyName); +// lbDataCtxt.setAutoscalePolicy(lbCartridgeInfo.getDefaultAutoscalingPolicy()); +// +// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); +// break; +// } +// +// } else if (StratosConstants.SERVICE_AWARE_LOAD_BALANCER.equals(name)) { +// +// if ("true".equals(value)) { +// +// lbDataCtxt.setLbCategory(StratosConstants.SERVICE_AWARE_LOAD_BALANCER); +// +// lbRefProperty.setValue(name); +// +// CartridgeInfo lbCartridgeInfo; +// +// try { +// lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType); +// +// } catch (Exception e) { +// String message = "Error getting info for " + lbCartridgeType; +// log.error(message, e); +// throw new ADCException(message, e); +// } +// +// if (lbCartridgeInfo == null) { +// String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " + +// StratosConstants.SERVICE_AWARE_LOAD_BALANCER; +// log.error(msg); +// throw new ADCException(msg); +// } +// +// lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo); +// +// // add a property for the service type +// Property loadBalancedServiceTypeProperty = new Property(); +// loadBalancedServiceTypeProperty.setName(StratosConstants.LOAD_BALANCED_SERVICE_TYPE); +// // set the load balanced service type +// loadBalancedServiceTypeProperty.setValue(serviceType); +// +// if (log.isDebugEnabled()) { +// log.debug("This cartridge uses a service aware load balancer. [Type] " + serviceType); +// } +// +// try { +// +// // get the valid policies for lb cartridge +// DeploymentPolicy[] lbCartridgeDepPolicies = getAutoscalerServiceClient().getDeploymentPolicies(lbCartridgeType); +// // traverse deployment policies of lb cartridge +// for (DeploymentPolicy policy : lbCartridgeDepPolicies) { +// // check existence of the subscribed policy +// if (deploymentPolicyName.equals(policy.getId())) { +// +// if (!getAutoscalerServiceClient().checkServiceLBExistenceAgainstPolicy(serviceType, deploymentPolicyName)) { +// +// Properties lbProperties = new Properties(); +// +// // if LB cartridge definition has properties as well, combine +// if (lbCartridgeInfo.getProperties() != null && lbCartridgeInfo.getProperties().length > 0) { +// lbProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{lbRefProperty, loadBalancedServiceTypeProperty})); +// +// } else { +// lbProperties.setProperties(new Property[]{lbRefProperty, loadBalancedServiceTypeProperty}); +// } +// +// // set a payload property for load balanced service type +// Property payloadProperty = new Property(); +// payloadProperty.setName("LOAD_BALANCED_SERVICE_TYPE"); //TODO: refactor hardcoded name +// payloadProperty.setValue(serviceType); +// +// lbDataCtxt.addLBProperties(lbProperties); +// } +// } +// } +// +// } catch (Exception ex) { +// // we don't need to throw the error here. +// log.error(ex.getMessage(), ex); +// } +// +// // set deployment and autoscaling policies +// lbDataCtxt.setDeploymentPolicy(deploymentPolicyName); +// lbDataCtxt.setAutoscalePolicy(lbCartridgeInfo.getDefaultAutoscalingPolicy()); +// +// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty); +// break; +// } +// } +// } - return lbDataCtxt; +// return lbDataCtxt; + return null; } private static AutoscalerServiceClient getAutoscalerServiceClient() throws ADCException { http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java index 943ff32..5da821f 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java @@ -478,7 +478,7 @@ public class StratosApiV40Utils { AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient(); if (autoscalerServiceClient != null) { try { - partitionGroups = autoscalerServiceClient.getPartitionGroups(deploymentPolicyId); + partitionGroups = autoscalerServiceClient.getApplicationLevelNetworkPartition(deploymentPolicyId); } catch (RemoteException e) { String errorMsg = "Error getting available partition groups for deployment policy id " http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 056c688..587ba1f 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -657,7 +657,7 @@ public class StratosApiV41Utils { AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient(); if (autoscalerServiceClient != null) { try { - partitionGroups = autoscalerServiceClient.getPartitionGroups(deploymentPolicyId); + partitionGroups = autoscalerServiceClient.getApplicationLevelNetworkPartition(deploymentPolicyId); } catch (RemoteException e) { String errorMsg = "Error getting available partition groups for deployment policy id " http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 34018ab..8a541e0 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -657,8 +657,8 @@ public class PojoConverter { deploymentPolicyBean.setDescription(deploymentPolicy.getDescription()); deploymentPolicyBean.setPublic(deploymentPolicy.getIsPublic()); //TODO populate the Network partition based on new policy structure -// if (deploymentPolicy.getPartitionGroups() != null && deploymentPolicy.getPartitionGroups().length > 0) { -// deploymentPolicyBean.setPartitionGroup(Arrays.asList(populatePartitionGroupPojos(deploymentPolicy.getPartitionGroups()))); +// if (deploymentPolicy.getApplicationLevelNetworkPartition() != null && deploymentPolicy.getApplicationLevelNetworkPartition().length > 0) { +// deploymentPolicyBean.setPartitionGroup(Arrays.asList(populatePartitionGroupPojos(deploymentPolicy.getApplicationLevelNetworkPartition()))); // } /*if (deploymentPolicy.getAllPartitions() != null && deploymentPolicy.getAllPartitions().length > 0) { http://git-wip-us.apache.org/repos/asf/stratos/blob/98872dbb/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml ---------------------------------------------------------------------- diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index ad4f1ad..4cda463 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -96,6 +96,7 @@ org.apache.stratos.autoscaler.stub.deployment.partition.*; version=${project.version}, org.apache.stratos.autoscaler.stub.exception.*; version=${project.version}, org.apache.stratos.autoscaler.stub.api.*; version=${project.version}, + org.apache.stratos.autoscaler.stub.*; version=${project.version}, </Export-Package> <Private-Package> </Private-Package>
