You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2014/10/18 18:26:18 UTC

git commit: refacting monitors to have their own status

Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping f6c0cfcb5 -> f00e2f369


refacting monitors to have their own status


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

Branch: refs/heads/4.0.0-grouping
Commit: f00e2f369fcde531784fd65c8e38e5e9f61757b9
Parents: f6c0cfc
Author: reka <rt...@gmail.com>
Authored: Sat Oct 18 21:56:01 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Sat Oct 18 21:56:01 2014 +0530

----------------------------------------------------------------------
 .../AutoscalerTopologyEventReceiver.java        |   2 +-
 .../monitor/ApplicationMonitorFactory.java      | 202 ++++++++++++-------
 .../stratos/autoscaler/monitor/Monitor.java     |  11 +-
 .../monitor/ParentComponentMonitor.java         |  18 +-
 .../monitor/application/ApplicationMonitor.java |  12 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |  76 ++++---
 .../status/checker/StatusChecker.java           |  24 ++-
 7 files changed, 188 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f00e2f36/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 5b765d4..1e20937 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
@@ -306,7 +306,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                     AbstractClusterMonitor monitor;
                     if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) {
                         monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId());
-                        monitor.setStatus(Status.In_Maintenance);
+                        monitor.setStatus(Status.In_Active);
                     } else if (AutoscalerContext.getInstance().
                             lbMonitorExist((cluster.getClusterId()))) {
                         AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()).

http://git-wip-us.apache.org/repos/asf/stratos/blob/f00e2f36/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
index 5f810d7..86e0931 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
@@ -38,6 +38,7 @@ import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
 import org.apache.stratos.autoscaler.partition.PartitionGroup;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 import org.apache.stratos.cloud.controller.stub.pojo.Properties;
