Updated Branches: refs/heads/master 9c1afd00e -> 20612592e
setting lb cluster id in network partition context when a new lb cluster got created Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/20612592 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/20612592 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/20612592 Branch: refs/heads/master Commit: 20612592e82496af814ab22e82a472144b1eb3a7 Parents: 9c1afd0 Author: Nirmal Fernando <[email protected]> Authored: Thu Dec 12 08:30:31 2013 +0530 Committer: Nirmal Fernando <[email protected]> Committed: Thu Dec 12 08:31:35 2013 +0530 ---------------------------------------------------------------------- .../autoscaler/NetworkPartitionContext.java | 4 ++ .../stratos/autoscaler/util/AutoscalerUtil.java | 52 +++++++------------- 2 files changed, 21 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/20612592/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java index a41d332..035b5c3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java @@ -94,6 +94,10 @@ public class NetworkPartitionContext { this.serviceNameToLBClusterIdMap = serviceToLBClusterId; } + + public void addServiceLB(final String serviceName, final String lbClusterId) { + this.serviceNameToLBClusterIdMap.put(serviceName, lbClusterId); + } public String getLBClusterIdOfCluster(final String clusterId) { http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/20612592/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 8d06141..7feda4b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -39,6 +39,7 @@ import org.apache.stratos.cloud.controller.pojo.Property; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; +import org.apache.stratos.messaging.util.Constants; import javax.xml.namespace.QName; @@ -199,29 +200,9 @@ public class AutoscalerUtil { throw new PolicyValidationException(msg); } -// Partition[] allPartitions = deploymentPolicy.getAllPartitions(); -// if (allPartitions == null) { -// String msg = -// "Deployment Policy's Partitions are null. Policy name: " + -// deploymentPolicyName; -// log.error(msg); -// throw new PolicyValidationException(msg); -// } -// -// try { -// validateExistenceOfPartions(allPartitions); -// } catch (InvalidPartitionException e) { -// String msg = "Deployment Policy is invalid. Policy name: " + deploymentPolicyName; -// log.error(msg, e); -// throw new PolicyValidationException(msg, e); -// } -// -// CloudControllerClient.getInstance() -// .validatePartitionsOfPolicy(cluster.getServiceName(), -// allPartitions); - + String clusterId = cluster.getClusterId(); LbClusterMonitor clusterMonitor = - new LbClusterMonitor(cluster.getClusterId(), + new LbClusterMonitor(clusterId, cluster.getServiceName(), deploymentPolicy, policy); // partition group = network partition context @@ -259,22 +240,23 @@ public class AutoscalerUtil { } networkPartitionContext.addPartitionContext(partitionContext); + + // populate lb cluster id in network partition context. + java.util.Properties props = cluster.getProperties(); + + if(props.containsKey(Constants.LOAD_BALANCER_REF)) { + String value = props.getProperty(Constants.LOAD_BALANCER_REF); + + if (value.equals(org.apache.stratos.messaging.util.Constants.DEFAULT_LOAD_BALANCER)) { + networkPartitionContext.setDefaultLbClusterId(clusterId); + } else if (value.equals(org.apache.stratos.messaging.util.Constants.SERVICE_AWARE_LOAD_BALANCER)) { + String serviceName = cluster.getServiceName(); + networkPartitionContext.addServiceLB(serviceName, clusterId); + } + } clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); } -// if (policy != null) { -// -// // get values from policy -// LoadThresholds loadThresholds = policy.getLoadThresholds(); -// float averageLimit = loadThresholds.getRequestsInFlight().getAverage(); -// float gradientLimit = loadThresholds.getRequestsInFlight().getGradient(); -// float secondDerivativeLimit = loadThresholds.getRequestsInFlight().getSecondDerivative(); -// -// clusterMonitor.setRequestsInFlightGradientThreshold(gradientLimit); -// clusterMonitor.setRequestsInFlightSecondDerivativeThreshold(secondDerivativeLimit); -// clusterMonitor.setAverageRequestsInFlightThreshold(averageLimit); -// -// } return clusterMonitor; }
