Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping 998f57e19 -> 4b46efe15


adding events support in autoscaler


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

Branch: refs/heads/4.0.0-grouping
Commit: 4b46efe15cdf1bd4062864faa72148881718d8bb
Parents: 998f57e
Author: reka <[email protected]>
Authored: Mon Sep 22 14:15:29 2014 +0530
Committer: reka <[email protected]>
Committed: Mon Sep 22 14:15:29 2014 +0530

----------------------------------------------------------------------
 .../grouping/topic/StatusEventPublisher.java    |  76 ++++++
 .../AutoscalerHealthStatEventReceiver.java      | 246 ++++++-------------
 .../AutoscalerTopologyEventReceiver.java        |  79 ++----
 .../monitor/AbstractClusterMonitor.java         |  18 +-
 .../stratos/autoscaler/monitor/Monitor.java     |  63 +++--
 .../monitor/application/ApplicationMonitor.java |  41 ++--
 .../monitor/cluster/ClusterMonitor.java         |   1 -
 .../monitor/cluster/LbClusterMonitor.java       |   2 +
 .../monitor/events/ClusterActivatedEvent.java   |   7 +
 .../events/ClusterInMaintenanceEvent.java       |   7 +
 .../monitor/events/GroupActivatedEvent.java     |   7 +
 .../monitor/events/GroupInMaintenanceEvent.java |   7 +
 .../autoscaler/monitor/events/MonitorEvent.java |   9 +
 .../autoscaler/monitor/group/GroupMonitor.java  |   6 -
 .../status/checker/ClusterStatusChecker.java    |  45 ----
 .../status/checker/GroupStatusChecker.java      |  35 ---
 .../status/checker/StatusChecker.java           |  72 ++++--
 .../cluster/status/ClusterActivatedEvent.java   |  52 ++++
 .../status/ClusterMaintenanceModeEvent.java     |  46 ++++
 .../status/ClusterReadyToShutdownEvent.java     |  50 ++++
 .../cluster/status/ClusterStatusEvent.java      |  31 +++
 .../event/group/status/GroupActivatedEvent.java |  46 ++++
 .../group/status/GroupMaintenanceModeEvent.java |  40 +++
 .../group/status/GroupReadyToShutdownEvent.java |  43 ++++
 .../event/group/status/GroupStatusEvent.java    |  31 +++
 .../event/topology/ClusterActivatedEvent.java   |  17 +-
 26 files changed, 695 insertions(+), 382 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/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
new file mode 100644
index 0000000..f7e5b28
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -0,0 +1,76 @@
+package org.apache.stratos.autoscaler.grouping.topic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.cluster.status.ClusterActivatedEvent;
+import 
org.apache.stratos.messaging.event.cluster.status.ClusterMaintenanceModeEvent;
+import org.apache.stratos.messaging.event.group.status.GroupActivatedEvent;
+import 
org.apache.stratos.messaging.event.group.status.GroupMaintenanceModeEvent;
+import org.apache.stratos.messaging.util.Constants;
+
+/**
+ * Created by reka on 9/21/14.
+ */
+public class StatusEventPublisher {
+    private static final Log log = 
LogFactory.getLog(StatusEventPublisher.class);
+
+    public static void sendClusterActivatedEvent (String appId, String 
serviceName, String clusterId) {
+
+        if(log.isInfoEnabled()) {
+            log.info("Publishing Cluster activated event for [application]: " 
+ appId +
+                    " [cluster]: " + clusterId );
+        }
+
+        ClusterActivatedEvent clusterActivatedEvent = new 
ClusterActivatedEvent(appId,serviceName, clusterId);
+
+        publishEvent(clusterActivatedEvent);
+    }
+
+    public static void sendClusterInMaintenanceEvent (String appId, String 
serviceName, String clusterId) {
+
+        if(log.isInfoEnabled()) {
+            log.info("Publishing Cluster in_maintenance event for 
[application]: " + appId +
+                    " [cluster]: " + clusterId );
+        }
+
+        ClusterMaintenanceModeEvent clusterInMaintenanceEvent =
+                                    new 
ClusterMaintenanceModeEvent(appId,serviceName, clusterId);
+
+        publishEvent(clusterInMaintenanceEvent);
+    }
+
+    public static void sendGroupActivatedEvent (String appId, String groupId) {
+
+        if(log.isInfoEnabled()) {
+            log.info("Publishing Group activated event for [application]: " + 
appId +
+                    " [group]: " + groupId );
+        }
+
+        GroupActivatedEvent groupActivatedEvent = new 
GroupActivatedEvent(appId, groupId);
+
+        publishEvent(groupActivatedEvent);
+    }
+
+    public static void sendGroupInMaintenanceEvent (String appId, String 
groupId) {
+
+        if(log.isInfoEnabled()) {
+            log.info("Publishing Group in_maintenance event for [application]: 
" + appId +
+                    " [group]: " + groupId );
+        }
+
+        GroupMaintenanceModeEvent groupMaintenanceModeEvent =
+                new GroupMaintenanceModeEvent(appId, groupId);
+
+        publishEvent(groupMaintenanceModeEvent);
+    }
+
+    public static void publishEvent(Event event) {
+        //TODO change the topics for cluster and group accordingly
+        EventPublisher eventPublisher = 
EventPublisherPool.getPublisher(Constants.INSTANCE_STATUS_TOPIC);
+        eventPublisher.publish(event);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
index 9ffe66d..26d3179 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
@@ -29,6 +29,7 @@ import 
org.apache.stratos.autoscaler.exception.TerminationException;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.policy.model.LoadAverage;
 import org.apache.stratos.autoscaler.policy.model.MemoryConsumption;
+import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.Member;
 import org.apache.stratos.messaging.domain.topology.Service;
@@ -93,19 +94,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Avg load avg event: [cluster] %s 
[network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -116,6 +105,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
 
             }
@@ -135,19 +126,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Avg Memory Consumption event: 
[cluster] %s [network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
 
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
@@ -159,6 +138,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
             }
 
@@ -177,19 +158,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Average Rif event: [cluster] %s 
[network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -200,6 +169,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
             }
 
@@ -217,19 +188,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Grad of load avg event: [cluster] 
%s [network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -240,6 +199,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
             }
 
@@ -258,19 +219,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Grad of Memory Consumption event: 
[cluster] %s [network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                };
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -281,6 +230,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
             }
 
@@ -298,19 +249,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Gradient of Rif event: [cluster] 
%s [network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -321,6 +260,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
             }
 
@@ -459,19 +400,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Second Derivation of load avg 
event: [cluster] %s [network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -482,6 +411,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
             }
 
@@ -500,19 +431,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Second Derivation of Memory 
Consumption event: [cluster] %s [network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -523,6 +442,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
 
             }
@@ -540,19 +461,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     log.debug(String.format("Second derivative of Rif event: 
[cluster] %s [network-partition] %s [value] %s",
                             clusterId, networkPartitionId, floatValue));
                 }
