Repository: stratos
Updated Branches:
  refs/heads/master 0426bb8ac -> 01e79e26d


Fixing memory consumption based instance calculation logic


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/01e79e26
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/01e79e26
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/01e79e26

Branch: refs/heads/master
Commit: 01e79e26dd81f5412e6300d8c4ec908cb03a77db
Parents: 0426bb8
Author: Lahiru Sandaruwan <[email protected]>
Authored: Sun Dec 21 16:49:15 2014 +0530
Committer: Lahiru Sandaruwan <[email protected]>
Committed: Sun Dec 21 16:49:15 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/rule/RuleTasksDelegator.java     | 21 ++++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/01e79e26/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 4318e51..37b6f4f 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
@@ -85,27 +85,26 @@ public class RuleTasksDelegator {
 
     public int getNumberOfInstancesRequiredBasedOnMemoryConsumption(float 
threshold, double predictedValue,
                                                                     int max, 
int min) {
-        /*double numberOfAdditionalInstancesRequired = 0;
+        double numberOfAdditionalInstancesRequired = 0;
         if(predictedValue != threshold) {
 
             float scalingRange = 100 - threshold;
             int instanceRange = max - min;
 
-            if(instanceRange >= 0){
+            if(instanceRange != 0){
 
                 float gradient = scalingRange / instanceRange;
                 numberOfAdditionalInstancesRequired = (predictedValue - 
threshold) / gradient;
-            }
-        }
-        return (int) Math.ceil(min + numberOfAdditionalInstancesRequired);*/
-
-        double numberOfInstances;
-        if(threshold != 0) {
+            } else {
 
-            numberOfInstances = (min * predictedValue) / threshold;
-            return (int) Math.ceil(numberOfInstances);
+                if(predictedValue > threshold) {
+                    return max + 1;
+                } else {
+                    return min - 1;
+                }
+            }
         }
-        return min;
+        return (int) Math.ceil(min + numberOfAdditionalInstancesRequired);
     }
 
     public int getNumberOfInstancesRequiredBasedOnLoadAverage(float threshold, 
double predictedValue, int min) {

Reply via email to