stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [01/50] [abbrv] git commit: initial app unsubscription changes
Date Thu, 30 Oct 2014 04:13:25 GMT
Repository: stratos
Updated Branches:
  refs/heads/docker-grouping-merge dd9cc950d -> 17cc86ebd


initial app unsubscription changes


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

Branch: refs/heads/docker-grouping-merge
Commit: 4f59f4b8bdbb4d9aeab043ea6544f9654ab2c634
Parents: 87d77a2
Author: Isuru Haththotuwa <isuruh@apache.org>
Authored: Sun Oct 26 21:47:35 2014 +0530
Committer: Isuru Haththotuwa <isuruh@apache.org>
Committed: Sun Oct 26 21:54:59 2014 +0530

----------------------------------------------------------------------
 .../grouping/topic/StatusEventPublisher.java    |  23 ++-
 .../AutoscalerTopologyEventReceiver.java        | 141 ++++++++-----------
 .../stratos/autoscaler/monitor/Monitor.java     |   7 +-
 .../monitor/ParentComponentMonitor.java         |  20 +--
 .../monitor/application/ApplicationMonitor.java |  40 +++---
 .../status/checker/StatusChecker.java           |  13 +-
 .../ApplicationStatusTopicReceiver.java         |   4 +-
 .../impl/CloudControllerServiceImpl.java        |   4 +-
 .../controller/topology/TopologyBuilder.java    | 129 ++++++++---------
 .../topology/TopologyEventPublisher.java        |  20 +++
 .../topology/ApplicationTerminatedEvent.java    |  12 +-
 .../topology/ApplicationTerminatingEvent.java   |  12 +-
 ...StatusClusterTerminatedMessageProcessor.java |   2 +-
 .../ApplicationTerminatingMessageProcessor.java |  10 +-
 .../topology/ClusterTerminatedProcessor.java    |  16 +--
 .../topology/ClusterTerminatingProcessor.java   |  16 +--
 .../topology/GroupTerminatedProcessor.java      |   4 +-
 17 files changed, 243 insertions(+), 230 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index 0800b14..c0c64ac 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -10,6 +10,7 @@ import org.apache.stratos.messaging.event.application.status.*;
 import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent;
 import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent;
 import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent;
+import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent;
 import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
 import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent;
 import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent;
@@ -72,9 +73,10 @@ public class StatusEventPublisher {
                     " [cluster]: " + clusterId);
         }
         //TODO
-        /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId);
+        AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
+                new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
 
-        publishEvent(clusterActivatedEvent);*/
+        publishEvent(appStatusClusterTerminatingEvent);
     }
 
     public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
@@ -83,10 +85,11 @@ public class StatusEventPublisher {
             log.info("Publishing Cluster in-activate event for [application]: " + appId +
                     " [cluster]: " + clusterId);
         }