-                AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                AbstractClusterMonitor monitor;
-
-                if(asCtx.monitorExist(clusterId)){
-                    monitor = asCtx.getMonitor(clusterId);
-                }else if(asCtx.lbMonitorExist(clusterId)){
-                    monitor = asCtx.getLBMonitor(clusterId);
-                }else{
-                    if(log.isDebugEnabled()){
-                        log.debug(String.format("A cluster monitor is not 
found in autoscaler context [cluster] %s", clusterId));
-                    }
-                    return;
-                }
+                AbstractClusterMonitor monitor = getMonitor(clusterId);
                 if(null != monitor){
                     NetworkPartitionContext networkPartitionContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId);
                     if(null != networkPartitionContext){
@@ -563,12 +472,31 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                                    " [network partition] %s", 
networkPartitionId));
                         }
                     }
+                } else {
+                    return;
                 }
             }
 
         });
     }
 
+    private AbstractClusterMonitor getMonitor(String clusterId) {
+        AutoscalerContext asCtx = AutoscalerContext.getInstance();
+        AbstractClusterMonitor monitor;
+
+        if(asCtx.monitorExist(clusterId)){
+            monitor = asCtx.getMonitor(clusterId);
+        }else if(asCtx.lbMonitorExist(clusterId)){
+            monitor = asCtx.getLBMonitor(clusterId);
+        }else{
+            if(log.isDebugEnabled()){
+                log.debug(String.format("A cluster monitor is not found in 
autoscaler context [cluster] %s", clusterId));
+            }
+            return null;
+        }
+        return null;
+    }
+
 
     private LoadAverage findLoadAverage(String memberId) {
 //        String memberId = event.getProperties().get("member_id");
@@ -582,26 +510,31 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
         }
         String clusterId = member.getClusterId();
 
-        AutoscalerContext asCtx = AutoscalerContext.getInstance();
-        AbstractClusterMonitor monitor;
+        AbstractClusterMonitor monitor = getMonitor(clusterId);
+        MemberStatsContext  memberStatsContext;
 
-        if(asCtx.monitorExist(clusterId)){
-            monitor = asCtx.getMonitor(clusterId);
-        }else if(asCtx.lbMonitorExist(clusterId)){
-            monitor = asCtx.getLBMonitor(clusterId);
-        }else{
-            if(log.isDebugEnabled()){
-                log.debug(String.format("A cluster monitor is not found in 
autoscaler context [cluster] %s", clusterId));
-            }
+        if(monitor != null) {
+          memberStatsContext = getMemberStatContext(memberId, monitor, member);
+        } else {
+            return null;
+        }
+        LoadAverage loadAverage;
+        if(memberStatsContext == null) {
             return null;
+        } else {
+            loadAverage = memberStatsContext.getLoadAverage();
         }
+        return loadAverage;
+    }
+
+    private MemberStatsContext getMemberStatContext(String memberId, 
AbstractClusterMonitor monitor, Member member) {
         String networkPartitionId = findNetworkPartitionId(memberId);
         MemberStatsContext memberStatsContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId)
-                        .getPartitionCtxt(member.getPartitionId())
-                        .getMemberStatsContext(memberId);
+                .getPartitionCtxt(member.getPartitionId())
+                .getMemberStatsContext(memberId);
         if(null == memberStatsContext){
             if(log.isDebugEnabled()) {
-               log.debug(String.format("Member context is not available for : 
[member] %s", memberId));
+                log.debug(String.format("Member context is not available for : 
[member] %s", memberId));
             }
             return null;
         }
@@ -612,9 +545,7 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
             }
             return null;
         }
-
-        LoadAverage loadAverage = memberStatsContext.getLoadAverage();
-        return loadAverage;
+        return memberStatsContext;
     }
 
     private MemoryConsumption findMemoryConsumption(String memberId) {
@@ -639,23 +570,13 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
             return null;
         }
 
-        String networkPartitionId = findNetworkPartitionId(memberId);
-        MemberStatsContext memberStatsContext = 
monitor.getNetworkPartitionCtxt(networkPartitionId)
-                        .getPartitionCtxt(member.getPartitionId())
-                        .getMemberStatsContext(memberId);
-        if(null == memberStatsContext){
-            if(log.isDebugEnabled()) {
-               log.debug(String.format("Member context is not available for : 
[member] %s", memberId));
-            }
-            return null;
-        }else if(!member.isActive()){
-            if(log.isDebugEnabled()){
-                log.debug(String.format("Member activated event has not 
received for the member %s. Therefore ignoring" +
-                        " the health stat", memberId));
-            }
+        MemberStatsContext  memberStatsContext = 
getMemberStatContext(memberId, monitor, member);
+        MemoryConsumption memoryConsumption;
+        if(memberStatsContext == null) {
             return null;
+        } else {
+            memoryConsumption = memberStatsContext.getMemoryConsumption();
         }
-        MemoryConsumption memoryConsumption = 
memberStatsContext.getMemoryConsumption();
 
         return memoryConsumption;
     }
@@ -690,21 +611,8 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
 
     private void handleMemberFaultEvent(String clusterId, String memberId) {
         try {
-               AutoscalerContext asCtx = AutoscalerContext.getInstance();
-               AbstractClusterMonitor monitor;
-               
-               if(asCtx.monitorExist(clusterId)){
-                       monitor = asCtx.getMonitor(clusterId);
-               }else if(asCtx.lbMonitorExist(clusterId)){
-                       monitor = asCtx.getLBMonitor(clusterId);
-               }else{
-                if(log.isDebugEnabled()){
-                    log.debug(String.format("A cluster monitor is not found in 
autoscaler context [cluster] %s", clusterId));
-                }
-                return;
-               }
-               
-               NetworkPartitionContext nwPartitionCtxt;
+            AbstractClusterMonitor monitor = getMonitor(clusterId);
+            NetworkPartitionContext nwPartitionCtxt;
             try{
                TopologyManager.acquireReadLock();
                Member member = findMember(memberId);
@@ -719,9 +627,12 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
                     }
                     return;
                 }
-                   
-                   nwPartitionCtxt = monitor.getNetworkPartitionCtxt(member);
-                   
+                   if(monitor != null) {
+                    nwPartitionCtxt = monitor.getNetworkPartitionCtxt(member);
+                } else {
+                    return;
+                }
+
             }finally{
                TopologyManager.releaseReadLock();
             }
@@ -741,6 +652,9 @@ public class AutoscalerHealthStatEventReceiver implements 
Runnable {
 
             // remove from active member list
             partitionCtxt.removeActiveMemberById(memberId);
+            //Check the clusterStatus as part of the member fault event
+            StatusChecker.getInstance().onMemberFaultEvent(clusterId, "appId", 
partitionCtxt);
+
 
             if (log.isInfoEnabled()) {
                 log.info(String.format("Faulty member is terminated and 
removed from the active members list: [member] %s [partition] %s [cluster] %s ",

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/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 d55459a..ad54152 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
@@ -26,9 +26,11 @@ import 
org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClie
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.TerminationException;
 import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
+import org.apache.stratos.autoscaler.monitor.Monitor;
 import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
 import org.apache.stratos.autoscaler.partition.PartitionManager;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
+import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.autoscaler.util.AutoscalerUtil;
 import org.apache.stratos.messaging.domain.topology.Application;
 import org.apache.stratos.messaging.domain.topology.Cluster;
@@ -106,7 +108,7 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
             @Override
             protected void onEvent(Event event) {
 
-                log.info("[ApplicationCreatedEventListener] Received: " + 
event.getClass());
+                log.info("[ApplicationCreatedEvent] Received: " + 
event.getClass());
 
                 ApplicationCreatedEvent applicationCreatedEvent = 
(ApplicationCreatedEvent) event;
 
@@ -127,6 +129,25 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
             }
         });
 
+        topologyEventReceiver.addEventListener(new 
ClusterActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+                log.info("[ClusterActivatedEvent] Received: " + 
event.getClass());
+
+                ClusterActivatedEvent clusterActivatedEvent = 
(ClusterActivatedEvent) event;
+                String appId = clusterActivatedEvent.getAppId();
+                String clusterId = clusterActivatedEvent.getClusterId();
+
+                ApplicationMonitor appMonitor = 
AutoscalerContext.getInstance().getAppMonitor(appId);
+                Monitor monitor = 
appMonitor.findParentMonitorOfCluster(clusterId);
+                monitor.notify();
+                //starting the status checker to decide on the status of it's 
parent
+                StatusChecker.getInstance().onClusterStatusChange(clusterId, 
appId);
+            }
+        });
+
+
         topologyEventReceiver.addEventListener(new 
ApplicationRemovedEventListener() {
             @Override
             protected void onEvent(Event event) {
@@ -391,58 +412,6 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
             }
         });
 
-        topologyEventReceiver.addEventListener(new 
MemberReadyToShutdownEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                try {
-                    MemberReadyToShutdownEvent memberReadyToShutdownEvent =
-                                                                
(MemberReadyToShutdownEvent) event;
-                    AutoscalerContext asCtx = AutoscalerContext.getInstance();
-                    AbstractClusterMonitor monitor;
-                    String clusterId = 
memberReadyToShutdownEvent.getClusterId();
-                    String memberId = memberReadyToShutdownEvent.getMemberId();
-
-                    if (asCtx.monitorExist(clusterId)) {
-                        monitor = asCtx.getMonitor(clusterId);
-                    } else if (asCtx.lbMonitorExist(clusterId)) {
-                        monitor = asCtx.getLBMonitor(clusterId);
-                    } else {
-                        if (log.isDebugEnabled()) {
-                            log.debug(String.format("A cluster monitor is not 
found in autoscaler " +
-                                    "context [cluster] %s", clusterId));
-                        }
-                        return;
-                    }
-
-                    NetworkPartitionContext nwPartitionCtxt;
-                    nwPartitionCtxt = 
monitor.getNetworkPartitionCtxt(memberReadyToShutdownEvent.
-                                                                            
getNetworkPartitionId());
-
-                    // start a new member in the same Partition
-                    String partitionId = 
monitor.getPartitionOfMember(memberId);
-                    PartitionContext partitionCtxt = 
nwPartitionCtxt.getPartitionCtxt(partitionId);
-
-
-                    // terminate the shutdown ready member
-                    CloudControllerClient ccClient = 
CloudControllerClient.getInstance();
-                    ccClient.terminate(memberId);
-
-                    // remove from active member list
-                    partitionCtxt.removeActiveMemberById(memberId);
-
-                    if (log.isInfoEnabled()) {
-                        log.info(String.format("Member is terminated and 
removed from the active " +
-                                        "members list: [member] %s [partition] 
%s [cluster] %s ",
-                                memberId, partitionId, clusterId));
-                    }
-                } catch (TerminationException e) {
-                    log.error(e);
-                }
-            }
-
-        });
-
-
         topologyEventReceiver.addEventListener(new MemberMaintenanceListener() 
{
             @Override
             protected void onEvent(Event event) {
@@ -552,8 +521,8 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
                 throw new RuntimeException(msg);
             }
 
-            Thread th = new Thread(applicationMonitor);
-            th.start();
+            AutoscalerContext.getInstance().addAppMonitor(applicationMonitor);
+            //TODO should start the appMonitor
 
             if (log.isInfoEnabled()) {
                 log.info(String.format("Application monitor has been added 
successfully: " +

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/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 4bf8b7f..cb93886 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
@@ -21,6 +21,8 @@ package org.apache.stratos.autoscaler.monitor;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 
 import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
 
 import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.commons.logging.Log;
@@ -42,7 +44,7 @@ import org.drools.runtime.rule.FactHandle;
  * and perform minimum instance check and scaling check using the underlying
  * rules engine.
  */
-abstract public class AbstractClusterMonitor implements Runnable {
+abstract public class AbstractClusterMonitor extends Observable implements 
Observer, Runnable {
 
     private static final Log log = 
LogFactory.getLog(AbstractClusterMonitor.class);
     // Map<NetworkpartitionId, Network Partition Context>
@@ -62,6 +64,7 @@ abstract public class AbstractClusterMonitor implements 
Runnable {
 
     protected String clusterId;
     protected String serviceId;
+    protected String appId;
 
     protected AutoscalerRuleEvaluator autoscalerRuleEvaluator;
 
@@ -159,6 +162,14 @@ abstract public class AbstractClusterMonitor implements 
Runnable {
         this.clusterId = clusterId;
     }
 
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
     public Map<String, NetworkPartitionContext> getNetworkPartitionCtxts() {
         return networkPartitionCtxts;
     }
@@ -217,6 +228,11 @@ abstract public class AbstractClusterMonitor implements 
Runnable {
         this.terminateDependencyFactHandle = terminateDependencyFactHandle;
     }
 
+    @Override
+    public void update(Observable observable, Object o) {
+
+    }
+
     public int getMonitorInterval() {
         return monitorInterval;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/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 6f66db1..7471703 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
@@ -41,7 +41,7 @@ import java.util.*;
  * Monitor is to monitor it's child monitors and
  * control them according to the dependencies respectively.
  */
-public abstract class Monitor implements Observer, Runnable {
+public abstract class Monitor extends Observable implements Observer {
 
     private static final Log log = LogFactory.getLog(Monitor.class);
 
@@ -117,20 +117,25 @@ public abstract class Monitor implements Observer, 
Runnable {
         //TODO find out the parallel ones
 
         //start the first dependency
-        String dependency = preOrderTraverse.poll();
-        if(dependency.contains("group")) {
-            startGroupMonitor(component.getGroup(dependency));
-        } else if(dependency.contains("cartridge")) {
-            String clusterId = component.getClusterId(dependency);
-            Cluster cluster = null;
-            TopologyManager.acquireReadLock();
-            cluster = 
TopologyManager.getTopology().getService(dependency).getCluster(clusterId);
-            TopologyManager.releaseReadLock();
-            if(cluster != null) {
-                startClusterMonitor(cluster);
-            } else {
-                //TODO throw exception since Topology is inconsistent
+        if(!preOrderTraverse.isEmpty()) {
+            String dependency = preOrderTraverse.poll();
+            if (dependency.contains("group")) {
+                startGroupMonitor(this, dependency, component);
+            } else if (dependency.contains("cartridge")) {
+                String clusterId = component.getClusterId(dependency);
+                Cluster cluster = null;
+                TopologyManager.acquireReadLock();
+                cluster = 
TopologyManager.getTopology().getService(dependency).getCluster(clusterId);
+                TopologyManager.releaseReadLock();
+                if (cluster != null) {
+                    startClusterMonitor(cluster);
+                } else {
+                    //TODO throw exception since Topology is inconsistent
+                }
             }
+        } else {
+            //all the groups/clusters have been started and waiting for 
activation
+            log.info("All the groups/clusters of the [group]: " + this.id + " 
have been started.");
         }
     }
     protected synchronized void startClusterMonitor(Cluster cluster) {
@@ -158,11 +163,11 @@ public abstract class Monitor implements Observer, 
Runnable {
         }
     }
 
-    protected synchronized void startGroupMonitor(Group group) {
+    protected synchronized void startGroupMonitor(Monitor parent, String 
dependency, ParentBehavior component) {
         Thread th = null;
-        if (!this.groupMonitors.containsKey(group.getAlias())) {
+        if (!this.groupMonitors.containsKey(dependency)) {
             th = new Thread(
-                    new GroupMonitorAdder(group));
+                    new GroupMonitorAdder(parent, dependency, component));
         }
 
         if (th != null) {
@@ -175,7 +180,7 @@ public abstract class Monitor implements Observer, Runnable 
{
             if (log.isDebugEnabled()) {
                 log.debug(String
                         .format("Group monitor thread has been started 
successfully: [group] %s ",
-                                group.getAlias()));
+                                dependency));
             }
         }
     }
@@ -234,10 +239,14 @@ public abstract class Monitor implements Observer, 
Runnable {
     }
 
     private class GroupMonitorAdder implements Runnable {
-        private Group group;
+        private ParentBehavior group;
+        private String dependency;
+        private Monitor parent;
 
-        public GroupMonitorAdder(Group group) {
+        public GroupMonitorAdder(Monitor parent, String dependency, 
ParentBehavior group) {
             this.group = group;
+            this.dependency = dependency;
+            this.parent = parent;
         }
 
         public void run() {
@@ -251,11 +260,12 @@ public abstract class Monitor implements Observer, 
Runnable {
                 }
 
                 try {
-                    monitor = AutoscalerUtil.getGroupMonitor(group);
+                    monitor = 
AutoscalerUtil.getGroupMonitor(group.getGroup(dependency));
+                    monitor.addObserver(parent);
                     success = true;
 
                 } catch (Exception e) {
-                    String msg = "Group monitor creation failed for group: " + 
group.getAlias();
+                    String msg = "Group monitor creation failed for group: " + 
dependency;
                     log.debug(msg, e);
                     retries--;
 
@@ -264,18 +274,17 @@ public abstract class Monitor implements Observer, 
Runnable {
 
             if (monitor == null) {
                 String msg = "Group monitor creation failed, even after 
retrying for 5 times, "
-                        + "for group: " + group.getAlias();
+                        + "for group: " + dependency;
                 log.error(msg);
                 throw new RuntimeException(msg);
             }
 
-            Thread th = new Thread(monitor);
-            th.start();
+            groupMonitors.put(dependency, monitor);
+            parent.addObserver(monitor);
 
-            groupMonitors.put(group.getAlias(), monitor);
             if (log.isInfoEnabled()) {
                 log.info(String.format("Group monitor has been added 
successfully: [group] %s",
-                        group.getAlias()));
+                        dependency));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/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 1407987..d3c4113 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
@@ -21,6 +21,7 @@ package org.apache.stratos.autoscaler.monitor.application;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.grouping.DependencyBuilder;
+import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.Monitor;
 import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
@@ -37,9 +38,9 @@ import java.util.*;
 public class ApplicationMonitor extends Monitor {
     private static final Log log = LogFactory.getLog(ApplicationMonitor.class);
 
-    public ApplicationMonitor(Application application) {
+    public ApplicationMonitor(ParentBehavior application) {
         super(application);
-        //TODO keep track of the parallel applications
+        //keep
     }
 
     @Override
@@ -83,11 +84,11 @@ public class ApplicationMonitor extends Monitor {
     }
 
 
-    public Monitor findParentOfGroup(String groupId) {
-      return findParentMonitor(groupId, this);
+    public Monitor findParentMonitorOfGroup(String groupId) {
+      return findParentMonitorForGroup(groupId, this);
     }
 
-    private Monitor findParentMonitor(String groupId, Monitor monitor) {
+    private Monitor findParentMonitorForGroup(String groupId, Monitor monitor) 
{
         //if this monitor has the group, return it as the parent
         if(monitor.getGroupMonitors().containsKey(groupId)) {
             return monitor;
@@ -95,7 +96,7 @@ public class ApplicationMonitor extends Monitor {
             if(monitor.getGroupMonitors() != null) {
                 //check whether the children has the group and find its parent
                 for(GroupMonitor groupMonitor : 
monitor.getGroupMonitors().values()) {
-                    return findParentMonitor(groupId, groupMonitor);
+                    return findParentMonitorForGroup(groupId, groupMonitor);
 
                 }
             }
@@ -104,22 +105,26 @@ public class ApplicationMonitor extends Monitor {
 
     }
 
+    public Monitor findParentMonitorOfCluster(String clusterId) {
+        return findParentMonitorForCluster(clusterId, this);
+    }
 
-    @Override
-    public void run() {
-        while (true) {
-            if (log.isDebugEnabled()) {
-                log.debug("Application monitor is running.. " + 
this.toString());
-            }
-                    monitor();
-            try {
-                Thread.sleep(10000);
-            } catch (InterruptedException e) {
-                e.printStackTrace();
+    private Monitor findParentMonitorForCluster(String clusterId, Monitor 
monitor) {
+        //if this monitor has the group, return it as the parent
+        if(monitor.getAbstractClusterMonitors().containsKey(clusterId)) {
+            return monitor;
+        } else {
+            if(monitor.getGroupMonitors() != null) {
+                //check whether the children has the group and find its parent
+                for(GroupMonitor groupMonitor : 
monitor.getGroupMonitors().values()) {
+                    return findParentMonitorForCluster(clusterId, 
groupMonitor);
+
+                }
             }
         }
-    }
+        return null;
 
+    }
 
     @Override
     public void monitor() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index 1cd6d9f..3fa9ada 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -47,7 +47,6 @@ public class ClusterMonitor extends AbstractClusterMonitor {
     private String lbReferenceType;
     private boolean hasPrimary;
     private ClusterStatus status;
-    private Group parent;
 
     public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy 
deploymentPolicy,
                           AutoscalePolicy autoscalePolicy) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
index 31c7ff7..45142c2 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
@@ -28,6 +28,7 @@ import 
org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 
+import java.util.Observable;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -125,4 +126,5 @@ public class LbClusterMonitor extends 
AbstractClusterMonitor {
     }
 
 
+
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java
new file mode 100644
index 0000000..e35fe74
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java
@@ -0,0 +1,7 @@
+package org.apache.stratos.autoscaler.monitor.events;
+
+/**
+ * Created by reka on 9/21/14.
+ */
+public class ClusterActivatedEvent extends MonitorEvent {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java
new file mode 100644
index 0000000..f227195
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java
@@ -0,0 +1,7 @@
+package org.apache.stratos.autoscaler.monitor.events;
+
+/**
+ * Created by reka on 9/21/14.
+ */
+public class ClusterInMaintenanceEvent extends MonitorEvent {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java
new file mode 100644
index 0000000..448df65
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java
@@ -0,0 +1,7 @@
+package org.apache.stratos.autoscaler.monitor.events;
+
+/**
+ * Created by reka on 9/21/14.
+ */
+public class GroupActivatedEvent extends MonitorEvent {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java
new file mode 100644
index 0000000..e7b0605
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java
@@ -0,0 +1,7 @@
+package org.apache.stratos.autoscaler.monitor.events;
+
+/**
+ * Created by reka on 9/21/14.
+ */
+public class GroupInMaintenanceEvent extends MonitorEvent {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
new file mode 100644
index 0000000..8fcf782
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
@@ -0,0 +1,9 @@
+package org.apache.stratos.autoscaler.monitor.events;
+
+import java.io.Serializable;
+
+/**
+ * Created by reka on 9/21/14.
+ */
+public abstract class MonitorEvent implements Serializable{
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 3b4b2f4..28662c6 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -49,10 +49,4 @@ public class GroupMonitor extends Monitor {
     protected void onEvent(Event event) {
 
     }
-
-
-    @Override
-    public void run() {
-
-    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java
deleted file mode 100644
index a47ee7f..0000000
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.status.checker;
-
-
-import org.apache.stratos.autoscaler.AutoscalerContext;
-import org.apache.stratos.autoscaler.NetworkPartitionContext;
-import org.apache.stratos.autoscaler.PartitionContext;
-import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
-import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
-import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.domain.topology.util.GroupStatus;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Cluster status checker will periodically check the cluster status
- * and notify the interested parties
- */
-public class ClusterStatusChecker {
-
-
-    
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java
deleted file mode 100644
index f69c2d6..0000000
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.autoscaler.status.checker;
-
-import org.apache.stratos.autoscaler.monitor.Monitor;
-
-/**
- * Group status checker will check the group status and
- * notify the interested parties on behalf of the status changes
- */
-public class GroupStatusChecker  {
-    private String groupId;
-    private String appId;
-
-    public GroupStatusChecker(String groupId, String appId) {
-        this.groupId = groupId;
-        this.appId = appId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/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 06cf2f6..79da514 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
@@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.NetworkPartitionContext;
 import org.apache.stratos.autoscaler.PartitionContext;
+import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 import org.apache.stratos.messaging.domain.topology.*;
 import org.apache.stratos.messaging.domain.topology.util.GroupStatus;
@@ -62,14 +63,18 @@ public class StatusChecker {
                     for (PartitionContext partitionContext : 
networkPartitionContext.getPartitionCtxts().values()) {
                         if(partitionContext.getMinimumMemberCount() == 
partitionContext.getActiveMemberCount()) {
                             clusterActive = true;
+                        } else if (partitionContext.getActiveMemberCount() > 
partitionContext.getMinimumMemberCount()) {
+                            log.info("cluster already activated...");
+                            clusterActive = true;
                         }
                         clusterActive = false;
                     }
-
                 }
                 // if active then notify upper layer
                 if(clusterActive) {
                     //send event to cluster status topic
+                    
StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
+                            monitor.getServiceId(), monitor.getClusterId());
 
                 }
 
@@ -80,36 +85,75 @@ public class StatusChecker {
 
     /**
      *
-     * @param id
+     * @param groupId
      * @param appId
      */
-    public void onGroupStatusChange(final String id, final String appId) {
+    public void onGroupStatusChange(final String groupId, final String appId) {
+        updateChild(groupId, appId);
+    }
+
+    /**
+     *
+     * @param clusterId
+     * @param appId
+     */
+    public void onClusterStatusChange(final String clusterId, final String 
appId) {
+        updateChild(clusterId, appId);
+    }
 
+    private void updateChild(final String clusterId, final String appId) {
         Runnable exGroup = new Runnable() {
             public void run() {
-                /**
-                 *
-                 */
                 Application application = 
TopologyManager.getTopology().getApplication(appId);
                 Map<String, String> clusterIds = application.getClusterMap();
                 Map<String, Group> groups = application.getGroupMap();
-                updateChildStatus(id, groups, clusterIds, application);
+                updateChildStatus(clusterId, groups, clusterIds, application);
             }
         };
     }
 
-    public void onClusterStatusChange(final String id, final String appId) {
-
-        Runnable exGroup = new Runnable() {
+    /**
+     *
+     * @param clusterId
+     * @param appId
+     * @param partitionContext is to decide in which partition has less 
members while others have active members
+     */
+    public void onMemberFaultEvent(final String clusterId, final String appId, 
final PartitionContext partitionContext) {
+        Runnable exCluster = new Runnable() {
             public void run() {
-                Application application = 
TopologyManager.getTopology().getApplication(appId);
-                Map<String, String> clusterIds = application.getClusterMap();
-                Map<String, Group> groups = application.getGroupMap();
-                updateChildStatus(id, groups, clusterIds, application);
+                ClusterMonitor monitor = 
AutoscalerContext.getInstance().getMonitor(clusterId);
+                boolean clusterActive = false;
+                boolean clusterInMaintenance = false;
+                for (NetworkPartitionContext networkPartitionContext : 
monitor.getNetworkPartitionCtxts().values()) {
+                    for (PartitionContext partition : 
networkPartitionContext.getPartitionCtxts().values()) {
+                        
if(partitionContext.getPartitionId().equals(partition.getPartitionId()) &&
+                                partition.getActiveMemberCount() < 
partition.getMinimumMemberCount()) {
+                            clusterInMaintenance = true;
+                        } else {
+                            log.info(String.format("Hence the [partition] %s, 
in [networkpartition], " +
+                                            "%s has exceeded the [minimum], %d 
with current active " +
+                                            "[members], %d the [cluster], %s 
is still in active mode."
+                                    , partition.getPartitionId(), 
partition.getNetworkPartitionId(),
+                                    partition.getMinimumMemberCount(), 
partition.getActiveMemberCount(), clusterId));
+                        }
+                        if(partitionContext.getMinimumMemberCount() >= 
partitionContext.getActiveMemberCount()) {
+                            clusterActive = true;
+                        }
+                        clusterActive = false;
+                    }
+
+                }
+                // if in maintenance then notify upper layer
+                if(clusterActive && clusterInMaintenance) {
+                    //send clusterInmaintenance event to cluster status topic
+
+                }
+
             }
         };
     }
 
+
     private boolean updateChildStatus(String id, Map<String, Group> groups, 
Map<String, String> clusterIds, ParentBehavior parent) {
         boolean groupActive = false;
         boolean clustersActive = false;

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java
new file mode 100644
index 0000000..ecc8c7a
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import java.io.Serializable;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class ClusterActivatedEvent extends ClusterStatusEvent implements 
Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterActivatedEvent(String appId, String serviceName, String 
clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java
new file mode 100644
index 0000000..691e77e
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.cluster.status;
+
+import java.io.Serializable;
+
+public class ClusterMaintenanceModeEvent extends ClusterStatusEvent implements 
Serializable {
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterMaintenanceModeEvent(String appId, String serviceName, 
String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java
new file mode 100644
index 0000000..2832a89
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.cluster.status;
+
+import java.io.Serializable;
+
+/**
+ *  This event is fired by cartridge agent when it has cleaned up the data and
+ *  ready to shutdown.
+ */
+public class ClusterReadyToShutdownEvent extends ClusterStatusEvent implements 
Serializable {
+    private final String serviceName;
+    private final String clusterId;
+    private String appId;
+
+    public ClusterReadyToShutdownEvent(String appId, String serviceName, 
String clusterId) {
+        this.serviceName = serviceName;
+        this.clusterId = clusterId;
+        this.appId = appId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java
new file mode 100644
index 0000000..42a430b
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.cluster.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
+/**
+ * Represents all instance status events.
+ */
+public abstract class ClusterStatusEvent extends Event implements Serializable 
{
+    private static final long serialVersionUID = -4790128084271867615L;
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java
new file mode 100644
index 0000000..c1075a0
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.group.status;
+
+import java.io.Serializable;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class GroupActivatedEvent extends GroupStatusEvent implements 
Serializable {
+    private static final long serialVersionUID = 2625412714611885089L;
+
+    private String groupId;
+    private String appId;
+
+    public GroupActivatedEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId(String groupId) {
+               return this.groupId;
+       }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java
new file mode 100644
index 0000000..a301da4
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.group.status;
+
+import java.io.Serializable;
+
+public class GroupMaintenanceModeEvent extends GroupStatusEvent implements 
Serializable {
+    private String groupId;
+    private String appId;
+
+    public GroupMaintenanceModeEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId(String groupId) {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java
new file mode 100644
index 0000000..70b44aa
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.group.status;
+
+import java.io.Serializable;
+
+/**
+ *  This event is fired by cartridge agent when it has cleaned up the data and
+ *  ready to shutdown.
+ */
+public class GroupReadyToShutdownEvent extends GroupStatusEvent implements 
Serializable {
+    private String groupId;
+    private String appId;
+
+    public GroupReadyToShutdownEvent(String appId, String groupId) {
+        this.appId = appId;
+        this.groupId = groupId;
+    }
+
+    public String getGroupId(String groupId) {
+        return this.groupId;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java
new file mode 100644
index 0000000..44ae0a9
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.group.status;
+
+import org.apache.stratos.messaging.event.Event;
+
+import java.io.Serializable;
+
+/**
+ * Represents all instance status events.
+ */
+public abstract class GroupStatusEvent extends Event implements Serializable {
+    private static final long serialVersionUID = -4790128084271867615L;
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4b46efe1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java
index c1ce207..db2ac44 100644
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java
@@ -28,12 +28,12 @@ public class ClusterActivatedEvent extends Event {
 
     private final String serviceName;
     private final String clusterId;
-    private ClusterStatus status;
     private String appId;
 
-    public ClusterActivatedEvent(String serviceName, String clusterId) {
+    public ClusterActivatedEvent(String appId, String serviceName, String 
clusterId) {
         this.serviceName = serviceName;
         this.clusterId = clusterId;
+        this.appId = appId;
     }
 
     public String getServiceName() {
@@ -43,26 +43,15 @@ public class ClusterActivatedEvent extends Event {
     @Override
     public String toString() {
         return "ClusterActivatedEvent [serviceName=" + serviceName + ", 
clusterStatus=" +
-                status.toString() + "]";
+                "]";
     }
 
     public String getClusterId() {
         return clusterId;
     }
 
-    public ClusterStatus getStatus() {
-        return status;
-    }
-
-    public void setStatus(ClusterStatus status) {
-        this.status = status;
-    }
-
     public String getAppId() {
         return appId;
     }
 
-    public void setAppId(String appId) {
-        this.appId = appId;
-    }
 }

Reply via email to