You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2014/11/04 12:29:48 UTC

[1/2] git commit: cleaning AutoscalerTopologyEventReceiver

Repository: stratos
Updated Branches:
  refs/heads/docker-grouping-merge f55d5447e -> 0137ebb94


cleaning AutoscalerTopologyEventReceiver


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

Branch: refs/heads/docker-grouping-merge
Commit: 1b385349f030df9f466eea297636272cb8ecfdf2
Parents: 77d1a7c
Author: R-Rajkumar <rr...@gmail.com>
Authored: Tue Nov 4 16:58:58 2014 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Tue Nov 4 16:58:58 2014 +0530

----------------------------------------------------------------------
 .../AutoscalerTopologyEventReceiver.java        | 105 +++++++++++--------
 1 file changed, 64 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/1b385349/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 df5b6a2..de07b17 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
@@ -196,14 +196,18 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event;
                 String clusterId = clusterActivatedEvent.getClusterId();
-                AbstractClusterMonitor clusterMonitor =
-                        AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-
-                //changing the status in the monitor, will notify its parent monitor
-                if (clusterMonitor != null) {
-                    clusterMonitor.setStatus(ClusterStatus.Active);
+                AutoscalerContext asCtx = AutoscalerContext.getInstance();
+                AbstractClusterMonitor monitor;
+                monitor = asCtx.getClusterMonitor(clusterId);
+                if (null == monitor) {
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("A cluster monitor is not found in autoscaler context "
+                                                + "[cluster] %s", clusterId));
+                    }
+                    return;
                 }
-
+                //changing the status in the monitor, will notify its parent monitor
+                monitor.setStatus(ClusterStatus.Active);
             }
         });
 
@@ -215,12 +219,20 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event;
                 String clusterId = clusterCreatedEvent.getCluster().getClusterId();
-                AbstractClusterMonitor clusterMonitor =
-                        AutoscalerContext.getInstance().getClusterMonitor(clusterId);
+                AutoscalerContext asCtx = AutoscalerContext.getInstance();
+                AbstractClusterMonitor monitor;
+                monitor = asCtx.getClusterMonitor(clusterId);
+                if (null == monitor) {
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("A cluster monitor is not found in autoscaler context "
+                                                + "[cluster] %s", clusterId));
+                    }
+                    return;
+                }
 
                 //changing the status in the monitor, will notify its parent monitor
-                clusterMonitor.setStop(true);
-                clusterMonitor.setStatus(ClusterStatus.Created);
+                monitor.setStop(true);
+                monitor.setStatus(ClusterStatus.Created);
 
             }
         });
@@ -239,14 +251,18 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 ClusterInactivateEvent clusterInactivateEvent = (ClusterInactivateEvent) event;
                 String clusterId = clusterInactivateEvent.getClusterId();
-                AbstractClusterMonitor clusterMonitor =
-                        AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-
-                //changing the status in the monitor, will notify its parent monitor
-                if (clusterMonitor != null) {
-                    clusterMonitor.setStatus(ClusterStatus.Inactive);
+                AutoscalerContext asCtx = AutoscalerContext.getInstance();
+                AbstractClusterMonitor monitor;
+                monitor = asCtx.getClusterMonitor(clusterId);
+                if (null == monitor) {
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("A cluster monitor is not found in autoscaler context "
+                                                + "[cluster] %s", clusterId));
+                    }
+                    return;
                 }
-
+                //changing the status in the monitor, will notify its parent monitor
+                monitor.setStatus(ClusterStatus.Inactive);
             }
         });
 
@@ -258,22 +274,24 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event;
                 String clusterId = clusterTerminatingEvent.getClusterId();
-                AbstractClusterMonitor clusterMonitor =
-                        AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-
-                //changing the status in the monitor, will notify its parent monitor
-                if (clusterMonitor != null) {
-                    if (clusterMonitor.getStatus() == ClusterStatus.Active) {
-                        // terminated gracefully
-                        clusterMonitor.setStatus(ClusterStatus.Terminating);
-                        InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId);
-                    } else {
-                        clusterMonitor.setStatus(ClusterStatus.Terminating);
-                        clusterMonitor.terminateAllMembers();
+                AutoscalerContext asCtx = AutoscalerContext.getInstance();
+                AbstractClusterMonitor monitor;
+                monitor = asCtx.getClusterMonitor(clusterId);
+                if (null == monitor) {
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("A cluster monitor is not found in autoscaler context "
+                                                + "[cluster] %s", clusterId));
                     }
-
+                    return;
+                }
+                //changing the status in the monitor, will notify its parent monitor
+                if (monitor.getStatus() == ClusterStatus.Active) {
+                	// terminated gracefully
+                	monitor.setStatus(ClusterStatus.Terminating);
+                	InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId);
                 } else {
-                    log.warn("No Cluster Monitor found for cluster id " + clusterId);
+                	monitor.setStatus(ClusterStatus.Terminating);
+                	monitor.terminateAllMembers();
                 }
             }
         });
@@ -285,17 +303,22 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
 
                 ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event;
                 String clusterId = clusterTerminatedEvent.getClusterId();
-                AbstractClusterMonitor clusterMonitor =
-                        AutoscalerContext.getInstance().getClusterMonitor(clusterId);
+                AutoscalerContext asCtx = AutoscalerContext.getInstance();
+                AbstractClusterMonitor monitor;
+                monitor = asCtx.getClusterMonitor(clusterId);
+                if (null == monitor) {
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("A cluster monitor is not found in autoscaler context "
+                                                + "[cluster] %s", clusterId));
+                    }
+                    return;
+                }
 
                 //changing the status in the monitor, will notify its parent monitor
-                if (clusterMonitor != null) {
-                    clusterMonitor.setStatus(ClusterStatus.Terminated);
-                    //Destroying and Removing the Cluster monitor
-                    clusterMonitor.destroy();
-                    AutoscalerContext.getInstance().removeClusterMonitor(clusterId);
-
-                }
+                monitor.setStatus(ClusterStatus.Terminated);
+                //Destroying and Removing the Cluster monitor
+                monitor.destroy();
+                AutoscalerContext.getInstance().removeClusterMonitor(clusterId);
             }
         });
 


[2/2] git commit: Merge branch 'docker-grouping-merge' of https://git-wip-us.apache.org/repos/asf/stratos into docker-grouping-merge

Posted by ra...@apache.org.
Merge branch 'docker-grouping-merge' of https://git-wip-us.apache.org/repos/asf/stratos into docker-grouping-merge


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

Branch: refs/heads/docker-grouping-merge
Commit: 0137ebb942355627feb05999fb7df845331b139a
Parents: 1b38534 f55d544
Author: R-Rajkumar <rr...@gmail.com>
Authored: Tue Nov 4 16:59:25 2014 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Tue Nov 4 16:59:25 2014 +0530

----------------------------------------------------------------------
 .../status/checker/StatusChecker.java           | 27 ++++++-------
 .../controller/topology/TopologyBuilder.java    |  2 +
 .../manager/client/AutoscalerServiceClient.java |  8 +---
 .../category/DefaultLoadBalancerCategory.java   |  2 +-
 .../ServiceLevelLoadBalancerCategory.java       |  2 +-
 .../bean/util/converter/PojoConverter.java      | 40 ++++++++++----------
 .../rest/endpoint/services/ServiceUtils.java    | 20 +++++-----
 7 files changed, 47 insertions(+), 54 deletions(-)
----------------------------------------------------------------------