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/11/27 05:33:49 UTC

[3/3] stratos git commit: adding multiple instances support

adding multiple instances support


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

Branch: refs/heads/master
Commit: 48595f1afbec4c443cb02e149f154bb0f044c785
Parents: 6c60e2d
Author: reka <rt...@gmail.com>
Authored: Thu Nov 27 09:55:54 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Thu Nov 27 10:03:34 2014 +0530

----------------------------------------------------------------------
 .../stratos/autoscaler/VMClusterContext.java    |  15 -
 .../AutoscalerTopologyEventReceiver.java        |   6 +-
 .../internal/AutoscalerServerComponent.java     |   4 +-
 .../monitor/ParentComponentMonitor.java         |  38 +-
 .../monitor/application/ApplicationMonitor.java |   6 +-
 .../application/ApplicationMonitorFactory.java  |   8 +-
 .../monitor/cluster/VMClusterMonitor.java       |   4 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |  56 +-
 .../status/checker/StatusChecker.java           | 522 -------------------
 .../status/checker/StatusProcessor.java         |  30 --
 .../status/checker/StatusProcessorChain.java    |  55 --
 .../cluster/ClusterStatusActiveProcessor.java   |  91 ----
 .../cluster/ClusterStatusInActiveProcessor.java | 105 ----
 .../checker/cluster/ClusterStatusProcessor.java |  34 --
 .../cluster/ClusterStatusProcessorChain.java    |  54 --
 .../ClusterStatusTerminatedProcessor.java       | 135 -----
 .../group/GroupStatusActiveProcessor.java       | 119 -----
 .../group/GroupStatusInActiveProcessor.java     | 166 ------
 .../checker/group/GroupStatusProcessor.java     | 122 -----
 .../group/GroupStatusProcessorChain.java        |  57 --
 .../group/GroupStatusTerminatedProcessor.java   | 118 -----
 .../group/GroupStatusTerminatingProcessor.java  | 119 -----
 .../status/processor/StatusChecker.java         | 520 ++++++++++++++++++
 .../status/processor/StatusProcessor.java       |  30 ++
 .../status/processor/StatusProcessorChain.java  |  52 ++
 .../cluster/ClusterStatusActiveProcessor.java   |  91 ++++
 .../cluster/ClusterStatusInActiveProcessor.java | 105 ++++
 .../cluster/ClusterStatusProcessor.java         |  34 ++
 .../cluster/ClusterStatusProcessorChain.java    |  53 ++
 .../ClusterStatusTerminatedProcessor.java       | 135 +++++
 .../group/GroupStatusActiveProcessor.java       | 119 +++++
 .../group/GroupStatusInActiveProcessor.java     | 166 ++++++
 .../processor/group/GroupStatusProcessor.java   | 122 +++++
 .../group/GroupStatusProcessorChain.java        |  57 ++
 .../group/GroupStatusTerminatedProcessor.java   | 118 +++++
 .../group/GroupStatusTerminatingProcessor.java  | 119 +++++
 .../autoscaler/util/ServiceReferenceHolder.java |   4 +-
 .../stratos/cartridge/agent/CartridgeAgent.java |   2 +-
 .../application/beans/GroupDefinition.java      |  12 +-
 .../bean/util/converter/PojoConverter.java      |   4 +-
 40 files changed, 1808 insertions(+), 1799 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/VMClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/VMClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/VMClusterContext.java
index b3f3246..1c031a5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/VMClusterContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/VMClusterContext.java
@@ -18,27 +18,12 @@
  */
 package org.apache.stratos.autoscaler;
 
-import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.client.CloudControllerClient;
-import org.apache.stratos.autoscaler.exception.TerminationException;
 import org.apache.stratos.autoscaler.policy.model.*;
-import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.autoscaler.util.ConfUtil;
-import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
-import org.apache.stratos.common.constants.StratosConstants;
-import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.event.health.stat.*;
-import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
-import java.io.Serializable;
 import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
 
 /*
  * It holds the runtime data of a VM cluster

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
index 15eaeea..63e7055 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -34,7 +34,8 @@ import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
 import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory;
 import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent;
-import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+import org.apache.stratos.autoscaler.status.processor.StatusChecker;
+import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Applications;
 import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
@@ -292,7 +293,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
                 	monitor.setStatus(ClusterStatus.Terminating);
                 	monitor.terminateAllMembers();
                 }
-                StatusChecker.getInstance().onMemberTermination(clusterId, instanceId);
+                ServiceReferenceHolder.getInstance().getClusterStatusProcessorChain().
+                        process("", clusterId, instanceId);
             }
         });
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
index c57a680..f37efdc 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java
@@ -31,8 +31,8 @@ import org.apache.stratos.autoscaler.partition.PartitionManager;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.registry.RegistryManager;
-import org.apache.stratos.autoscaler.status.checker.cluster.ClusterStatusProcessorChain;
-import org.apache.stratos.autoscaler.status.checker.group.GroupStatusProcessorChain;
+import org.apache.stratos.autoscaler.status.processor.cluster.ClusterStatusProcessorChain;
+import org.apache.stratos.autoscaler.status.processor.group.GroupStatusProcessorChain;
 import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 import org.apache.stratos.common.kubernetes.KubernetesGroup;

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/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 5cc7251..77832b0 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
@@ -36,8 +36,7 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
 import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory;
 import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
-import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.autoscaler.status.processor.StatusChecker;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.applications.ParentComponent;
 import org.apache.stratos.messaging.domain.instance.context.InstanceContext;
@@ -80,11 +79,11 @@ public abstract class ParentComponentMonitor extends Monitor {
      * This will start the parallel dependencies at once from the top level.
      * it will get invoked when the monitor starts up only.
      */
