You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2014/10/21 14:24:53 UTC
[1/2] git commit: updating the monitors with termination,
inactive and terminated events
Repository: stratos
Updated Branches:
refs/heads/4.0.0-grouping 50e9e69b2 -> 77676a680
updating the monitors with termination, inactive and terminated events
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4a3a9425
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4a3a9425
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4a3a9425
Branch: refs/heads/4.0.0-grouping
Commit: 4a3a94255c9013e52fbf3e5e9c1519074c2cb6c2
Parents: 50e9e69
Author: reka <rt...@gmail.com>
Authored: Tue Oct 21 17:27:59 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Tue Oct 21 17:27:59 2014 +0530
----------------------------------------------------------------------
.../monitor/ParentComponentMonitor.java | 126 +++++++++++++++
.../monitor/application/ApplicationMonitor.java | 91 +++--------
.../autoscaler/monitor/group/GroupMonitor.java | 156 ++-----------------
.../status/checker/StatusChecker.java | 144 +++++++++--------
4 files changed, 240 insertions(+), 277 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4a3a9425/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 0d64e3e..74a421b 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
@@ -28,8 +28,13 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder;
import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
+import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
+import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.GroupStatus;
import org.apache.stratos.messaging.domain.topology.ParentComponent;
+import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
import java.util.HashMap;
import java.util.List;
@@ -64,6 +69,127 @@ public abstract class ParentComponentMonitor extends Monitor {
protected abstract void monitor(MonitorStatusEvent statusEvent);
+ protected void onChildActivatedEvent(MonitorStatusEvent statusEvent) {
+ try {
+ //if the activated monitor is in in_active map move it to active map
+ if (this.aliasToInActiveMonitorsMap.containsKey(id)) {
+ this.aliasToActiveMonitorsMap.put(id, this.aliasToInActiveMonitorsMap.remove(id));
+ }
+ boolean startDep = startDependency(statusEvent.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("started a child: " + startDep + " by the group/cluster: " + id);
+
+ }
+ if (!startDep) {
+ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+ }
+ } catch (TopologyInConsistentException e) {
+ //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
+ log.error(e);
+ }
+
+ }
+
+ protected void onChildTerminatingEvent() {
+ //Check whether hasDependent true
+ if (!this.aliasToInActiveMonitorsMap.containsKey(id)) {
+ this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id));
+ }
+
+ Monitor monitor = this.aliasToInActiveMonitorsMap.get(id);
+ for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) {
+ if (monitor.hasMonitors()) {
+ StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId());
+ } else {
+ StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+ ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId());
+ }
+ }
+ }
+
+ protected void onChildInActiveEvent() {
+ List<ApplicationContext> terminationList;
+ Monitor monitor;
+ terminationList = this.dependencyTree.getTerminationDependencies(id);
+ //Temporarily move the group/cluster to inactive list
+ this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id));
+
+ if (terminationList != null) {
+ //Checking the termination dependents status
+ for (ApplicationContext terminationContext : terminationList) {
+ //Check whether dependent is in_active, then start to kill it
+ monitor = this.aliasToActiveMonitorsMap.
+ get(terminationContext.getId());
+ //start to kill it
+ if (monitor.hasMonitors()) {
+ //it is a group
+ StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
+ } else {
+ StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+ ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+
+ }
+ }
+ } else {
+ log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]"
+ + " where child is identified as a independent");
+ }
+ }
+
+ protected void onChildTerminatedEvent() {
+ List<ApplicationContext> terminationList;
+ boolean allDependentTerminated = true;
+ terminationList = this.dependencyTree.getTerminationDependencies(id);
+ if (terminationList != null) {
+ for (ApplicationContext context1 : terminationList) {
+ if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
+ log.info("Waiting for the [Parent Monitor] " + context1.getId()
+ + " to be terminated");
+ allDependentTerminated = false;
+ } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
+ log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state");
+ allDependentTerminated = false;
+ } else {
+ allDependentTerminated = true;
+ }
+ }
+
+ if (allDependentTerminated) {
+
+ }
+ } else {
+ List<ApplicationContext> parentContexts = this.dependencyTree.findAllParentContextWithId(id);
+ boolean canStart = false;
+ if (parentContexts != null) {
+ for (ApplicationContext context1 : parentContexts) {
+ if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
+ log.info("Waiting for the [Parent Monitor] " + context1.getId()
+ + " to be terminated");
+ canStart = false;
+ } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
+ if (canStart) {
+ log.warn("Found the Dependent [monitor] " + context1.getId()
+ + " in the active list wrong state");
+ }
+ } else {
+ log.info("[Parent Monitor] " + context1.getId()
+ + " has already been terminated");
+ canStart = true;
+ }
+ }
+
+ if (canStart) {
+ //start the monitor
+ }
+
+ } else {
+ //Start the monitor
+ }
+
+ }
+ }
+
+
/**
* This will start the parallel dependencies at once from the top level.
* it will get invoked when the monitor starts up only.
http://git-wip-us.apache.org/repos/asf/stratos/blob/4a3a9425/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 7befc2b..c587115 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
@@ -32,6 +32,9 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
import org.apache.stratos.messaging.domain.topology.Application;
import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.GroupStatus;
+import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
import java.util.ArrayList;
import java.util.Collection;
@@ -86,33 +89,6 @@ public class ApplicationMonitor extends ParentComponentMonitor {
}
- /**
- * utility method to recursively search for cluster monitors in the App monitor
- *
- * @param clusterId cluster id of the monitor to be searched
- * @param clusterMonitors cluster monitors found in the app Monitor
- * @param groupMonitors group monitors found in the app monitor
- * @return the found cluster monitor
- */
- /*private AbstractClusterMonitor findClusterMonitor(String clusterId,
- Collection<AbstractClusterMonitor> clusterMonitors,
- Collection<Monitor> groupMonitors) {
- for (AbstractClusterMonitor monitor : clusterMonitors) {
- // check if alias is equal, if so, return
- if (monitor.equals(clusterId)) {
- return monitor;
- }
- }
-
- for (Monitor groupMonitor : groupMonitors) {
- return findClusterMonitor(clusterId,
- groupMonitor.getClusterIdToClusterMonitorsMap().values(),
- groupMonitor.getAliasToGroupMonitorsMap().values());
- }
- return null;
-
- }
-*/
/**
* Find the group monitor by traversing recursively in the hierarchical monitors.
@@ -180,52 +156,27 @@ public class ApplicationMonitor extends ParentComponentMonitor {
@Override
protected void monitor(MonitorStatusEvent statusEvent) {
- /*ApplicationContext context = this.dependencyTree.
- findApplicationContextWithId(statusEvent.getId());
- //TODO remove activated
- if(context.getStatusLifeCycle().isEmpty() || context.getStatus() == Status.Activated) {
- try {
- //if life cycle is empty, need to start the monitor
- boolean dependencyStarted = startDependency(statusEvent.getId());
- if(!dependencyStarted) {
- //Have to check whether all other dependencies started
-
- }
- //updating the life cycle
- context.addStatusToLIfeCycle(statusEvent.getStatus());
- } catch (TopologyInConsistentException e) {
- //TODO revert the siblings
- log.error(e);
- }
- } else {
- //TODO act based on life cycle events
- }*/
-
String id = statusEvent.getId();
- ApplicationContext context = this.dependencyTree.
- findApplicationContextWithId(id);
- if (context.getStatusLifeCycle().isEmpty()) {
- try {
- //if life cycle is empty, need to start the monitor
- boolean startDep = startDependency(statusEvent.getId());
- if (log.isDebugEnabled()) {
- log.debug("started a child: " + startDep + " by the group/cluster: " + id);
-
- }
- //updating the life cycle and current status
- if (!startDep) {
- //Checking in the children whether all are active,
- // since no dependency found to be started.
- StatusChecker.getInstance().onChildStatusChange(id, this.appId);
- }
- } catch (TopologyInConsistentException e) {
- //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
- log.error(e);
+ LifeCycleState status1 = statusEvent.getStatus();
+ //Events coming from parent are In_Active(in faulty detection), Scaling events, termination
+ if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
+ onChildActivatedEvent(statusEvent);
+ } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
+ onChildInActiveEvent();
+ //TODO update the status of the Application as in_active when child becomes in_active
+ } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
+ onChildTerminatingEvent();
+ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+ } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
+ //Check whether all dependent goes Terminated and then start them in parallel.
+ this.aliasToInActiveMonitorsMap.remove(id);
+ if (this.status != ApplicationStatus.Terminating) {
+ onChildTerminatedEvent();
+ } else {
+ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+ log.info("Executing the un-subscription request for the [monitor] " + id);
}
- } else {
- //TODO act based on life cycle events
}
-
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4a3a9425/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 f278fb6..1b01ed0 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
@@ -34,7 +34,6 @@ import org.apache.stratos.messaging.domain.topology.Group;
import org.apache.stratos.messaging.domain.topology.GroupStatus;
import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -81,148 +80,27 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
protected void monitor(MonitorStatusEvent statusEvent) {
String id = statusEvent.getId();
LifeCycleState status1 = statusEvent.getStatus();
- ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id);
//Events coming from parent are In_Active(in faulty detection), Scaling events, termination
- if (!isParent(id)) {
- if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
- try {
- //if the activated monitor is in in_active map move it to active map
- if(this.aliasToInActiveMonitorsMap.containsKey(id)) {
- this.aliasToActiveMonitorsMap.put(id, this.aliasToInActiveMonitorsMap.remove(id));
- }
- boolean startDep = startDependency(statusEvent.getId());
- if (log.isDebugEnabled()) {
- log.debug("started a child: " + startDep + " by the group/cluster: " + id);
-
- }
- if (!startDep) {
- StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
- }
- } catch (TopologyInConsistentException e) {
- //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
- log.error(e);
- }
-
- } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
-
- List<ApplicationContext> terminationList;
- Monitor monitor;
- terminationList = this.dependencyTree.getTerminationDependencies(id);
- //Temporarily move the group/cluster to inactive list
- this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id));
-
- if (terminationList != null) {
- //Checking the termination dependents status
- for (ApplicationContext terminationContext : terminationList) {
- //Check whether dependent is in_active, then start to kill it
- monitor = this.aliasToActiveMonitorsMap.
- get(terminationContext.getId());
- //start to kill it
- if(monitor.hasMonitors()) {
- //it is a group
- StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
- } else {
- StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
- ((AbstractClusterMonitor)monitor).getServiceId(), terminationContext.getId());
-
- }
- }
- } else {
- log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]"
- + " where child is identified as a independent");
- /*//find any other immediate dependent which is in_active/created state
- ApplicationContext context1 = this.dependencyTree.findParentContextWithId(id);
- if(context1 != null) {
- if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
- monitor = this.aliasToInActiveMonitorsMap.get(id);
- //killall
- monitor.onEvent(new MonitorTerminateAllEvent(id));
-
- } else {
- log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]"
- + " where child is identified as a independent");
- }
- }*/
- }
- //To update the status of the Group
+ if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
+ onChildActivatedEvent(statusEvent);
+ } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
+ onChildInActiveEvent();
+ //To update the status of the Group
+ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+ } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
+ onChildTerminatingEvent();
+ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+ } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
+ //Check whether all dependent goes Terminated and then start them in parallel.
+ this.aliasToInActiveMonitorsMap.remove(id);
+ if (this.status != GroupStatus.Terminating) {
+ onChildTerminatedEvent();
+ } else {
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
-
- } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
- //Check whether hasDependent true
- if(!this.aliasToInActiveMonitorsMap.containsKey(id)) {
- this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id));
- }
-
- Monitor monitor = this.aliasToInActiveMonitorsMap.get(id);
- for(Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) {
- if(monitor.hasMonitors()) {
- StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId());
- } else {
- StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
- ((AbstractClusterMonitor)monitor1).getServiceId(), monitor.getId());
- }
- }
- StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
- } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
- //Check whether all dependent goes Terminated and then start them in parallel.
- this.aliasToInActiveMonitorsMap.remove(id);
- if(this.status != GroupStatus.Terminating) {
- List<ApplicationContext> terminationList;
- boolean allDependentTerminated = true;
- terminationList = this.dependencyTree.getTerminationDependencies(id);
- if(terminationList != null) {
- for(ApplicationContext context1 : terminationList) {
- if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
- log.info("Waiting for the [Parent Monitor] " + context1.getId()
- + " to be terminated");
- allDependentTerminated = false;
- } else if(this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
- log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state");
- allDependentTerminated = false;
- } else {
- allDependentTerminated = true;
- }
- }
-
- if(allDependentTerminated) {
-
- }
- } else {
- List<ApplicationContext> parentContexts = this.dependencyTree.findAllParentContextWithId(id);
- boolean canStart = false;
- if(parentContexts != null) {
- for(ApplicationContext context1 : parentContexts) {
- if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
- log.info("Waiting for the [Parent Monitor] " + context1.getId()
- + " to be terminated");
- canStart = false;
- } else if(this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
- if(canStart) {
- log.warn("Found the Dependent [monitor] " + context1.getId()
- + " in the active list wrong state");
- }
- } else {
- log.info("[Parent Monitor] " + context1.getId()
- + " has already been terminated");
- canStart = true;
- }
- }
-
- if(canStart) {
- //start the monitor
- }
-
- } else {
- //Start the monitor
- }
-
- }
- } else {
- StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
- log.info("Executing the un-subscription request for the [monitor] " + id);
- }
+ log.info("Executing the un-subscription request for the [monitor] " + id);
}
}
+
}
public ParentComponentMonitor getParent() {
http://git-wip-us.apache.org/repos/asf/stratos/blob/4a3a9425/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index b896378..34388b8 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -75,6 +75,7 @@ public class StatusChecker {
if(clusterMonitorHasMembers) {
//monitor.pause();
// if cluster not having any members and if the cluster was in_active then send created Events
+ //TODO
StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(),
monitor.getClusterId());
}
@@ -161,47 +162,21 @@ public class StatusChecker {
updateChild(idOfChild, groupId, appId);
}
- /**
- * This will calculate whether the children of an application are active or not. If active, then
- * it will send the ApplicationActivatedEvent.
- *
- * @param idOfChild
- * @param appId
- */
- public void onChildStatusChange(final String idOfChild, final String appId) {
- updateChild(idOfChild, appId);
- }
-
private void updateChild(final String idOfChild, final String groupId, final String appId) {
Runnable group = new Runnable() {
public void run() {
try {
- //TODO getting lock
TopologyManager.acquireReadLockForApplication(appId);
- ParentComponent component1 = TopologyManager.getTopology().
- getApplication(appId).getGroupRecursively(groupId);
- Map<String, ClusterDataHolder> clusterIds = component1.getClusterDataMap();
- Map<String, Group> groups = component1.getAliasToGroupMap();
- updateChildStatus(appId, idOfChild, groups, clusterIds, component1);
- } finally {
- TopologyManager.releaseReadLockForApplication(appId);
-
- }
-
- }
- };
- Thread groupThread = new Thread(group);
- groupThread.start();
- }
-
- private void updateChild(final String idOfChild, final String appId) {
- Runnable group = new Runnable() {
- public void run() {
- try {
- //TODO getting lock
- TopologyManager.acquireReadLockForApplication(appId);
- ParentComponent component = TopologyManager.getTopology().
- getApplication(appId);
+ ParentComponent component;
+ if(groupId.equals(appId)) {
+ //it is an application
+ component = TopologyManager.getTopology().
+ getApplication(appId);
+ } else {
+ //it is a group
+ component = TopologyManager.getTopology().
+ getApplication(appId).getGroupRecursively(groupId);
+ }
Map<String, ClusterDataHolder> clusterIds = component.getClusterDataMap();
Map<String, Group> groups = component.getAliasToGroupMap();
updateChildStatus(appId, idOfChild, groups, clusterIds, component);
@@ -216,7 +191,6 @@ public class StatusChecker {
groupThread.start();
}
-
/**
* This will use to calculate whether all children of a particular component is active by travesing Top
*
@@ -230,8 +204,8 @@ public class StatusChecker {
private boolean updateChildStatus(String appId, String id, Map<String, Group> groups,
Map<String, ClusterDataHolder> clusterData, ParentComponent parent) {
boolean groupActive = false;
- ClusterStatus clustersActive;
- GroupStatus groupsActive;
+ ClusterStatus clusterStatus;
+ GroupStatus groupStatus;
boolean childFound = false;
boolean clusterFound = false;
@@ -266,43 +240,48 @@ public class StatusChecker {
groupActive = clustersActive == ClusterStatus.Active;
} */
- clustersActive = getClusterStatus(clusterData);
- groupsActive = getGroupStatus(groups);
+ clusterStatus = getClusterStatus(clusterData);
+ groupStatus = getGroupStatus(groups);
- if (groupsActive == null && clustersActive == ClusterStatus.Active ||
- clustersActive == null && groupsActive == GroupStatus.Active ||
- groupsActive == GroupStatus.Active && clustersActive == ClusterStatus.Active) {
+ if (groups.isEmpty() && clusterStatus == ClusterStatus.Active ||
+ clusterData.isEmpty() && groupStatus == GroupStatus.Active ||
+ groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) {
//send activation event
if (parent instanceof Application) {
//send application activated event
- log.info("sending app activate found: " + appId);
+ log.info("sending app activate: " + appId);
StatusEventPublisher.sendApplicationActivatedEvent(appId);
} else if (parent instanceof Group) {
//send activation to the parent
- log.info("sending group activate found: " + parent.getUniqueIdentifier());
+ log.info("sending group activate: " + parent.getUniqueIdentifier());
StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier());
}
- } else if (groupsActive == null && clustersActive == ClusterStatus.Inactive ||
- clustersActive == null && groupsActive == GroupStatus.Inactive ||
- groupsActive == GroupStatus.Inactive && clustersActive == ClusterStatus.Inactive) {
+ } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive ||
+ clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
+ groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) {
//send the in activation event
if (parent instanceof Application) {
//send application activated event
- log.info("sending app in-active found: " + appId);
+ log.info("sending app in-active : " + appId);
StatusEventPublisher.sendApplicationInactivatedEvent(appId);
} else if (parent instanceof Group) {
//send activation to the parent
- log.info("sending group in-active found: " + parent.getUniqueIdentifier());
+ log.info("sending group in-active: " + parent.getUniqueIdentifier());
StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier());
}
- } else if (groupsActive == null && clustersActive == ClusterStatus.Terminating ||
- clustersActive == null && groupsActive == GroupStatus.Terminating ||
- groupsActive == GroupStatus.Terminating && clustersActive == ClusterStatus.Terminating) {
- //send the terminating event
- } else if (groupsActive == null && clustersActive == ClusterStatus.Terminated ||
- clustersActive == null && groupsActive == GroupStatus.Terminated ||
- groupsActive == GroupStatus.Terminated && clustersActive == ClusterStatus.Terminated) {
+ } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated ||
+ clusterData.isEmpty() && groupStatus == GroupStatus.Terminated ||
+ groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) {
//send the terminated event
+ if (parent instanceof Application) {
+ //send application activated event
+ log.info("sending app terminated: " + appId);
+ //StatusEventPublisher.sendApp(appId);
+ } else if (parent instanceof Group) {
+ //send activation to the parent
+ log.info("sending group terminated : " + parent.getUniqueIdentifier());
+ //StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier());
+ }
} else {
log.warn("Clusters/groups not found in this [component] " + appId);
}
@@ -319,6 +298,8 @@ public class StatusChecker {
private GroupStatus getGroupStatus(Map<String, Group> groups) {
boolean groupActiveStatus = false;
GroupStatus status = null;
+ boolean groupActive = false;
+ boolean groupTerminated = false;
for (Group group : groups.values()) {
/*if (group.getTempStatus() == Status.Activated) {
@@ -329,42 +310,69 @@ public class StatusChecker {
}*/
if (group.getStatus() == GroupStatus.Active) {
- status = GroupStatus.Active;
+ groupActive = true;
+ groupTerminated = false;
} else if(group.getStatus() == GroupStatus.Inactive){
status = GroupStatus.Inactive;
break;
+ } else if(group.getStatus() == GroupStatus.Terminated) {
+ groupActive = false;
+ groupTerminated = true;
} else if(group.getStatus() == GroupStatus.Created) {
+ groupActive = false;
+ groupTerminated = false;
status = GroupStatus.Created;
} else if(group.getStatus() == GroupStatus.Terminating) {
+ groupActive = false;
+ groupTerminated = false;
status = GroupStatus.Terminating;
- break;
- } else if(group.getStatus() == GroupStatus.Terminated) {
- status = GroupStatus.Terminated;
+
}
}
+
+ if(groupActive) {
+ status = GroupStatus.Active;
+ } else if(groupTerminated) {
+ status = GroupStatus.Terminated;
+ }
return status;
}
private ClusterStatus getClusterStatus(Map<String, ClusterDataHolder> clusterData) {
ClusterStatus status = null;
+ boolean clusterActive = false;
+ boolean clusterTerminated = 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() == ClusterStatus.Active) {
- status = ClusterStatus.Active;
+ clusterActive = true;
+ clusterTerminated = false;
} else if(cluster.getStatus() == ClusterStatus.Inactive){
status = ClusterStatus.Inactive;
+ clusterActive = false;
+ clusterTerminated = false;
break;
- } else if(cluster.getStatus() == ClusterStatus.Created) {
- status = ClusterStatus.Created;
+ } else if(cluster.getStatus() == ClusterStatus.Terminated) {
+ clusterActive = false;
+ clusterTerminated = true;
} else if(cluster.getStatus() == ClusterStatus.Terminating) {
status = ClusterStatus.Terminating;
- break;
- } else if(cluster.getStatus() == ClusterStatus.Terminated) {
- status = ClusterStatus.Terminated;
+ clusterActive = false;
+ clusterTerminated = false;
+ } else if(cluster.getStatus() == ClusterStatus.Created) {
+ status = ClusterStatus.Created;
+ clusterActive = false;
+ clusterTerminated = false;
}
}
+
+ if(clusterActive) {
+ status = ClusterStatus.Active;
+ } else if(clusterTerminated) {
+ status = ClusterStatus.Terminated;
+ }
return status;
}
[2/2] git commit: removing the common Status for Topology and using
the correct status for the application, Group and cluster
Posted by re...@apache.org.
removing the common Status for Topology and using the correct status for the application, Group and cluster
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/77676a68
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/77676a68
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/77676a68
Branch: refs/heads/4.0.0-grouping
Commit: 77676a680ce3a270f267af367e4652db0a259416
Parents: 4a3a942
Author: reka <rt...@gmail.com>
Authored: Tue Oct 21 17:54:38 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Tue Oct 21 17:54:38 2014 +0530
----------------------------------------------------------------------
.../grouping/dependency/DependencyTree.java | 22 +-
.../AutoscalerTopologyEventReceiver.java | 35 --
.../monitor/MonitorStatusEventBuilder.java | 3 +-
.../monitor/cluster/ClusterMonitor.java | 1 -
.../monitor/cluster/LbClusterMonitor.java | 9 +-
.../monitor/events/ClusterStatusEvent.java | 1 -
.../termination-change.patch | 596 +++++++++++++++++++
.../impl/CloudControllerServiceImpl.java | 4 +-
.../controller/topology/TopologyBuilder.java | 15 +-
.../topology/TopologyEventPublisher.java | 18 +-
.../messaging/domain/topology/Cluster.java | 57 +-
.../domain/topology/ParentComponent.java | 10 -
.../messaging/domain/topology/Status.java | 40 --
.../topology/ClusterMaintenanceModeEvent.java | 58 --
.../ClusterMaintenanceModeEventListener.java | 25 -
.../ApplicationActivatedMessageProcessor.java | 6 +-
.../topology/ClusterActivatedProcessor.java | 11 +-
.../topology/ClusterInActivateProcessor.java | 19 +-
.../ClusterMaintenanceModeMessageProcessor.java | 129 ----
.../topology/GroupActivatedProcessor.java | 4 +-
.../topology/GroupInActivateProcessor.java | 5 +-
.../topology/TopologyMessageProcessorChain.java | 6 -
22 files changed, 665 insertions(+), 409 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
index 6dbbce3..61648b3 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
@@ -21,7 +21,6 @@ package org.apache.stratos.autoscaler.grouping.dependency;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
-import org.apache.stratos.messaging.domain.topology.Status;
import java.util.ArrayList;
import java.util.List;
@@ -34,8 +33,6 @@ public class DependencyTree {
private List<ApplicationContext> applicationContextList;
- private Status status;
-
private boolean started;
private boolean terminated;
@@ -115,11 +112,11 @@ public class DependencyTree {
private List<ApplicationContext> findAllParent(List<ApplicationContext> parentContexts, String id) {
ApplicationContext context = findParentContextWithId(null, id, this.applicationContextList);
- if(context != null) {
+ if (context != null) {
parentContexts.add(context);
findAllParent(parentContexts, context.getId());
}
- return parentContexts;
+ return parentContexts;
}
@@ -137,6 +134,7 @@ public class DependencyTree {
}
return null;
}
+
/**
* Getting the next start able dependencies upon the activate event
* received for a group/cluster which is part of this tree.
@@ -175,9 +173,9 @@ public class DependencyTree {
if (this.killDependent) {
//finding the ApplicationContext of the given id
//finding all the children of the found application context
- findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
- allChildrenOfAppContext);
- return allChildrenOfAppContext;
+ findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
+ allChildrenOfAppContext);
+ return allChildrenOfAppContext;
} else if (this.killAll) {
//killall will be killed by the monitor from it's list.
findAllChildrenOfAppContext(this.applicationContextList,
@@ -236,14 +234,6 @@ public class DependencyTree {
this.terminated = terminated;
}
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-
public boolean isKillDependent() {
return killDependent;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index c5095e3..c650a3d 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -344,41 +344,6 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
});
-
- topologyEventReceiver.addEventListener(new ClusterMaintenanceModeEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- ClusterMaintenanceModeEvent clusterMaitenanceEvent = null;
-
- try {
- log.info("Event received: " + event);
- clusterMaitenanceEvent = (ClusterMaintenanceModeEvent) event;
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(clusterMaitenanceEvent.getServiceName(),
- clusterMaitenanceEvent.getClusterId());
-
- Service service = TopologyManager.getTopology().getService(clusterMaitenanceEvent.getServiceName());
- Cluster cluster = service.getCluster(clusterMaitenanceEvent.getClusterId());
- AbstractClusterMonitor monitor;
- if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) {
- monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId());
- monitor.setStatus(ClusterStatus.Inactive);
- } else {
- log.error("cluster monitor not exists for the cluster: " + cluster.toString());
- }
- } catch (Exception e) {
- log.error("Error processing event", e);
- } finally {
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(clusterMaitenanceEvent.getServiceName(),
- clusterMaitenanceEvent.getClusterId());
- }
- }
-
- });
-
-
topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() {
@Override
protected void onEvent(Event event) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
index a27e056..fcb0f06 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
@@ -27,7 +27,6 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.GroupStatus;
-import org.apache.stratos.messaging.domain.topology.Status;
/**
* This will build the necessary monitor status events to be sent to the parent/child monitor
@@ -51,7 +50,7 @@ public class MonitorStatusEventBuilder {
}
private static void notifyParent(ParentComponentMonitor parent, MonitorStatusEvent statusEvent) {
- parent.onEvent(statusEvent);
+ parent.onEvent(statusEvent);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index a129d18..5fabab4 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -31,7 +31,6 @@ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
import org.apache.stratos.cloud.controller.stub.pojo.Properties;
import org.apache.stratos.cloud.controller.stub.pojo.Property;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Status;
import java.util.ArrayList;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
index d3a2371..895f018 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
@@ -27,7 +27,6 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Status;
import java.util.concurrent.ConcurrentHashMap;
@@ -39,7 +38,6 @@ import java.util.concurrent.ConcurrentHashMap;
public class LbClusterMonitor extends AbstractClusterMonitor {
private static final Log log = LogFactory.getLog(LbClusterMonitor.class);
- private Status status;
public LbClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy,
AutoscalePolicy autoscalePolicy) {
@@ -63,12 +61,12 @@ public class LbClusterMonitor extends AbstractClusterMonitor {
log.debug("Cluster monitor is running.. " + this.toString());
}
try {
- if( !ClusterStatus.Inactive.equals(status)) {
+ if (!ClusterStatus.Inactive.equals(status)) {
monitor();
} else {
if (log.isDebugEnabled()) {
log.debug("LB Cluster monitor is suspended as the cluster is in " +
- ClusterStatus.Inactive + " mode......");
+ ClusterStatus.Inactive + " mode......");
}
}
} catch (Exception e) {
@@ -92,7 +90,7 @@ public class LbClusterMonitor extends AbstractClusterMonitor {
if (partitionContext != null) {
minCheckKnowledgeSession.setGlobal("clusterId", clusterId);
minCheckKnowledgeSession.setGlobal("isPrimary", false);
-
+
if (log.isDebugEnabled()) {
log.debug(String.format("Running minimum check for partition %s ",
partitionContext.getPartitionId()));
@@ -117,5 +115,4 @@ public class LbClusterMonitor extends AbstractClusterMonitor {
}
-
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java
index de8f0d5..58c59ba 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java
@@ -19,7 +19,6 @@
package org.apache.stratos.autoscaler.monitor.events;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import org.apache.stratos.messaging.domain.topology.Status;
/**
* This will use to notify observers upon a cluster activation events received in Topology.
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.autoscaler/termination-change.patch
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/termination-change.patch b/components/org.apache.stratos.autoscaler/termination-change.patch
new file mode 100644
index 0000000..8573805
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/termination-change.patch
@@ -0,0 +1,596 @@
+diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
+index d3dded3..156f3a5 100644
+--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
+@@ -46,6 +46,10 @@ public class DependencyTree {
+
+ private boolean killDependent;
+
++ private boolean startupOder;
++
++ private boolean reverseStartupOrder;
++
+ private String id;
+
+ public DependencyTree(String id) {
+@@ -88,7 +92,7 @@ public class DependencyTree {
+ */
+ private ApplicationContext findApplicationContextWithId(String id, List<ApplicationContext> contexts) {
+ for (ApplicationContext context : contexts) {
+- if (context.getId().equals(id)) {
++ if (context.getId().equals(id) && context.getCurrentStatus() == null) {
+ return context;
+ }
+ }
+@@ -130,23 +134,23 @@ 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> getKillDependencies(String id) {
++ public List<ApplicationContext> getTerminationDependencies(String id) {
+ List<ApplicationContext> allChildrenOfAppContext = new ArrayList<ApplicationContext>();
++ ApplicationContext applicationContext = findApplicationContextWithId(id);
+
+- if (killDependent) {
++ if (this.killDependent) {
+ //finding the ApplicationContext of the given id
+- ApplicationContext applicationContext = findApplicationContextWithId(id);
+ //finding all the children of the found application context
+- findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
+- allChildrenOfAppContext);
+- return allChildrenOfAppContext;
+- } else if (killAll) {
++ findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
++ allChildrenOfAppContext);
++ return allChildrenOfAppContext;
++ } else if (this.killAll) {
+ //killall will be killed by the monitor from it's list.
+ findAllChildrenOfAppContext(this.applicationContextList,
+ allChildrenOfAppContext);
+
+ }
+- //return empty for the kill-none case
++ //return empty for the kill-none case, what ever returns here will be killed in
+ return allChildrenOfAppContext;
+ }
+
+@@ -221,4 +225,20 @@ public class DependencyTree {
+ public void setId(String id) {
+ this.id = id;
+ }
++
++ public boolean isStartupOder() {
++ return startupOder;
++ }
++
++ public void setStartupOder(boolean startupOder) {
++ this.startupOder = startupOder;
++ }
++
++ public boolean isReverseStartupOrder() {
++ return reverseStartupOrder;
++ }
++
++ public void setReverseStartupOrder(boolean reverseStartupOrder) {
++ this.reverseStartupOrder = reverseStartupOrder;
++ }
+ }
+diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
+index f923bb0..5b98264 100644
+--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
+@@ -22,6 +22,7 @@ import org.apache.stratos.messaging.domain.topology.Status;
+
+ import java.util.ArrayList;
+ import java.util.List;
++import java.util.Stack;
+
+ /**
+ * This is to keep track of the
+@@ -35,13 +36,13 @@ public abstract class ApplicationContext {
+
+ private Status status;
+
+- private List<Status> statusLifeCycle;
++ private Stack<Status> statusLifeCycle;
+
+ protected boolean killDependent;
+
+ public ApplicationContext(String id, boolean killDependent) {
+ applicationContextList = new ArrayList<ApplicationContext>();
+- statusLifeCycle = new ArrayList<Status>();
++ statusLifeCycle = new Stack<Status>();
+ this.killDependent = killDependent;
+ this.id = id;
+ }
+@@ -60,7 +61,7 @@ public abstract class ApplicationContext {
+ }
+
+ public void addStatusToLIfeCycle(Status status) {
+- this.statusLifeCycle.add(status);
++ this.statusLifeCycle.push(status);
+ }
+
+ public String getId() {
+@@ -71,11 +72,11 @@ public abstract class ApplicationContext {
+ this.id = id;
+ }
+
+- public Status getStatus() {
++ public Status getCurrentStatus() {
+ return status;
+ }
+
+- public void setStatus(Status status) {
++ public void setCurrentStatus(Status status) {
+ this.status = status;
+ }
+
+@@ -83,7 +84,15 @@ public abstract class ApplicationContext {
+ return statusLifeCycle;
+ }
+
+- public void setStatusLifeCycle(List<Status> statusLifeCycle) {
+- this.statusLifeCycle = statusLifeCycle;
++ public boolean hasChild() {
++ boolean hasChild;
++ if(this.applicationContextList.isEmpty()) {
++ hasChild = false;
++ } else {
++ hasChild = true;
++ }
++ return hasChild;
+ }
++
++
+ }
+diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+index 801af0e..c19c2a0 100644
+--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+@@ -430,6 +430,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
+ String memberId = memberTerminatedEvent.getMemberId();
+ partitionContext.removeMemberStatsContext(memberId);
+
++
+ if (partitionContext.removeTerminationPendingMember(memberId)) {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Member is removed from termination pending " +
+@@ -452,6 +453,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
+ log.info(String.format("Member stat context has been removed " +
+ " successfully: [member] %s", memberId));
+ }
++ //Checking whether the cluster state can be changed either from in_active to created/terminating to terminated
++ StatusChecker.getInstance().onMemberTermination(clusterId);
++
+ // partitionContext.decrementCurrentActiveMemberCount(1);
+
+
+diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+index 4f501d2..aeb0e28 100644
+--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+@@ -120,6 +120,7 @@ public abstract class Monitor implements EventHandler {
+ }
+ if (context instanceof GroupContext) {
+ startGroupMonitor(this, context.getId());
++ //context.setCurrentStatus(Status.Created);
+ } else if (context instanceof ClusterContext) {
+ String clusterId = context.getId();
+ String serviceName = null;
+@@ -144,6 +145,7 @@ public abstract class Monitor implements EventHandler {
+ log.debug("Dependency check starting the [cluster]" + clusterId);
+ }
+ startClusterMonitor(this, cluster);
++ //context.setCurrentStatus(Status.Created);
+ } else {
+ String msg = "[Cluster] " + clusterId + " cannot be found in the " +
+ "Topology for [service] " + serviceName;
+@@ -372,9 +374,10 @@ public abstract class Monitor implements EventHandler {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Group monitor is going to be started for [group] "
+- + groupId);
++ + groupId );
+ }
+ monitor = AutoscalerUtil.getGroupMonitor(groupId, appId);
++ //setting the parent monitor
+ monitor.setParent(parent);
+ //setting the status of cluster monitor w.r.t Topology cluster
+ //if(group.getStatus() != Status.Created &&
+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 5b6598a..5eab977 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
+@@ -29,7 +29,6 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
+ import org.apache.stratos.autoscaler.monitor.group.GroupMonitor;
+ import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+ import org.apache.stratos.messaging.domain.topology.Application;
+-import org.apache.stratos.messaging.domain.topology.ParentComponent;
+ import org.apache.stratos.messaging.domain.topology.Status;
+
+ import java.util.ArrayList;
+@@ -63,7 +62,7 @@ public class ApplicationMonitor extends Monitor {
+ for (AbstractClusterMonitor monitor : this.clusterIdToClusterMonitorsMap.values()) {
+ clusters.add(monitor.getClusterId());
+ }
+- //TODO rest
++ //TODO restart
+ return clusters;
+
+ }
+@@ -261,7 +260,7 @@ public class ApplicationMonitor extends Monitor {
+
+ }
+ //updating the life cycle and current status
+- context.setStatus(statusEvent.getStatus());
++ context.setCurrentStatus(statusEvent.getStatus());
+ context.addStatusToLIfeCycle(statusEvent.getStatus());
+ if(!startDep) {
+ //Checking in the children whether all are active,
+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 0bdad16..0aa89fa 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
+@@ -23,16 +23,21 @@ import org.apache.commons.logging.LogFactory;
+ import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
+ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
+ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
++import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext;
++import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext;
++import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
++import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
+ import org.apache.stratos.autoscaler.monitor.EventHandler;
+ import org.apache.stratos.autoscaler.monitor.Monitor;
+ import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
+-import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent;
+-import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent;
+ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
+ import org.apache.stratos.autoscaler.status.checker.StatusChecker;
++import org.apache.stratos.messaging.domain.topology.Application;
+ import org.apache.stratos.messaging.domain.topology.Group;
+ import org.apache.stratos.messaging.domain.topology.Status;
+-import org.apache.stratos.messaging.event.application.status.StatusEvent;
++
++import java.util.ArrayList;
++import java.util.List;
+
+ /**
+ * This is GroupMonitor to monitor the group which consists of
+@@ -43,9 +48,6 @@ public class GroupMonitor extends Monitor implements EventHandler {
+
+ //Parent monitor of this monitor
+ private Monitor parent;
+- //Application id of this particular monitor
+- protected String appId;
+-
+
+ /**
+ * Constructor of GroupMonitor
+@@ -53,7 +55,7 @@ public class GroupMonitor extends Monitor implements EventHandler {
+ * @throws DependencyBuilderException throws when couldn't build the Topology
+ * @throws TopologyInConsistentException throws when topology is inconsistent
+ */
+- public GroupMonitor(Group group) throws DependencyBuilderException,
++ public GroupMonitor(Group group, String appId) throws DependencyBuilderException,
+ TopologyInConsistentException {
+ super(group);
+ startDependency();
+@@ -79,32 +81,86 @@ public class GroupMonitor extends Monitor implements EventHandler {
+ @Override
+ protected void monitor(MonitorStatusEvent statusEvent) {
+ String id = statusEvent.getId();
+- ApplicationContext context = this.dependencyTree.
+- findApplicationContextWithId(id);
+- if(context.getStatusLifeCycle().isEmpty()) {
+- try {
+- //if life cycle is empty, need to start the monitor
+- boolean startDep = startDependency(statusEvent.getId());
+- if(log.isDebugEnabled()) {
+- log.debug("started a child: " + startDep + " by the group/cluster: " + id);
++ Status status1 = statusEvent.getStatus();
++ ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id);
++ //Events coming from parent are In_Active(in faulty detection), Scaling events, termination
++ //TODO if statusEvent is for active, then start the next one if any available
++ if(!isParent(id)) {
++ if(status1 == Status.Activated) {
++ try {
++ //if life cycle is empty, need to start the monitor
++ boolean startDep = startDependency(statusEvent.getId());
++ if (log.isDebugEnabled()) {
++ log.debug("started a child: " + startDep + " by the group/cluster: " + id);
+
++ }
++ //updating the life cycle and current status
++ if (startDep) {
++ context.setCurrentStatus(Status.Created);
++ context.addStatusToLIfeCycle(Status.Created);
++ } else {
++ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
++ }
++
++ } catch (TopologyInConsistentException e) {
++ //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
++ log.error(e);
+ }
+- //updating the life cycle and current status
+- context.setStatus(statusEvent.getStatus());
+- context.addStatusToLIfeCycle(statusEvent.getStatus());
+- if(!startDep) {
+- //Checking in the children whether all are active,
+- // since no dependency found to be started.
+- StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
++ } else if(status1 == Status.In_Active) {
++ //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and
++ //TODO need to send in_active for c1. When C1 in_active receives, get dependent and
++ //TODO check whether dependent in_active. Then kill c1.
++ //evaluate termination behavior and take action based on that.
++
++ List<ApplicationContext> terminationList = new ArrayList<ApplicationContext>();
++ terminationList = this.dependencyTree.getTerminationDependencies(id);
++
++ //check whether all the children are in_active state
++ for(ApplicationContext terminationContext : terminationList) {
++ terminationContext
++ }
++
++ /*if(terminationList != null && !terminationList.isEmpty()) {
++ for(ApplicationContext context1 : terminationList) {
++ if(context1 instanceof ClusterContext) {
++ AbstractClusterMonitor monitor = this.clusterIdToClusterMonitorsMap.
++ get(context1.getId());
++ //Whether life cycle change to Created
++ if(monitor.getStatus() == Status.Created) {
++ canTerminate = true;
++ } else {
++ //TODO sending group in_active event to dependent cluster/group
++ StatusEventPublisher.sendGroupActivatedEvent(this.appId, this.id);
++ //not all dependent clusters are in created state.
++ canTerminate = false;
++ }
++ }
++ }
++ if(canTerminate) {
++ //
++ }*/
++ } else {
++ //TODO get dependents
++ List<ApplicationContext> dependents = this.dependencyTree.getTerminationDependencies(id);
+ }
+- } catch (TopologyInConsistentException e) {
+- //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
+- log.error(e);
++
++
++
++
++
++ } else if(status1 == Status.Created) {
++ //the dependent goes to be created state, so terminate the dependents
+ }
+ } else {
+- //TODO act based on life cycle events
++ //If it is coming from parent, then can be unsubscribe/scaling/terminate
++ // request upon other siblings's status changes
++
++
++
+ }
+
++
++
+ }
+
+ public Monitor getParent() {
+@@ -123,4 +179,16 @@ public class GroupMonitor extends Monitor implements EventHandler {
+ this.appId = appId;
+ }
+
++ private boolean isParent(String id) {
++ if(this.parent.getId().equals(id)) {
++ return true;
++ } else {
++ return false;
++ }
++ }
++
++
++
++
++
+ }
+diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+index ee04fff..e298df3 100644
+--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+@@ -64,6 +64,13 @@ public class StatusChecker {
+ }
+ }
+
++ public void onMemberTermination(String clusterId) {
++ ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId);
++ //TODO get Topology status
++ // if cluster not having any members and if the cluster was in_active then send created Events
++ // if cluster was in terminating, then send terminated event.
++ }
++
+ private boolean clusterActive(AbstractClusterMonitor monitor) {
+ boolean clusterActive = false;
+ for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) {
+@@ -84,6 +91,42 @@ public class StatusChecker {
+ }
+
+ /**
++ * @param clusterId
++ * @param appId
++ * @param partitionContext is to decide in which partition has less members while others have active members
++ */
++ public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) {
++ ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId);
++ boolean clusterInActive = getClusterInActive(monitor, partitionContext);
++ if (clusterInActive) {
++ //TODO evaluate life cycle
++ //send cluster In-Active event to cluster status topic
++
++ } else {
++ boolean clusterActive = clusterActive(monitor);
++ if(clusterActive) {
++ //TODO evaluate life cycle
++ //send clusterActive event to cluster status topic
++ }
++ }
++ }
++
++ private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionContext partitionContext) {
++ boolean clusterInActive = false;
++ for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) {
++ for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) {
++ if (partitionContext.getPartitionId().equals(partition.getPartitionId()) &&
++ partition.getActiveMemberCount() < partition.getMinimumMemberCount()) {
++ clusterInActive = true;
++ return clusterInActive;
++ }
++ }
++
++ }
++ return clusterInActive;
++ }
++
++ /**
+ *
+ * @param idOfChild
+ * @param groupId
+@@ -149,47 +192,7 @@ public class StatusChecker {
+ }
+
+
+- /**
+- * @param clusterId
+- * @param appId
+- * @param partitionContext is to decide in which partition has less members while others have active members
+- */
+- public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) {
+- Runnable memberFault = new Runnable() {
+- public void run() {
+- ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId);
+- boolean clusterActive = false;
+- boolean clusterInMaintenance = false;
+- for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) {
+- for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) {
+- if (partitionContext.getPartitionId().equals(partition.getPartitionId()) &&
+- partition.getActiveMemberCount() < partition.getMinimumMemberCount()) {
+- clusterInMaintenance = true;
+- } else {
+- log.info(String.format("Hence the [partition] %s, in [networkpartition], " +
+- "%s has exceeded the [minimum], %d with current active " +
+- "[members], %d the [cluster], %s is still in active mode."
+- , partition.getPartitionId(), partition.getNetworkPartitionId(),
+- partition.getMinimumMemberCount(), partition.getActiveMemberCount(), clusterId));
+- }
+- if (partitionContext.getMinimumMemberCount() >= partitionContext.getActiveMemberCount()) {
+- clusterActive = true;
+- }
+- clusterActive = false;
+- }
+-
+- }
+- // if in maintenance then notify upper layer
+- if (clusterActive && clusterInMaintenance) {
+- //send clusterInmaintenance event to cluster status topic
+-
+- }
+
+- }
+- };
+- Thread faultHandlingThread = new Thread(memberFault);
+- faultHandlingThread.start();
+- }
+
+ /**
+ * This will use to calculate whether all children of a particular component is active by travesing Top
+diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
+index cb03158..77af14c 100644
+--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
+@@ -163,7 +163,7 @@ public class AutoscalerUtil {
+ }
+
+ clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext);
+- //clusterMonitor.setStatus(Status.Created);
++ //clusterMonitor.setCurrentStatus(Status.Created);
+ if(log.isInfoEnabled()){
+ log.info(String.format("Network partition context has been added: [network partition] %s",
+ networkPartitionContext.getId()));
+diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java
+index 7ba27fc..2bd0945 100644
+--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java
++++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java
+@@ -24,8 +24,9 @@ public enum Status {
+ Created(1),
+ Running(2),
+ Activated(3),
+- In_Maintenance(4),
+- Removed(5);
++ In_Active(4),
++ Terminating(4),
++ Terminated(5);
+
+ private int code;
+
+diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json
+index 942ef8b..0043e2e 100755
+--- a/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json
++++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json
+@@ -4,12 +4,15 @@
+ "group1"
+ ],
+ "cartridges": [
+- "tomcat"
++ "tomcat","tomcat1"
+ ],
+ "dependencies": {
+ "startupOrders": [
+ "group.group1,cartridge.tomcat"
+ ],
+- "killBehaviour": "kill-dependents"
+- }
++ "termination": {
++ "terminationBehaviour": "kill-dependents",
++ "terminationOrder" : "startupOrder/reverseStartupOrder"
++ }
++ }
+ }
+diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json
+index b234c49..95c61b4 100644
+--- a/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json
++++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json
+@@ -13,7 +13,12 @@
+ "type": "tomcat",
+ "alias": "mygroup2tomcat"
+
+- }
++ },
++ {
++ "type": "tomcat1",
++ "alias": "mygroup2tomcat1"
++ }
++
+ ],
+ "subGroups": [
+ {
+@@ -88,6 +93,15 @@
+ "alias": "mygroup1tomcat1",
+ "deploymentPolicy": "deployment_policy_1",
+ "autoscalingPolicy": "autoscale_policy_1"
++ },
++ {
++ "alias": "mygroup2tomcat1",
++ "deploymentPolicy": "deployment_policy_1",
++ "autoscalingPolicy": "autoscale_policy_1",
++ "repoURL": "www.mygit.com/php.git",
++ "privateRepo": "true",
++ "repoUsername": "admin",
++ "repoPassword": "xxxx"
+ }
+
+ ]
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 68ccc5e..ce09d15 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -1212,7 +1212,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
@Override
public void unregisterService(String clusterId) throws UnregisteredClusterException {
final String clusterId_ = clusterId;
- TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_));
+ /*TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_));
Runnable terminateInTimeout = new Runnable() {
@Override
@@ -1309,7 +1309,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
};
new Thread(terminateInTimeout).start();
- new Thread(unregister).start();
+ new Thread(unregister).start();*/
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index b54b203..81c228c 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -114,7 +114,7 @@ public class TopologyBuilder {
}
public static void handleClusterCreated(Registrant registrant, boolean isLb) {
- Topology topology = TopologyManager.getTopology();
+ /*Topology topology = TopologyManager.getTopology();
Service service;
try {
TopologyManager.acquireWriteLock();
@@ -156,7 +156,7 @@ public class TopologyBuilder {
} finally {
TopologyManager.releaseWriteLock();
- }
+ }*/
}
public static void handleClusterRemoved(ClusterContext ctxt) {
@@ -187,7 +187,7 @@ public class TopologyBuilder {
TopologyEventPublisher.sendClusterRemovedEvent(ctxt, deploymentPolicy);
}
- public static void handleClusterMaintenanceMode(ClusterContext ctxt) {
+ /*public static void handleClusterMaintenanceMode(ClusterContext ctxt) {
Topology topology = TopologyManager.getTopology();
Service service = topology.getService(ctxt.getCartridgeType());
@@ -211,15 +211,12 @@ public class TopologyBuilder {
log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive);
}
cluster.setStatus(ClusterStatus.Inactive);
- // temporary; should be removed
- cluster.setTempStatus(Status.In_Active);
- //cluster.setStatus(Status.In_Maintenance);
TopologyManager.updateTopology(topology);
} finally {
TopologyManager.releaseWriteLock();
}
TopologyEventPublisher.sendClusterMaintenanceModeEvent(ctxt);
- }
+ }*/
public static void handleMemberSpawned(String serviceName,
@@ -774,8 +771,6 @@ public class TopologyBuilder {
TopologyManager.acquireWriteLock();
//cluster.setStatus(Status.Activated);
cluster.setStatus(ClusterStatus.Active);
- // temporary; should be removed
- cluster.setTempStatus(Status.Activated);
log.info("Cluster activated adding status started");
@@ -810,7 +805,7 @@ public class TopologyBuilder {
groupActivatedEvent.getGroupId());
try {
TopologyManager.acquireWriteLock();
- group.setTempStatus(Status.Activated);
+ group.setStatus(GroupStatus.Active);
log.info("Group activated adding status started");
TopologyManager.updateTopology(topology);
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index b3f60b9..2786605 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -81,11 +81,11 @@ public class TopologyEventPublisher {
}
}
- public static void sendClusterCreatedEvent(String serviceName, String clusterId, Cluster cluster) {
- ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(serviceName, clusterId, cluster);
+ public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
+ ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId,serviceName, clusterId);
if(log.isInfoEnabled()) {
- log.info("Publishing cluster created event: " +cluster.toString());
+ log.info("Publishing cluster created event: " +clusterId);
}
publishEvent(clusterCreatedEvent);
@@ -121,18 +121,6 @@ public class TopologyEventPublisher {
}
- public static void sendClusterMaintenanceModeEvent(ClusterContext ctxt) {
-
- ClusterMaintenanceModeEvent clusterMaintenanceModeEvent = new ClusterMaintenanceModeEvent(ctxt.getCartridgeType(), ctxt.getClusterId());
- clusterMaintenanceModeEvent.setStatus(Status.In_Active);
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing cluster maintenance mode event: [service] %s [cluster] %s",
- clusterMaintenanceModeEvent.getServiceName(), clusterMaintenanceModeEvent.getClusterId()));
- }
- publishEvent(clusterMaintenanceModeEvent);
-
- }
-
public static void sendInstanceSpawnedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId,
String lbClusterId, String publicIp, String privateIp, MemberContext context) {
InstanceSpawnedEvent instanceSpawnedEvent = new InstanceSpawnedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
index 3325561..06d408c 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
@@ -36,9 +36,9 @@ import java.util.*;
@XmlRootElement
public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<ClusterStatus> {
- private static final long serialVersionUID = -361960242360176077L;
-
- private final String serviceName;
+ private static final long serialVersionUID = -361960242360176077L;
+
+ private final String serviceName;
private final String clusterId;
private final String autoscalePolicyName;
private final String deploymentPolicyName;
@@ -50,7 +50,7 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
@XmlJavaTypeAdapter(MapAdapter.class)
private Map<String, Member> memberMap;
- private Status tempStatus;
+ private ClusterStatus status;
private String appId;
@@ -70,7 +70,7 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
this.appId = appId;
this.clusterStateManager = new LifeCycleStateManager<ClusterStatus>(ClusterStatus.Created);
// temporary; should be removed
- this.tempStatus = Status.Created;
+ this.status = ClusterStatus.Created;
}
public String getServiceName() {
@@ -103,11 +103,10 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
}
public boolean hasMembers() {
- return memberMap.isEmpty();
+ return memberMap.isEmpty();
}
-
public void addMember(Member member) {
memberMap.put(member.getMemberId(), member);
}
@@ -136,9 +135,9 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
return autoscalePolicyName;
}
- public String getDeploymentPolicyName() {
- return deploymentPolicyName;
- }
+ public String getDeploymentPolicyName() {
+ return deploymentPolicyName;
+ }
public String getLoadBalanceAlgorithmName() {
return loadBalanceAlgorithmName;
@@ -155,7 +154,7 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
public void setLbCluster(boolean isLbCluster) {
this.isLbCluster = isLbCluster;
}
-
+
@Override
public String toString() {
return "Cluster [serviceName=" + serviceName + ", clusterId=" + clusterId +
@@ -171,24 +170,22 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
* @return
*/
public boolean tenantIdInRange(int tenantId) {
- if(StringUtils.isBlank(getTenantRange())) {
+ if (StringUtils.isBlank(getTenantRange())) {
return false;
}
- if("*".equals(getTenantRange())) {
+ if ("*".equals(getTenantRange())) {
return true;
- }
- else {
+ } else {
String[] array = getTenantRange().split("-");
int tenantStart = Integer.parseInt(array[0]);
- if(tenantStart <= tenantId) {
+ if (tenantStart <= tenantId) {
String tenantEndStr = array[1];
- if("*".equals(tenantEndStr)) {
+ if ("*".equals(tenantEndStr)) {
return true;
- }
- else {
+ } else {
int tenantEnd = Integer.parseInt(tenantEndStr);
- if(tenantId <= tenantEnd) {
+ if (tenantId <= tenantEnd) {
return true;
}
}
@@ -204,8 +201,8 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
*/
public Collection<String> findPartitionIds() {
Map<String, Boolean> partitionIds = new HashMap<String, Boolean>();
- for(Member member : getMembers()) {
- if((StringUtils.isNotBlank(member.getPartitionId())) && (!partitionIds.containsKey(member.getPartitionId()))) {
+ for (Member member : getMembers()) {
+ if ((StringUtils.isNotBlank(member.getPartitionId())) && (!partitionIds.containsKey(member.getPartitionId()))) {
partitionIds.put(member.getPartitionId(), true);
}
}
@@ -233,19 +230,19 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
}
public boolean equals(Object other) {
- if(other == null || !(other instanceof Cluster)) {
+ if (other == null || !(other instanceof Cluster)) {
return false;
}
- if(this == other) {
+ if (this == other) {
return true;
}
- Cluster that = (Cluster)other;
+ Cluster that = (Cluster) other;
return this.clusterId.equals(that.clusterId);
}
- public int hashCode () {
+ public int hashCode() {
return clusterId.hashCode();
}
@@ -253,12 +250,12 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior<C
return appId;
}
- public Status getTempStatus () {
- return tempStatus;
+ public ClusterStatus getTempStatus() {
+ return status;
}
- public void setTempStatus (Status tempStatus) {
- this.tempStatus = tempStatus;
+ public void setTempStatus(ClusterStatus status) {
+ this.status = status;
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java
index dc5dd20..86000e9 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java
@@ -36,10 +36,8 @@ public abstract class ParentComponent implements Serializable {
// Cluster Id map, key = subscription alias for the cartridge type
private Map<String, ClusterDataHolder> aliasToClusterDataMap;
// Application status
- private Status tempStatus;
public ParentComponent () {
- this.tempStatus = Status.Created;
aliasToGroupMap = new HashMap<String, Group>();
aliasToClusterDataMap = new HashMap<String, ClusterDataHolder>();
}
@@ -211,12 +209,4 @@ public abstract class ParentComponent implements Serializable {
}
}
}
-
- public Status getTempStatus() {
- return tempStatus;
- }
-
- public void setTempStatus(Status status) {
- this.tempStatus = status;
- }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java
deleted file mode 100644
index 2bd0945..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java
+++ /dev/null
@@ -1,40 +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.messaging.domain.topology;
-
-public enum Status {
-
- Created(1),
- Running(2),
- Activated(3),
- In_Active(4),
- Terminating(4),
- Terminated(5);
-
- private int code;
-
- private Status(int code) {
- this.code = code;
- }
-
- public int getCode() {
- return code;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java
deleted file mode 100644
index 9b31a13..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java
+++ /dev/null
@@ -1,58 +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.messaging.event.topology;
-
-import org.apache.stratos.messaging.domain.topology.Status;
-
-import java.io.Serializable;
-
-public class ClusterMaintenanceModeEvent extends TopologyEvent implements Serializable {
-
- private final String serviceName;
- private final String clusterId;
- private Status status;
-
- public ClusterMaintenanceModeEvent(String serviceName, String clusterId) {
- this.serviceName = serviceName;
- this.clusterId = clusterId;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- @Override
- public String toString() {
- return "ClusterMaintenanceModeEvent [serviceName=" + serviceName + ", clusterStatus=" +
- status.toString() + "]";
- }
-
- public String getClusterId() {
- return clusterId;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java
deleted file mode 100644
index 3bd2a19..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.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.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ClusterMaintenanceModeEventListener extends EventListener {
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
index 9bcf47d..8626fca 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java
@@ -21,7 +21,7 @@ package org.apache.stratos.messaging.message.processor.topology;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.Status;
+import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
@@ -76,7 +76,7 @@ public class ApplicationActivatedMessageProcessor extends MessageProcessor {
}
}
- private boolean doProcess (ApplicationActivatedEvent event, Topology topology) {
+ private boolean doProcess(ApplicationActivatedEvent event, Topology topology) {
// Validate event against the existing topology
Application application = topology.getApplication(event.getAppId());
@@ -88,7 +88,7 @@ public class ApplicationActivatedMessageProcessor extends MessageProcessor {
return false;
} else {
// Apply changes to the topology
- application.setTempStatus(Status.Activated);
+ application.setStatus(ApplicationStatus.Active);
if (log.isInfoEnabled()) {
log.info(String.format("Application updated as activated : %s",
application.toString()));
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java
index 1a6ffc7..f2f2521 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java
@@ -20,7 +20,10 @@ package org.apache.stratos.messaging.message.processor.topology;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
@@ -63,7 +66,7 @@ public class ClusterActivatedProcessor extends MessageProcessor {
TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId());
}
- } else {
+ } else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
return nextProcessor.process(type, message, topology);
@@ -73,7 +76,7 @@ public class ClusterActivatedProcessor extends MessageProcessor {
}
}
- private boolean doProcess (ClusterActivatedEvent event,Topology topology) {
+ private boolean doProcess(ClusterActivatedEvent event, Topology topology) {
// Apply service filter
if (TopologyServiceFilter.getInstance().isActive()) {
@@ -119,8 +122,6 @@ public class ClusterActivatedProcessor extends MessageProcessor {
log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active);
}
cluster.setStatus(ClusterStatus.Active);
- // temporary; should be removed
- cluster.setTempStatus(Status.Activated);
if (log.isInfoEnabled()) {
log.info(String.format("Cluster updated as activated : %s",
cluster.toString()));
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java
index 8156055..c9499fb 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java
@@ -21,10 +21,9 @@ package org.apache.stratos.messaging.message.processor.topology;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Status;
import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent;
import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
@@ -67,7 +66,7 @@ public class ClusterInActivateProcessor extends MessageProcessor {
TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId());
}
- } else {
+ } else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
return nextProcessor.process(type, message, topology);
@@ -77,9 +76,8 @@ public class ClusterInActivateProcessor extends MessageProcessor {
}
}
- private boolean doProcess (ClusterInActivateEvent event,Topology topology) {
-
- // Apply service filter
+ private boolean doProcess(ClusterInActivateEvent event, Topology topology) {
+// Apply service filter
if (TopologyServiceFilter.getInstance().isActive()) {
if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
// Service is excluded, do not update topology or fire event
@@ -119,10 +117,12 @@ public class ClusterInActivateProcessor extends MessageProcessor {
}
} else {
// Apply changes to the topology
- //TODO
- // cluster.setStatus(Status.Activated);
+ if (!cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
+ log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive);
+ }
+ cluster.setStatus(ClusterStatus.Inactive);
if (log.isInfoEnabled()) {
- log.info(String.format("Cluster updated as activated : %s",
+ log.info(String.format("Cluster updated as maintenance mode: %s",
cluster.toString()));
}
}
@@ -131,5 +131,4 @@ public class ClusterInActivateProcessor extends MessageProcessor {
notifyEventListeners(event);
return true;
}
-
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java
deleted file mode 100644
index 096c9a3..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java
+++ /dev/null
@@ -1,129 +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.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent;
-import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
-import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-public class ClusterMaintenanceModeMessageProcessor extends MessageProcessor {
- private static final Log log = LogFactory.getLog(ClusterMaintenanceModeMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
-
- if (ClusterMaintenanceModeEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
- return false;
-
- // Parse complete message and build event
- ClusterMaintenanceModeEvent event = (ClusterMaintenanceModeEvent) Util.
- jsonToObject(message, ClusterMaintenanceModeEvent.class);
-
- TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
- try {
- return doProcess(event, topology);
-
- } finally {
- TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId());
- }
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-
- private boolean doProcess (ClusterMaintenanceModeEvent event,Topology topology) {
-
- // Apply service filter
- if (TopologyServiceFilter.getInstance().isActive()) {
- if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
- // Service is excluded, do not update topology or fire event
- if (log.isDebugEnabled()) {
- log.debug(String.format("Service is excluded: [service] %s", event.getServiceName()));
- }
- return false;
- }
- }
-
- // Apply cluster filter
- if (TopologyClusterFilter.getInstance().isActive()) {
- if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) {
- // Cluster is excluded, do not update topology or fire event
- if (log.isDebugEnabled()) {
- log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId()));
- }
- return false;
- }
- }
-
- // Validate event against the existing topology
- Service service = topology.getService(event.getServiceName());
- if (service == null) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("Service does not exist: [service] %s",
- event.getServiceName()));
- }
- return false;
- }
- Cluster cluster = service.getCluster(event.getClusterId());
-
- if (cluster == null) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(),
- event.getClusterId()));
- }
- } else {
- // Apply changes to the topology
- if (!cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
- log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive);
- }
- cluster.setStatus(ClusterStatus.Inactive);
- // temporary; should be removed
- cluster.setTempStatus(Status.In_Active);
- if (log.isInfoEnabled()) {
- log.info(String.format("Cluster updated as maintenance mode: %s",
- cluster.toString()));
- }
- }
-
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
index 1ed6b27..d7f2de6 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java
@@ -91,9 +91,9 @@ public class GroupActivatedProcessor extends MessageProcessor {
} else {
// Apply changes to the topology
if (!group.isStateTransitionValid(GroupStatus.Active)) {
- log.error("Invalid State Transition from " + application.getTempStatus() + " to " + GroupStatus.Active);
+ log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
}
- group.setTempStatus(Status.Activated);
+ group.setStatus(GroupStatus.Active);
if (log.isInfoEnabled()) {
log.info(String.format("Group updated as activated : %s",
group.getUniqueIdentifier()));
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
index 36ca259..571fc74 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
@@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.topology.Application;
import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.Status;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
import org.apache.stratos.messaging.event.topology.GroupInActivateEvent;
@@ -74,7 +73,7 @@ public class GroupInActivateProcessor extends MessageProcessor {
}
}
- private boolean doProcess (GroupInActivateEvent event,Topology topology) {
+ private boolean doProcess(GroupInActivateEvent event, Topology topology) {
// Validate event against the existing topology
Application application = topology.getApplication(event.getAppId());
@@ -96,7 +95,7 @@ public class GroupInActivateProcessor extends MessageProcessor {
// Apply changes to the topology
//TODO
// group.setStatus(Status.Activated);
- if (log.isInfoEnabled()) {
+ if (log.isInfoEnabled()) {
log.info(String.format("Group updated as activated : %s",
group.getUniqueIdentifier()));
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/77676a68/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
index db9e8b1..e6535f1 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
@@ -37,7 +37,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
private ServiceRemovedMessageProcessor serviceRemovedMessageProcessor;
private ClusterCreatedMessageProcessor clusterCreatedMessageProcessor;
private ClusterActivatedProcessor clusterActivatedProcessor;
- private ClusterMaintenanceModeMessageProcessor clusterMaintenanceModeMessageProcessor;
private ClusterRemovedMessageProcessor clusterRemovedMessageProcessor;
private InstanceSpawnedMessageProcessor instanceSpawnedMessageProcessor;
private MemberStartedMessageProcessor memberStartedMessageProcessor;
@@ -69,9 +68,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
clusterActivatedProcessor = new ClusterActivatedProcessor();
add(clusterActivatedProcessor);
- clusterMaintenanceModeMessageProcessor = new ClusterMaintenanceModeMessageProcessor();
- add(clusterMaintenanceModeMessageProcessor);
-
clusterRemovedMessageProcessor = new ClusterRemovedMessageProcessor();
add(clusterRemovedMessageProcessor);
@@ -120,8 +116,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
clusterCreatedMessageProcessor.addEventListener(eventListener);
} else if (eventListener instanceof ClusterActivatedEventListener) {
clusterActivatedProcessor.addEventListener(eventListener);
- } else if (eventListener instanceof ClusterMaintenanceModeEventListener) {
- clusterMaintenanceModeMessageProcessor.addEventListener(eventListener);
} else if (eventListener instanceof ClusterRemovedEventListener) {
clusterRemovedMessageProcessor.addEventListener(eventListener);
} else if (eventListener instanceof InstanceSpawnedEventListener) {