Repository: stratos Updated Branches: refs/heads/master ea721512a -> 03480a455
udpating setStatus with instance id in cluster monitor Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/03480a45 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/03480a45 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/03480a45 Branch: refs/heads/master Commit: 03480a4555585c971bd14fa4c78840265351cd54 Parents: 0c5d4ca Author: reka <[email protected]> Authored: Tue Dec 2 23:28:02 2014 +0530 Committer: reka <[email protected]> Committed: Tue Dec 2 23:28:17 2014 +0530 ---------------------------------------------------------------------- .../topology/AutoscalerTopologyEventReceiver.java | 13 ++++++++----- .../monitor/component/ParentComponentMonitor.java | 7 ++++++- 2 files changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/03480a45/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java index f54654b..8e25408 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -229,6 +229,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { log.info("[ClusterCreatedEvent] Received: " + event.getClass()); ClusterResetEvent clusterResetEvent = (ClusterResetEvent) event; String clusterId = clusterResetEvent.getClusterId(); + String instanceId = clusterResetEvent.getInstanceId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; monitor = asCtx.getClusterMonitor(clusterId); @@ -241,7 +242,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { } //changing the status in the monitor, will notify its parent monitor monitor.destroy(); - monitor.setStatus(ClusterStatus.Created); + monitor.setStatus(ClusterStatus.Created, instanceId); } }); @@ -259,6 +260,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { log.info("[ClusterInActivateEvent] Received: " + event.getClass()); ClusterInactivateEvent clusterInactivateEvent = (ClusterInactivateEvent) event; String clusterId = clusterInactivateEvent.getClusterId(); + String instanceId = clusterInactivateEvent.getInstanceId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; monitor = asCtx.getClusterMonitor(clusterId); @@ -270,7 +272,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { return; } //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(ClusterStatus.Inactive); + monitor.setStatus(ClusterStatus.Inactive, instanceId); } }); @@ -297,10 +299,10 @@ public class AutoscalerTopologyEventReceiver implements Runnable { //changing the status in the monitor, will notify its parent monitor if (monitor.getStatus() == ClusterStatus.Active) { // terminated gracefully - monitor.setStatus(ClusterStatus.Terminating); + monitor.setStatus(ClusterStatus.Terminating, instanceId); InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId); } else { - monitor.setStatus(ClusterStatus.Terminating); + monitor.setStatus(ClusterStatus.Terminating, instanceId); monitor.terminateAllMembers(); } ServiceReferenceHolder.getInstance().getClusterStatusProcessorChain(). @@ -314,6 +316,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { log.info("[ClusterTerminatedEvent] Received: " + event.getClass()); ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event; String clusterId = clusterTerminatedEvent.getClusterId(); + String instanceId = clusterTerminatedEvent.getInstanceId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; monitor = asCtx.getClusterMonitor(clusterId); @@ -330,7 +333,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { return; } //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(ClusterStatus.Terminated); + monitor.setStatus(ClusterStatus.Terminated, instanceId); //Destroying and Removing the Cluster monitor monitor.destroy(); AutoscalerContext.getInstance().removeClusterMonitor(clusterId); http://git-wip-us.apache.org/repos/asf/stratos/blob/03480a45/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java index 01c1787..0ea9462 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java @@ -64,6 +64,8 @@ public abstract class ParentComponentMonitor extends Monitor { protected DependencyTree scalingDependencyTree; //monitors map, key=GroupAlias/clusterId and value=GroupMonitor/AbstractClusterMonitor protected Map<String, Monitor> aliasToActiveMonitorsMap; + //Pending monitors list + protected List<String> pendingMonitorsList; //instanceIds map, stopped monitors protected List<String> inactiveMonitorsList; //terminating instances list @@ -73,6 +75,7 @@ public abstract class ParentComponentMonitor extends Monitor { aliasToActiveMonitorsMap = new HashMap<String, Monitor>(); inactiveMonitorsList = new ArrayList<String>(); terminatingMonitorsList = new ArrayList<String>(); + pendingMonitorsList = new ArrayList<String>(); //clusterIdToClusterMonitorsMap = new HashMap<String, AbstractClusterMonitor>(); this.id = component.getUniqueIdentifier(); //Building the startup dependencies for this monitor within the immediate children @@ -258,7 +261,7 @@ public abstract class ParentComponentMonitor extends Monitor { } boolean startDep; - if(!aliasToActiveMonitorsMap.containsKey(eventId)) { + if(!aliasToActiveMonitorsMap.containsKey(eventId) || !pendingMonitorsList.contains(eventId)) { startDep = startDependency(eventId, instanceId); } else { startDep = startDependencyByInstanceCreation(eventId, instanceId); @@ -498,6 +501,7 @@ public abstract class ParentComponentMonitor extends Monitor { ApplicationChildContext context, List<String> instanceId) { Thread th = null; if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) { + pendingMonitorsList.add(context.getId()); th = new Thread( new MonitorAdder(parent, context, this.appId, instanceId)); if (log.isDebugEnabled()) { @@ -643,6 +647,7 @@ public abstract class ParentComponentMonitor extends Monitor { } aliasToActiveMonitorsMap.put(context.getId(), monitor); + pendingMonitorsList.remove(context.getId()); // ApplicationBuilder. if (log.isInfoEnabled()) { log.info(String.format("Monitor has been added successfully for: %s",
