You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/11/14 15:06:45 UTC

stratos git commit: Rename Application child contexts

Repository: stratos
Updated Branches:
  refs/heads/master baa307d40 -> a261fc948


Rename Application child contexts


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

Branch: refs/heads/master
Commit: a261fc948bd5b019f021179160ae95badd21c2d9
Parents: baa307d
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Fri Nov 14 19:31:11 2014 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Fri Nov 14 19:31:11 2014 +0530

----------------------------------------------------------------------
 .../dependency/DependencyBuilder.java           |  21 ++--
 .../applications/dependency/DependencyTree.java |  74 +++++------
 .../context/ApplicationChildContext.java        | 123 +++++++++++++++++++
 .../context/ApplicationChildContextFactory.java | 101 +++++++++++++++
 .../dependency/context/ApplicationContext.java  | 123 -------------------
 .../context/ApplicationContextFactory.java      | 101 ---------------
 .../dependency/context/ClusterChildContext.java |  38 ++++++
 .../dependency/context/ClusterContext.java      |  38 ------
 .../dependency/context/GroupChildContext.java   |  25 ++++
 .../dependency/context/GroupContext.java        |  25 ----
 .../monitor/ParentComponentMonitor.java         |  36 +++---
 .../application/ApplicationMonitorFactory.java  |  18 +--
 12 files changed, 361 insertions(+), 362 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java
index 17365a7..9049a5c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java
@@ -21,9 +21,9 @@ package org.apache.stratos.autoscaler.applications.dependency;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.*;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationChildContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationChildContextFactory;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
-import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
-import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContextFactory;
 import org.apache.stratos.messaging.domain.applications.*;
 
 import java.util.Set;
