You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2013/11/12 11:28:53 UTC

[1/2] git commit: Fixed OneAfterAnother algorithm scale up and scale down logic and exported org.apache.stratos.messaging.domain.topology.xsd package in org.apache.stratos.lb.cartridge.autoscaler.service.stub

Updated Branches:
  refs/heads/master 127a11b12 -> 48340ed87


Fixed OneAfterAnother algorithm scale up and scale down logic and exported org.apache.stratos.messaging.domain.topology.xsd package in org.apache.stratos.lb.cartridge.autoscaler.service.stub


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

Branch: refs/heads/master
Commit: 06d3bcd35db648e0c50238b2dc8760b4111128b7
Parents: 2ed82b3
Author: Imesh Gunaratne <im...@apache.org>
Authored: Tue Nov 12 15:56:25 2013 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Tue Nov 12 15:56:25 2013 +0530

----------------------------------------------------------------------
 .../autoscaler/algorithm/OneAfterAnother.java   | 77 +++++++++++---------
 .../pom.xml                                     |  3 +-
 2 files changed, 46 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/06d3bcd3/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 a113300..040a85f 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
@@ -32,40 +32,44 @@ public class OneAfterAnother implements AutoscaleAlgorithm {
 
     public Partition getNextScaleUpPartition(String clusterId) {
 
-        String policyId = null;
-        int nextPartitionIndex;
+        // Find cluster context
         ClusterContext clusterContext = AutoscalerContext.getInstance().getClusterContext(clusterId);
-        int currentPartitionIndex = clusterContext.getCurrentPartitionIndex();
 
+        // Find service id
         String serviceId = AutoscalerContext.getInstance().getClusterContext(clusterId).getServiceId();
 
         //Find relevant policyId using topology
-        policyId = TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
-
+        String policyId = TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
 
+        // Find number of partitions
         int noOfPartitions = PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().size();
 
-        //Here in "one after another" algorithm, next partition is also the current partition unless it reached its max
-        nextPartitionIndex = currentPartitionIndex;
-
-        //Set next partition as current partition in Autoscaler Context
-        AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(nextPartitionIndex);
+        // Here in "one after another" algorithm, next partition is also the current partition unless it reached its max
+        int nextPartitionIndex = clusterContext.getCurrentPartitionIndex();;
 
         //Find next partition
-        Partition nextPartition = PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions()
-                .get(nextPartitionIndex);
+        Partition nextPartition = PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().get(nextPartitionIndex);
         String nextPartitionId = nextPartition.getId();
 
         if (clusterContext.partitionCountExists(nextPartitionId)) {
-
-            //If the current partitions max is reached, it will try next partition
             if (clusterContext.getPartitionCount(nextPartitionId) >= nextPartition.getPartitionMembersMax()) {
+                if(nextPartitionIndex == (noOfPartitions - 1)) {
+                    // All partitions have reached their max
+                    return null;
+                }
 
-                nextPartition = getNextScaleUpPartition(clusterId);
+                // Selected partition's max has reached, it will try next partition
+                AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(nextPartitionIndex + 1);
+
+                return getNextScaleUpPartition(clusterId);
+            }
+            else {
+                // Increase member partition member count by one
+                AutoscalerContext.getInstance().getClusterContext(clusterId).increaseMemberCountInPartition(nextPartitionId, 1);
             }
         } else {
 
-            //Add the partition count entry to cluster context
+            // Add the partition count entry to cluster context
             AutoscalerContext.getInstance().getClusterContext(clusterId).addPartitionCount(nextPartitionId, 1);
         }
         return nextPartition;
@@ -73,38 +77,45 @@ public class OneAfterAnother implements AutoscaleAlgorithm {
 
     public Partition getNextScaleDownPartition(String clusterId) {
 
-        String policyId = null;
-        int nextPartitionIndex;
-        Partition nextPartition = null;
+        // Find cluster context
         ClusterContext clusterContext = AutoscalerContext.getInstance().getClusterContext(clusterId);
-        int currentPartitionIndex = clusterContext.getCurrentPartitionIndex();
 
+        // Find service id
         String serviceId = AutoscalerContext.getInstance().getClusterContext(clusterId).getServiceId();
 
         //Find relevant policyId using topology
-        policyId = TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
+        String policyId = TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
 
-        //Find number of partitions relevant for this clusters policy
+        // Find number of partitions
         int noOfPartitions = PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().size();
 
-        //Here in "one after another" algorithm, next partition is also the current partition unless it reached its max
-        nextPartitionIndex = currentPartitionIndex;
-
-        //Set next partition as current partition in Autoscaler Context
-        AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(nextPartitionIndex);
+        // Here in "one after another" algorithm, next partition is also the current partition unless it reached its max
+        int nextPartitionIndex = clusterContext.getCurrentPartitionIndex();;
 
         //Find next partition
-        nextPartition = PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions()
-                .get(nextPartitionIndex);
+        Partition nextPartition = PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().get(nextPartitionIndex);
         String nextPartitionId = nextPartition.getId();
 
-        if (clusterContext.partitionCountExists(nextPartitionId) &&
-                (clusterContext.getPartitionCount(nextPartitionId) <= nextPartition.getPartitionMembersMin())) {
+        if (clusterContext.partitionCountExists(nextPartitionId)) {
+            if (clusterContext.getPartitionCount(nextPartitionId) >= nextPartition.getPartitionMembersMax()) {
+                if(nextPartitionIndex == 0) {
+                    // All partitions have reached their max
+                    return null;
+                }
+
+                // Selected partition's max has reached, it will try next partition
+                AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(nextPartitionIndex - 1);
 
-        //If the current partitions max is reached, it will try next partition
-            nextPartition = getNextScaleDownPartition(clusterId);
+                return getNextScaleUpPartition(clusterId);
+            }
+            else {
+                // Increase member partition member count by one
+                AutoscalerContext.getInstance().getClusterContext(clusterId).increaseMemberCountInPartition(nextPartitionId, 1);
+            }
         } else {
 
+            // Add the partition count entry to cluster context
+            AutoscalerContext.getInstance().getClusterContext(clusterId).addPartitionCount(nextPartitionId, 1);
         }
         return nextPartition;
     }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/06d3bcd3/service-stubs/org.apache.stratos.lb.cartridge.autoscaler.service.stub/pom.xml
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.lb.cartridge.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.lb.cartridge.autoscaler.service.stub/pom.xml
index 6b99652..c186113 100644
--- a/service-stubs/org.apache.stratos.lb.cartridge.autoscaler.service.stub/pom.xml
+++ b/service-stubs/org.apache.stratos.lb.cartridge.autoscaler.service.stub/pom.xml
@@ -89,7 +89,8 @@
                         <Export-Package>
                             org.apache.stratos.cloud.controller.exception.xsd.*; version=${project.version},
                             org.apache.stratos.cloud.controller.stub.*; version=${project.version},
-                            org.apache.stratos.cloud.controller.util.xsd.*; version=${project.version}
+                            org.apache.stratos.cloud.controller.util.xsd.*; version=${project.version},
+                            org.apache.stratos.messaging.domain.topology.xsd.*; version=${project.version}
                         </Export-Package>
                         <Import-Package>
                             *;resolution:=optional


[2/2] git commit: Merge remote-tracking branch 'origin/master'

Posted by im...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/master
Commit: 48340ed874d05662c8eecee49cec4e01ccd85fa3
Parents: 06d3bcd 127a11b
Author: Imesh Gunaratne <im...@apache.org>
Authored: Tue Nov 12 15:57:57 2013 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Tue Nov 12 15:57:57 2013 +0530

----------------------------------------------------------------------
 .../cartridge-agent/ec2/php/cartridge-agent.sh  |  6 ++++++
 .../src/main/bin/health-publisher.sh            |  6 +++++-
 .../agent/health/publisher/HealthPublisher.java |  1 +
 .../health/publisher/HealthPublisherClient.java | 20 ++++++++++++++------
 4 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------