-        //TODO
-       /* Cluster clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId);
 
-        publishEvent(clusterActivatedEvent);*/
+        AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
+                new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
+
+        publishEvent(appStatusClusterTerminatedEvent);
     }
 
     public static void sendGroupActivatedEvent(String appId, String groupId) {
@@ -156,6 +159,16 @@ public class StatusEventPublisher {
         publishEvent(applicationInActivatedEvent);
     }
 
+    public static void sendApplicationTerminatingEvent (String appId) {
+        if (log.isInfoEnabled()) {
+            log.info("Publishing Application terminated event for [application]: " + appId);
+        }
+
+        ApplicationTerminatingEvent applicationTerminatingEvent = new ApplicationTerminatingEvent(appId);
+
+        publishEvent(applicationTerminatingEvent);
+    }
+
     public static void sendApplicationTerminatedEvent (String appId, Set<ClusterDataHolder> clusterData) {
         if (log.isInfoEnabled()) {
             log.info("Publishing Application terminated event for [application]: " + appId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index 2f7cca4..654d5b2 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -41,7 +41,6 @@ import org.apache.stratos.messaging.event.topology.*;
 import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
 import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
 import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent;
 import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
 import org.apache.stratos.messaging.listener.topology.*;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
@@ -204,9 +203,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 log.info("[ClusterInActivateEvent] Received: " + event.getClass());
 
-                ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event;
-                String appId = clusterInactivateEvent.getAppId();
-                String clusterId = clusterInactivateEvent.getClusterId();
+                ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event;
+                String appId = clusterTerminatingEvent.getAppId();
+                String clusterId = clusterTerminatingEvent.getClusterId();
                 AbstractClusterMonitor clusterMonitor =
                         (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
 
@@ -224,9 +223,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 log.info("[ClusterInActivateEvent] Received: " + event.getClass());
 
-                ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event;
-                String appId = clusterInactivateEvent.getAppId();
-                String clusterId = clusterInactivateEvent.getClusterId();
+                ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event;
+                String appId = clusterTerminatedEvent.getAppId();
+                String clusterId = clusterTerminatedEvent.getClusterId();
                 AbstractClusterMonitor clusterMonitor =
                         (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
 
@@ -328,78 +327,17 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
             }
         });
 
-//        topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() {
-//            @Override
-//            protected void onEvent(Event event) {
-//
-//                log.info("[ApplicationUndeployedEvent] Received: " + event.getClass());
-//
-//                ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event;
-//
-//                // acquire reead locks for application and relevant clusters
-//                TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId());
-//                Set<ClusterDataHolder> clusterDataHolders = applicationUndeployedEvent.getClusterData();
-//                if (clusterDataHolders != null) {
-//                    for (ClusterDataHolder clusterData : clusterDataHolders) {
-//                        TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
-//                                clusterData.getClusterId());
-//                    }
-//                }
-//
-//                try {
-//                    ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
-//                            getAppMonitor(applicationUndeployedEvent.getApplicationId());
-//
-//                    if (appMonitor != null) {
-//                        // update the status as Terminating
-//                        appMonitor.setStatus(ApplicationStatus.Terminating);
-//
-//                        List<String> clusters = appMonitor.
-//                                findClustersOfApplication(applicationUndeployedEvent.getApplicationId());
-//
-//                        for (String clusterId : clusters) {
-//                            //stopping the cluster monitor and remove it from the AS
-//                            ClusterMonitor clusterMonitor =
-//                                    ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId));
-//                            if (clusterMonitor != null) {
-//                                clusterMonitor.setDestroyed(true);
-//                                clusterMonitor.terminateAllMembers();
-//                                clusterMonitor.setStatus(ClusterStatus.Terminating);
-//                            } else {
-//                                log.warn("No Cluster Monitor found for cluster id " + clusterId);
-//                            }
-//                        }
-//
-//                    } else {
-//                        log.warn("Application Monitor cannot be found for the undeployed [application] "
-//                                + applicationUndeployedEvent.getApplicationId());
-//                    }
-//
-//                } finally {
-//                    if (clusterDataHolders != null) {
-//                        for (ClusterDataHolder clusterData : clusterDataHolders) {
-//                            TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
-//                                    clusterData.getClusterId());
-//                        }
-//                    }
-//                    TopologyManager.
-//                            releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
-//                }
-//            }
-//        });
-
-
-        topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
+        topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() {
             @Override
             protected void onEvent(Event event) {
 
-                log.info("[ApplicationTerminatingEvent] Received: " + event.getClass());
+                log.info("[ApplicationUndeployedEvent] Received: " + event.getClass());
 
-                ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event;
+                ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event;
 
                 // acquire reead locks for application and relevant clusters
-                TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId());
-                Set<ClusterDataHolder> clusterDataHolders = appTerminatingEvent.getClusterData();
+                TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+                Set<ClusterDataHolder> clusterDataHolders = applicationUndeployedEvent.getClusterData();
                 if (clusterDataHolders != null) {
                     for (ClusterDataHolder clusterData : clusterDataHolders) {
                         TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
@@ -409,31 +347,31 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 try {
                     ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
-                            getAppMonitor(appTerminatingEvent.getAppId());
+                            getAppMonitor(applicationUndeployedEvent.getApplicationId());
 
                     if (appMonitor != null) {
                         // update the status as Terminating
                         appMonitor.setStatus(ApplicationStatus.Terminating);
 
-                        List<String> clusters = appMonitor.
-                                findClustersOfApplication(appTerminatingEvent.getAppId());
+//                        List<String> clusters = appMonitor.
+//                                findClustersOfApplication(applicationUndeployedEvent.getApplicationId());
 
-                        for (String clusterId : clusters) {
+                        for (ClusterDataHolder clusterData : clusterDataHolders) {
                             //stopping the cluster monitor and remove it from the AS
                             ClusterMonitor clusterMonitor =
-                                    ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId));
+                                    ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId()));
                             if (clusterMonitor != null) {
                                 clusterMonitor.setDestroyed(true);
                                 clusterMonitor.terminateAllMembers();
                                 clusterMonitor.setStatus(ClusterStatus.Terminating);
                             } else {
-                                log.warn("No Cluster Monitor found for cluster id " + clusterId);
+                                log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId());
                             }
                         }
 
                     } else {
                         log.warn("Application Monitor cannot be found for the undeployed [application] "
-                                + appTerminatingEvent.getAppId());
+                                + applicationUndeployedEvent.getApplicationId());
                     }
 
                 } finally {
@@ -444,6 +382,38 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                         }
                     }
                     TopologyManager.
