Updated Branches: refs/heads/master 1ed43c887 -> 8a6dc7fcf
Fixing STRATOS-223 Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/99d1d3c6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/99d1d3c6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/99d1d3c6 Branch: refs/heads/master Commit: 99d1d3c63680d5811fa47f85b5d36c7afb94ff59 Parents: 63c5c1c Author: Lahiru Sandaruwan <[email protected]> Authored: Mon Dec 2 12:22:49 2013 +0530 Committer: Lahiru Sandaruwan <[email protected]> Committed: Mon Dec 2 12:22:49 2013 +0530 ---------------------------------------------------------------------- .../algorithm/AutoscaleAlgorithm.java | 32 +++++++++++++++++--- .../autoscaler/algorithm/OneAfterAnother.java | 27 +++++++++++------ .../PartitionGroupOneAfterAnother.java | 14 ++++----- .../autoscaler/algorithm/RoundRobin.java | 28 +++++++++-------- .../interfaces/CloudControllerService.java | 2 +- 5 files changed, 69 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/99d1d3c6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java index 54ec855..8f003aa 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java @@ -24,15 +24,39 @@ import org.apache.stratos.cloud.controller.deployment.partition.Partition; /** - * + * This interface is should be implemented by all the algorithms that are there to select partitions of a particulaler + * partition group */ public interface AutoscaleAlgorithm { + /** + * Returns whether there is available {@link Partition} to scale up considering the current count and maximum + * @param clusterId Id of the cluster which need the availability information + * @return availability of {@link Partition}s to scale up + */ public boolean scaleUpPartitionAvailable(String clusterId); + /** + * Returns whether there is available {@link Partition} to scale down considering the current count and minimum + * @param clusterId Id of the cluster which need the availability information + * @return availability of {@link Partition}s to scale down + */ public boolean scaleDownPartitionAvailable(String clusterId); - public Partition getNextScaleUpPartition(PartitionGroup partition, String clusterId); - - public Partition getNextScaleDownPartition(PartitionGroup partition, String clusterId); + /** + * Returns a {@link Partition} to scale up from the given {@link PartitionGroup} according to algorithm + * @param partitionGroup {@link PartitionGroup} which need the {@link Partition} + * @param clusterId Id of the cluster which need the {@link Partition} + * @return {@link Partition} to scale up + */ + public Partition getNextScaleUpPartition(PartitionGroup partitionGroup, String clusterId); + + + /** + * Returns a {@link Partition} to scale down from the given {@link PartitionGroup} according to algorithm + * @param partitionGroup {@link PartitionGroup} which need the {@link Partition} + * @param clusterId Id of the cluster which need the {@link Partition} + * @return {@link Partition} to scale down + */ + public Partition getNextScaleDownPartition(PartitionGroup partitionGroup, String clusterId); } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/99d1d3c6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java index 9d34385..ae01360 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java @@ -19,8 +19,7 @@ package org.apache.stratos.autoscaler.algorithm; -import java.util.List; - +import edu.emory.mathcs.backport.java.util.Arrays; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; @@ -28,20 +27,28 @@ import org.apache.stratos.autoscaler.ClusterContext; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.cloud.controller.deployment.partition.Partition; -import edu.emory.mathcs.backport.java.util.Arrays; +import java.util.List; /** - * Completes partitions in the order defined in autoscaler policy, go to next if current one reached the max limit + * */ +/** +* This class is used for selecting a {@link Partition} one after another and checking availability of + * partitions of a {@link PartitionGroup} + * One after another means it completes partitions in the order defined in + * {@link org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy}, and go to next if current one + * reached the max limit + * +*/ public class OneAfterAnother implements AutoscaleAlgorithm { private static final Log log = LogFactory.getLog(OneAfterAnother.class); - public Partition getNextScaleUpPartition(PartitionGroup partitionGrp, String clusterId) { + public Partition getNextScaleUpPartition(PartitionGroup partitionGroup, String clusterId) { ClusterContext clusterContext = AutoscalerContext.getInstance().getClusterContext(clusterId); int currentPartitionIndex = clusterContext.getCurrentPartitionIndex(); - List<?> partitions = Arrays.asList(partitionGrp.getPartitions()); + List<?> partitions = Arrays.asList(partitionGroup.getPartitions()); int noOfPartitions = partitions.size(); for(int i=currentPartitionIndex; i< noOfPartitions; i++) @@ -76,16 +83,16 @@ public class OneAfterAnother implements AutoscaleAlgorithm { } if(log.isDebugEnabled()) - log.debug("No free partition found at partition group" + partitionGrp); + log.debug("No free partition found at partition group" + partitionGroup); return null; } - public Partition getNextScaleDownPartition(PartitionGroup partitionGrp, String clusterId) { + public Partition getNextScaleDownPartition(PartitionGroup partitionGroup, String clusterId) { ClusterContext clusterContext = AutoscalerContext.getInstance().getClusterContext(clusterId); int currentPartitionIndex = clusterContext.getCurrentPartitionIndex(); - List<?> partitions = Arrays.asList(partitionGrp.getPartitions()); + List<?> partitions = Arrays.asList(partitionGroup.getPartitions()); for(int i = currentPartitionIndex; i >= 0; i--) { @@ -116,7 +123,7 @@ public class OneAfterAnother implements AutoscaleAlgorithm { } if(log.isDebugEnabled()) - log.debug("No space found in this partition group " + partitionGrp.getId()); + log.debug("No space found in this partition group " + partitionGroup.getId()); return null; } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/99d1d3c6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java index f954c97..91e7e38 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java @@ -19,22 +19,22 @@ package org.apache.stratos.autoscaler.algorithm; -import java.util.List; - +import edu.emory.mathcs.backport.java.util.Arrays; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.ClusterContext; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.cloud.controller.deployment.partition.Partition; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import edu.emory.mathcs.backport.java.util.Arrays; +import java.util.List; /** - * Completes partitions in the order defined in autoscaler policy, go to next if current one reached the max limit + * Completes {@link PartitionGroup} in the order defined in * {@link org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy}, and go to next if current one + * reached the max limit policy, go to next if current one reached the max limit */ public class PartitionGroupOneAfterAnother implements AutoscaleAlgorithm { @@ -149,14 +149,14 @@ public class PartitionGroupOneAfterAnother implements AutoscaleAlgorithm { } @Override - public Partition getNextScaleUpPartition(PartitionGroup partition, + public Partition getNextScaleUpPartition(PartitionGroup partitionGroup, String clusterId) { // TODO Auto-generated method stub return null; } @Override - public Partition getNextScaleDownPartition(PartitionGroup partition, + public Partition getNextScaleDownPartition(PartitionGroup partitionGroup, String clusterId) { // TODO Auto-generated method stub return null; http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/99d1d3c6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java index 83d48bc..01b63fc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java @@ -31,16 +31,19 @@ import edu.emory.mathcs.backport.java.util.Arrays; import java.util.List; /** -* Select partition in round robin manner and return +* This class is used for selecting a {@link Partition} in round robin manner and checking availability of + * {@link Partition}s of a {@link PartitionGroup} + * */ public class RoundRobin implements AutoscaleAlgorithm{ private static final Log log = LogFactory.getLog(RoundRobin.class); - public Partition getNextScaleUpPartition(PartitionGroup partitionGrp, String clusterId){ - - ClusterContext clusterContext = AutoscalerContext.getInstance().getClusterContext(clusterId); - List<?> partitions = Arrays.asList(partitionGrp.getPartitions()); + public Partition getNextScaleUpPartition(PartitionGroup partitionGroup, String clusterId){ + + + ClusterContext clusterContext = AutoscalerContext.getInstance().getClusterContext(clusterId); + List<?> partitions = Arrays.asList(partitionGroup.getPartitions()); int noOfPartitions = partitions.size(); for(int i=0; i < noOfPartitions; i++) @@ -64,29 +67,30 @@ public class RoundRobin implements AutoscaleAlgorithm{ if(log.isDebugEnabled()) log.debug("Free space found in partition " + currentPartition.getId()); return currentPartition; - } - if(log.isDebugEnabled()) { + } + + if(log.isDebugEnabled()) log.debug("No free space for a new instance in partition " + currentPartition.getId()); - } + } } // none of the partitions were free. if(log.isDebugEnabled()) { - log.debug("No free partition found at partition group " + partitionGrp); + log.debug("No free partition found at partition group " + partitionGroup); } return null; } @Override - public Partition getNextScaleDownPartition(PartitionGroup partitionGrp, String clusterId) { + public Partition getNextScaleDownPartition(PartitionGroup partitionGroup, String clusterId) { ClusterContext clusterContext = AutoscalerContext.getInstance() .getClusterContext(clusterId); - List<?> partitions = Arrays.asList(partitionGrp.getPartitions()); + List<?> partitions = Arrays.asList(partitionGroup.getPartitions()); int noOfPartitions = partitions.size(); for (int i = 0; i < noOfPartitions; i++) { @@ -130,7 +134,7 @@ public class RoundRobin implements AutoscaleAlgorithm{ if (log.isDebugEnabled()) log.debug("No partition found for scale down at partition group " + - partitionGrp.getId()); + partitionGroup.getId()); // none of the partitions were free. return null; } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/99d1d3c6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index b4bba09..2784eb8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -87,7 +87,7 @@ public interface CloudControllerService { public MemberContext startInstance(MemberContext member) throws IllegalArgumentException, UnregisteredCartridgeException; /** - * Calling this method will spawn more than one ininstances in the + * Calling this method will spawn more than one instances in the * specified partition for the particular cluster * * @param clusterId
