You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/03/05 17:51:49 UTC

stratos git commit: refactoring partition algorithms

Repository: stratos
Updated Branches:
  refs/heads/master 7c4cd8cc5 -> 67e9f85ce


refactoring partition algorithms


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

Branch: refs/heads/master
Commit: 67e9f85ce31583cd21b6cc0ee9a72c484041b2c7
Parents: 7c4cd8c
Author: R-Rajkumar <rr...@gmail.com>
Authored: Thu Mar 5 22:21:15 2015 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Thu Mar 5 22:21:15 2015 +0530

----------------------------------------------------------------------
 .../algorithm/AutoscaleAlgorithm.java           |  43 --------
 .../autoscaler/algorithm/OneAfterAnother.java   |  74 -------------
 .../autoscaler/algorithm/RoundRobin.java        | 109 ------------------
 .../algorithms/PartitionAlgorithm.java          |  43 ++++++++
 .../algorithms/partition/OneAfterAnother.java   |  75 +++++++++++++
 .../algorithms/partition/RoundRobin.java        | 110 +++++++++++++++++++
 .../monitor/component/GroupMonitor.java         |   4 +-
 .../component/ParentComponentMonitor.java       |  10 +-
 .../autoscaler/rule/RuleTasksDelegator.java     |  10 +-
 .../resources/test-minimum-autoscaler-rule.drl  |   6 +-
 .../test-terminating-obsoleted-members-rule.drl |   6 +-
 .../src/main/conf/drools/dependent-scaling.drl  |   8 +-
 .../src/main/conf/drools/mincheck.drl           |  10 +-
 .../src/main/conf/drools/obsoletecheck.drl      |   6 +-
 .../src/main/conf/drools/scaling.drl            |  12 +-
 15 files changed, 264 insertions(+), 262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/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