+                            releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+                }
+            }
+        });
+
+
+        topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                log.info("[ApplicationTerminatingEvent] Received: " + event.getClass());
+
+                ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event;
+
+                // acquire reead locks for application and relevant clusters
+                TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId());
+
+                try {
+                    ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
+                            getAppMonitor(appTerminatingEvent.getAppId());
+
+                    if (appMonitor != null) {
+                        // update the status as Terminating
+                        appMonitor.setStatus(ApplicationStatus.Terminating);
+
+                    } else {
+                        log.warn("Application Monitor cannot be found for the undeployed [application] "
+                                + appTerminatingEvent.getAppId());
+                    }
+
+                } finally {
+                    TopologyManager.
                             releaseReadLockForApplication(appTerminatingEvent.getAppId());
                 }
             }
@@ -472,12 +442,13 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                     ApplicationMonitor monitor = AutoscalerContext.getInstance().
                             getAppMonitor(applicationRemovedEvent.getApplicationId());
                     if (monitor != null) {
-                        List<String> clusters = monitor.
-                                findClustersOfApplication(applicationRemovedEvent.getApplicationId());
-                        for (String clusterId : clusters) {
+                        //List<String> clusters = monitor.
+                        //        findClustersOfApplication(applicationRemovedEvent.getApplicationId());
+                        for (ClusterDataHolder clusterData : clusterDataHolders) {
                             //stopping the cluster monitor and remove it from the AS
-                            ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)).setDestroyed(true);
-                            AutoscalerContext.getInstance().removeMonitor(clusterId);
+                            ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())).
+                                    setDestroyed(true);
+                            AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId());
                         }
                         //removing the application monitor
                         AutoscalerContext.getInstance().

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
index 1ac0893..7199ee8 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
@@ -73,7 +73,7 @@ public abstract class Monitor implements EventHandler {
         this.appId = parent.getAppId();
     }
 