@@ -54,17 +55,29 @@ import java.util.Map;
 public class ApplicationMonitorFactory {
     private static final Log log = LogFactory.getLog(ApplicationMonitorFactory.class);
 
-    public static Monitor getMonitor(ApplicationContext context, String appId)
+    /**
+     * Factor method used to create relevant monitors based on the given context
+     *
+     * @param context       Application/Group/Cluster context
+     * @param appId         appId of the application which requires to create app monitor
+     * @param parentMonitor parent of the monitor
+     * @return Monitor which can be ApplicationMonitor/GroupMonitor/ClusterMonitor
+     * @throws TopologyInConsistentException throws while traversing thr topology
+     * @throws DependencyBuilderException    throws while building dependency for app monitor
+     * @throws PolicyValidationException     throws while validating the policy associated with cluster
+     * @throws PartitionValidationException  throws while validating the partition used in a cluster
+     */
+    public static Monitor getMonitor(ParentComponentMonitor parentMonitor, ApplicationContext context, String appId)
             throws TopologyInConsistentException,
             DependencyBuilderException, PolicyValidationException, PartitionValidationException {
         Monitor monitor;
 
         if (context instanceof GroupContext) {
-            monitor = getGroupMonitor(context.getId(), appId);
+            monitor = getGroupMonitor(parentMonitor, context.getId(), appId);
         } else if (context instanceof ClusterContext) {
-            monitor = getClusterMonitor((ClusterContext) context, appId);
+            monitor = getClusterMonitor(parentMonitor, (ClusterContext) context, appId);
             //Start the thread
-            Thread th = new Thread((AbstractClusterMonitor)monitor);
+            Thread th = new Thread((AbstractClusterMonitor) monitor);
             th.start();
         } else {
             monitor = getApplicationMonitor(appId);
@@ -72,7 +85,18 @@ public class ApplicationMonitorFactory {
         return monitor;
     }
 
-    public static Monitor getGroupMonitor(String groupId, String appId) throws DependencyBuilderException,
+    /**
+     * This will create the GroupMonitor based on given groupId by going thr Topology
+     *
+     * @param parentMonitor parent of the monitor
+     * @param groupId       groupId of the group
+     * @param appId         appId of the relevant application
+     * @return Group monitor
+     * @throws DependencyBuilderException    throws while building dependency for app monitor
+     * @throws TopologyInConsistentException throws while traversing thr topology
+     */
+    public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, String groupId, String appId)
+            throws DependencyBuilderException,
             TopologyInConsistentException {
         GroupMonitor groupMonitor;
         TopologyManager.acquireReadLockForApplication(appId);
@@ -81,8 +105,10 @@ public class ApplicationMonitorFactory {
             Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(groupId);
             groupMonitor = new GroupMonitor(group, appId);
             groupMonitor.setAppId(appId);
+            groupMonitor.setParent(parentMonitor);
             if (group.getStatus() != groupMonitor.getStatus()) {
-                //updating the status, so that it will notify the parent
+                //updating the status, if the group is not in created state when creating group Monitor
+                //so that groupMonitor will notify the parent (useful when restarting stratos)
                 groupMonitor.setStatus(group.getStatus());
             }
         } finally {
@@ -93,6 +119,15 @@ public class ApplicationMonitorFactory {
 
     }
 
+    /**
+     * This will create a new app monitor based on the give appId by getting the
+     * application from Topology
+     *
+     * @param appId appId of the application which requires to create app monitor
+     * @return ApplicationMonitor
+     * @throws DependencyBuilderException    throws while building dependency for app monitor
+     * @throws TopologyInConsistentException throws while traversing thr topology
+     */
     public static ApplicationMonitor getApplicationMonitor(String appId)
             throws DependencyBuilderException,
             TopologyInConsistentException {
@@ -117,12 +152,14 @@ public class ApplicationMonitorFactory {
     /**
      * Updates ClusterContext for given cluster
      *
+     * @param parentMonitor parent of the monitor
      * @param context
      * @return ClusterMonitor - Updated ClusterContext
      * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException
      * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException
      */
-    public static ClusterMonitor getClusterMonitor(ClusterContext context, String appId)
+    public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor,
+                                                   ClusterContext context, String appId)
             throws PolicyValidationException,
             PartitionValidationException,
             TopologyInConsistentException {
@@ -131,6 +168,7 @@ public class ApplicationMonitorFactory {
         String serviceName = context.getServiceName();
 
         Cluster cluster;
+        ClusterMonitor clusterMonitor;
         //acquire read lock for the service and cluster
         TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
         try {
@@ -154,101 +192,111 @@ public class ApplicationMonitorFactory {
                 throw new TopologyInConsistentException(msg);
 
             }
-        } finally {
-            //release read lock for the service and cluster
-            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-        }
 
-        String autoscalePolicyName = cluster.getAutoscalePolicyName();
-        String deploymentPolicyName = cluster.getDeploymentPolicyName();
+            String autoscalePolicyName = cluster.getAutoscalePolicyName();
+            String deploymentPolicyName = cluster.getDeploymentPolicyName();
 
-        if (log.isDebugEnabled()) {
-            log.debug("Deployment policy name: " + deploymentPolicyName);
-            log.debug("Autoscaler policy name: " + autoscalePolicyName);
-        }
+            if (log.isDebugEnabled()) {
+                log.debug("Deployment policy name: " + deploymentPolicyName);
+                log.debug("Autoscaler policy name: " + autoscalePolicyName);
+            }
 
-        AutoscalePolicy policy =
-                PolicyManager.getInstance()
-                        .getAutoscalePolicy(autoscalePolicyName);
-        DeploymentPolicy deploymentPolicy =
-                PolicyManager.getInstance()
-                        .getDeploymentPolicy(deploymentPolicyName);
-
-        if (deploymentPolicy == null) {
-            String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName;
-            log.error(msg);
-            throw new PolicyValidationException(msg);
-        }
+            AutoscalePolicy policy =
+                    PolicyManager.getInstance()
+                            .getAutoscalePolicy(autoscalePolicyName);
+            DeploymentPolicy deploymentPolicy =
+                    PolicyManager.getInstance()
+                            .getDeploymentPolicy(deploymentPolicyName);
+
+            if (deploymentPolicy == null) {
+                String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName;
+                log.error(msg);
+                throw new PolicyValidationException(msg);
+            }
 
-        Partition[] allPartitions = deploymentPolicy.getAllPartitions();
-        if (allPartitions == null) {
-            String msg =
-                    "Deployment Policy's Partitions are null. Policy name: " +
-                            deploymentPolicyName;
-            log.error(msg);
-            throw new PolicyValidationException(msg);
-        }
+            Partition[] allPartitions = deploymentPolicy.getAllPartitions();
+            if (allPartitions == null) {
+                String msg =
+                        "Deployment Policy's Partitions are null. Policy name: " +
+                                deploymentPolicyName;
+                log.error(msg);
+                throw new PolicyValidationException(msg);
+            }
 
-        CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy);
+            CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy);
 
-        ClusterMonitor clusterMonitor =
-                new ClusterMonitor(cluster.getClusterId(),
-                        cluster.getServiceName(),
-                        deploymentPolicy, policy);
-        clusterMonitor.setAppId(cluster.getAppId());
+            clusterMonitor = new ClusterMonitor(cluster.getClusterId(), cluster.getServiceName(),
+                    deploymentPolicy, policy);
+            clusterMonitor.setAppId(cluster.getAppId());
 
-        for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) {
+            for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) {
 
-            NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(),
-                    partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions());
+                NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(),
+                        partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions());
 
-            for (Partition partition : partitionGroup.getPartitions()) {
-                PartitionContext partitionContext = new PartitionContext(partition);
-                partitionContext.setServiceName(cluster.getServiceName());
-                partitionContext.setProperties(cluster.getProperties());
-                partitionContext.setNetworkPartitionId(partitionGroup.getId());
+                for (Partition partition : partitionGroup.getPartitions()) {
+                    PartitionContext partitionContext = new PartitionContext(partition);
+                    partitionContext.setServiceName(cluster.getServiceName());
+                    partitionContext.setProperties(cluster.getProperties());
+                    partitionContext.setNetworkPartitionId(partitionGroup.getId());
 
-                for (Member member : cluster.getMembers()) {
-                    String memberId = member.getMemberId();
-                    if (member.getPartitionId().equalsIgnoreCase(partition.getId())) {
-                        MemberContext memberContext = new MemberContext();
-                        memberContext.setClusterId(member.getClusterId());
-                        memberContext.setMemberId(memberId);
-                        memberContext.setPartition(partition);
-                        memberContext.setProperties(convertMemberPropsToMemberContextProps(member.getProperties()));
+                    for (Member member : cluster.getMembers()) {
+                        String memberId = member.getMemberId();
+                        if (member.getPartitionId().equalsIgnoreCase(partition.getId())) {
+                            MemberContext memberContext = new MemberContext();
+                            memberContext.setClusterId(member.getClusterId());
+                            memberContext.setMemberId(memberId);
+                            memberContext.setPartition(partition);
+                            memberContext.setProperties(convertMemberPropsToMemberContextProps(member.getProperties()));
 
-                        if (MemberStatus.Activated.equals(member.getStatus())) {
-                            partitionContext.addActiveMember(memberContext);
+                            if (MemberStatus.Activated.equals(member.getStatus())) {
+                                partitionContext.addActiveMember(memberContext);
+                                //triggering the status checker
 //                            networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1);
 //                            partitionContext.incrementCurrentActiveMemberCount(1);
 
-                        } else if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) {
-                            partitionContext.addPendingMember(memberContext);
+                            } else if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) {
+                                partitionContext.addPendingMember(memberContext);
 
 //                            networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1);
-                        } else if (MemberStatus.Suspended.equals(member.getStatus())) {
+                            } else if (MemberStatus.Suspended.equals(member.getStatus())) {
 //                            partitionContext.addFaultyMember(memberId);
+                            }
+                            partitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
+                            if (log.isInfoEnabled()) {
+                                log.info(String.format("Member stat context has been added: [member] %s", memberId));
+                            }
                         }
-                        partitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
-                        if (log.isInfoEnabled()) {
-                            log.info(String.format("Member stat context has been added: [member] %s", memberId));
-                        }
-                    }
 
+                    }
+                    if (cluster.hasMembers()) {
+                        //triggering the status checker if cluster has members to decide
+                        // on the current status of the cluster
+                        StatusChecker.getInstance().onMemberStatusChange(clusterId);
+                    }
+                    networkPartitionContext.addPartitionContext(partitionContext);
+                    if (log.isInfoEnabled()) {
+                        log.info(String.format("Partition context has been added: [partition] %s",
+                                partitionContext.getPartitionId()));
+                    }
                 }
-                networkPartitionContext.addPartitionContext(partitionContext);
+
+                clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext);
+                clusterMonitor.setParent(parentMonitor);
+                //clusterMonitor.setCurrentStatus(Status.Created);
                 if (log.isInfoEnabled()) {
-                    log.info(String.format("Partition context has been added: [partition] %s",
-                            partitionContext.getPartitionId()));
+                    log.info(String.format("Network partition context has been added: [network partition] %s",
+                            networkPartitionContext.getId()));
                 }
             }
 
-            clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext);
-            //clusterMonitor.setCurrentStatus(Status.Created);
-            if (log.isInfoEnabled()) {
-                log.info(String.format("Network partition context has been added: [network partition] %s",
-                        networkPartitionContext.getId()));
+            if (cluster.getStatus() != clusterMonitor.getStatus()) {
+                //updating the status, so that it will notify the parent
+                clusterMonitor.setStatus(cluster.getStatus());
             }
+        } finally {
+            //release read lock for the service and cluster
+            TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
         }
 
         // set hasPrimary property

http://git-wip-us.apache.org/repos/asf/stratos/blob/f00e2f36/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 bb09811..f08be7f 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
@@ -18,22 +18,19 @@
  */
 package org.apache.stratos.autoscaler.monitor;
 
-import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
-import org.apache.stratos.messaging.domain.topology.ParentComponent;
-
 import java.util.Map;
 
 /**
  * Abstract class for the monitoring functionality in autoscaler.
  */
 public abstract class Monitor implements EventHandler {
+    //Id of the monitor, cluster=clusterId, group=group-alias, application=app-alias
     protected String id;
-
+    //The parent app which this monitor relates to
     protected String appId;
-
+    //Parent monitor of this monitor, for appMonitor parent will be none.
     protected ParentComponentMonitor parent;
-
-    //GroupMonitor map, key=GroupAlias and value=GroupMonitor
+    //monitors map, key=GroupAlias/clusterId and value=GroupMonitor/AbstractClusterMonitor
     protected Map<String, Monitor> aliasToMonitorsMap;
 
     public String getId() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/f00e2f36/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 1168883..3cd2d9f 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
@@ -30,7 +30,6 @@ import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
 import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 import org.apache.stratos.messaging.domain.topology.ParentComponent;
-import org.apache.stratos.messaging.domain.topology.Status;
 
 import java.util.HashMap;
 import java.util.List;
@@ -44,13 +43,8 @@ public abstract class ParentComponentMonitor extends Monitor {
 
     //id of the monitor, it can be alias or the id
     protected String id;
-
-    //AbstractMonitor map, key=clusterId and value=AbstractMonitors
-    //protected Map<String, AbstractClusterMonitor> clusterIdToClusterMonitorsMap;
     //The monitors dependency tree with all the startable/killable dependencies
     protected DependencyTree dependencyTree;
-    //status of the monitor whether it is running/in_maintainable/terminated
-    protected Status status;
     //Application id of this particular monitor
     protected String appId;
 
@@ -58,7 +52,6 @@ public abstract class ParentComponentMonitor extends Monitor {
         aliasToMonitorsMap = new HashMap<String, Monitor>();
         //clusterIdToClusterMonitorsMap = new HashMap<String, AbstractClusterMonitor>();
         this.id = component.getUniqueIdentifier();
-        this.status = component.getStatus();
         //Building the dependency for this monitor within the immediate children
         dependencyTree = DependencyBuilder.getInstance().buildDependency(component);
     }
@@ -118,10 +111,6 @@ public abstract class ParentComponentMonitor extends Monitor {
 
     }
 
-    public Status getStatus() {
-        return status;
-    }
-
     public String getId() {
         return this.id;
     }
@@ -171,7 +160,7 @@ public abstract class ParentComponentMonitor extends Monitor {
         public void run() {
             Monitor monitor = null;
             int retries = 5;
-            boolean success = false;
+            boolean success;
             do {
                 try {
                     Thread.sleep(5000);
@@ -183,10 +172,7 @@ public abstract class ParentComponentMonitor extends Monitor {
                             + context.getId());
                 }
                 try {
-                    monitor = ApplicationMonitorFactory.getMonitor(context, appId);
-                    monitor.setParent(parent);
-                    //TODO start the status checker
-
+                    monitor = ApplicationMonitorFactory.getMonitor(parent, context, appId);
                 } catch (DependencyBuilderException e) {
                     String msg = "Monitor creation failed for: " + context.getId();
                     log.warn(msg, e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/f00e2f36/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 92bf6fa..5df3367 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
@@ -40,10 +40,13 @@ import java.util.List;
  */
 public class ApplicationMonitor extends ParentComponentMonitor {
     private static final Log log = LogFactory.getLog(ApplicationMonitor.class);
+    //status of the monitor whether it is running/in_maintainable/terminated
+    protected Status status;
 
     public ApplicationMonitor(Application application) throws DependencyBuilderException,
-                                                        TopologyInConsistentException {
+            TopologyInConsistentException {
         super(application);
+        //setting the appId for the application
         this.appId = application.getUniqueIdentifier();
         //starting the first set of dependencies from its children
         startDependency();
@@ -107,6 +110,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
 
     }
 */
+
     /**
      * Find the group monitor by traversing recursively in the hierarchical monitors.
      *
@@ -183,18 +187,18 @@ public class ApplicationMonitor extends ParentComponentMonitor {
         String id = statusEvent.getId();
         ApplicationContext context = this.dependencyTree.
                 findApplicationContextWithId(id);
-        if(context.getStatusLifeCycle().isEmpty()) {
+        if (context.getStatusLifeCycle().isEmpty()) {
             try {
                 //if life cycle is empty, need to start the monitor
                 boolean startDep = startDependency(statusEvent.getId());
-                if(log.isDebugEnabled()) {
+                if (log.isDebugEnabled()) {
                     log.debug("started a child: " + startDep + " by the group/cluster: " + id);
 
                 }
                 //updating the life cycle and current status
                 context.setCurrentStatus(statusEvent.getStatus());
                 context.addStatusToLIfeCycle(statusEvent.getStatus());
-                if(!startDep) {
+                if (!startDep) {
                     //Checking in the children whether all are active,
                     // since no dependency found to be started.
                     StatusChecker.getInstance().onChildStatusChange(id, this.appId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/f00e2f36/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 c76f02b..9f83578 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
@@ -24,8 +24,8 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
 import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
 import org.apache.stratos.autoscaler.monitor.EventHandler;
-import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
 import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
+import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
 import org.apache.stratos.messaging.domain.topology.Group;
@@ -40,35 +40,24 @@ import java.util.List;
  */
 public class GroupMonitor extends ParentComponentMonitor implements EventHandler {
     private static final Log log = LogFactory.getLog(GroupMonitor.class);
-
-    //Parent monitor of this monitor
-    private ParentComponentMonitor parent;
+    //status of the monitor whether it is running/in_maintainable/terminated
+    private Status status;
 
     /**
      * Constructor of GroupMonitor
+     *
      * @param group Takes the group from the Topology
-     * @throws DependencyBuilderException throws when couldn't build the Topology
+     * @throws DependencyBuilderException    throws when couldn't build the Topology
      * @throws TopologyInConsistentException throws when topology is inconsistent
      */
     public GroupMonitor(Group group, String appId) throws DependencyBuilderException,
-                                            TopologyInConsistentException {
+            TopologyInConsistentException {
         super(group);
         this.appId = appId;
+        this.setStatus(group.getStatus());
         startDependency();
     }
 
-    /**
-     * Will set the status of the monitor based on Topology Group status/child status like scaling
-     * @param status
-     */
-    public void setStatus(Status status) {
-        log.info(String.format("[Monitor] %s is notifying the parent" +
-                "on its state change from %s to %s", id, this.status, status));
-        this.status = status;
-        //notifying the parent
-        MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
-    }
-
     @Override
     public void onEvent(MonitorStatusEvent statusEvent) {
         monitor(statusEvent);
@@ -81,8 +70,8 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
         ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id);
         //Events coming from parent are In_Active(in faulty detection), Scaling events, termination
         //TODO if statusEvent is for active, then start the next one if any available
-        if(!isParent(id)) {
-            if(status1 == Status.Activated) {
+        if (!isParent(id)) {
+            if (status1 == Status.Activated) {
                 try {
                     //if life cycle is empty, need to start the monitor
                     boolean startDep = startDependency(statusEvent.getId());
@@ -102,7 +91,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
                     //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
                     log.error(e);
                 }
-            } else if(status1 == Status.In_Maintenance) {
+            } else if (status1 == Status.In_Active) {
                 //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and
                 //TODO need to send in_active for c1. When C1 in_active receives, get dependent and
                 //TODO check whether dependent in_active. Then kill c1.
@@ -112,8 +101,8 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
                 terminationList = this.dependencyTree.getTerminationDependencies(id);
 
                 //check whether all the children are in_active state
-                for(ApplicationContext terminationContext : terminationList) {
-                   //terminationContext
+                for (ApplicationContext terminationContext : terminationList) {
+                    //terminationContext
                 }
 
                 /*if(terminationList != null && !terminationList.isEmpty()) {
@@ -135,23 +124,16 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
                     if(canTerminate) {
                        //
                     }*/
-                } else {
-                    //TODO get dependents
-                    List<ApplicationContext> dependents = this.dependencyTree.getTerminationDependencies(id);
-                }
-
-
-
-
-
-            } else if(status1 == Status.Created) {
-                //the dependent goes to be created state, so terminate the dependents
+            } else {
+                //TODO get dependents
+                List<ApplicationContext> dependents = this.dependencyTree.getTerminationDependencies(id);
             }
-        }
-
-
 
 
+        } else if (status1 == Status.Created) {
+            //the dependent goes to be created state, so terminate the dependents
+        }
+    }
 
     public ParentComponentMonitor getParent() {
         return parent;
@@ -170,15 +152,27 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
     }
 
     private boolean isParent(String id) {
-        if(this.parent.getId().equals(id)) {
+        if (this.parent.getId().equals(id)) {
             return true;
         } else {
             return false;
         }
     }
 
+    public Status getStatus() {
+        return status;
+    }
 
-
-
-
+    /**
+     * Will set the status of the monitor based on Topology Group status/child status like scaling
+     *
+     * @param status
+     */
+    public void setStatus(Status status) {
+        log.info(String.format("[Monitor] %s is notifying the parent" +
+                "on its state change from %s to %s", id, this.status, status));
+        this.status = status;
+        //notifying the parent
+        MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/f00e2f36/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 04ed325..c76df01 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
@@ -51,11 +51,14 @@ public class StatusChecker {
     /**
      * Calculating whether the cluster has all min instances as active and send the
      * ClusterActivatedEvent.
+     *
      * @param clusterId id of the cluster
      */
     public void onMemberStatusChange(String clusterId) {
         ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
         boolean clusterActive = clusterActive(monitor);
+        log.info("Status checker running for [cluster] " + clusterId +
+                " the status [clusterActive] " + clusterActive);
         // if active then notify upper layer
         if (clusterActive) {
             //send event to cluster status topic
@@ -104,7 +107,7 @@ public class StatusChecker {
 
         } else {
             boolean clusterActive = clusterActive(monitor);
-            if(clusterActive) {
+            if (clusterActive) {
                 //TODO evaluate life cycle
                 //send clusterActive event to cluster status topic
             }
@@ -127,7 +130,6 @@ public class StatusChecker {
     }
 
     /**
-     *
      * @param idOfChild
      * @param groupId
      * @param appId
@@ -140,6 +142,7 @@ public class StatusChecker {
     /**
      * This will calculate whether the children of an application are active or not. If active, then
      * it will send the ApplicationActivatedEvent.
+     *
      * @param idOfChild
      * @param appId
      */
@@ -192,10 +195,9 @@ public class StatusChecker {
     }
 
 
-
-
     /**
      * This will use to calculate whether  all children of a particular component is active by travesing Top
+     *
      * @param appId
      * @param id
      * @param groups
@@ -211,8 +213,8 @@ public class StatusChecker {
         boolean childFound = false;
         boolean clusterFound = false;
 
-        for(ClusterDataHolder clusterDataHolder : clusterData.values()) {
-            if(clusterDataHolder.getClusterId().equals(id)) {
+        for (ClusterDataHolder clusterDataHolder : clusterData.values()) {
+            if (clusterDataHolder.getClusterId().equals(id)) {
                 clusterFound = true;
             }
         }
@@ -220,29 +222,29 @@ public class StatusChecker {
         if (clusterFound || groups.containsKey(id)) {
             childFound = true;
             if (!clusterData.isEmpty() && !groups.isEmpty()) {
-                if(log.isDebugEnabled()) {
+                if (log.isDebugEnabled()) {
                     log.debug("group active found: " + clusterFound);
                 }
                 clustersActive = getClusterStatus(clusterData);
                 groupsActive = getGroupStatus(groups);
-                if(log.isDebugEnabled()) {
+                if (log.isDebugEnabled()) {
                     log.debug("Active cluster" + clustersActive + " and group: " + groupActive);
                 }
                 groupActive = clustersActive && groupsActive;
             } else if (!groups.isEmpty()) {
                 groupsActive = getGroupStatus(groups);
-                if(log.isDebugEnabled()) {
+                if (log.isDebugEnabled()) {
                     log.info("group active found: " + clusterFound);
                 }
                 groupActive = groupsActive;
             } else if (!clusterData.isEmpty()) {
                 clustersActive = getClusterStatus(clusterData);
-                if(log.isDebugEnabled()) {
+                if (log.isDebugEnabled()) {
                     log.debug("Active cluster" + clustersActive + " and group: " + groupActive);
                 }
                 groupActive = clustersActive;
             } else {
-                log.warn("Clusters/groups not found in this [component] "+ appId);
+                log.warn("Clusters/groups not found in this [component] " + appId);
             }
             //send the activation event
             if (parent instanceof Application && groupActive) {