stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [12/50] [abbrv] git commit: fixing on member terminatiin status checker
Date Thu, 30 Oct 2014 04:13:36 GMT
fixing on member terminatiin status checker


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

Branch: refs/heads/docker-grouping-merge
Commit: 66aeb302c2e61373ce38aace419a568701fe3462
Parents: 1b224bd
Author: reka <rthirunavukkarasu23@gmail.com>
Authored: Mon Oct 27 17:12:13 2014 +0530
Committer: reka <rthirunavukkarasu23@gmail.com>
Committed: Mon Oct 27 17:12:13 2014 +0530

----------------------------------------------------------------------
 .../monitor/AbstractClusterMonitor.java         |  6 +--
 .../status/checker/StatusChecker.java           | 46 ++++++++++++++------
 2 files changed, 36 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/66aeb302/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 838929c..588d2c4 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -234,11 +234,11 @@ abstract public class AbstractClusterMonitor extends Monitor implements
Runnable
          * If the cluster in_active and if it is a in_dependent cluster,
          * then won't send the notification to parent.
          */
-        if((status == ClusterStatus.Inactive && this.hasDependent)) {
-            MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status,
this.clusterId);
-        } else {
+        if(status == ClusterStatus.Inactive && !this.hasDependent) {
             log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
                     "since it is identified as the independent unit");
+        } else {
+            MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status,
this.clusterId);
         }
 
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/66aeb302/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 6309e02..7b3e0ac 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -73,20 +73,40 @@ public class StatusChecker {
 
     public void onMemberTermination(String clusterId) {
         ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
-        //TODO get Topology status
-        boolean clusterMonitorHasMembers;
-        clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
-        if(clusterMonitorHasMembers) {
-            //monitor.pause();
-            // if cluster not having any members and if the cluster was in_active then send
created Events
-            //TODO
-            StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(),
-                    monitor.getClusterId());
-        } else {
-            StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
-                    monitor.getClusterId());
+        boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
+        boolean clusterActive = clusterActive(monitor);
+
+        try {
+            TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
+            Service service = TopologyManager.getTopology().getService(monitor.getServiceId());
+            Cluster cluster;
+            if(service != null) {
+                cluster = service.getCluster(monitor.getClusterId());
+                if(cluster != null) {
+                    if(!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating)
{
+                        StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(),
monitor.getServiceId(),
+                                monitor.getClusterId());
+                    } else {
+                        log.info("Cluster has non terminated [members] and in the [status]
"
+                                        + cluster.getStatus().toString());
+
+                        /*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive
||
+                                cluster.getStatus() == ClusterStatus.Terminating)) {
+                            cluster.getStatus()
+                            StatusEventPublisher.sendClusterInActivateEvent(monitor.getAppId(),
+                                    monitor.getServiceId(), clusterId);
+
+                        }*/
+                    }
+                }
+            }
+
+
+        } finally {
+            TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
+
         }
-        // TODO if cluster was in terminating, then send terminated event.
+
     }
 
     private boolean clusterActive(AbstractClusterMonitor monitor) {


Mime
View raw message