You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2014/10/27 12:42:25 UTC
git commit: fixing on member terminatiin status checker
Repository: stratos
Updated Branches:
refs/heads/4.0.0-grouping 1b224bd86 -> 66aeb302c
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/4.0.0-grouping
Commit: 66aeb302c2e61373ce38aace419a568701fe3462
Parents: 1b224bd
Author: reka <rt...@gmail.com>
Authored: Mon Oct 27 17:12:13 2014 +0530
Committer: reka <rt...@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) {