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 <[email protected]> Authored: Tue Oct 21 17:54:38 2014 +0530 Committer: reka <[email protected]> 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) {