-    public boolean hasMonitors() {
+    public boolean hasActiveMonitors() {
         boolean hasMonitor = false;
         if(this.aliasToActiveMonitorsMap != null ) {
             hasMonitor = true;
@@ -81,6 +81,11 @@ public abstract class Monitor implements EventHandler {
         return hasMonitor;
     }
 
+    public boolean hasMonitors () {
+
+        return this.aliasToActiveMonitorsMap != null || this.aliasToInActiveMonitorsMap != null;
+    }
+
     public boolean isHasDependent() {
         return hasDependent;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 26eff1d..4eb4bcb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -20,7 +20,6 @@ package org.apache.stratos.autoscaler.monitor;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 import org.apache.stratos.autoscaler.exception.PolicyValidationException;
@@ -96,16 +95,19 @@ public abstract class ParentComponentMonitor extends Monitor {
 
         Monitor monitor = this.aliasToInActiveMonitorsMap.get(idOfEvent);
         if (monitor != null) {
-            for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) {
-                if (monitor.hasMonitors()) {
-                    StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId());
-                } else {
-                    StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
-                            ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId());
+            // check if aliasToActiveMonitors are null (in case of a Cluster Monitor)
+            if (monitor.getAliasToActiveMonitorsMap() != null) {
+                for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) {
+                    if (monitor.hasActiveMonitors()) {
+                        StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId());
+                    } else {
+                        StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+                                ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId());
+                    }
                 }
             }
         } else {
-            log.warn("Active Monitor not found for the id " + idOfEvent);
+            log.warn("Inactive Monitor not found for the id " + idOfEvent);
         }
     }
 
