You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2015/05/13 19:12:00 UTC
[3/3] stratos git commit: fixing no of instances calculation for MC
when having lower threshold
fixing no of instances calculation for MC when having lower threshold
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e9b7c5cb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e9b7c5cb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e9b7c5cb
Branch: refs/heads/master
Commit: e9b7c5cb7024ffbb0f833e180cad504e3cbf4025
Parents: 9b61f3f
Author: reka <rt...@gmail.com>
Authored: Wed May 13 15:21:02 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed May 13 22:41:09 2015 +0530
----------------------------------------------------------------------
.../monitor/component/GroupMonitor.java | 20 ++++++++++++--------
.../autoscaler/rule/RuleTasksDelegator.java | 6 ++++++
2 files changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/e9b7c5cb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
index 4f0f09b..69222ea 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
@@ -144,6 +144,14 @@ public class GroupMonitor extends ParentComponentMonitor {
handleScalingDownBeyondMin(instanceContext,
networkPartitionContext, false);
}
+
+ //Resetting the events events
+ instanceContext.setIdToScalingOverMaxEvent(
+ new ConcurrentHashMap<String, ScalingUpBeyondMaxEvent>());
+ instanceContext.setIdToScalingEvent(
+ new ConcurrentHashMap<String, ScalingEvent>());
+ instanceContext.setIdToScalingOverMaxEvent(
+ new ConcurrentHashMap<String, ScalingUpBeyondMaxEvent>());
}
}
@@ -211,9 +219,6 @@ public class GroupMonitor extends ParentComponentMonitor {
} else {
notifyParentOnScalingUpBeyondMax(networkPartitionContext, instanceContext);
}
- //Resetting the max events
- instanceContext.setIdToScalingOverMaxEvent(
- new ConcurrentHashMap<String, ScalingUpBeyondMaxEvent>());
}
/**
@@ -236,7 +241,8 @@ public class GroupMonitor extends ParentComponentMonitor {
allChildrenScaleDown = true;
}
}
- //all the children sent the scale down only, it will try to scale down
+ //all the children sent the scale down, then the group-instance will try to scale down or
+ // if it is a force scale-down
if (allChildrenScaleDown || forceScaleDown) {
if (hasScalingDependents) {
if (nwPartitionContext.getNonTerminatedInstancesCount() >
@@ -278,9 +284,6 @@ public class GroupMonitor extends ParentComponentMonitor {
}
}
- //Resetting the events
- instanceContext.setIdToScalingDownBeyondMinEvent(
- new ConcurrentHashMap<String, ScalingDownBeyondMinEvent>());
}
/**
@@ -354,7 +357,8 @@ public class GroupMonitor extends ParentComponentMonitor {
networkPartitionContext).getMaxInstanceCount();
if (groupScalingEnabled && maxInstances > networkPartitionContext.
getNonTerminatedInstancesCount()) {
- //increase group by one more instance
+ //increase group by one more instance and calculate the factor for the group scaling
+ // and notify parent to scale all the dependent in parallel with this factor
float minInstances = ((GroupLevelNetworkPartitionContext)
networkPartitionContext).getMinInstanceCount();
http://git-wip-us.apache.org/repos/asf/stratos/blob/e9b7c5cb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
index 304387f..e942f1f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
@@ -95,6 +95,11 @@ public class RuleTasksDelegator {
float gradient = scalingRange / instanceRange;
numberOfAdditionalInstancesRequired = (predictedValue - threshold) / gradient;
}
+
+ if(predictedValue < threshold) {
+ //Since predicted-value is less, it can be scale-down
+ return min - 1;
+ }
}
return (int) Math.ceil(min + numberOfAdditionalInstancesRequired);
@@ -109,6 +114,7 @@ public class RuleTasksDelegator {
numberOfInstances = (min * predictedValue) / threshold;
return (int) Math.ceil(numberOfInstances);
}
+
return min;
}