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/08 13:16:35 UTC

[3/3] stratos git commit: Running maxcheck from cluster monitor

Running maxcheck from cluster monitor


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

Branch: refs/heads/master
Commit: 0f4599e64aed74d0cac004e4c820e59f097debc6
Parents: 7aa8627
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Apr 8 16:45:50 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Apr 8 16:45:50 2015 +0530

----------------------------------------------------------------------
 .../monitor/cluster/ClusterMonitor.java         | 29 +++++++++++++++++++-
 .../common/constants/StratosConstants.java      |  1 +
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/0f4599e6/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 91a5971..da3aa31 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
@@ -45,7 +45,10 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.autoscaler.status.processor.cluster.ClusterStatusActiveProcessor;
 import org.apache.stratos.autoscaler.status.processor.cluster.ClusterStatusInactiveProcessor;
 import org.apache.stratos.autoscaler.status.processor.cluster.ClusterStatusTerminatedProcessor;
-import org.apache.stratos.autoscaler.util.*;
+import org.apache.stratos.autoscaler.util.AutoscalerConstants;
+import org.apache.stratos.autoscaler.util.AutoscalerObjectConverter;
+import org.apache.stratos.autoscaler.util.ConfUtil;
+import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
 import org.apache.stratos.cloud.controller.stub.domain.MemberContext;
 import org.apache.stratos.common.Properties;
 import org.apache.stratos.common.Property;
@@ -86,6 +89,7 @@ public class ClusterMonitor extends Monitor implements Runnable {
     private final ExecutorService executorService;
 
     protected FactHandle minCheckFactHandle;
+    protected FactHandle maxCheckFactHandle;
     protected FactHandle obsoleteCheckFactHandle;
     protected FactHandle scaleCheckFactHandle;
     protected FactHandle dependentScaleCheckFactHandle;
@@ -93,6 +97,7 @@ public class ClusterMonitor extends Monitor implements Runnable {
     protected boolean stop = false;
     protected AbstractClusterContext clusterContext;
     protected StatefulKnowledgeSession minCheckKnowledgeSession;
+    protected StatefulKnowledgeSession maxCheckKnowledgeSession;
     protected StatefulKnowledgeSession obsoleteCheckKnowledgeSession;
     protected StatefulKnowledgeSession scaleCheckKnowledgeSession;
     protected StatefulKnowledgeSession dependentScaleCheckKnowledgeSession;
@@ -128,6 +133,7 @@ public class ClusterMonitor extends Monitor implements Runnable {
         autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.OBSOLETE_CHECK_DROOL_FILE);
         autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.SCALE_CHECK_DROOL_FILE);
         autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.MIN_CHECK_DROOL_FILE);
+        autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.MAX_CHECK_DROOL_FILE);
         autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
 
         this.obsoleteCheckKnowledgeSession = autoscalerRuleEvaluator.getStatefulSession(
@@ -136,6 +142,8 @@ public class ClusterMonitor extends Monitor implements Runnable {
                 StratosConstants.SCALE_CHECK_DROOL_FILE);
         this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getStatefulSession(
                 StratosConstants.MIN_CHECK_DROOL_FILE);
+        this.maxCheckKnowledgeSession = autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.MAX_CHECK_DROOL_FILE);
         this.dependentScaleCheckKnowledgeSession = autoscalerRuleEvaluator.getStatefulSession(
                 StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
 
@@ -255,6 +263,10 @@ public class ClusterMonitor extends Monitor implements Runnable {
         return minCheckKnowledgeSession;
     }
 
+    public StatefulKnowledgeSession getMaxCheckKnowledgeSession() {
+        return maxCheckKnowledgeSession;
+    }
+
     public void setMinCheckKnowledgeSession(
             StatefulKnowledgeSession minCheckKnowledgeSession) {
         this.minCheckKnowledgeSession = minCheckKnowledgeSession;
@@ -520,6 +532,21 @@ public class ClusterMonitor extends Monitor implements Runnable {
                                         minCheckFactHandle, instanceContext);
 
 
+                                getMaxCheckKnowledgeSession().setGlobal("primaryMemberCount",
+                                        primaryMemberListInClusterInstance.size());
+                                getMaxCheckKnowledgeSession().setGlobal("clusterId", getClusterId());
+                                getMaxCheckKnowledgeSession().setGlobal("isPrimary", hasPrimary);
+                                getMaxCheckKnowledgeSession().setGlobal("primaryMembers",
+                                        primaryMemberListInClusterInstance);
+                                if (log.isDebugEnabled()) {
+                                    log.debug(String.format("Running max check for cluster instance %s ",
+                                            instanceContext.getId() + " for the cluster: " + clusterId));
+                                }
+
+                                maxCheckFactHandle = AutoscalerRuleEvaluator.evaluate(getMaxCheckKnowledgeSession(),
+                                        maxCheckFactHandle, instanceContext);
+
+
                                 //checking the status of the cluster
                                 boolean rifReset = instanceContext.isRifReset();
                                 boolean memoryConsumptionReset = instanceContext.isMemoryConsumptionReset();

http://git-wip-us.apache.org/repos/asf/stratos/blob/0f4599e6/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
index 733f641..c05a230 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
@@ -155,6 +155,7 @@ public class StratosConstants {
     public static final String SCALE_CHECK_DROOL_FILE = "scaling.drl";
     public static final String DEPENDENT_SCALE_CHECK_DROOL_FILE = "dependent-scaling.drl";
     public static final String MIN_CHECK_DROOL_FILE = "mincheck.drl";
+    public static final String MAX_CHECK_DROOL_FILE = "maxcheck.drl";
     public static final String OBSOLETE_CHECK_DROOL_FILE = "obsoletecheck.drl";
     public static final String MIN_COUNT = "MIN_COUNT";