@@ -78,8 +78,8 @@ public class DependencyBuilder {
 
             //Parsing the start up order
             Set<StartupOrder> startupOrders = dependencyOrder.getStartupOrders();
-            ApplicationContext foundContext;
-            ApplicationContext parentContext;
+            ApplicationChildContext foundContext;
+            ApplicationChildContext parentContext;
 
             if (startupOrders != null) {
                 for (StartupOrder startupOrder : startupOrders) {
@@ -88,11 +88,11 @@ public class DependencyBuilder {
                     for (String startupOrderComponent : startupOrder.getStartupOrderComponentList()) {
 
                         if (startupOrderComponent != null) {
-                            ApplicationContext applicationContext = ApplicationContextFactory.
+                            ApplicationChildContext applicationContext = ApplicationChildContextFactory.
                                     getApplicationContext(startupOrderComponent, component, dependencyTree);
                             String id = applicationContext.getId();
 
-                            ApplicationContext existingApplicationContext =
+                            ApplicationChildContext existingApplicationContext =
                                     dependencyTree.findApplicationContextWithIdInPrimaryTree(id);
                             if (existingApplicationContext == null) {
                                 if (parentContext != null) {
@@ -158,10 +158,10 @@ public class DependencyBuilder {
                             }
 
                             if(applicationContextId != null) {
-                                ApplicationContext applicationContext
+                                ApplicationChildContext applicationContext
                                          = dependencyTree.findApplicationContextWithIdInPrimaryTree(applicationContextId);
 
-                                ApplicationContext existingApplicationContext =
+                                ApplicationChildContext existingApplicationContext =
                                         dependencyTree.findApplicationContextWithIdInScalingDependencyTree(applicationContextId);
                                 if (existingApplicationContext == null) {
 
@@ -200,14 +200,13 @@ public class DependencyBuilder {
         // as they can start in parallel.
         for (Group group1 : component.getAliasToGroupMap().values()) {
             if (dependencyTree.findApplicationContextWithIdInPrimaryTree(group1.getAlias()) == null) {
-                ApplicationContext context = ApplicationContextFactory.
-                        getGroupContext(group1.getAlias(), dependencyTree.isTerminateDependent());
+                ApplicationChildContext context = ApplicationChildContextFactory.getGroupChildContext(group1.getAlias(), dependencyTree.isTerminateDependent());
                 dependencyTree.addPrimaryApplicationContext(context);
             }
         }
         for (ClusterDataHolder dataHolder : component.getClusterDataMap().values()) {
             if (dependencyTree.findApplicationContextWithIdInPrimaryTree(dataHolder.getClusterId()) == null) {
-                ApplicationContext context = ApplicationContextFactory.getClusterContext(dataHolder,
+                ApplicationChildContext context = ApplicationChildContextFactory.getClusterChildContext(dataHolder,
                         dependencyTree.isTerminateDependent());
                 dependencyTree.addPrimaryApplicationContext(context);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java
index 7cdf431..56efa9a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java
@@ -20,7 +20,7 @@ package org.apache.stratos.autoscaler.applications.dependency;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationChildContext;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -31,9 +31,9 @@ import java.util.List;
 public class DependencyTree {
     private static final Log log = LogFactory.getLog(DependencyTree.class);
 
-    private List<ApplicationContext> primaryApplicationContextList;
+    private List<ApplicationChildContext> primaryApplicationContextList;
 
-    private List<ApplicationContext> scalingDependencyApplicationContextList;
+    private List<ApplicationChildContext> scalingDependencyApplicationContextList;
 
     private boolean started;
 
@@ -48,27 +48,27 @@ public class DependencyTree {
     private String id;
 
     public DependencyTree(String id) {
-        primaryApplicationContextList = new ArrayList<ApplicationContext>();
+        primaryApplicationContextList = new ArrayList<ApplicationChildContext>();
         this.setId(id);
         if (log.isDebugEnabled()) {
             log.debug("Starting a dependency tree for the [group/application] " + id);
         }
     }
 
-    public List<ApplicationContext> getPrimaryApplicationContextList() {
+    public List<ApplicationChildContext> getPrimaryApplicationContextList() {
         return primaryApplicationContextList;
     }
 
-    public void setPrimaryApplicationContextList(List<ApplicationContext> primaryApplicationContextList) {
+    public void setPrimaryApplicationContextList(List<ApplicationChildContext> primaryApplicationContextList) {
         this.primaryApplicationContextList = primaryApplicationContextList;
     }
 
-    public void addPrimaryApplicationContext(ApplicationContext applicationContext) {
+    public void addPrimaryApplicationContext(ApplicationChildContext applicationContext) {
         primaryApplicationContextList.add(applicationContext);
 
     }
 
-    public void addScalingApplicationContext(ApplicationContext applicationContext) {
+    public void addScalingApplicationContext(ApplicationChildContext applicationContext) {
         scalingDependencyApplicationContextList.add(applicationContext);
 
     }
@@ -79,7 +79,7 @@ public class DependencyTree {
      * @param id the alias/id of group/cluster
      * @return ApplicationContext of the given id
      */
-    public ApplicationContext findApplicationContextWithIdInPrimaryTree(String id) {
+    public ApplicationChildContext findApplicationContextWithIdInPrimaryTree(String id) {
         return findApplicationContextWithId(id, primaryApplicationContextList);
     }
 
@@ -89,7 +89,7 @@ public class DependencyTree {
      * @param id the alias/id of group/cluster
      * @return ApplicationContext of the given id
      */
-    public ApplicationContext findApplicationContextWithIdInScalingDependencyTree(String id) {
+    public ApplicationChildContext findApplicationContextWithIdInScalingDependencyTree(String id) {
         return findApplicationContextWithId(id, scalingDependencyApplicationContextList);
     }
 
@@ -100,31 +100,31 @@ public class DependencyTree {
      * @param contexts the list of contexts in the same level of the tree
      * @return ApplicationContext of the given id
      */
-    private ApplicationContext findApplicationContextWithId(String id, List<ApplicationContext> contexts) {
-        for (ApplicationContext context : contexts) {
+    private ApplicationChildContext findApplicationContextWithId(String id, List<ApplicationChildContext> contexts) {
+        for (ApplicationChildContext context : contexts) {
             //TODO check for the status
             if (context.getId().equals(id)) {
                 return context;
             }
         }
         //if not found in the top level search recursively
-        for (ApplicationContext context : contexts) {
+        for (ApplicationChildContext context : contexts) {
             return findApplicationContextWithId(id, context.getApplicationContextList());
         }
         return null;
     }
 
-    public ApplicationContext findParentContextWithId(String id) {
+    public ApplicationChildContext findParentContextWithId(String id) {
         return findParentContextWithId(null, id, this.primaryApplicationContextList);
     }
 
-    public List<ApplicationContext> findAllParentContextWithId(String id) {
-        List<ApplicationContext> applicationContexts = new ArrayList<ApplicationContext>();
+    public List<ApplicationChildContext> findAllParentContextWithId(String id) {
+        List<ApplicationChildContext> applicationContexts = new ArrayList<ApplicationChildContext>();
         return findAllParent(applicationContexts, id);
     }
 
-    private List<ApplicationContext> findAllParent(List<ApplicationContext> parentContexts, String id) {
-        ApplicationContext context = findParentContextWithId(null, id, this.primaryApplicationContextList);
+    private List<ApplicationChildContext> findAllParent(List<ApplicationChildContext> parentContexts, String id) {
+        ApplicationChildContext context = findParentContextWithId(null, id, this.primaryApplicationContextList);
         if (context != null) {
             parentContexts.add(context);
             findAllParent(parentContexts, context.getId());
@@ -133,16 +133,16 @@ public class DependencyTree {
     }
 
 
-    private ApplicationContext findParentContextWithId(ApplicationContext parent, String id,
-                                                       List<ApplicationContext> contexts) {
-        for (ApplicationContext context : contexts) {
+    private ApplicationChildContext findParentContextWithId(ApplicationChildContext parent, String id,
+                                                       List<ApplicationChildContext> contexts) {
+        for (ApplicationChildContext context : contexts) {
             //TODO check for the status
             if (context.getId().equals(id)) {
                 return parent;
             }
         }
         //if not found in the top level search recursively
-        for (ApplicationContext context : this.primaryApplicationContextList) {
+        for (ApplicationChildContext context : this.primaryApplicationContextList) {
             return findParentContextWithId(context, id, context.getApplicationContextList());
         }
         return null;
@@ -155,10 +155,10 @@ public class DependencyTree {
      * @param id the alias/id of group/cluster which received the activated event.
      * @return list of dependencies
      */
-    public List<ApplicationContext> getStarAbleDependencies(String id) {
+    public List<ApplicationChildContext> getStarAbleDependencies(String id) {
         //finding the application context which received the activated event and
         // returning it's immediate children as the dependencies.
-        ApplicationContext context = findApplicationContextWithIdInPrimaryTree(id);
+        ApplicationChildContext context = findApplicationContextWithIdInPrimaryTree(id);
         return context.getApplicationContextList();
     }
 
@@ -167,25 +167,25 @@ public class DependencyTree {
      *
      * @return list of dependencies
      */
-    public List<ApplicationContext> getStarAbleDependencies() {
+    public List<ApplicationChildContext> getStarAbleDependencies() {
         //returning the top level as the monitor is in initializing state
         return this.primaryApplicationContextList;
     }
 
-    public List<ApplicationContext> getStarAbleDependenciesByTermination() {
+    public List<ApplicationChildContext> getStarAbleDependenciesByTermination() {
         //Breadth First search over the graph to find out which level has the terminated contexts
         return traverseGraphByLevel(this.primaryApplicationContextList);
     }
 
 
-    private List<ApplicationContext> traverseGraphByLevel(List<ApplicationContext> contexts) {
-        for(ApplicationContext context : contexts) {
+    private List<ApplicationChildContext> traverseGraphByLevel(List<ApplicationChildContext> contexts) {
+        for(ApplicationChildContext context : contexts) {
             if(context.isTerminated()) {
                 return contexts;
             }
         }
 
-        for(ApplicationContext context : contexts) {
+        for(ApplicationChildContext context : contexts) {
             return traverseGraphByLevel(context.getApplicationContextList());
         }
         return null;
@@ -200,9 +200,9 @@ public class DependencyTree {
      * @param id the alias/id of group/cluster in which terminated event received
      * @return all the kill able children dependencies
      */
-    public List<ApplicationContext> getTerminationDependencies(String id) {
-        List<ApplicationContext> allChildrenOfAppContext = new ArrayList<ApplicationContext>();
-        ApplicationContext applicationContext = findApplicationContextWithIdInPrimaryTree(id);
+    public List<ApplicationChildContext> getTerminationDependencies(String id) {
+        List<ApplicationChildContext> allChildrenOfAppContext = new ArrayList<ApplicationChildContext>();
+        ApplicationChildContext applicationContext = findApplicationContextWithIdInPrimaryTree(id);
         //adding the terminated one to the list
         allChildrenOfAppContext.add(applicationContext);
         if (terminationBehavior == TerminationBehavior.TERMINATE_DEPENDENT) {
@@ -228,9 +228,9 @@ public class DependencyTree {
      * @param childContexts       contains the children of the node
      * @return all the children of the given node
      */
-    public List<ApplicationContext> findAllChildrenOfAppContext(List<ApplicationContext> applicationContexts,
-                                                                List<ApplicationContext> childContexts) {
-        for (ApplicationContext context : applicationContexts) {
+    public List<ApplicationChildContext> findAllChildrenOfAppContext(List<ApplicationChildContext> applicationContexts,
+                                                                List<ApplicationChildContext> childContexts) {
+        for (ApplicationChildContext context : applicationContexts) {
             childContexts.add(context);
             findAllChildrenOfAppContext(context.getApplicationContextList(), childContexts);
         }
@@ -249,11 +249,11 @@ public class DependencyTree {
         return this.terminationBehavior == TerminationBehavior.TERMINATE_ALL;
     }
 
-    public List<ApplicationContext> getScalingDependencyApplicationContextList() {
+    public List<ApplicationChildContext> getScalingDependencyApplicationContextList() {
         return scalingDependencyApplicationContextList;
     }
 
-    public void setScalingDependencyApplicationContextList(List<ApplicationContext> scalingDependencyApplicationContextList) {
+    public void setScalingDependencyApplicationContextList(List<ApplicationChildContext> scalingDependencyApplicationContextList) {
         this.scalingDependencyApplicationContextList = scalingDependencyApplicationContextList;
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContext.java
new file mode 100644
index 0000000..81ac279
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContext.java
@@ -0,0 +1,123 @@
+/*
+ * 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.applications.dependency.context;
+
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * This is to keep track of the group/cluster status and their dependencies
+ */
+public abstract class ApplicationChildContext {
+    private List<ApplicationChildContext> applicationContextList;
+
+    private String id;
+    protected boolean started;
+    private boolean terminated;
+
+    private ClusterStatus status;
+
+    private Stack<ClusterStatus> statusLifeCycle;
+
+    protected boolean hasStartupDependents;
+    
+    protected boolean hasScalingDependents;
+
+    public ApplicationChildContext(String id, boolean killDependent) {
+        applicationContextList = new ArrayList<ApplicationChildContext>();
+        statusLifeCycle = new Stack<ClusterStatus>();
+        this.setHasStartupDependents(killDependent);
+        this.id = id;
+    }
+
+    public List<ApplicationChildContext> getApplicationContextList() {
+        return applicationContextList;
+    }
+
+    public void setApplicationContextList(List<ApplicationChildContext> applicationContextList) {
+        this.applicationContextList = applicationContextList;
+    }
+
+    public void addApplicationContext(ApplicationChildContext applicationContext) {
+        applicationContextList.add(applicationContext);
+
+    }
+
+    public void addStatusToLIfeCycle(ClusterStatus status) {
+       this.statusLifeCycle.push(status);
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public ClusterStatus getCurrentStatus() {
+        return status;
+    }
+
+    public void setCurrentStatus(ClusterStatus status) {
+        this.status = status;
+    }
+
+    public List<ClusterStatus> getStatusLifeCycle() {
+        return statusLifeCycle;
+    }
+
+    public boolean hasChild() {
+        boolean hasChild;
+        if(this.applicationContextList.isEmpty()) {
+            hasChild = false;
+        } else {
+            hasChild = true;
+        }
+        return hasChild;
+    }
+
+
+    public boolean isTerminated() {
+        return terminated;
+    }
+
+    public void setTerminated(boolean terminated) {
+        this.terminated = terminated;
+    }
+
+    public boolean hasStartupDependents() {
+        return hasStartupDependents;
+    }
+
+    public void setHasStartupDependents(boolean isDependent) {
+        this.hasStartupDependents = isDependent;
+    }
+
+    public boolean hasScalingDependents() {
+        return hasScalingDependents;
+    }
+
+    public void setHasScalingDependents(boolean isDependent) {
+        this.hasScalingDependents = isDependent;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContextFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContextFactory.java
new file mode 100644
index 0000000..c08d190
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationChildContextFactory.java
@@ -0,0 +1,101 @@
+/*
+ * 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.applications.dependency.context;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.Constants;
+import org.apache.stratos.autoscaler.applications.dependency.DependencyTree;
+import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.applications.ParentComponent;
+
+/**
+ * Factory to create new GroupChildContext or ClusterChildContext
+ */
+public class ApplicationChildContextFactory {
+    private static final Log log = LogFactory.getLog(ApplicationChildContextFactory.class);
+
+    /**
+     * Will return the GroupChildContext/ClusterChildContext based on the type in start order/scaling order
+     *
+     * @param order      reference of group/cluster in the start/scaling order
+     * @param component       The component which used to build the dependency
+     * @param tree kill dependent behaviour of this component
+     * @return Context
+     */
+    public static ApplicationChildContext getApplicationContext(String order,
+                                                           ParentComponent component,
+                                                           DependencyTree tree) {
+        String id;
+        ApplicationChildContext applicationContext = null;
+        boolean hasDependents = tree.isTerminateDependent() || tree.isTerminateAll();
+        if (order.startsWith(Constants.GROUP + ".")) {
+            //getting the group alias
+            id = getGroupFromStartupOrder(order);
+            applicationContext = getGroupChildContext(id, hasDependents);
+        } else if (order.startsWith(Constants.CARTRIDGE + ".")) {
+            //getting the cluster alias
+            id = getClusterFromStartupOrder(order);
+            //getting the cluster-id from cluster alias
+            ClusterDataHolder clusterDataHolder = component.getClusterDataMap().get(id);
+            applicationContext = getClusterChildContext(clusterDataHolder, hasDependents);
+
+        } else {
+            log.warn("[Startup Order]: " + order + " contains unknown reference");
+        }
+        return applicationContext;
+
+    }
+
+    /**
+     * Utility method to get the group alias from the startup order Eg: group.mygroup
+     *
+     * @param startupOrder startup order
+     * @return group alias
+     */
+    public static String getGroupFromStartupOrder(String startupOrder) {
+        return startupOrder.substring(Constants.GROUP.length() + 1);
+    }
+
+    /**
+     * Utility method to get the cluster alias from startup order Eg: cartridge.myphp
+     *
+     * @param startupOrder startup order
+     * @return cluster alias
+     */
+    public static String getClusterFromStartupOrder(String startupOrder) {
+        return startupOrder.substring(Constants.CARTRIDGE.length() + 1);
+    }
+
+    public static ApplicationChildContext getClusterChildContext(ClusterDataHolder dataHolder,
+                                                       boolean isKillDependent) {
+        ApplicationChildContext applicationContext;
+        applicationContext = new ClusterChildContext(dataHolder.getClusterId(),
+                isKillDependent);
+        ((ClusterChildContext) applicationContext).setServiceName(dataHolder.getServiceType());
+        return  applicationContext;
+    }
+
+    public static ApplicationChildContext getGroupChildContext(String id, boolean isDependent) {
+        ApplicationChildContext applicationContext;
+        applicationContext = new GroupChildContext(id,
+                isDependent);
+        return applicationContext;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java
deleted file mode 100644
index 1e2813c..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java
+++ /dev/null
@@ -1,123 +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.applications.dependency.context;
-
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-/**
- * This is to keep track of the group/cluster status and their dependencies
- */
-public abstract class ApplicationContext {
-    private List<ApplicationContext> applicationContextList;
-
-    private String id;
-    protected boolean started;
-    private boolean terminated;
-
-    private ClusterStatus status;
-
-    private Stack<ClusterStatus> statusLifeCycle;
-
-    protected boolean hasStartupDependents;
-    
-    protected boolean hasScalingDependents;
-
-    public ApplicationContext(String id, boolean killDependent) {
-        applicationContextList = new ArrayList<ApplicationContext>();
-        statusLifeCycle = new Stack<ClusterStatus>();
-        this.setHasStartupDependents(killDependent);
-        this.id = id;
-    }
-
-    public List<ApplicationContext> getApplicationContextList() {
-        return applicationContextList;
-    }
-
-    public void setApplicationContextList(List<ApplicationContext> applicationContextList) {
-        this.applicationContextList = applicationContextList;
-    }
-
-    public void addApplicationContext(ApplicationContext applicationContext) {
-        applicationContextList.add(applicationContext);
-
-    }
-
-    public void addStatusToLIfeCycle(ClusterStatus status) {
-       this.statusLifeCycle.push(status);
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public ClusterStatus getCurrentStatus() {
-        return status;
-    }
-
-    public void setCurrentStatus(ClusterStatus status) {
-        this.status = status;
-    }
-
-    public List<ClusterStatus> getStatusLifeCycle() {
-        return statusLifeCycle;
-    }
-
-    public boolean hasChild() {
-        boolean hasChild;
-        if(this.applicationContextList.isEmpty()) {
-            hasChild = false;
-        } else {
-            hasChild = true;
-        }
-        return hasChild;
-    }
-
-
-    public boolean isTerminated() {
-        return terminated;
-    }
-
-    public void setTerminated(boolean terminated) {
-        this.terminated = terminated;
-    }
-
-    public boolean hasStartupDependents() {
-        return hasStartupDependents;
-    }
-
-    public void setHasStartupDependents(boolean isDependent) {
-        this.hasStartupDependents = isDependent;
-    }
-
-    public boolean hasScalingDependents() {
-        return hasScalingDependents;
-    }
-
-    public void setHasScalingDependents(boolean isDependent) {
-        this.hasScalingDependents = isDependent;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java
deleted file mode 100644
index c1da1cc..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java
+++ /dev/null
@@ -1,101 +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.applications.dependency.context;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.Constants;
-import org.apache.stratos.autoscaler.applications.dependency.DependencyTree;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.applications.ParentComponent;
-
-/**
- * Factory to create new GroupContext or ClusterContext
- */
-public class ApplicationContextFactory {
-    private static final Log log = LogFactory.getLog(ApplicationContextFactory.class);
-
-    /**
-     * Will return the GroupContext/ClusterContext based on the type in start order/scaling order
-     *
-     * @param order      reference of group/cluster in the start/scaling order
-     * @param component       The component which used to build the dependency
-     * @param tree kill dependent behaviour of this component
-     * @return Context
-     */
-    public static ApplicationContext getApplicationContext(String order,
-                                                           ParentComponent component,
-                                                           DependencyTree tree) {
-        String id;
-        ApplicationContext applicationContext = null;
-        boolean hasDependents = tree.isTerminateDependent() || tree.isTerminateAll();
-        if (order.startsWith(Constants.GROUP + ".")) {
-            //getting the group alias
-            id = getGroupFromStartupOrder(order);
-            applicationContext = getGroupContext(id, hasDependents);
-        } else if (order.startsWith(Constants.CARTRIDGE + ".")) {
-            //getting the cluster alias
-            id = getClusterFromStartupOrder(order);
-            //getting the cluster-id from cluster alias
-            ClusterDataHolder clusterDataHolder = component.getClusterDataMap().get(id);
-            applicationContext = getClusterContext(clusterDataHolder, hasDependents);
-
-        } else {
-            log.warn("[Startup Order]: " + order + " contains unknown reference");
-        }
-        return applicationContext;
-
-    }
-
-    /**
-     * Utility method to get the group alias from the startup order Eg: group.mygroup
-     *
-     * @param startupOrder startup order
-     * @return group alias
-     */
-    public static String getGroupFromStartupOrder(String startupOrder) {
-        return startupOrder.substring(Constants.GROUP.length() + 1);
-    }
-
-    /**
-     * Utility method to get the cluster alias from startup order Eg: cartridge.myphp
-     *
-     * @param startupOrder startup order
-     * @return cluster alias
-     */
-    public static String getClusterFromStartupOrder(String startupOrder) {
-        return startupOrder.substring(Constants.CARTRIDGE.length() + 1);
-    }
-
-    public static ApplicationContext getClusterContext(ClusterDataHolder dataHolder,
-                                                       boolean isKillDependent) {
-        ApplicationContext applicationContext;
-        applicationContext = new ClusterContext(dataHolder.getClusterId(),
-                isKillDependent);
-        ((ClusterContext) applicationContext).setServiceName(dataHolder.getServiceType());
-        return  applicationContext;
-    }
-
-    public static ApplicationContext getGroupContext(String id, boolean isDependent) {
-        ApplicationContext applicationContext;
-        applicationContext = new GroupContext(id,
-                isDependent);
-        return applicationContext;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterChildContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterChildContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterChildContext.java
new file mode 100644
index 0000000..39d2d91
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterChildContext.java
@@ -0,0 +1,38 @@
+/*
+ * 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.applications.dependency.context;
+
+/**
+ * ClusterContext to keep cluster level context information
+ */
+public class ClusterChildContext extends ApplicationChildContext {
+    private String serviceName;
+
+    public ClusterChildContext(String id, boolean killDependent) {
+        super(id ,killDependent);
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java
deleted file mode 100644
index 6de38d4..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java
+++ /dev/null
@@ -1,38 +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.applications.dependency.context;
-
-/**
- * ClusterContext to keep cluster level context information
- */
-public class ClusterContext extends ApplicationContext {
-    private String serviceName;
-
-    public ClusterContext(String id, boolean killDependent) {
-        super(id ,killDependent);
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupChildContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupChildContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupChildContext.java
new file mode 100644
index 0000000..d681d00
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupChildContext.java
@@ -0,0 +1,25 @@
+/*
+ * 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.applications.dependency.context;
+
+public class GroupChildContext extends ApplicationChildContext {
+    public GroupChildContext(String id, boolean killDependent) {
+        super(id ,killDependent);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java
deleted file mode 100644
index 3f546c5..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java
+++ /dev/null
@@ -1,25 +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.applications.dependency.context;
-
-public class GroupContext extends ApplicationContext {
-    public GroupContext(String id, boolean killDependent) {
-        super(id ,killDependent);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/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 25fed07..1e536a6 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
@@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.applications.dependency.DependencyBuilder;
 import org.apache.stratos.autoscaler.applications.dependency.DependencyTree;
-import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationChildContext;
 import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
 import org.apache.stratos.autoscaler.event.publisher.ClusterStatusEventPublisher;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
@@ -125,7 +125,7 @@ public abstract class ParentComponentMonitor extends Monitor {
      * @param eventId
      */
     protected void onChildInactiveEvent(String eventId) {
-        List<ApplicationContext> terminationList;
+        List<ApplicationChildContext> terminationList;
         Monitor monitor;
 
         if (this.hasDependent) {
@@ -149,7 +149,7 @@ public abstract class ParentComponentMonitor extends Monitor {
 
                 if (terminationList != null) {
                     //Checking the termination dependents status
-                    for (ApplicationContext terminationContext : terminationList) {
+                    for (ApplicationChildContext terminationContext : terminationList) {
                         //Check whether dependent is in_active, then start to kill it
                         monitor = this.aliasToActiveMonitorsMap.
                                 get(terminationContext.getId());
@@ -182,10 +182,10 @@ public abstract class ParentComponentMonitor extends Monitor {
     }
 
     protected void onChildTerminatedEvent(String eventId) {
-        List<ApplicationContext> terminationList;
+        List<ApplicationChildContext> terminationList;
         boolean allDependentTerminated = false;
 
-        ApplicationContext context = this.startupDependencyTree.findApplicationContextWithIdInPrimaryTree(eventId);
+        ApplicationChildContext context = this.startupDependencyTree.findApplicationContextWithIdInPrimaryTree(eventId);
         context.setTerminated(true);
 
         terminationList = this.startupDependencyTree.getTerminationDependencies(eventId);
@@ -198,7 +198,7 @@ public abstract class ParentComponentMonitor extends Monitor {
             allDependentTerminated = allDependentTerminated(terminationList);
         }
 
-        List<ApplicationContext> parentContexts = this.startupDependencyTree.findAllParentContextWithId(eventId);
+        List<ApplicationChildContext> parentContexts = this.startupDependencyTree.findAllParentContextWithId(eventId);
         boolean parentsTerminated = false;
         if (parentContexts != null) {
             parentsTerminated = allParentTerminated(parentContexts);
@@ -222,9 +222,9 @@ public abstract class ParentComponentMonitor extends Monitor {
 
     }
 
-    private boolean allDependentTerminated(List<ApplicationContext> terminationList) {
+    private boolean allDependentTerminated(List<ApplicationChildContext> terminationList) {
         boolean allDependentTerminated = false;
-        for (ApplicationContext context1 : terminationList) {
+        for (ApplicationChildContext context1 : terminationList) {
             if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
                 log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state");
                 allDependentTerminated = false;
@@ -241,9 +241,9 @@ public abstract class ParentComponentMonitor extends Monitor {
     }
 
 
-    private boolean allParentTerminated(List<ApplicationContext> parentContexts) {
+    private boolean allParentTerminated(List<ApplicationChildContext> parentContexts) {
         boolean parentsTerminated = false;
-        for (ApplicationContext context1 : parentContexts) {
+        for (ApplicationChildContext context1 : parentContexts) {
             if (this.inactiveMonitorsList.contains(context1.getId())) {
                 log.info("Waiting for the [Parent Monitor] " + context1.getId()
                         + " to be terminated");
@@ -270,7 +270,7 @@ public abstract class ParentComponentMonitor extends Monitor {
      */
     public void startDependency() throws TopologyInConsistentException {
         //start the first dependency
-        List<ApplicationContext> applicationContexts = this.startupDependencyTree.getStarAbleDependencies();
+        List<ApplicationChildContext> applicationContexts = this.startupDependencyTree.getStarAbleDependencies();
         startDependency(applicationContexts);
 
     }
@@ -282,7 +282,7 @@ public abstract class ParentComponentMonitor extends Monitor {
      */
     public void startDependencyOnTermination() throws TopologyInConsistentException {
         //start the first dependency which went to terminated
-        List<ApplicationContext> applicationContexts = this.startupDependencyTree.
+        List<ApplicationChildContext> applicationContexts = this.startupDependencyTree.
                 getStarAbleDependenciesByTermination();
         startDependency(applicationContexts);
 
@@ -294,7 +294,7 @@ public abstract class ParentComponentMonitor extends Monitor {
      * @param id alias/clusterId of which receive the activated event
      */
     public boolean startDependency(String id) throws TopologyInConsistentException {
-        List<ApplicationContext> applicationContexts = this.startupDependencyTree.getStarAbleDependencies(id);
+        List<ApplicationChildContext> applicationContexts = this.startupDependencyTree.getStarAbleDependencies(id);
         return startDependency(applicationContexts);
     }
 
@@ -303,7 +303,7 @@ public abstract class ParentComponentMonitor extends Monitor {
      *
      * @param applicationContexts the found applicationContexts to be started
      */
-    private boolean startDependency(List<ApplicationContext> applicationContexts)
+    private boolean startDependency(List<ApplicationChildContext> applicationContexts)
             throws TopologyInConsistentException {
         if (applicationContexts != null && applicationContexts.isEmpty()) {
             //all the groups/clusters have been started and waiting for activation
@@ -311,7 +311,7 @@ public abstract class ParentComponentMonitor extends Monitor {
             return false;
 
         }
-        for (ApplicationContext context : applicationContexts) {
+        for (ApplicationChildContext context : applicationContexts) {
             if (log.isDebugEnabled()) {
                 log.debug("Dependency check for the Group " + context.getId() + " started");
             }
@@ -341,7 +341,7 @@ public abstract class ParentComponentMonitor extends Monitor {
         this.appId = appId;
     }
 
-    protected synchronized void startMonitor(ParentComponentMonitor parent, ApplicationContext context) {
+    protected synchronized void startMonitor(ParentComponentMonitor parent, ApplicationChildContext context) {
         Thread th = null;
         if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) {
             th = new Thread(
@@ -361,11 +361,11 @@ public abstract class ParentComponentMonitor extends Monitor {
     }
 
     private class MonitorAdder implements Runnable {
-        private ApplicationContext context;
+        private ApplicationChildContext context;
         private ParentComponentMonitor parent;
         private String appId;
 
-        public MonitorAdder(ParentComponentMonitor parent, ApplicationContext context, String appId) {
+        public MonitorAdder(ParentComponentMonitor parent, ApplicationChildContext context, String appId) {
             this.parent = parent;
             this.context = context;
             this.appId = appId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/a261fc94/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 badebb7..06246da 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
@@ -20,9 +20,9 @@ package org.apache.stratos.autoscaler.monitor.application;
 
 import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
-import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext;
-import org.apache.stratos.autoscaler.applications.dependency.context.ClusterContext;
-import org.apache.stratos.autoscaler.applications.dependency.context.GroupContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationChildContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.ClusterChildContext;
+import org.apache.stratos.autoscaler.applications.dependency.context.GroupChildContext;
 import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 import org.apache.stratos.autoscaler.exception.PolicyValidationException;
@@ -57,15 +57,15 @@ public class ApplicationMonitorFactory {
      * @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)
+    public static Monitor getMonitor(ParentComponentMonitor parentMonitor, ApplicationChildContext context, String appId)
             throws TopologyInConsistentException,
             DependencyBuilderException, PolicyValidationException, PartitionValidationException {
     	
         Monitor monitor;
-        if (context instanceof GroupContext) {
+        if (context instanceof GroupChildContext) {
             monitor = getGroupMonitor(parentMonitor, context, appId);
-        } else if (context instanceof ClusterContext) {
-            monitor = getClusterMonitor(parentMonitor, (ClusterContext) context, appId);
+        } else if (context instanceof ClusterChildContext) {
+            monitor = getClusterMonitor(parentMonitor, (ClusterChildContext) context, appId);
             if (monitor != null) {
             	((AbstractClusterMonitor)monitor).startScheduler();
             	AutoscalerContext.getInstance().addClusterMonitor((AbstractClusterMonitor)monitor);
@@ -86,7 +86,7 @@ public class ApplicationMonitorFactory {
      * @throws DependencyBuilderException    throws while building dependency for app monitor
      * @throws TopologyInConsistentException throws while traversing thr topology
      */
-    public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, ApplicationContext context, String appId)
+    public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, ApplicationChildContext context, String appId)
             throws DependencyBuilderException,
             TopologyInConsistentException {
         GroupMonitor groupMonitor;
@@ -165,7 +165,7 @@ public class ApplicationMonitorFactory {
      * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException
      */
     public static AbstractClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor,
-                                                     ClusterContext context, String appId)
+                                                     ClusterChildContext context, String appId)
             throws PolicyValidationException,
             PartitionValidationException,
             TopologyInConsistentException {