-    public void startDependency(ParentComponent component, String instanceId) throws TopologyInConsistentException {
+    public void startDependency(ParentComponent component, List<String> instanceIds) throws TopologyInConsistentException {
         //start the first dependency
         List<ApplicationChildContext> applicationContexts = this.startupDependencyTree.
                 getStarAbleDependencies();
-        startDependency(applicationContexts, instanceId);
+        startDependency(applicationContexts, instanceIds);
 
     }
 
@@ -98,10 +97,11 @@ public abstract class ParentComponentMonitor extends Monitor {
                 getStarAbleDependencies();
         Collection<InstanceContext> contexts = component.getInstanceIdToInstanceContextMap().values();
         //traversing through all the Instance context and start them
+        List<String> instanceIds = new ArrayList<String>();
         for(InstanceContext context : contexts) {
-            startDependency(applicationContexts, context.getInstanceId());
+            instanceIds.add(context.getInstanceId());
         }
-
+        startDependency(applicationContexts, instanceIds);
     }
 
     /**
@@ -112,7 +112,9 @@ public abstract class ParentComponentMonitor extends Monitor {
     public boolean startDependency(String id, String instanceId) throws TopologyInConsistentException {
         List<ApplicationChildContext> applicationContexts = this.startupDependencyTree
                 .getStarAbleDependencies(id);
-        return startDependency(applicationContexts, instanceId);
+        List<String> instanceIds = new ArrayList<String>();
+        instanceIds.add(instanceId);
+        return startDependency(applicationContexts, instanceIds);
     }
 
     public boolean startAllChildrenDependency(ParentComponent component, String instanceId) throws TopologyInConsistentException {
@@ -140,7 +142,7 @@ public abstract class ParentComponentMonitor extends Monitor {
      *
      * @param applicationContexts the found applicationContexts to be started
      */
-    private boolean startDependency(List<ApplicationChildContext> applicationContexts, String instanceId)
+    private boolean startDependency(List<ApplicationChildContext> applicationContexts, List<String> instanceIds)
             throws TopologyInConsistentException {
         if (applicationContexts != null && applicationContexts.isEmpty()) {
             //all the groups/clusters have been started and waiting for activation
@@ -154,15 +156,18 @@ public abstract class ParentComponentMonitor extends Monitor {
             }
             if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) {
                 //to avoid if it is already started
-                startMonitor(this, context, instanceId);
+                startMonitor(this, context, instanceIds);
             } else {
                 //starting a new instance of the child
                 Monitor monitor = aliasToActiveMonitorsMap.get(context.getId());
-                if(context instanceof ClusterChildContext) {
-                    MonitorStatusEventBuilder.notifyChildCluster(monitor, ClusterStatus.Created, instanceId);
-                } else if(context instanceof GroupChildContext) {
-                    MonitorStatusEventBuilder.notifyChildGroup(monitor, GroupStatus.Created, instanceId);
+                for(String instanceId : instanceIds) {
+                    if(context instanceof ClusterChildContext) {
+                        MonitorStatusEventBuilder.notifyChildCluster(monitor, ClusterStatus.Created, instanceId);
+                    } else if(context instanceof GroupChildContext) {
+                        MonitorStatusEventBuilder.notifyChildGroup(monitor, GroupStatus.Created, instanceId);
+                    }
                 }
+
             }
         }
 
@@ -423,7 +428,8 @@ public abstract class ParentComponentMonitor extends Monitor {
         }
     }
 
-    protected synchronized void startMonitor(ParentComponentMonitor parent, ApplicationChildContext context, String instanceId) {
+    protected synchronized void startMonitor(ParentComponentMonitor parent,
+                                             ApplicationChildContext context, List<String> instanceId) {
         Thread th = null;
         if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) {
             th = new Thread(
@@ -494,10 +500,10 @@ public abstract class ParentComponentMonitor extends Monitor {
         private ApplicationChildContext context;
         private ParentComponentMonitor parent;
         private String appId;
-        private String instanceId;
+        private List<String> instanceId;
 
         public MonitorAdder(ParentComponentMonitor parent, ApplicationChildContext context,
-                            String appId, String instanceId) {
+                            String appId, List<String> instanceId) {
             this.parent = parent;
             this.context = context;
             this.appId = appId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/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 65a21f8..6d9ffdc 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
@@ -35,7 +35,9 @@ import org.apache.stratos.messaging.domain.applications.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 /**
  * ApplicationMonitor is to control the child monitors
@@ -178,7 +180,9 @@ public class ApplicationMonitor extends ParentComponentMonitor {
     private void createInstanceAndStartDependency(Application application)
             throws TopologyInConsistentException {
         String instanceId = createApplicationInstance(application);
-        startDependency(application, instanceId);
+        List<String> instanceIds = new ArrayList<String>();
+        instanceIds.add(instanceId);
+        startDependency(application, instanceIds);
     }
 
     private String createApplicationInstance(Application application) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
index 4e504d2..c7d6d02 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java
@@ -40,6 +40,8 @@ import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
+import java.util.List;
+
 /**
  * Factory class to get the Monitors.
  */
@@ -58,7 +60,7 @@ public class ApplicationMonitorFactory {
      * @throws PartitionValidationException  throws while validating the partition used in a cluster
      */
     public static Monitor getMonitor(ParentComponentMonitor parentMonitor,
-                                     ApplicationChildContext context, String appId, String instanceId)
+                                     ApplicationChildContext context, String appId, List<String> instanceId)
             throws TopologyInConsistentException,
             DependencyBuilderException, PolicyValidationException, PartitionValidationException {
     	
@@ -72,7 +74,7 @@ public class ApplicationMonitorFactory {
                 ClusterChildContext clusterChildCtxt = (ClusterChildContext) context;
                 AbstractClusterMonitor clusterMonitor = (AbstractClusterMonitor)monitor;
                 // FIXME: passing null as alias for cluster instance temporarily. should be removed.
-                createClusterInstance(clusterChildCtxt.getServiceName(), clusterMonitor.getClusterId(), null, instanceId);
+                createClusterInstance(clusterChildCtxt.getServiceName(), clusterMonitor.getClusterId(), null, instanceId.get(0));
             	AutoscalerContext.getInstance().addClusterMonitor((AbstractClusterMonitor)monitor);
 			}
         } else {
@@ -96,7 +98,7 @@ public class ApplicationMonitorFactory {
      * @throws TopologyInConsistentException throws while traversing thr topology
      */
     public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor,
-                                          ApplicationChildContext context, String appId, String instanceId)
+                                          ApplicationChildContext context, String appId, List<String> instanceId)
             throws DependencyBuilderException,
             TopologyInConsistentException {
         GroupMonitor groupMonitor;

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
index 8ae88c1..f22d2d2 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java
@@ -25,12 +25,10 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.*;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
-import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.exception.TerminationException;
-import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
-import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+import org.apache.stratos.autoscaler.status.processor.StatusChecker;
 import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
 import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 import org.apache.stratos.messaging.domain.topology.Cluster;

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/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 eeb21c6..8fde5dd 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
@@ -35,9 +35,13 @@ import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
 import org.apache.stratos.autoscaler.monitor.events.*;
 import org.apache.stratos.messaging.domain.applications.*;
 import org.apache.stratos.messaging.domain.instance.context.GroupInstanceContext;
+import org.apache.stratos.messaging.domain.instance.context.InstanceContext;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * This is GroupMonitor to monitor the group which consists of
  * groups and clusters
@@ -54,7 +58,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
      * @throws DependencyBuilderException    throws when couldn't build the Topology
      * @throws TopologyInConsistentException throws when topology is inconsistent
      */
-    public GroupMonitor(Group group, String appId, String parentInstanceId) throws DependencyBuilderException,
+    public GroupMonitor(Group group, String appId, List<String> parentInstanceId) throws DependencyBuilderException,
             TopologyInConsistentException {
         super(group);
         this.appId = appId;
@@ -221,42 +225,56 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
         this.groupScalingEnabled = groupScalingEnabled;
     }
 
-    private void startMinimumDependencies(Group group, String parentInstanceId)
+    private void startMinimumDependencies(Group group, List<String> parentInstanceIds)
             throws TopologyInConsistentException {
         int min = group.getGroupMinInstances();
         if(group.getInstanceContextCount() >= min) {
             startDependency(group);
         } else {
             if(group.getInstanceContextCount() > 0) {
-                startDependency(group);
-                int remainingInstancesToBeStarted = min - group.getInstanceContextCount();
-                while (remainingInstancesToBeStarted > 0) {
-                    createInstanceAndStartDependency(group, parentInstanceId);
-                    remainingInstancesToBeStarted--;
-                }
+                List<String> instanceIds = new ArrayList<String>();
+                for(String parentInstanceId : parentInstanceIds) {
+                    List<InstanceContext> contexts1 =  group.getInstanceContextsWithParentId(parentInstanceId);
+                    //Finding the non startable instance ids
+                    if(group.getInstanceContexts(parentInstanceId) == null || contexts1.isEmpty() ||
+                            contexts1.size() == 0) {
+                        instanceIds.add(parentInstanceId);
 
+                    }
+                }
+                if(instanceIds.size() > 0) {
+                    createInstanceAndStartDependency(group, parentInstanceIds);
+                } else {
+                    startDependency(group);
+                }
             } else {
                 //No available instances in the Applications. Need to start them all
-                int instancesToBeStarted = min;
-                while(instancesToBeStarted > 0) {
-                    createInstanceAndStartDependency(group, parentInstanceId);
-                    instancesToBeStarted--;
-
-                }
+                createInstanceAndStartDependency(group, parentInstanceIds);
             }
         }
     }
 
-    private void createInstanceAndStartDependency(Group group, String parentInstanceId)
+    private void createInstanceAndStartDependency(Group group, List<String> parentInstanceIds)
             throws TopologyInConsistentException {
-        String instanceId  = createGroupInstance(group, parentInstanceId);
-        startDependency(group, instanceId);
+        List<String> instanceIds = new ArrayList<String>();
+        String instanceId;
+        for(String parentInstanceId : parentInstanceIds) {
+            instanceId = createGroupInstance(group, parentInstanceId);
+            instanceIds.add(instanceId);
+
+        }
+        startDependency(group, instanceIds);
     }
 
     private String createGroupInstance(Group group, String parentInstanceId) {
         String instanceId = parentInstanceId;
-        if (group.isGroupScalingEnabled()) {
-            this.groupScalingEnabled = true;
+        int minGroupInstances = group.getGroupMinInstances();
+        int maxGroupInstances = group.getGroupMaxInstances();
+        /*
+        * When min != 1 or max != 1, we need to generate
+        * instance ids as it is having more than one group instances
+        */
+        if (minGroupInstances > 1 || maxGroupInstances > 1) {
             instanceId = this.generateInstanceId(group);
         }
         ApplicationBuilder.handleGroupInstanceCreatedEvent(appId, group.getUniqueIdentifier(),

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/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
deleted file mode 100644
index b36ce2a..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ /dev/null
@@ -1,522 +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.commons.logging.Log;
-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.applications.ApplicationHolder;
-import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
-import org.apache.stratos.autoscaler.event.publisher.ClusterStatusEventPublisher;
-import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
-import org.apache.stratos.messaging.domain.applications.*;
-import org.apache.stratos.messaging.domain.instance.context.ClusterInstanceContext;
-import org.apache.stratos.messaging.domain.instance.context.GroupInstanceContext;
-import org.apache.stratos.messaging.domain.instance.context.InstanceContext;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.event.topology.ClusterInstanceCreatedEvent;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-
-import java.util.Map;
-
-
-/**
- * This will be used to evaluate the status of a group
- * and notify the interested parties about the status changes.
- */
-public class StatusChecker {
-    private static final Log log = LogFactory.getLog(StatusChecker.class);
-
-
-    private StatusChecker() {
-
-    }
-
-    public static StatusChecker getInstance() {
-        return Holder.INSTANCE;
-    }
-
-    /**
-     * Calculating whether the cluster has all min instances as active and send the
-     * ClusterActivatedEvent.
-     *
-     * @param clusterId id of the cluster
-     */
-    public void onMemberStatusChange(final String clusterId) {
-        Runnable group = new Runnable() {
-            public void run() {
-                VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-                boolean clusterActive = false;
-                if (monitor != null) {
-                    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
-                    monitor.setHasFaultyMember(false);
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster activated event for [application]: "
-                                + monitor.getAppId() + " [cluster]: " + clusterId);
-                    }
-                    ClusterStatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
-                            monitor.getServiceId(), monitor.getClusterId());
-                }
-            }
-        };
-        Thread groupThread = new Thread(group);
-        groupThread.start();
-    }
-
-    /**
-     * This will calculate the status of the cluster upon a member termination.
-     * The possible states which cluster can change upon member termination are
-     * Active --> InActive, Terminating-->Terminated, Terminating-->Reset(Created)
-     *
-     * @param clusterId id of the cluster
-     */
-    public void onMemberTermination(final String clusterId, final String instanceId) {
-        Runnable group = new Runnable() {
-            public void run() {
-                VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-                boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
-                boolean clusterActive = clusterActive(monitor);
-
-                try {
-                    TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
-                    Service service = TopologyManager.getTopology().getService(monitor.getServiceId());
-                    Cluster cluster;
-                    String appId = monitor.getAppId();
-                    if (service != null) {
-                        cluster = service.getCluster(monitor.getClusterId());
-                        if (cluster != null) {
-                            try {
-                                ApplicationHolder.acquireReadLock();
-                                Application application = ApplicationHolder.getApplications().getApplication(appId);
-                                //if all members removed from the cluster and cluster is in terminating,
-                                // either it has to be terminated or Reset
-                                if (!clusterMonitorHasMembers && cluster.getStatus(null) == ClusterStatus.Terminating) {
-                                    if (application.getStatus(null) == ApplicationStatus.Terminating) {
-                                        if (log.isInfoEnabled()) {
-                                            log.info("Publishing Cluster terminated event for [application]: " + appId +
-                                                    " [cluster]: " + clusterId);
-                                        }
-                                        ClusterStatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
-                                                monitor.getClusterId(), instanceId);
-                                    } else {
-                                        if (log.isInfoEnabled()) {
-                                            log.info("Publishing Cluster created event for [application]: " + appId +
-                                                    " [cluster]: " + clusterId);
-                                        }
-                                        ClusterStatusEventPublisher.sendClusterResetEvent(appId, monitor.getServiceId(),
-                                                monitor.getClusterId(), instanceId);
-                                    }
-
-                                } else {
-                                    //if the cluster is not active and, if it is in Active state
-                                    if (!clusterActive && cluster.getStatus(null) == ClusterStatus.Active) {
-                                        if (log.isInfoEnabled()) {
-                                            log.info("Publishing Cluster in-activate event for [application]: "
-                                                    + monitor.getAppId() + " [cluster]: " + clusterId);
-                                        }
-                                        ClusterStatusEventPublisher.sendClusterInActivateEvent(monitor.getAppId(),
-                                                monitor.getServiceId(), clusterId, instanceId);
-                                    } else {
-                                        log.info("Cluster has non terminated [members] and in the [status] "
-                                                + cluster.getStatus(null).toString());
-                                    }
-                                }
-                            } finally {
-                                ApplicationHolder.releaseReadLock();
-                            }
-                        }
-                    }
-
-
-                } finally {
-                    TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
-
-                }
-            }
-        };
-        Thread groupThread = new Thread(group);
-        groupThread.start();
-
-    }
-
-    /**
-     * Calculate whether the cluster is active based on the minimum count available in each partition
-     *
-     * @param monitor Cluster monitor which has the member
-     * @return whether cluster is active or not
-     */
-    private boolean clusterActive(VMClusterMonitor monitor) {
-        boolean clusterActive = false;
-        for (NetworkPartitionContext networkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
-            //minimum check per partition
-            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;
-                } else {
-                    return false;
-                }
-            }
-        }
-        return clusterActive;
-    }
-
-    /**
-     * Find out whether cluster monitor has any non terminated members
-     *
-     * @param monitor the cluster monitor
-     * @return whether has members or not
-     */
-    private boolean clusterMonitorHasMembers(VMClusterMonitor monitor) {
-        boolean hasMember = false;
-        for (NetworkPartitionContext networkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
-            //minimum check per partition
-            for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) {
-                if (partitionContext.getNonTerminatedMemberCount() > 0) {
-                    hasMember = true;
-                } else {
-                    hasMember = false;
-                }
-            }
-        }
-        return hasMember;
-    }
-
-    /**
-     * This will calculate the status of the cluster upon a member fault event
-     *
-     * @param clusterId   id of the cluster
-     * @param partitionId is to decide in which partition has less members while others have active members
-     */
-    public void onMemberFaultEvent(final String clusterId, final String partitionId, final String instanceId) {
-        Runnable group = new Runnable() {
-            public void run() {
-                VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-                boolean clusterInActive = getClusterInactive(monitor, partitionId);
-                String appId = monitor.getAppId();
-                if (clusterInActive) {
-                    //if the monitor is dependent, temporarily pausing it
-                    if (monitor.hasStartupDependents()) {
-                        monitor.setHasFaultyMember(true);
-                    }
-                    if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster in-activate event for [application]: "
-                                + monitor.getAppId() + " [cluster]: " + clusterId);
-                    }
-                    //send cluster In-Active event to cluster status topic
-                    ClusterStatusEventPublisher.sendClusterInActivateEvent(appId,
-                            monitor.getServiceId(), clusterId, instanceId);
-
-                } else {
-                    boolean clusterActive = clusterActive(monitor);
-                    if (clusterActive) {
-                        if (log.isInfoEnabled()) {
-                            log.info("Publishing Cluster active event for [application]: "
-                                    + monitor.getAppId() + " [cluster]: " + clusterId);
-                        }
-                        ClusterStatusEventPublisher.sendClusterActivatedEvent(appId, monitor.getServiceId(), clusterId);
-                    }
-                }
-
-            }
-        };
-        Thread groupThread = new Thread(group);
-        groupThread.start();
-    }
-
-    /**
-     * This will calculate whether all the minimum of partition in a cluster satisfy in order
-     * to decide on the cluster status.
-     *
-     * @param monitor     Cluster monitor of which the status needs to be calculated
-     * @param partitionId partition which got the faulty member
-     * @return whether cluster inActive or not
-     */
-    private boolean getClusterInactive(VMClusterMonitor monitor, String partitionId) {
-        boolean clusterInActive = false;
-        for (NetworkPartitionContext networkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
-            for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) {
-                if (partitionId.equals(partition.getPartitionId()) &&
-                        partition.getActiveMemberCount() <= partition.getMinimumMemberCount()) {
-                    clusterInActive = true;
-                    return clusterInActive;
-                }
-            }
-
-        }
-        return clusterInActive;
-    }
-
-    /**
-     * This will use to calculate whether  all children of a particular component is active by traversing Top
-     *
-     * @param appId         application id
-     * @param idOfComponent id of the component to which calculate the status
-     * @param idOfChild     children of the component as groups
-     */
-    public void onChildStatusChange(String idOfChild, String idOfComponent, String appId, String instanceId) {
-        ParentComponent component;
-        Map<String, Group> groups;
-        Map<String, ClusterDataHolder> clusterData;
-
-        if (log.isInfoEnabled()) {
-            log.info("StatusChecker calculating the status for the group [ " + idOfChild + " ]");
-        }
-
-        try {
-            ApplicationHolder.acquireWriteLock();
-            if (idOfComponent.equals(appId)) {
-                //it is an application
-                component = ApplicationHolder.getApplications().
-                        getApplication(appId);
-            } else {
-                //it is a group
-                component = ApplicationHolder.getApplications().
-                        getApplication(appId).getGroupRecursively(idOfComponent);
-            }
-            groups = component.getAliasToGroupMap();
-            clusterData = component.getClusterDataMap();
-
-            if(component.isGroupScalingEnabled()) {
-                //TODO
-                handleStateWithGroupScalingEnabled();
-            } else {
-                handleStateChangeGroupScalingDisabled(component, appId, instanceId, groups, clusterData);
-            }
-        } finally {
-            ApplicationHolder.releaseWriteLock();
-
-        }
-
-    }
-
-    private void handleStateWithGroupScalingEnabled() {
-
-    }
-
-    private void handleStateChangeGroupScalingDisabled(ParentComponent component, String appId,
-                                                       String instanceId,
-                                                       Map<String, Group> groups,
-                                                       Map<String, ClusterDataHolder> clusterData) {
-        if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Active, instanceId) ||
-                clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active, instanceId) ||
-                getAllClusterInSameState(clusterData, ClusterStatus.Active, instanceId) &&
-                        getAllGroupInSameState(groups, GroupStatus.Active, instanceId)) {
-            //send activation event
-            if (component instanceof Application) {
-                //send application activated event
-                if (((Application) component).getStatus(null) != ApplicationStatus.Active) {
-                    log.info("sending app activate: " + appId);
-                    ApplicationBuilder.handleApplicationActivatedEvent(appId, instanceId);
-                }
-            } else if (component instanceof Group) {
-                //send activation to the parent
-                if (((Group) component).getStatus(null) != GroupStatus.Active) {
-                    log.info("sending group activate: " + component.getUniqueIdentifier());
-                    ApplicationBuilder.handleGroupActivatedEvent(appId, component.getUniqueIdentifier(), instanceId);
-                }
-            }
-        } else if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Terminated, instanceId) ||
-                clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Terminated, instanceId) ||
-                getAllClusterInSameState(clusterData, ClusterStatus.Terminated, instanceId) &&
-                        getAllGroupInSameState(groups, GroupStatus.Terminated, instanceId)) {
-            //send the terminated event
-            if (component instanceof Application) {
-                log.info("sending app terminated: " + appId);
-                ApplicationBuilder.handleApplicationTerminatedEvent(appId);
-            } else if (component instanceof Group) {
-                //send activation to the parent
-                if (((Group) component).getStatus(null) != GroupStatus.Terminated) {
-                    log.info("sending group terminated : " + component.getUniqueIdentifier());
-                    ApplicationBuilder.handleGroupTerminatedEvent(appId, component.getUniqueIdentifier(), instanceId);
-                }
-            }
-        } else if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Created, instanceId) ||
-                clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Created, instanceId) ||
-                getAllClusterInSameState(clusterData, ClusterStatus.Created, instanceId) &&
-                        getAllGroupInSameState(groups, GroupStatus.Created, instanceId)) {
-            if (component instanceof Application) {
-                log.info("[Application] " + appId + "couldn't change to Created, since it is" +
-                        "already in " + ((Application) component).getStatus(null).toString());
-            } else if (component instanceof Group) {
-                //send activation to the parent
-                if (((Group) component).getStatus(null) != GroupStatus.Created) {
-                    log.info("sending group created : " + component.getUniqueIdentifier());
-                    ApplicationBuilder.handleGroupCreatedEvent(appId, component.getUniqueIdentifier(), instanceId);
-                }
-            }
-        } else if (groups.isEmpty() && getAllClusterInactive(clusterData) ||
-                clusterData.isEmpty() && getAllGroupInActive(groups) ||
-                getAllClusterInactive(clusterData) || getAllGroupInActive(groups)) {
-            //send the in activation event
-            if (component instanceof Application) {
-                //send application activated event
-                log.warn("Application can't be in in-active : " + appId);
-                //StatusEventPublisher.sendApplicationInactivatedEvent(appId);
-            } else if (component instanceof Group) {
-                //send activation to the parent
-                if (((Group) component).getStatus(null) != GroupStatus.Inactive) {
-                    log.info("sending group in-active: " + component.getUniqueIdentifier());
-                    ApplicationBuilder.handleGroupInActivateEvent(appId, component.getUniqueIdentifier(), instanceId);
-                }
-            }
-        } else {
-            if (component instanceof Application) {
-                //send application activated event
-                log.warn("Application can't be in in-active : " + appId);
-                //StatusEventPublisher.sendApplicationInactivatedEvent(appId);
-            } else if (component instanceof Group) {
-                //send activation to the parent
-                if (((Group) component).getStatus(null) != GroupStatus.Inactive) {
-                    log.info("sending group in-active: " + component.getUniqueIdentifier());
-                    ApplicationBuilder.handleGroupInActivateEvent(appId, component.getUniqueIdentifier(), "test*****");
-                }
-            }
-        }
-    }
-
-    private boolean getAllInstancesOfGroupActive(Group group) {
-        int activeGroupInstances = 0;
-        for(GroupInstanceContext context : group.getInstanceIdToInstanceContextMap().values()) {
-            if(context.getStatus() == GroupStatus.Active) {
-                activeGroupInstances++;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Find out whether all the any group is inActive
-     *
-     * @param groups groups of a group/application
-     * @return whether inActive or not
-     */
-    private boolean getAllGroupInActive(Map<String, Group> groups) {
-        boolean groupStat = false;
-        for (Group group : groups.values()) {
-            if (group.getStatus(null) == GroupStatus.Inactive) {
-                groupStat = true;
-                return groupStat;
-            } else {
-                groupStat = false;
-            }
-        }
-        return groupStat;
-    }
-
-    /**
-     * Find out whether all the groups of a group in the same state or not
-     *
-     * @param groups groups of a group/application
-     * @param status the state to check in all groups
-     * @return whether groups in the given state or not
-     */
-    private boolean getAllGroupInSameState(Map<String, Group> groups, GroupStatus status, String instanceId) {
-        boolean groupStat = false;
-        for (Group group : groups.values()) {
-            GroupInstanceContext context = group.getInstanceContexts(instanceId);
-            if(context != null) {
-                if(context.getStatus() == status) {
-                    groupStat = true;
-                } else {
-                    groupStat = false;
-                    return groupStat;
-                }
-            } else {
-                groupStat = false;
-                return groupStat;
-            }
-        }
-        return groupStat;
-    }
-
-
-    /**
-     * Find out whether any of the clusters of a group in the InActive state
-     *
-     * @param clusterData clusters of the group
-     * @return whether inActive or not
-     */
-    private boolean getAllClusterInactive(Map<String, ClusterDataHolder> clusterData) {
-        boolean clusterStat = false;
-        for (Map.Entry<String, ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
-            Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType());
-            Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId());
-            if (cluster.getStatus(null) == ClusterStatus.Inactive) {
-                clusterStat = true;
-                return clusterStat;
-            } else {
-                clusterStat = false;
-
-            }
-        }
-        return clusterStat;
-    }
-
-    /**
-     * Find out whether all the clusters of a group are in the same state
-     *
-     * @param clusterData clusters of the group
-     * @param status      the status to check of the group
-     * @return whether all groups in the same state or not
-     */
-    private boolean getAllClusterInSameState(Map<String, ClusterDataHolder> clusterData,
-                                             ClusterStatus status, String instanceId) {
-        boolean clusterStat = false;
-        for (Map.Entry<String, ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
-            String serviceName = clusterDataHolderEntry.getValue().getServiceType();
-            String clusterId = clusterDataHolderEntry.getValue().getClusterId();
-            TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
-            try {
-                Service service = TopologyManager.getTopology().getService(serviceName);
-                Cluster cluster = service.getCluster(clusterId);
-                ClusterInstanceContext context = cluster.getInstanceContexts(instanceId);
-                if (context.getStatus() == status) {
-                    clusterStat = true;
-                } else {
-                    clusterStat = false;
-                    return clusterStat;
-                }
-            } finally {
-                TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
-            }
-
-        }
-        return clusterStat;
-    }
-
-    private static class Holder {
-        private static final StatusChecker INSTANCE = new StatusChecker();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessor.java
deleted file mode 100644
index d558620..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessor.java
+++ /dev/null
@@ -1,30 +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;
-
-/**
- * Created by reka on 11/25/14.
- */
-public abstract class StatusProcessor {
-    /**
-     * Link a message processor and its successor, if there's any.
-     * @param nextProcessor
-     */
-    public abstract void setNext(StatusProcessor nextProcessor);
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessorChain.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessorChain.java
deleted file mode 100644
index 3a2eefa..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusProcessorChain.java
+++ /dev/null
@@ -1,55 +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.messaging.listener.EventListener;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-
-import java.util.LinkedList;
-
-/**
- * This is the abstract class for the status checker
- */
-public abstract class StatusProcessorChain {
-    protected LinkedList<StatusProcessor> list;
-
-    public StatusProcessorChain() {
-        list = new LinkedList<StatusProcessor>();
-        initialize();
-    }
-
-    protected abstract void initialize();
-
-    public void add(StatusProcessor messageProcessor) {
-        if(list.size() > 0) {
-            list.getLast().setNext(messageProcessor);
-        }
-        list.add(messageProcessor);
-    }
-
-    public void removeLast() {
-        list.removeLast();
-        if(list.size() > 0) {
-            list.getLast().setNext(null);
-        }
-    }
-
-
-}
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusActiveProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusActiveProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusActiveProcessor.java
deleted file mode 100644
index 29e3f9a..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusActiveProcessor.java
+++ /dev/null
@@ -1,91 +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.cluster;
-
-import org.apache.commons.logging.Log;
-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.event.publisher.ClusterStatusEventPublisher;
-import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
-import org.apache.stratos.autoscaler.status.checker.StatusProcessor;
-
-/**
- * Cluster active status processor
- */
-public class ClusterStatusActiveProcessor extends ClusterStatusProcessor {
-    private static final Log log = LogFactory.getLog(ClusterStatusActiveProcessor.class);
-    private ClusterStatusProcessor nextProcessor;
-
-    @Override
-    public void setNext(StatusProcessor nextProcessor) {
-        this.nextProcessor = (ClusterStatusProcessor) nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String clusterId, String instanceId) {
-        boolean statusChanged;
-        if (type == null || (ClusterStatusActiveProcessor.class.getName().equals(type))) {
-            statusChanged = doProcess(clusterId, instanceId);
-            if (statusChanged) {
-                return statusChanged;
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, clusterId, instanceId);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using " +
-                                "available message processors: [type] %s [cluster] %s [instance]",
-                                type, clusterId, instanceId));
-            }
-        }
-       return false;
-    }
-
-    private boolean doProcess(String clusterId, String instanceId) {
-        VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().
-                                    getClusterMonitor(clusterId);
-        boolean clusterActive = false;
-        for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts(instanceId).values()) {
-            //minimum check per partition
-            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;
-                } else {
-                    return false;
-                }
-            }
-        }
-        if(clusterActive) {
-            if (log.isInfoEnabled()) {
-                log.info("Publishing Cluster activated event for [application]: "
-                        + monitor.getAppId() + " [cluster]: " + clusterId);
-            }
-            ClusterStatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
-                    monitor.getServiceId(), monitor.getClusterId());
-        }
-        return clusterActive;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusInActiveProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusInActiveProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusInActiveProcessor.java
deleted file mode 100644
index 9b60a9e..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusInActiveProcessor.java
+++ /dev/null
@@ -1,105 +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.cluster;
-
-import org.apache.commons.logging.Log;
-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.event.publisher.ClusterStatusEventPublisher;
-import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
-import org.apache.stratos.autoscaler.status.checker.StatusProcessor;
-
-/**
- * Cluster inActive checking processor
- */
-public class ClusterStatusInActiveProcessor extends ClusterStatusProcessor {
-    private static final Log log = LogFactory.getLog(ClusterStatusInActiveProcessor.class);
-    private ClusterStatusProcessor nextProcessor;
-
-    @Override
-    public void setNext(StatusProcessor nextProcessor) {
-        this.nextProcessor = (ClusterStatusProcessor) nextProcessor;
-    }
-    @Override
-    public boolean process(String type, String clusterId, String instanceId) {
-        boolean statusChanged;
-        if (type == null || (ClusterStatusInActiveProcessor.class.getName().equals(type))) {
-            statusChanged = doProcess(clusterId, instanceId);
-            if (statusChanged) {
-                return statusChanged;
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(type, clusterId, instanceId);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using " +
-                                "available message processors: [type] %s [cluster] %s [instance]",
-                        type, clusterId, instanceId));
-            }
-        }
-        return false;
-    }
-
-    private boolean doProcess(String clusterId, String instanceId) {
-        VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().
-                getClusterMonitor(clusterId);
-
-        boolean clusterInActive;
-        clusterInActive = getClusterInactive(monitor);
-        if(clusterInActive) {
-            //if the monitor is dependent, temporarily pausing it
-            if (monitor.hasStartupDependents()) {
-                monitor.setHasFaultyMember(true);
-            }
-            if (log.isInfoEnabled()) {
-                log.info("Publishing Cluster in-activate event for [application]: "
-                        + monitor.getAppId() + " [cluster]: " + clusterId);
-            }
-            //send cluster In-Active event to cluster status topic
-            ClusterStatusEventPublisher.sendClusterInActivateEvent(monitor.getAppId(),
-                    monitor.getServiceId(), clusterId, instanceId);
-        } else {
-            if (log.isInfoEnabled()) {
-                log.info("Publishing Cluster active event for [application]: "
-                        + monitor.getAppId() + " [cluster]: " + clusterId);
-            }
-            ClusterStatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
-                                                        monitor.getServiceId(), clusterId);
-        }
-        return clusterInActive;
-    }
-
-    private boolean getClusterInactive(VMClusterMonitor monitor) {
-        boolean clusterInActive = false;
-        for (NetworkPartitionContext networkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
-            for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) {
-                if (partition.getActiveMemberCount() <= partition.getMinimumMemberCount()) {
-                    clusterInActive = true;
-                    return clusterInActive;
-                }
-            }
-
-        }
-        return clusterInActive;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessor.java
deleted file mode 100644
index bf1637e..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessor.java
+++ /dev/null
@@ -1,34 +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.cluster;
-
-import org.apache.stratos.autoscaler.status.checker.StatusProcessor;
-
-/**
- * Created by reka on 11/25/14.
- */
-public abstract class ClusterStatusProcessor extends StatusProcessor {
-    /**
-     * Message processing and delegating logic.
-     * @param clusterId real message body.
-     * @param instanceId Object that will get updated.
-     * @return whether the processing was successful or not.
-     */
-    public abstract boolean process(String type, String clusterId, String instanceId);
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessorChain.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessorChain.java
deleted file mode 100644
index 2bacdd8..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusProcessorChain.java
+++ /dev/null
@@ -1,54 +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.cluster;
-
-import org.apache.stratos.autoscaler.status.checker.StatusProcessorChain;
-import org.apache.stratos.autoscaler.status.checker.group.GroupStatusProcessor;
-
-/**
- * Cluster status tracking processor chain
- */
-public class ClusterStatusProcessorChain extends StatusProcessorChain {
-    private ClusterStatusTerminatedProcessor clusterStatusTerminatedProcessor;
-    private ClusterStatusInActiveProcessor clusterStatusInActiveProcessor;
-    private ClusterStatusActiveProcessor clusterStatusActiveProcessor;
-
-    @Override
-    public void initialize() {
-        clusterStatusTerminatedProcessor = new ClusterStatusTerminatedProcessor();
-        add(clusterStatusTerminatedProcessor);
-
-        clusterStatusInActiveProcessor = new ClusterStatusInActiveProcessor();
-        add(clusterStatusInActiveProcessor);
-
-        clusterStatusActiveProcessor = new ClusterStatusActiveProcessor();
-        add(clusterStatusActiveProcessor);
-
-    }
-
-    public boolean process(String type, String clusterId, String instanceId) {
-        ClusterStatusProcessor root = (ClusterStatusProcessor) list.getFirst();
-        if (root == null) {
-            throw new RuntimeException("Message processor chain is not initialized");
-        }
-        return root.process(type, clusterId, instanceId);
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusTerminatedProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusTerminatedProcessor.java
deleted file mode 100644
index a2a6b13..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/cluster/ClusterStatusTerminatedProcessor.java
+++ /dev/null
@@ -1,135 +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.cluster;
-
-import org.apache.commons.logging.Log;
-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.applications.ApplicationHolder;
-import org.apache.stratos.autoscaler.event.publisher.ClusterStatusEventPublisher;
-import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
-import org.apache.stratos.autoscaler.status.checker.StatusProcessor;
-import org.apache.stratos.messaging.domain.applications.Application;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-
-/**
- * Cluster terminated checking processor.
- */
-public class ClusterStatusTerminatedProcessor extends ClusterStatusProcessor {
-    private static final Log log = LogFactory.getLog(ClusterStatusInActiveProcessor.class);
-    private ClusterStatusProcessor nextProcessor;
-
-    @Override
-    public void setNext(StatusProcessor nextProcessor) {
-        this.nextProcessor = (ClusterStatusProcessor) nextProcessor;
-    }
-
-    @Override
-    public boolean process(String type, String clusterId, String instanceId) {
-        boolean statusChanged;
-        if (type == null || (ClusterStatusTerminatedProcessor.class.getName().equals(type))) {
-            statusChanged = doProcess(clusterId, instanceId);
-            if (statusChanged) {
-                return statusChanged;
-            }
-
-        } else {
-            if (nextProcessor != null) {
-                // ask the next processor to take care of the message.
-                return nextProcessor.process(null, clusterId, instanceId);
-            } else {
-                throw new RuntimeException(String.format("Failed to process message using " +
-                                "available message processors: [type] %s [cluster] %s [instance]",
-                        type, clusterId, instanceId));
-            }
-        }
-        return false;
-    }
-
-    private boolean doProcess(String clusterId, String instanceId) {
-        VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().
-                getClusterMonitor(clusterId);
-        boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
-        boolean clusterTerminated = false;
-        try {
-            TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
-            Service service = TopologyManager.getTopology().getService(monitor.getServiceId());
-            Cluster cluster;
-            String appId = monitor.getAppId();
-            if (service != null) {
-                cluster = service.getCluster(monitor.getClusterId());
-                if (cluster != null) {
-                    try {
-                        ApplicationHolder.acquireReadLock();
-                        Application application = ApplicationHolder.getApplications().getApplication(appId);
-                        //if all members removed from the cluster and cluster is in terminating,
-                        // either it has to be terminated or Reset
-                        if (!clusterMonitorHasMembers && cluster.getStatus(null) == ClusterStatus.Terminating) {
-                            if (log.isInfoEnabled()) {
-                                log.info("Publishing Cluster terminated event for [application]: " + appId +
-                                        " [cluster]: " + clusterId);
-                            }
-                            ClusterStatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(),
-                                    monitor.getClusterId(), instanceId);
-                            clusterTerminated = true;
-
-                        } else {
-                            log.info("Cluster has non terminated [members] and in the [status] "
-                                    + cluster.getInstanceContexts(instanceId).getStatus().toString());
-                        }
-                    } finally {
-                        ApplicationHolder.releaseReadLock();
-                    }
-                }
-            }
-
-
-        } finally {
-            TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
-
-        }
-        return clusterTerminated;
-    }
-
-    /**
-     * Find out whether cluster monitor has any non terminated members
-     *
-     * @param monitor the cluster monitor
-     * @return whether has members or not
-     */
-    private boolean clusterMonitorHasMembers(VMClusterMonitor monitor) {
-        boolean hasMember = false;
-        for (NetworkPartitionContext networkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
-            //minimum check per partition
-            for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) {
-                if (partitionContext.getNonTerminatedMemberCount() > 0) {
-                    hasMember = true;
-                } else {
-                    hasMember = false;
-                }
-            }
-        }
-        return hasMember;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/48595f1a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/group/GroupStatusActiveProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/group/GroupStatusActiveProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/group/GroupStatusActiveProcessor.java
deleted file mode 100644
index aa65bc6..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/group/GroupStatusActiveProcessor.java
+++ /dev/null
@@ -1,119 +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.group;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.applications.ApplicationHolder;
-import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
-import org.apache.stratos.autoscaler.status.checker.StatusProcessor;
-import org.apache.stratos.messaging.domain.applications.*;
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-
-import java.util.Map;
-
-/**
- * Cluster active status processor
- */
-public class GroupStatusActiveProcessor extends GroupStatusProcessor {
-    private static final Log log = LogFactory.getLog(GroupStatusActiveProcessor.class);
-    private GroupStatusProcessor nextProcessor;
-
-    @Override
-    public void setNext(StatusProcessor nextProcessor) {
-        this.nextProcessor = (GroupStatusProcessor) nextProcessor;
-    }
-
-    @Override
-    public boolean process(String idOfChild, String idOfComponent, String appId,
-                           String instanceId) {
-        boolean statusChanged;
-        statusChanged = doProcess(idOfChild, idOfComponent, appId, instanceId);
-        if (statusChanged) {
-            return statusChanged;
-        }
-
-        if (nextProcessor != null) {
-            // ask the next processor to take care of the message.
-            return nextProcessor.process(idOfChild, idOfComponent, appId, instanceId);
-        } else {
-            throw new RuntimeException(String.format("Failed to process message using " +
-                            "available message processors: [component] %s [instance]",
-                    idOfComponent, instanceId));
-        }
-    }
-
-
-    private boolean doProcess(String idOfChild, String idOfComponent, String appId, String instanceId) {
-        ParentComponent component;
-        Map<String, Group> groups;
-        Map<String, ClusterDataHolder> clusterData;
-
-        if (log.isInfoEnabled()) {
-            log.info("StatusChecker calculating the status for the group [ " + idOfChild + " ]");
-        }
-
-        try {
-            ApplicationHolder.acquireWriteLock();
-            if (idOfComponent.equals(appId)) {
-                //it is an application
-                component = ApplicationHolder.getApplications().
-                        getApplication(appId);
-            } else {
-                //it is a group
-                component = ApplicationHolder.getApplications().
-                        getApplication(appId).getGroupRecursively(idOfComponent);
-            }
-            //finding all the children of the application/group
-            groups = component.getAliasToGroupMap();
-            clusterData = component.getClusterDataMap();
-
-            if (component.isGroupScalingEnabled()) {
-
-            } else {
-                if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Active, instanceId) ||
-                        clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active, instanceId) ||
-                        getAllClusterInSameState(clusterData, ClusterStatus.Active, instanceId) &&
-                                getAllGroupInSameState(groups, GroupStatus.Active, instanceId)) {
-                    //send activation event
-                    if (component instanceof Application) {
-                        //send application activated event
-                        log.info("sending app activate: " + appId);
-                        ApplicationBuilder.handleApplicationActivatedEvent(appId, instanceId);
-                    } else if (component instanceof Group) {
-                        //send activation to the parent
-                        log.info("sending group activate: " + component.getUniqueIdentifier());
-                        ApplicationBuilder.handleGroupActivatedEvent(appId, component.getUniqueIdentifier(), instanceId);
-                    }
-
-                }
-            }
-
-
-        } finally {
-            ApplicationHolder.releaseWriteLock();
-
-        }
-
-
-        return true;
-    }
-
-
-}