deleted file mode 100644
index 177674a..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.autoscaler.algorithm;
-
-import org.apache.stratos.autoscaler.context.partition.PartitionContext;
-
-
-/**
- * This interface is should be implemented by all the algorithms that are there to select partitions context
- */
-public interface AutoscaleAlgorithm {
-
-    /**
-     * Returns a {@link PartitionContext} to scale up from the given list
-     * @param partitionContexts is the array of partition contexts which will be select the partition context from
-     * @return {@link PartitionContext} to scale up
-     */
-    public PartitionContext getNextScaleUpPartitionContext(PartitionContext[] partitionContexts);
-
-    /**
-     * Returns a {@link PartitionContext} to scale down from the given list
-     * @param partitionContexts is the array of partition contexts which will be select the partition context from
-     * @return {@link PartitionContext} to scale down
-     */
-    public PartitionContext getNextScaleDownPartitionContext(PartitionContext[] partitionContexts);
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/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
deleted file mode 100644
index 5eb8282..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-package org.apache.stratos.autoscaler.algorithm;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.context.partition.PartitionContext;
-
-/**
- * This class is used for selecting a {@link PartitionContext} using one after another algorithm
- * One after another means it completes partitions in the order defined in
- * {@link org.apache.stratos.autoscaler.pojo.policy.deployment.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);
-
-    @Override
-    public PartitionContext getNextScaleUpPartitionContext(PartitionContext[] partitionContexts) {
-
-        for(PartitionContext partitionContext : partitionContexts) {
-
-            if(partitionContext.getNonTerminatedMemberCount() < partitionContext.getMax()) {
-
-                if(log.isDebugEnabled()){
-                    log.debug(String.format("[one-after-another algorithm] [scale-up] [partition] %s has space to create " +
-                            "members. [non terminated count] %s [max] %s", partitionContext.getPartitionId(),
-                            partitionContext.getNonTerminatedMemberCount(), partitionContext.getMax()));
-                }
-                return partitionContext;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public PartitionContext getNextScaleDownPartitionContext(PartitionContext[] partitionContexts) {
-
-        for(int partitionIndex = partitionContexts.length - 1; partitionIndex >= 0; partitionIndex--) {
-
-            if(partitionContexts[partitionIndex].getNonTerminatedMemberCount() > 0) {
-
-                if(log.isDebugEnabled()){
-                    log.debug(String.format("[one-after-another algorithm] [scale-down] [partition] %s has members that" +
-                            " can be removed. [non terminated count] %s",
-                            partitionContexts[partitionIndex].getPartitionId(),
-                            partitionContexts[partitionIndex].getNonTerminatedMemberCount()));
-                }
-                return partitionContexts[partitionIndex];
-            }
-        }
-        return null;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/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
deleted file mode 100644
index b92f9dc..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-package org.apache.stratos.autoscaler.algorithm;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.context.partition.PartitionContext;
-
-/**
-* This class is used for selecting a {@link PartitionContext} in round robin manner and checking availability of
- * {@link PartitionContext}s according to the partitions defined
- * in {@link org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy}
- *
-*/
-public class RoundRobin implements AutoscaleAlgorithm{
-
-	private static final Log log = LogFactory.getLog(RoundRobin.class);
-
-    @Override
-    public PartitionContext getNextScaleUpPartitionContext(PartitionContext[] partitionContexts) {
-    	
-    	if (partitionContexts == null) {
-			return null;
-		}
-
-        int selectedIndex = 0;
-        int lowestInstanceCount = partitionContexts[0].getNonTerminatedMemberCount();
-
-        for(int partitionIndex = 0; partitionIndex < partitionContexts.length; partitionIndex++) {
-        	
-        	// it means we have to choose the current partitionIndex, no need to continue the loop
-        	if (lowestInstanceCount == 0) {
-				break;
-			}
-        	
-            if(partitionContexts[partitionIndex].getNonTerminatedMemberCount() < lowestInstanceCount) {
-                lowestInstanceCount = partitionContexts[partitionIndex].getNonTerminatedMemberCount();
-                selectedIndex = partitionIndex;
-            }
-        }
-
-        if(partitionContexts[selectedIndex].getNonTerminatedMemberCount() < partitionContexts[selectedIndex].getMax()) {
-
-            if(log.isDebugEnabled()){
-                log.debug(String.format("[round-robin algorithm] [scale-up] [partition] %s has space to create members. " +
-                        "[non terminated count] %s [max] %s"
-                        , partitionContexts[selectedIndex].getPartitionId(),
-                        partitionContexts[selectedIndex].getNonTerminatedMemberCount(),
-                        partitionContexts[selectedIndex].getMax()));
-            }
-            return partitionContexts[selectedIndex];
-        } else {
-
-            return null;
-        }
-    }
-
-    @Override
-    public PartitionContext getNextScaleDownPartitionContext(PartitionContext[] partitionContexts) {
-
-    	if (partitionContexts == null) {
-			return null;
-		}
-    	
-        int selectedIndex = 0;
-        int highestInstanceCount = partitionContexts[0].getNonTerminatedMemberCount();
-
-        for(int partitionIndex = partitionContexts.length - 1; partitionIndex >= 0; partitionIndex--) {
-
-            if(partitionContexts[partitionIndex].getNonTerminatedMemberCount() > highestInstanceCount) {
-
-                highestInstanceCount = partitionContexts[partitionIndex].getNonTerminatedMemberCount();
-                selectedIndex = partitionIndex;
-            }
-        }
-
-        if(partitionContexts[selectedIndex].getNonTerminatedMemberCount() < partitionContexts[selectedIndex].getMax()) {
-
-            if(log.isDebugEnabled()){
-                log.debug(String.format("[round-robin algorithm] [scale-down] [partition] %s has has members that" +
-                        " can be removed.[non terminated count] %s ", partitionContexts[selectedIndex].getPartitionId(),
-                        partitionContexts[selectedIndex].getNonTerminatedMemberCount()));
-            }
-            return partitionContexts[selectedIndex];
-        } else {
-
-            return null;
-        }
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/PartitionAlgorithm.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/PartitionAlgorithm.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/PartitionAlgorithm.java
new file mode 100644
index 0000000..3ad3c85
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/PartitionAlgorithm.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.algorithms;
+
+import org.apache.stratos.autoscaler.context.partition.PartitionContext;
+
+
+/**
+ * This interface is should be implemented by all the algorithms that are there to select partitions context
+ */
+public interface PartitionAlgorithm {
+
+    /**
+     * Returns a {@link PartitionContext} to scale up from the given list
+     * @param partitionContexts is the array of partition contexts which will be select the partition context from
+     * @return {@link PartitionContext} to scale up
+     */
+    public PartitionContext getNextScaleUpPartitionContext(PartitionContext[] partitionContexts);
+
+    /**
+     * Returns a {@link PartitionContext} to scale down from the given list
+     * @param partitionContexts is the array of partition contexts which will be select the partition context from
+     * @return {@link PartitionContext} to scale down
+     */
+    public PartitionContext getNextScaleDownPartitionContext(PartitionContext[] partitionContexts);
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/OneAfterAnother.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/OneAfterAnother.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/OneAfterAnother.java
new file mode 100644
index 0000000..d3c916b
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/OneAfterAnother.java
@@ -0,0 +1,75 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.stratos.autoscaler.algorithms.partition;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.context.partition.PartitionContext;
+
+/**
+ * This class is used for selecting a {@link PartitionContext} using one after another algorithm
+ * One after another means it completes partitions in the order defined in
+ * {@link org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy}, and go to next if current one
+ * reached the max limit
+ */
+public class OneAfterAnother implements PartitionAlgorithm {
+
+    private static final Log log = LogFactory.getLog(OneAfterAnother.class);
+
+    @Override
+    public PartitionContext getNextScaleUpPartitionContext(PartitionContext[] partitionContexts) {
+
+        for(PartitionContext partitionContext : partitionContexts) {
+
+            if(partitionContext.getNonTerminatedMemberCount() < partitionContext.getMax()) {
+
+                if(log.isDebugEnabled()){
+                    log.debug(String.format("[one-after-another algorithm] [scale-up] [partition] %s has space to create " +
+                            "members. [non terminated count] %s [max] %s", partitionContext.getPartitionId(),
+                            partitionContext.getNonTerminatedMemberCount(), partitionContext.getMax()));
+                }
+                return partitionContext;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public PartitionContext getNextScaleDownPartitionContext(PartitionContext[] partitionContexts) {
+
+        for(int partitionIndex = partitionContexts.length - 1; partitionIndex >= 0; partitionIndex--) {
+
+            if(partitionContexts[partitionIndex].getNonTerminatedMemberCount() > 0) {
+
+                if(log.isDebugEnabled()){
+                    log.debug(String.format("[one-after-another algorithm] [scale-down] [partition] %s has members that" +
+                            " can be removed. [non terminated count] %s",
+                            partitionContexts[partitionIndex].getPartitionId(),
+                            partitionContexts[partitionIndex].getNonTerminatedMemberCount()));
+                }
+                return partitionContexts[partitionIndex];
+            }
+        }
+        return null;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/RoundRobin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/RoundRobin.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/RoundRobin.java
new file mode 100644
index 0000000..4977cfd
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/partition/RoundRobin.java
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.stratos.autoscaler.algorithms.partition;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.context.partition.PartitionContext;
+
+/**
+* This class is used for selecting a {@link PartitionContext} in round robin manner and checking availability of
+ * {@link PartitionContext}s according to the partitions defined
+ * in {@link org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy}
+ *
+*/
+public class RoundRobin implements PartitionAlgorithm{
+
+	private static final Log log = LogFactory.getLog(RoundRobin.class);
+
+    @Override
+    public PartitionContext getNextScaleUpPartitionContext(PartitionContext[] partitionContexts) {
+    	
+    	if (partitionContexts == null) {
+			return null;
+		}
+
+        int selectedIndex = 0;
+        int lowestInstanceCount = partitionContexts[0].getNonTerminatedMemberCount();
+
+        for(int partitionIndex = 0; partitionIndex < partitionContexts.length; partitionIndex++) {
+        	
+        	// it means we have to choose the current partitionIndex, no need to continue the loop
+        	if (lowestInstanceCount == 0) {
+				break;
+			}
+        	
+            if(partitionContexts[partitionIndex].getNonTerminatedMemberCount() < lowestInstanceCount) {
+                lowestInstanceCount = partitionContexts[partitionIndex].getNonTerminatedMemberCount();
+                selectedIndex = partitionIndex;
+            }
+        }
+
+        if(partitionContexts[selectedIndex].getNonTerminatedMemberCount() < partitionContexts[selectedIndex].getMax()) {
+
+            if(log.isDebugEnabled()){
+                log.debug(String.format("[round-robin algorithm] [scale-up] [partition] %s has space to create members. " +
+                        "[non terminated count] %s [max] %s"
+                        , partitionContexts[selectedIndex].getPartitionId(),
+                        partitionContexts[selectedIndex].getNonTerminatedMemberCount(),
+                        partitionContexts[selectedIndex].getMax()));
+            }
+            return partitionContexts[selectedIndex];
+        } else {
+
+            return null;
+        }
+    }
+
+    @Override
+    public PartitionContext getNextScaleDownPartitionContext(PartitionContext[] partitionContexts) {
+
+    	if (partitionContexts == null) {
+			return null;
+		}
+    	
+        int selectedIndex = 0;
+        int highestInstanceCount = partitionContexts[0].getNonTerminatedMemberCount();
+
+        for(int partitionIndex = partitionContexts.length - 1; partitionIndex >= 0; partitionIndex--) {
+
+            if(partitionContexts[partitionIndex].getNonTerminatedMemberCount() > highestInstanceCount) {
+
+                highestInstanceCount = partitionContexts[partitionIndex].getNonTerminatedMemberCount();
+                selectedIndex = partitionIndex;
+            }
+        }
+
+        if(partitionContexts[selectedIndex].getNonTerminatedMemberCount() < partitionContexts[selectedIndex].getMax()) {
+
+            if(log.isDebugEnabled()){
+                log.debug(String.format("[round-robin algorithm] [scale-down] [partition] %s has has members that" +
+                        " can be removed.[non terminated count] %s ", partitionContexts[selectedIndex].getPartitionId(),
+                        partitionContexts[selectedIndex].getNonTerminatedMemberCount()));
+            }
+            return partitionContexts[selectedIndex];
+        } else {
+
+            return null;
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/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 6608335..769c0e0 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
@@ -26,7 +26,7 @@ import java.util.concurrent.ExecutorService;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
 import org.apache.stratos.autoscaler.context.InstanceContext;
@@ -789,7 +789,7 @@ public class GroupMonitor extends ParentComponentMonitor {
                 new GroupLevelPartitionContext[partitionContexts.size()];
         if (parentPartitionId == null) {
             if (!partitionContexts.isEmpty()) {
-                AutoscaleAlgorithm algorithm = this.getAutoscaleAlgorithm(
+                PartitionAlgorithm algorithm = this.getAutoscaleAlgorithm(
                         groupLevelNetworkPartitionContext.getPartitionAlgorithm());
                 partitionContext = algorithm.getNextScaleUpPartitionContext(
                         (partitionContexts.toArray(groupLevelPartitionContexts)));

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
index 182f64e..0337c87 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
@@ -20,9 +20,9 @@ package org.apache.stratos.autoscaler.monitor.component;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
-import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
-import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.dependency.DependencyBuilder;
 import org.apache.stratos.autoscaler.applications.dependency.DependencyTree;
@@ -725,8 +725,8 @@ public abstract class ParentComponentMonitor extends Monitor implements Runnable
         this.terminatingInstancesMap = terminatingInstancesMap;
     }
 
-    public AutoscaleAlgorithm getAutoscaleAlgorithm(String partitionAlgorithm) {
-        AutoscaleAlgorithm autoscaleAlgorithm = null;
+    public PartitionAlgorithm getAutoscaleAlgorithm(String partitionAlgorithm) {
+        PartitionAlgorithm autoscaleAlgorithm = null;
         if (log.isDebugEnabled()) {
             log.debug(String.format("Partition algorithm is ", partitionAlgorithm));
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/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 b9613e6..d796d32 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
@@ -23,9 +23,9 @@ package org.apache.stratos.autoscaler.rule;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
-import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
-import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
 import org.apache.stratos.autoscaler.context.AutoscalerContext;
 import org.apache.stratos.autoscaler.context.cluster.ClusterContext;
@@ -137,9 +137,9 @@ public class RuleTasksDelegator {
         return numberOfInstances;
     }
 
-    public AutoscaleAlgorithm getAutoscaleAlgorithm(String partitionAlgorithm) {
+    public PartitionAlgorithm getPartitionAlgorithm(String partitionAlgorithm) {
 
-        AutoscaleAlgorithm autoscaleAlgorithm = null;
+        PartitionAlgorithm autoscaleAlgorithm = null;
         //FIXME to not parse for algo when partition is chosen by the parent
 
         if(partitionAlgorithm == null) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl b/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
index fca3739..38a8f0e 100644
--- a/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
+++ b/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
@@ -28,9 +28,9 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.RequestsInFlight;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadThresholds;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
-import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
-import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl b/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl
index 616cc3c..168a5cf 100644
--- a/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl
+++ b/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl
@@ -28,9 +28,9 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.RequestsInFlight;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadThresholds;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
-import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
-import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/products/stratos/modules/distribution/src/main/conf/drools/dependent-scaling.drl
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/drools/dependent-scaling.drl b/products/stratos/modules/distribution/src/main/conf/drools/dependent-scaling.drl
index b225958..336833a 100644
--- a/products/stratos/modules/distribution/src/main/conf/drools/dependent-scaling.drl
+++ b/products/stratos/modules/distribution/src/main/conf/drools/dependent-scaling.drl
@@ -20,7 +20,7 @@
 package org.apache.stratos.autoscaler.rule;
 
 import org.apache.stratos.autoscaler.context.cluster.ClusterInstanceContext;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.autoscaler.context.member.MemberStatsContext;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.RequestsInFlight;
@@ -41,7 +41,7 @@ dialect "mvel"
 	when
 
         clusterInstanceContext : ClusterInstanceContext ()
-        autoscaleAlgorithm : AutoscaleAlgorithm() from  delegator.getAutoscaleAlgorithm(algorithmName)
+        partitionAlgorithm : PartitionAlgorithm() from  delegator.getPartitionAlgorithm(algorithmName)
 
         nonTerminatedMembers : Integer() from clusterInstanceContext.getNonTerminatedMemberCount()
 
@@ -79,7 +79,7 @@ dialect "mvel"
 
                 while(count != additionalInstances  && partitionsAvailable) {
 
-                    ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext)autoscaleAlgorithm.getNextScaleUpPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
+                    ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext)partitionAlgorithm.getNextScaleUpPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
                     if(partitionContext != null) {
 
                         log.info("[dependency-scale][scale-up] Partition available, hence trying to spawn an instance to scale up!" );
@@ -123,7 +123,7 @@ dialect "mvel"
                 MemberStatsContext selectedMemberStatsContext = null;
                 double lowestOverallLoad = 0.0;
                 boolean foundAValue = false;
-                ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext)autoscaleAlgorithm.getNextScaleDownPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
+                ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext)partitionAlgorithm.getNextScaleDownPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
                 if(partitionContext != null){
                     log.info("[dependency-scale][scale-down] Partition available to scale down, hence trying to terminate an instance to scale down!" );
                     log.debug("[dependency-scale][scale-down] " + " [partition] " + partitionContext.getPartitionId() + " [cluster] " + clusterId );

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl b/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl
index 4cd5bc4..ddf9f1d 100755
--- a/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl
+++ b/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl
@@ -28,9 +28,9 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.RequestsInFlight;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadThresholds;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
-import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
-import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
@@ -54,7 +54,7 @@ dialect "mvel"
     when
         clusterInstanceContext : ClusterInstanceContext ()
 
-        autoscaleAlgorithm : AutoscaleAlgorithm() from  delegator.getAutoscaleAlgorithm(algorithmName)
+        partitionAlgorithm : PartitionAlgorithm() from  delegator.getPartitionAlgorithm(algorithmName)
 
         eval(log.debug("Running minimum rule: [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + " [cluster-instance] " + clusterInstanceContext.getId()))
         eval(log.debug("[min-check] [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + " [cluster-instance] " + clusterInstanceContext.getId() + " [cluster] " + clusterId + " Non terminated member count: " + clusterInstanceContext.getNonTerminatedMemberCount()))
@@ -79,7 +79,7 @@ dialect "mvel"
         boolean partitionsAvailable = true;
         while(count != additionalInstances && partitionsAvailable){
 
-            ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext)autoscaleAlgorithm.getNextScaleUpPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
+            ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext)partitionAlgorithm.getNextScaleUpPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
              if(partitionContext != null){
 
                 log.info("[min-check] Partition available, hence trying to spawn an instance to fulfil minimum count!" + " [cluster] " + clusterId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/products/stratos/modules/distribution/src/main/conf/drools/obsoletecheck.drl
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/drools/obsoletecheck.drl b/products/stratos/modules/distribution/src/main/conf/drools/obsoletecheck.drl
index 27d958a..82b9d3a 100755
--- a/products/stratos/modules/distribution/src/main/conf/drools/obsoletecheck.drl
+++ b/products/stratos/modules/distribution/src/main/conf/drools/obsoletecheck.drl
@@ -28,9 +28,9 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.RequestsInFlight;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadThresholds;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
-import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
-import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;

http://git-wip-us.apache.org/repos/asf/stratos/blob/67e9f85c/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
index 3d13308..0ece190 100644
--- a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
+++ b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
@@ -32,9 +32,9 @@ import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadThresholds;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.MemoryConsumption;
 import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadAverage;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
-import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
-import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
-import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.cloud.controller.stub.domain.Partition;
@@ -62,7 +62,7 @@ dialect "mvel"
        clusterInstanceContext : ClusterInstanceContext ()
 
         loadThresholds : LoadThresholds() from  autoscalePolicy.getLoadThresholds()
-        autoscaleAlgorithm : AutoscaleAlgorithm() from  delegator.getAutoscaleAlgorithm(algorithmName)
+        partitionAlgorithm : PartitionAlgorithm() from  delegator.getPartitionAlgorithm(algorithmName)
 
         eval(log.debug("Running scale up rule: [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + " [cluster] " + clusterId))
         eval(log.debug("[scaling] [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + " [cluster] " + clusterId + " Algorithm name: " + algorithmName))
@@ -152,7 +152,7 @@ dialect "mvel"
 
                     while(count != additionalInstances && partitionsAvailable){
 
-                        ClusterLevelPartitionContext partitionContext = (ClusterLevelPartitionContext)autoscaleAlgorithm.getNextScaleUpPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
+                        ClusterLevelPartitionContext partitionContext = (ClusterLevelPartitionContext)partitionAlgorithm.getNextScaleUpPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray());
                         if(partitionContext != null){
 
                             log.info("[scale-up] Partition available, hence trying to spawn an instance to scale up!" );
@@ -191,7 +191,7 @@ dialect "mvel"
                         MemberStatsContext selectedMemberStatsContext = null;
                         double lowestOverallLoad = 0.0;
                         boolean foundAValue = false;
-                        ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext) autoscaleAlgorithm.getNextScaleDownPartitionContext((clusterInstanceContext.getPartitionCtxtsAsAnArray()));
+                        ClusterLevelPartitionContext partitionContext =  (ClusterLevelPartitionContext) partitionAlgorithm.getNextScaleDownPartitionContext((clusterInstanceContext.getPartitionCtxtsAsAnArray()));
                         if(partitionContext != null){
                             log.info("[scale-down] Partition available to scale down ");
         //                    log.debug("[scale-down] " + " [partition] " + partition.getId() + " [cluster] " + clusterId);