You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/04/24 12:48:37 UTC

[6/9] stratos git commit: Update cluster monitor to clean obsolete partition context when removed

Update cluster monitor to clean obsolete partition context when removed


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

Branch: refs/heads/master
Commit: e30dfbb839df6b5e47f0fe64f1194ba5cfd97fec
Parents: 4dab322
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Fri Apr 24 14:40:54 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Fri Apr 24 14:40:54 2015 +0530

----------------------------------------------------------------------
 .../stratos/autoscaler/monitor/MonitorFactory.java   |  5 ++---
 .../autoscaler/monitor/cluster/ClusterMonitor.java   | 15 +++++++++++----
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e30dfbb8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
index a531d59..8446bf6 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
@@ -273,9 +273,8 @@ public class MonitorFactory {
                     }
 
                     try {
-                        org.apache.stratos.cloud.controller.stub.domain.Partition[] partitions
-                                = convertPartitionsToCCPartitions(partitionList.toArray(new Partition[partitionList.size()]));
-                        CloudControllerServiceClient.getInstance().validateDeploymentPolicy(serviceName, networkPartition.getId());
+
+                        CloudControllerServiceClient.getInstance().validateNetworkPartitionOfDeploymentPolicy(serviceName, networkPartition.getId());
                     } catch (Exception e) {
                         String msg = String.format("Error while validating deployment policy from cloud controller [network-partition-id] %s", networkPartition.getId());
                         log.error(msg, e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/e30dfbb8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index da3aa31..cba4871 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -95,7 +95,7 @@ public class ClusterMonitor extends Monitor implements Runnable {
     protected FactHandle dependentScaleCheckFactHandle;
     protected boolean hasFaultyMember = false;
     protected boolean stop = false;
-    protected AbstractClusterContext clusterContext;
+    protected ClusterContext clusterContext;
     protected StatefulKnowledgeSession minCheckKnowledgeSession;
     protected StatefulKnowledgeSession maxCheckKnowledgeSession;
     protected StatefulKnowledgeSession obsoleteCheckKnowledgeSession;
@@ -113,7 +113,7 @@ public class ClusterMonitor extends Monitor implements Runnable {
     private boolean groupScalingEnabledSubtree;
 
     private static final Log log = LogFactory.getLog(ClusterMonitor.class);
-    private Map<String, ClusterLevelNetworkPartitionContext> networkPartitionIdToClusterLevelNetworkPartitionCtxts;
+        private Map<String, ClusterLevelNetworkPartitionContext> networkPartitionIdToClusterLevelNetworkPartitionCtxts;
     private boolean hasPrimary;
     private float scalingFactorBasedOnDependencies = 1.0f;
     private String deploymentPolicyId;
@@ -349,11 +349,11 @@ public class ClusterMonitor extends Monitor implements Runnable {
         this.dependentScaleCheckKnowledgeSession = dependentScaleCheckKnowledgeSession;
     }
 
-    public AbstractClusterContext getClusterContext() {
+    public ClusterContext getClusterContext() {
         return clusterContext;
     }
 
-    public void setClusterContext(AbstractClusterContext clusterContext) {
+    public void setClusterContext(ClusterContext clusterContext) {
         this.clusterContext = clusterContext;
     }
 
@@ -608,6 +608,13 @@ public class ClusterMonitor extends Monitor implements Runnable {
                                 getObsoleteCheckKnowledgeSession().setGlobal("clusterId", clusterId);
                                 obsoleteCheckFactHandle = AutoscalerRuleEvaluator.evaluate(
                                         getObsoleteCheckKnowledgeSession(), obsoleteCheckFactHandle, partitionContext);
+
+                                if (partitionContext.isObsoletePartition()
+                                        && partitionContext.getTerminationPendingMembers().size() == 0
+                                        && partitionContext.getObsoletedMembers().size() == 0) {
+
+                                    instanceContext.removePartitionCtxt(partitionContext.getPartition().getId());
+                                }
                             }
                         };
                         executorService.execute(monitoringRunnable);