@@ -123,7 +125,7 @@ public abstract class ParentComponentMonitor extends Monitor {
                 monitor = this.aliasToActiveMonitorsMap.
                         get(terminationContext.getId());
                 //start to kill it
-                if (monitor.hasMonitors()) {
+                if (monitor.hasActiveMonitors()) {
                     //it is a group
                     StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
                 } else {

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
index deb0950..45530c5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
@@ -61,26 +61,26 @@ public class ApplicationMonitor extends ParentComponentMonitor {
      * @param appId the application which contains the clusters
      * @return all the clusters of the application
      */
-    public List<String> findClustersOfApplication(String appId) {
-        List<String> clusters = new ArrayList<String>();
-        Set<ClusterDataHolder> clusterData;
-
-        TopologyManager.acquireReadLockForApplication(appId);
-        try {
-            clusterData = TopologyManager.getTopology().getApplication(appId).getClusterDataRecursively();
-
-        } finally {
-            TopologyManager.releaseReadLockForApplication(appId);
-        }
-
-        if (clusterData != null) {
-            for (ClusterDataHolder clusterDataHolder : clusterData) {
-                clusters.add(clusterDataHolder.getClusterId());
-            }
-        }
-
-        return clusters;
-    }
+//    public List<String> findClustersOfApplication(String appId) {
+//        List<String> clusters = new ArrayList<String>();
+//        Set<ClusterDataHolder> clusterData;
+//
+//        TopologyManager.acquireReadLockForApplication(appId);
+//        try {
+//            clusterData = TopologyManager.getTopology().getApplication(appId).getClusterDataRecursively();
+//
+//        } finally {
+//            TopologyManager.releaseReadLockForApplication(appId);
+//        }
+//
+//        if (clusterData != null) {
+//            for (ClusterDataHolder clusterDataHolder : clusterData) {
+//                clusters.add(clusterDataHolder.getClusterId());
+//            }
+//        }
+//
+//        return clusters;
+//    }
 
     /**
      * Find the cluster monitor by traversing recursively in the hierarchical monitors.

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/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 7aef08e..7019d0b 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
@@ -82,6 +82,9 @@ public class StatusChecker {
             //TODO
             StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(),
                     monitor.getClusterId());
+        } else {
+            StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
+                    monitor.getClusterId());
         }
         // TODO if cluster was in terminating, then send terminated event.
     }
@@ -264,9 +267,9 @@ public class StatusChecker {
                     clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
                     groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) {
                     //send the in activation event
-                if (parent instanceof Application) {
-                    //send application activated event
-                    log.info("sending app in-active : " + appId);
+                    if (parent instanceof Application) {
+                        //send application activated event
+                        log.info("sending app in-active : " + appId);
                     StatusEventPublisher.sendApplicationInactivatedEvent(appId);
                 } else if (parent instanceof Group) {
                     //send activation to the parent
@@ -294,12 +297,12 @@ public class StatusChecker {
                 if (parent instanceof Application) {
                     //send application activated event
                     log.info("sending app terminating: " + appId);
-                    StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
+                    StatusEventPublisher.sendApplicationTerminatingEvent(appId);
                     //StatusEventPublisher.sendApp(appId);
                 } else if (parent instanceof Group) {
                     //send activation to the parent
                     log.info("sending group terminating : " + parent.getUniqueIdentifier());
-                    StatusEventPublisher.sendGroupTerminatedEvent(appId, parent.getUniqueIdentifier());
+                    StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier());
                 }
             } else {
                 log.warn("Clusters/groups not found in this [component] " + appId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index 5aa4467..1a62fef 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -74,14 +74,14 @@ public class ApplicationStatusTopicReceiver implements Runnable {
         statusEventReceiver.addEventListener(new AppStatusClusterTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatedEvent((ClusterActivatedEvent) event);
+                TopologyBuilder.handleClusterTerminatedEvent((AppStatusClusterTerminatedEvent) event);
             }
         });
 
         statusEventReceiver.addEventListener(new AppStatusClusterTerminatingEventListener(){
             @Override
             protected void onEvent(Event event) {
-                TopologyBuilder.handleClusterTerminatingEvent((ClusterActivatedEvent) event);
+                TopologyBuilder.handleClusterTerminatingEvent((AppStatusClusterTerminatingEvent) event);
             }
         });
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 2fbf89a..0b322f8 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -1415,9 +1415,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
     @Override
     public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException {
 
-        TopologyBuilder.handleApplicationUndeployed(dataHolder, applicationId, tenantId, tenantDomain);
-
-        //persist();
+        TopologyBuilder.handleApplicationUndeployed(applicationId);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index d245a6f..4d929b1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -678,8 +678,7 @@ public class TopologyBuilder {
         }
     }
 
-    public static synchronized void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder,
-                                                                String applicationId, int tenantId, String tenantDomain) {
+    public static synchronized void handleApplicationUndeployed(String applicationId) {
 
         Set<ClusterDataHolder> clusterData;
 
@@ -702,7 +701,6 @@ public class TopologyBuilder {
             }
             // for now anyway update the status forcefully
             application.setStatus(ApplicationStatus.Terminating);
-            log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating);
 
             // update all the Clusters' statuses to 'Terminating'
             clusterData = application.getClusterDataRecursively();
@@ -730,6 +728,13 @@ public class TopologyBuilder {
                 }
             }
 
+            // update all Group's statuses to 'Terminating'
+            if (application.getGroups() != null) {
+                updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
+            }
+
+            TopologyManager.updateTopology(topology);
+
         } finally {
             TopologyManager.releaseWriteLock();
         }
@@ -934,10 +939,9 @@ public class TopologyBuilder {
 
     public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) {
 
-        Set<ClusterDataHolder> clusterData;
         String applicationId = event.getAppId();
 
-        // update the Application and Cluster Statuses as 'Terminating'
+        // update the Application Status as 'Terminating'
         TopologyManager.acquireWriteLock();
 
         try {
@@ -958,44 +962,12 @@ public class TopologyBuilder {
             application.setStatus(ApplicationStatus.Terminating);
             log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating);
 
-            // update all the Clusters' statuses to 'Terminating'
-            clusterData = application.getClusterDataRecursively();
-            for (ClusterDataHolder clusterDataHolder : clusterData) {
-                Service service = topology.getService(clusterDataHolder.getServiceType());
-                if (service != null) {
-                    Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
-                    if (aCluster != null) {
-                        // validate state transition
-                        if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
-                            log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
-                                    + ClusterStatus.Terminating);
-                        }
-                        // for now anyway update the status forcefully
-                        aCluster.setStatus(ClusterStatus.Terminating);
-
-                    } else {
-                        log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
-                                " in Topology");
-                    }
-
-                } else {
-                    log.warn("Unable to update cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
-                            " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found");
-                }
-            }
-
-            // update all Group's statuses to 'Terminating'
-            if (application.getGroups() != null) {
-                updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
-            }
-
         } finally {
             TopologyManager.releaseWriteLock();
         }
 
         TopologyEventPublisher.sendApplicationTerminatingEvent(
-                new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(
-                        applicationId, clusterData));
+                new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(applicationId));
     }
 
     private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Collection<Group> groups) {
@@ -1015,30 +987,6 @@ public class TopologyBuilder {
     }
 
     public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) {
-//        Topology topology = TopologyManager.getTopology();
-//        Application application = topology.getApplication(event.getAppId());
-//        //update the status of the Group
-//        if (application == null) {
-//            log.warn(String.format("Application %s does not exist",
-//                    event.getAppId()));
-//            return;
-//        }
-//
-//        org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent applicationTerminatedEvent =
-//                new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent(
-//                        event.getAppId());
-//        try {
-//            TopologyManager.acquireWriteLock();
-//            application.setStatus(ApplicationStatus.Terminated);
-//            log.info("Application terminated adding status started for Topology");
-//
-//            TopologyManager.updateTopology(topology);
-//        } finally {
-//            TopologyManager.releaseWriteLock();
-//        }
-//        //publishing data
-//        TopologyEventPublisher.sendApplicationTerminatedEvent(applicationTerminatedEvent);
-
 
      Topology topology = TopologyManager.getTopology();
 
@@ -1051,6 +999,13 @@ public class TopologyBuilder {
 
             } else {
                 Application application = topology.getApplication(event.getAppId());
+
+                if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+                    log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated);
+                }
+                // forcefully set status for now
+                application.setStatus(ApplicationStatus.Terminated);
+
                 int tenantId = application.getTenantId();
                 String tenantDomain = application.getTenantDomain();
                 Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
@@ -1201,11 +1156,57 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent);
     }
 
-    public static void handleClusterTerminatedEvent(ClusterActivatedEvent event) {
+    public static void handleClusterTerminatedEvent(AppStatusClusterTerminatedEvent event) {
+
+        TopologyManager.acquireWriteLock();
+
+        try {
+            Topology topology = TopologyManager.getTopology();
+            Cluster cluster = topology.getService(event.getServiceName()).
+                    getCluster(event.getClusterId());
+
+            if (!cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+                log.error("Invalid state transfer from " + cluster.getStatus() + " to " +
+                        ClusterStatus.Terminated);
+            }
+            // forcefully update status
+            cluster.setStatus(ClusterStatus.Terminated);
+
+            TopologyManager.updateTopology(topology);
+        } finally {
+            TopologyManager.releaseWriteLock();
+        }
+
+        ClusterTerminatedEvent clusterTerminatedEvent = new ClusterTerminatedEvent(event.getAppId(),
+                event.getServiceName(), event.getClusterId());
 
+        TopologyEventPublisher.sendClusterTerminatedEvent(clusterTerminatedEvent);
     }
 
-    public static void handleClusterTerminatingEvent(ClusterActivatedEvent event) {
+    public static void handleClusterTerminatingEvent(AppStatusClusterTerminatingEvent event) {
+
+        TopologyManager.acquireWriteLock();
+
+        try {
+            Topology topology = TopologyManager.getTopology();
+            Cluster cluster = topology.getService(event.getServiceName()).
+                    getCluster(event.getClusterId());
+
+            if (!cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+                log.error("Invalid state transfer from " + cluster.getStatus() + " to " +
+                        ClusterStatus.Terminating);
+            }
+            // forcefully update status
+            cluster.setStatus(ClusterStatus.Terminating);
+
+            TopologyManager.updateTopology(topology);
+        } finally {
+            TopologyManager.releaseWriteLock();
+        }
+
+        ClusterTerminatingEvent clusterTerminaingEvent = new ClusterTerminatingEvent(event.getAppId(),
+                event.getServiceName(), event.getClusterId());
 
+        TopologyEventPublisher.sendClusterTerminatingEvent(clusterTerminaingEvent);
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index 3c6277d..cd13111 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -297,4 +297,24 @@ public class TopologyEventPublisher {
         }
         publishEvent(groupTerminatingTopologyEvent);
     }
+
+    public static void sendClusterTerminatingEvent (ClusterTerminatingEvent clusterTerminatingEvent) {
+
+        if(log.isInfoEnabled()) {
+            log.info(String.format("Publishing Cluster terminating event: [appId] %s [cluster id] %s",
+                    clusterTerminatingEvent.getAppId(), clusterTerminatingEvent.getClusterId()));
+        }
+
+        publishEvent(clusterTerminatingEvent);
+    }
+
+    public static void sendClusterTerminatedEvent (ClusterTerminatedEvent clusterTerminatedEvent) {
+
+        if(log.isInfoEnabled()) {
+            log.info(String.format("Publishing Cluster terminated event: [appId] %s [cluster id] %s",
+                    clusterTerminatedEvent.getAppId(), clusterTerminatedEvent.getClusterId()));
+        }
+
+        publishEvent(clusterTerminatedEvent);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
index 441b902..6607a02 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
@@ -18,17 +18,27 @@
  */
 package org.apache.stratos.messaging.event.topology;
 
+import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+
+import java.util.Set;
+
 /**
  * This event will be sent to Topology upon termination of application
  */
 public class ApplicationTerminatedEvent extends TopologyEvent {
     private final String appId;
+    private final Set<ClusterDataHolder> clusterData;
 
-    public ApplicationTerminatedEvent(String appId) {
+    public ApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
         this.appId = appId;
+        this.clusterData = clusterData;
     }
 
     public String getAppId() {
         return appId;
     }
+
+    public Set<ClusterDataHolder> getClusterData() {
+        return clusterData;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
index c718f08..48fde61 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
@@ -18,28 +18,18 @@
  */
 package org.apache.stratos.messaging.event.topology;
 
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
-
-import java.util.Set;
-
 /**
  * This event will be sent to Topology upon terminating of application
  */
 public class ApplicationTerminatingEvent extends TopologyEvent {
 
     private final String appId;
-    private Set<ClusterDataHolder> clusterData;
 
-    public ApplicationTerminatingEvent(String appId, Set<ClusterDataHolder> clusterData) {
+    public ApplicationTerminatingEvent(String appId) {
         this.appId = appId;
-        this.clusterData = clusterData;
     }
 
     public String getAppId() {
         return appId;
     }
-
-    public Set<ClusterDataHolder> getClusterData() {
-        return clusterData;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
index a5bed11..6cdde51 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
@@ -39,7 +39,7 @@ public class AppStatusClusterTerminatedMessageProcessor extends MessageProcessor
     public boolean process(String type, String message, Object object) {
         if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) {
             // Parse complete message and build event
-            ClusterTerminatedEvent event = (ClusterTerminatedEvent) Util.
+            AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util.
                                                 jsonToObject(message, AppStatusClusterTerminatedEvent.class);
 
             if(log.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
index cb6e887..6ad43d8 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
@@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.topology.Application;
 import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
 import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
 import org.apache.stratos.messaging.util.Util;
@@ -48,14 +48,14 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
     public boolean process(String type, String message, Object object) {
         Topology topology = (Topology) object;
 
-        if (ApplicationInactivatedEvent.class.getName().equals(type)) {
+        if (ApplicationTerminatingEvent.class.getName().equals(type)) {
             // Return if topology has not been initialized
             if (!topology.isInitialized())
                 return false;
 
             // Parse complete message and build event
-            ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util.
-                    jsonToObject(message, ApplicationInactivatedEvent.class);
+            ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util.
+                    jsonToObject(message, ApplicationTerminatingEvent.class);
 
             TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
 
@@ -76,7 +76,7 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) {
+    private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) {
 
         // Validate event against the existing topology
         Application application = topology.getApplication(event.getAppId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
index 0536011..98599d3 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
@@ -24,7 +24,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent;
 import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
 import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
@@ -48,15 +48,15 @@ public class ClusterTerminatedProcessor extends MessageProcessor {
 
         Topology topology = (Topology) object;
 
-        if (ClusterActivatedEvent.class.getName().equals(type)) {
+        if (ClusterTerminatedEvent.class.getName().equals(type)) {
             // Return if topology has not been initialized
             if (!topology.isInitialized()) {
                 return false;
             }
 
             // Parse complete message and build event
-            ClusterActivatedEvent event = (ClusterActivatedEvent) Util.
-                    jsonToObject(message, ClusterActivatedEvent.class);
+            ClusterTerminatedEvent event = (ClusterTerminatedEvent) Util.
+                    jsonToObject(message, ClusterTerminatedEvent.class);
 
             TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
             try {
@@ -76,7 +76,7 @@ public class ClusterTerminatedProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess(ClusterActivatedEvent event, Topology topology) {
+    private boolean doProcess(ClusterTerminatedEvent event, Topology topology) {
 
         // Apply service filter
         if (TopologyServiceFilter.getInstance().isActive()) {
@@ -118,10 +118,10 @@ public class ClusterTerminatedProcessor extends MessageProcessor {
             }
         } else {
             // Apply changes to the topology
-            if (!cluster.isStateTransitionValid(ClusterStatus.Active)) {
-                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active);
+            if (!cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Terminated);
             }
-            cluster.setStatus(ClusterStatus.Active);
+            cluster.setStatus(ClusterStatus.Terminated);
 
         }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
index 1ed2671..cd30618 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
@@ -24,7 +24,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterTerminatingEvent;
 import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
 import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
@@ -48,15 +48,15 @@ public class ClusterTerminatingProcessor extends MessageProcessor {
 
         Topology topology = (Topology) object;
 
-        if (ClusterActivatedEvent.class.getName().equals(type)) {
+        if (ClusterTerminatingEvent.class.getName().equals(type)) {
             // Return if topology has not been initialized
             if (!topology.isInitialized()) {
                 return false;
             }
 
             // Parse complete message and build event
-            ClusterActivatedEvent event = (ClusterActivatedEvent) Util.
-                    jsonToObject(message, ClusterActivatedEvent.class);
+            ClusterTerminatingEvent event = (ClusterTerminatingEvent) Util.
+                    jsonToObject(message, ClusterTerminatingEvent.class);
 
             TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
             try {
@@ -76,7 +76,7 @@ public class ClusterTerminatingProcessor extends MessageProcessor {
         }
     }
 
-    private boolean doProcess(ClusterActivatedEvent event, Topology topology) {
+    private boolean doProcess(ClusterTerminatingEvent event, Topology topology) {
 
         // Apply service filter
         if (TopologyServiceFilter.getInstance().isActive()) {
@@ -118,10 +118,10 @@ public class ClusterTerminatingProcessor extends MessageProcessor {
             }
         } else {
             // Apply changes to the topology
-            if (!cluster.isStateTransitionValid(ClusterStatus.Active)) {
-                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active);
+            if (!cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+                log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Terminating);
             }
-            cluster.setStatus(ClusterStatus.Active);
+            cluster.setStatus(ClusterStatus.Terminating);
 
         }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
index 5e96709..5a308ba 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
@@ -93,8 +93,8 @@ public class GroupTerminatedProcessor extends MessageProcessor {
             }
         } else {
             // Apply changes to the topology
-            if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
-                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
+            if (!group.isStateTransitionValid(GroupStatus.Terminated)) {
+                log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated);
             }
             group.setStatus(GroupStatus.Terminated);
 


Mime
View raw message