You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2015/05/11 10:29:23 UTC

[4/4] stratos git commit: fixing STRATOS-1369 - app bursing issue

fixing STRATOS-1369 - app bursing issue


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

Branch: refs/heads/master
Commit: e0ccfe65d04e7d9718d568cfd419408ab81ff27b
Parents: a773ae2
Author: reka <rt...@gmail.com>
Authored: Thu May 7 13:39:18 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon May 11 13:58:44 2015 +0530

----------------------------------------------------------------------
 .../monitor/component/GroupMonitor.java         |  2 +-
 .../component/ParentComponentMonitor.java       | 62 ++++++++++----------
 .../cluster/ClusterStatusActiveProcessor.java   | 12 +---
 .../cluster/ClusterStatusInactiveProcessor.java |  8 ---
 .../ClusterStatusTerminatedProcessor.java       |  4 --
 5 files changed, 35 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e0ccfe65/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
index 33f5af5..9378230 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
@@ -441,7 +441,7 @@ public class GroupMonitor extends ParentComponentMonitor {
         GroupInstance instance = (GroupInstance) instanceIdToInstanceMap.get(instanceId);
         if (instance != null) {
             // If this parent instance is terminating, then based on child notification,
-            // it has to decide its state
+            // it has to decide its state rather than starting a the children recovery
             if (instance.getStatus() == GroupStatus.Terminating ||
                     instance.getStatus() == GroupStatus.Terminated) {
                 ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(id,

http://git-wip-us.apache.org/repos/asf/stratos/blob/e0ccfe65/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 4ffda9f..75b18f1 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
@@ -116,6 +116,9 @@ public abstract class ParentComponentMonitor extends Monitor {
         networkPartitionCtxts = new HashMap<String, NetworkPartitionContext>();
     }
 
+    /**
+     * Starting the scheduler for the monitor
+     */
     public void startScheduler() {
         schedulerFuture = scheduler.scheduleAtFixedRate(this, 0, monitoringIntervalMilliseconds, TimeUnit.MILLISECONDS);
     }
@@ -136,10 +139,6 @@ public abstract class ParentComponentMonitor extends Monitor {
     }
 
     /**
-     *
-     */
-
-    /**
      * This will start the parallel dependencies at once from the top level.
      * it will get invoked when the monitor starts up only.
      *
@@ -163,8 +162,7 @@ public abstract class ParentComponentMonitor extends Monitor {
      * @return whether the instance has created or not
      * @throws MonitorNotFoundException if the monitor is not there
      */
-    public boolean startDependency(String componentId, String instanceId)
-            throws MonitorNotFoundException {
+    public boolean startDependency(String componentId, String instanceId) {
         List<ApplicationChildContext> applicationContexts = this.startupDependencyTree.
                 getStarAbleDependencies(componentId);
         List<String> instanceIds = new ArrayList<String>();
@@ -190,8 +188,8 @@ public abstract class ParentComponentMonitor extends Monitor {
                 log.debug("Dependency check for the Group " + context.getId() + " started");
             }
             if (!this.aliasToActiveChildMonitorsMap.containsKey(context.getId())) {
-                log.info(String.format("Starting dependent monitor on termination: [application] %s [component] %s",
-                        getAppId(), context.getId()));
+                log.info(String.format("Starting dependent monitor on termination: [application] %s " +
+                        "[component] %s", getAppId(), context.getId()));
                 List<String> parentInstanceIds = new ArrayList<String>();
                 parentInstanceIds.add(instanceId);
                 startMonitor(this, context, parentInstanceIds);
@@ -326,27 +324,25 @@ public abstract class ParentComponentMonitor extends Monitor {
      * @param childId parent id of the event which received
      */
     protected void onChildActivatedEvent(String childId, String instanceId) {
-        try {
-            removeInstanceFromFromInactiveMap(childId, instanceId);
-            removeInstanceFromFromTerminatingMap(childId, instanceId);
-
-            boolean startDep = false;
-            if (!aliasToActiveChildMonitorsMap.containsKey(childId) ||
-                    !pendingChildMonitorsList.contains(childId)) {
-                startDep = startDependency(childId, instanceId);
-            }
 
-            //Checking whether all the monitors got created
-            if (!startDep) {
-                ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().
-                        process(this.id, this.appId, instanceId);
-            } else {
-                log.info("started a child: " + startDep + " by the group/cluster: " + this.id);
-            }
-        } catch (MonitorNotFoundException e) {
-            //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
-            log.error(e);
+        removeInstanceFromFromInactiveMap(childId, instanceId);
+        removeInstanceFromFromTerminatingMap(childId, instanceId);
+
+        boolean startDep = false;
+        if (!aliasToActiveChildMonitorsMap.containsKey(childId) ||
+                !pendingChildMonitorsList.contains(childId)) {
+            startDep = startDependency(childId, instanceId);
         }
+
+        //Checking whether all the monitors got created
+        if (!startDep) {
+            ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().
+                    process(this.id, this.appId, instanceId);
+        } else {
+            log.info("started a child: " + startDep + " upon activation of " + childId +
+                    " for [application] " + appId + " [" + getMonitorType() + "] " + id);
+        }
+
     }
 
     /**
@@ -421,7 +417,7 @@ public abstract class ParentComponentMonitor extends Monitor {
                     }
                 } else {
                     if (log.isInfoEnabled()) {
-                        log.info("Publishing Cluster Terminating event for [application]: " + appId +
+                        log.info("Publishing Cluster Terminating event for [application] " + appId +
                                 " [group] " + this.id + " [cluster]: " + terminationContext.getId());
                     }
                     ClusterStatusEventPublisher.sendClusterStatusClusterTerminatingEvent(this.appId,
@@ -430,7 +426,7 @@ public abstract class ParentComponentMonitor extends Monitor {
                 }
             } else {
                 log.warn("The relevant [monitor] " + terminationContext.getId() +
-                        "is not in the active map....");
+                        " in [application] " + appId + "is not in the active map....");
             }
 
         }
@@ -636,7 +632,6 @@ public abstract class ParentComponentMonitor extends Monitor {
                             getNetworkPartitionCtxts().get(networkPartitionId);
             int minInstances = networkPartitionContext.getMinInstanceCount();
             //if terminated all the instances in this instances map should be in terminated state
-            //if terminated all the instances in this instances map should be in terminated state
             if (noOfInstancesOfRequiredStatus == this.inactiveInstancesMap.size() &&
                     requiredStatus == GroupStatus.Terminated) {
                 return true;
@@ -653,7 +648,12 @@ public abstract class ParentComponentMonitor extends Monitor {
         return false;
     }
 
-
+    /**
+     * handling the dependent scaling
+     *
+     * @param instanceContext
+     * @param networkPartitionContext
+     */
     protected void handleDependentScaling(InstanceContext instanceContext,
                                           NetworkPartitionContext networkPartitionContext) {
         /**

http://git-wip-us.apache.org/repos/asf/stratos/blob/e0ccfe65/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusActiveProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusActiveProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusActiveProcessor.java
index 1c7fd2a..eb35f4f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusActiveProcessor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusActiveProcessor.java
@@ -61,10 +61,11 @@ public class ClusterStatusActiveProcessor extends ClusterStatusProcessor {
     }
 
     private boolean doProcess(String clusterId, String instanceId) {
-        ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().
+        ClusterMonitor monitor = AutoscalerContext.getInstance().
                 getClusterMonitor(clusterId);
         boolean clusterActive = false;
-        for (ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext : monitor.getNetworkPartitionCtxts()) {
+        for (ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext :
+                monitor.getNetworkPartitionCtxts()) {
             //minimum check per partition
             ClusterInstanceContext instanceContext =
                     (ClusterInstanceContext) clusterLevelNetworkPartitionContext.
@@ -72,16 +73,9 @@ public class ClusterStatusActiveProcessor extends ClusterStatusProcessor {
             if (instanceContext != null) {
                 if (instanceContext.getActiveMembers() >= instanceContext.getMinInstanceCount()) {
                     clusterActive = true;
-                    break;
-                } else {
-                    clusterActive = false;
-                    break;
                 }
-            } else {
-                clusterActive = false;
                 break;
             }
-
         }
         if (clusterActive) {
             if (log.isInfoEnabled()) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/e0ccfe65/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusInactiveProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusInactiveProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusInactiveProcessor.java
index b938680..8383513 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusInactiveProcessor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusInactiveProcessor.java
@@ -93,17 +93,9 @@ public class ClusterStatusInactiveProcessor extends ClusterStatusProcessor {
             if (instanceContext != null) {
                 if (instanceContext.getActiveMembers() < instanceContext.getMinInstanceCount()) {
                     clusterInactive = true;
-                    break;
-                } else {
-                    clusterInactive = false;
-                    break;
                 }
-            } else {
-                clusterInactive = false;
                 break;
             }
-
-
         }
         return clusterInactive;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/e0ccfe65/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusTerminatedProcessor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusTerminatedProcessor.java
index 1b70bc0..9a6216a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusTerminatedProcessor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusTerminatedProcessor.java
@@ -136,11 +136,7 @@ public class ClusterStatusTerminatedProcessor extends ClusterStatusProcessor {
                             hasMember = false;
                         }
                     }
-                } else {
-                    hasMember = false;
-                    return hasMember;
                 }
-
             }
 
         }