stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject stratos git commit: removing status from cluster monitor and fixing relevant places to get status from cluster instance
Date Mon, 08 Dec 2014 06:11:12 GMT
Repository: stratos
Updated Branches:
  refs/heads/master b21f3ec93 -> d830fab50


removing status from cluster monitor and fixing relevant places to get status from cluster
instance


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

Branch: refs/heads/master
Commit: d830fab50315f20f3a8d664de9c4024ec41a087d
Parents: b21f3ec
Author: reka <rthirunavukkarasu23@gmail.com>
Authored: Sun Dec 7 23:39:47 2014 +0530
Committer: reka <rthirunavukkarasu23@gmail.com>
Committed: Sun Dec 7 23:39:47 2014 +0530

----------------------------------------------------------------------
 .../monitor/cluster/AbstractClusterMonitor.java |  8 -----
 .../KubernetesServiceClusterMonitor.java        |  6 ++--
 .../monitor/cluster/VMClusterMonitor.java       |  2 +-
 .../monitor/component/GroupMonitor.java         | 34 ++++++++++++++++++++
 .../component/ParentComponentMonitor.java       |  8 ++---
 5 files changed, 42 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d830fab5/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 5710ef4..277948f 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
@@ -70,7 +70,6 @@ public abstract class AbstractClusterMonitor extends Monitor implements
Runnable
     private AtomicBoolean monitoringStarted;
     private String clusterId;
     private Cluster cluster;
-    private ClusterStatus status;
     private int monitoringIntervalMilliseconds;
     private boolean isDestroyed;
 
@@ -81,9 +80,6 @@ public abstract class AbstractClusterMonitor extends Monitor implements
Runnable
         this.serviceType = cluster.getServiceName();
         this.clusterId = cluster.getClusterId();
         this.monitoringStarted = new AtomicBoolean(false);
-        //this.clusterContext = abstractClusterContext;
-        //this.instanceIdToClusterContextMap = new HashMap<String, AbstractClusterContext>();
-        this.status = ClusterStatus.Created;
     }
 
     protected abstract void readConfigurations();
@@ -205,10 +201,6 @@ public abstract class AbstractClusterMonitor extends Monitor implements
Runnable
         this.clusterId = clusterId;
     }
 
-    public ClusterStatus getStatus() {
-        return status;
-    }
-
     public void notifyParentMonitor(ClusterStatus status, String instanceId) {
         /**
          * notifying the parent monitor about the state change

http://git-wip-us.apache.org/repos/asf/stratos/blob/d830fab5/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java
index 0221a05..d456a43 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java
@@ -59,14 +59,14 @@ public final class KubernetesServiceClusterMonitor extends KubernetesClusterMoni
         }
         try {
 
-            if (!ClusterStatus.Active.getNextStates().contains(getStatus())) {
+            //TODO to get status from correct instance if (!ClusterStatus.Active.getNextStates().contains(getStatus()))
{
                 monitor();
-            } else {
+            /*} else {
                 if (log.isDebugEnabled()) {
                     log.debug("KubernetesServiceClusterMonitor is suspended as the cluster
is in "
                             + getStatus() + "state");
                 }
-            }
+            }*/
         } catch (Exception e) {
             log.error("KubernetesServiceClusterMonitor: Monitor failed." + this.toString(),
                     e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/d830fab5/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 9a4019c..745f104 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
@@ -184,7 +184,7 @@ public class VMClusterMonitor extends AbstractClusterMonitor {
                 ClusterInstance instance = (ClusterInstance) this.instanceIdToInstanceMap.
                         get(instanceContext.getId());
                 if ((instance.getStatus().getCode() <= ClusterStatus.Active.getCode())
||
-                        (getStatus() == ClusterStatus.Inactive && !hasStartupDependents)
&& !this.hasFaultyMember
+                        (instance.getStatus() == ClusterStatus.Inactive && !hasStartupDependents)
&& !this.hasFaultyMember
                                 && !stop) {
 
                     Runnable monitoringRunnable = new Runnable() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/d830fab5/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 f0b43ec..ac271ba 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
@@ -630,5 +630,39 @@ public class GroupMonitor extends ParentComponentMonitor implements Runnable
{
         this.isDestroyed = isDestroyed;
     }
 
+    public boolean verifyGroupStatus(String instanceId, GroupStatus requiredStatus) {
+        if(this.instanceIdToInstanceMap.containsKey(instanceId)) {
+            if(((GroupInstance)this.instanceIdToInstanceMap.get(instanceId)).getStatus()
== requiredStatus) {
+                return true;
+            }
+        } else {
+            List<GroupInstance> instances = new ArrayList<GroupInstance>();
+            String networkPartitionId = null;
+            int noOfInstancesOfRequiredStatus = 0;
+            for(Instance instance : this.instanceIdToInstanceMap.values()) {
+                GroupInstance groupInstance = (GroupInstance)instance;
+                if(groupInstance.getParentId().equals(instanceId)) {
+                    instances.add(groupInstance);
+                    networkPartitionId = groupInstance.getNetworkPartitionId();
+                    if(groupInstance.getStatus() == requiredStatus) {
+                        noOfInstancesOfRequiredStatus ++;
+                    }
+                }
+            }
+            if(!instances.isEmpty()) {
+                int minInstances = this.networkPartitionCtxts.get(networkPartitionId).
+                                                getMinInstanceCount();
+                if(noOfInstancesOfRequiredStatus >= minInstances) {
+                    return true;
+                } else {
+                    if(requiredStatus == GroupStatus.Inactive && noOfInstancesOfRequiredStatus
>= 1) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d830fab5/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 721f291..217d0db 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
@@ -455,11 +455,10 @@ public abstract class ParentComponentMonitor extends Monitor {
                     GroupMonitor monitor1 = (GroupMonitor) monitor;
                     ApplicationHolder.acquireReadLock();
                     try {
-                        //TODO***********
-                        /*if (monitor1.getStatus() == GroupStatus.Active) {
+                        if (monitor1.verifyGroupStatus(instanceId, GroupStatus.Active)) {
                             parentsActive = true;
 
-                        }*/
+                        }
                     } finally {
                         ApplicationHolder.releaseReadLock();
                     }
@@ -468,7 +467,8 @@ public abstract class ParentComponentMonitor extends Monitor {
                     TopologyManager.acquireReadLockForCluster(monitor1.getServiceId(),
                             monitor1.getClusterId());
                     try {
-                        if (monitor1.getStatus() == ClusterStatus.Active) {
+                        if (((ClusterInstance)monitor1.getInstance(instanceId)).getStatus()
+                                                    == ClusterStatus.Active) {
                             parentsActive = true;
                         }
                     } finally {


Mime
View raw message