Repository: stratos Updated Branches: refs/heads/master 5c326250e -> 60213bb5c
Implementing One after another algorithm body Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/60213bb5 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/60213bb5 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/60213bb5 Branch: refs/heads/master Commit: 60213bb5cc9f399cee7be5e6a3e914989cd48329 Parents: 5c32625 Author: Lahiru Sandaruwan <[email protected]> Authored: Mon Dec 1 17:20:26 2014 +0530 Committer: Lahiru Sandaruwan <[email protected]> Committed: Mon Dec 1 17:20:26 2014 +0530 ---------------------------------------------------------------------- .../stratos/autoscaler/algorithm/OneAfterAnother.java | 13 +++++++++++++ .../autoscaler/context/partition/PartitionContext.java | 4 ++++ 2 files changed, 17 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/60213bb5/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 eaeb6dc..41c4529 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 @@ -150,11 +150,24 @@ public class OneAfterAnother implements AutoscaleAlgorithm { @Override public PartitionContext getNextScaleUpPartitionContext(PartitionContext[] partitionContexts) { + for(PartitionContext partitionContext : partitionContexts){ + if(partitionContext.getActiveInstanceCount() < partitionContext.getMax()){ + return partitionContext; + } + } return null; } @Override public PartitionContext getNextScaleDownPartitionContext(PartitionContext[] partitionContexts) { + + for(int partitionIndex = partitionContexts.length - 1; partitionIndex >= 0; partitionIndex--){ + + if(partitionContexts[partitionIndex].getActiveInstanceCount() > 0) { + + return partitionContexts[partitionIndex]; + } + } return null; } http://git-wip-us.apache.org/repos/asf/stratos/blob/60213bb5/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/partition/PartitionContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/partition/PartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/partition/PartitionContext.java index 856b582..3a81952 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/partition/PartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/partition/PartitionContext.java @@ -84,4 +84,8 @@ public abstract class PartitionContext implements Serializable{ public ChildLevelPartition getChildLevelPartition() { return childLevelPartition; } + + public int getMax() { + return max; + } }
