Repository: stratos
Updated Branches:
  refs/heads/master 347648197 -> 5fde35954


Initializing drools session in relavent cluster monitors


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

Branch: refs/heads/master
Commit: 5fde35954807445ade7151caf4fcf61ce28e6418
Parents: 3476481
Author: Lahiru Sandaruwan <[email protected]>
Authored: Wed Dec 3 21:07:01 2014 +0530
Committer: Lahiru Sandaruwan <[email protected]>
Committed: Wed Dec 3 21:07:10 2014 +0530

----------------------------------------------------------------------
 .../monitor/cluster/AbstractClusterMonitor.java | 27 ++++++--------------
 .../cluster/KubernetesClusterMonitor.java       | 23 ++++++++++++++++-
 .../monitor/cluster/VMClusterMonitor.java       | 19 +++++++++++++-
 3 files changed, 48 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/5fde3595/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java
index 6f5c714..b094a12 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java
@@ -64,18 +64,20 @@ public abstract class AbstractClusterMonitor extends 
Monitor implements Runnable
     protected boolean stop = false;
     private AtomicBoolean monitoringStarted;
     protected AbstractClusterContext clusterContext;
+
+    protected StatefulKnowledgeSession minCheckKnowledgeSession;
+    protected StatefulKnowledgeSession obsoleteCheckKnowledgeSession;
+    protected StatefulKnowledgeSession scaleCheckKnowledgeSession;
+    protected StatefulKnowledgeSession dependentScaleCheckKnowledgeSession;
+
     private String clusterId;
     private ClusterStatus status;
     private int monitoringIntervalMilliseconds;
-    private StatefulKnowledgeSession minCheckKnowledgeSession;
-    private StatefulKnowledgeSession obsoleteCheckKnowledgeSession;
-    private StatefulKnowledgeSession scaleCheckKnowledgeSession;
-    private StatefulKnowledgeSession dependentScaleCheckKnowledgeSession;
     private boolean isDestroyed;
-    private AutoscalerRuleEvaluator autoscalerRuleEvaluator;
+    protected AutoscalerRuleEvaluator autoscalerRuleEvaluator;
     protected String serviceType;
 
-    protected AbstractClusterMonitor(String serviceType, String clusterId, 
AutoscalerRuleEvaluator autoscalerRuleEvaluator) {
+    protected AbstractClusterMonitor(String serviceType, String clusterId) {
 
         super();
         this.serviceType = serviceType;
@@ -84,19 +86,6 @@ public abstract class AbstractClusterMonitor extends Monitor 
implements Runnable
         this.monitoringStarted = new AtomicBoolean(false);
         //this.clusterContext = abstractClusterContext;
         //this.instanceIdToClusterContextMap = new HashMap<String, 
AbstractClusterContext>();
-        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.VM_OBSOLETE_CHECK_DROOL_FILE);
-        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.VM_SCALE_CHECK_DROOL_FILE);
-        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.VM_MIN_CHECK_DROOL_FILE);
-        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
-
-        this.obsoleteCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
-                StratosConstants.VM_OBSOLETE_CHECK_DROOL_FILE);
-        this.scaleCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
-                StratosConstants.VM_SCALE_CHECK_DROOL_FILE);
-        this.minCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
-                StratosConstants.VM_MIN_CHECK_DROOL_FILE);
-        this.dependentScaleCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
-                StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
         this.status = ClusterStatus.Created;
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/5fde3595/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java
index a8bd3f2..b5d35be 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java
@@ -25,7 +25,9 @@ import 
org.apache.stratos.autoscaler.context.member.MemberStatsContext;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
 import org.apache.stratos.autoscaler.exception.cartridge.TerminationException;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
+import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 import org.apache.stratos.messaging.domain.topology.Member;
 import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent;
@@ -51,6 +53,7 @@ import 
org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent;
 import org.apache.stratos.messaging.event.topology.MemberStartedEvent;
 import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 /*
  * Every kubernetes cluster monitor should extend this class
@@ -59,12 +62,30 @@ public abstract class KubernetesClusterMonitor extends 
AbstractClusterMonitor {
 
     private static final Log log = 
LogFactory.getLog(KubernetesClusterMonitor.class);
 
+    private StatefulKnowledgeSession dependentScaleCheckKnowledgeSession;
+
     private KubernetesClusterContext kubernetesClusterCtxt;
 
     protected KubernetesClusterMonitor(String serviceType, String clusterId,
                                        AutoscalerRuleEvaluator 
autoscalerRuleEvaluator) {
 
-        super(serviceType, clusterId, autoscalerRuleEvaluator);
+        super(serviceType, clusterId);
+
+        autoscalerRuleEvaluator = new AutoscalerRuleEvaluator();
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.CONTAINER_OBSOLETE_CHECK_DROOL_FILE);
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.CONTAINER_SCALE_CHECK_DROOL_FILE);
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.CONTAINER_MIN_CHECK_DROOL_FILE);
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
+
+        this.obsoleteCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.VM_OBSOLETE_CHECK_DROOL_FILE);
+        this.scaleCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.VM_SCALE_CHECK_DROOL_FILE);
+        this.minCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.VM_MIN_CHECK_DROOL_FILE);
+        this.dependentScaleCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
+
         //this.kubernetesClusterCtxt = kubernetesClusterContext;
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/5fde3595/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
index 3763c94..9e8ff93 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
@@ -44,14 +44,17 @@ 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;
+import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 import org.apache.stratos.messaging.domain.topology.Member;
 import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.event.health.stat.*;
 import org.apache.stratos.messaging.event.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 import java.util.*;
 
@@ -68,10 +71,24 @@ public class VMClusterMonitor extends 
AbstractClusterMonitor {
     private float scalingFactorBasedOnDependencies = 1.0f;
 
     protected VMClusterMonitor(String serviceType, String clusterId) {
-        super(serviceType, clusterId, new AutoscalerRuleEvaluator());
+        super(serviceType, clusterId);
         this.networkPartitionIdToClusterLevelNetworkPartitionCtxts = new 
HashMap<String, ClusterLevelNetworkPartitionContext>();
 
         readConfigurations();
+        autoscalerRuleEvaluator = new AutoscalerRuleEvaluator();
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.VM_OBSOLETE_CHECK_DROOL_FILE);
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.VM_SCALE_CHECK_DROOL_FILE);
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.VM_MIN_CHECK_DROOL_FILE);
+        
autoscalerRuleEvaluator.parseAndBuildKnowledgeBaseForDroolsFile(StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
+
+        this.obsoleteCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.VM_OBSOLETE_CHECK_DROOL_FILE);
+        this.scaleCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.VM_SCALE_CHECK_DROOL_FILE);
+        this.minCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.VM_MIN_CHECK_DROOL_FILE);
+        this.dependentScaleCheckKnowledgeSession = 
autoscalerRuleEvaluator.getStatefulSession(
+                StratosConstants.DEPENDENT_SCALE_CHECK_DROOL_FILE);
     }
 
     private static void terminateMember(String memberId) {

Reply via email to