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

git commit: fixing inActive handling issue

Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping ed1af704a -> 3b51d5c8f


fixing inActive handling issue


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

Branch: refs/heads/4.0.0-grouping
Commit: 3b51d5c8f184643b8aa9cc7c6d8855b1f09596b5
Parents: ed1af70
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 14:52:22 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 14:52:22 2014 +0530

----------------------------------------------------------------------
 .../monitor/ParentComponentMonitor.java         | 75 ++++++++++----------
 .../monitor/application/ApplicationMonitor.java |  4 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |  2 +-
 3 files changed, 42 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/3b51d5c8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 6aa76b6..bd50f42 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -30,7 +30,6 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationCont
 import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
 import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
 import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
 import org.apache.stratos.messaging.domain.topology.ParentComponent;
 
 import java.util.HashMap;
@@ -115,50 +114,54 @@ public abstract class ParentComponentMonitor extends Monitor {
     protected void onChildInActiveEvent(String idOfEvent) {
         List<ApplicationContext> terminationList;
         Monitor monitor;
-        //Temporarily move the group/cluster to inactive list
-        //this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent));
 
-        if(this.hasDependent) {
+        if (this.hasDependent) {
             //need to notify the parent
             StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId);
         } else {
             terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent);
-            if(this.hasInDependentChild()) {
-                if(this.parent != null) {
+            //Checking whether all children are to be terminated.
+            if (terminationList.size() ==
+                    (this.aliasToActiveMonitorsMap.size() + this.aliasToInActiveMonitorsMap.size())) {
+                if (this.parent != null) {
+                    StatusEventPublisher.sendGroupTerminatingEvent(this.appId, this.id);
+                }
+            } else {
+                //TODO application InActive
+                if (this.parent != null) {
                     StatusEventPublisher.sendGroupInActivateEvent(this.appId, this.id);
-                } /*else {
-                    StatusEventPublisher.sendApplicationInactivatedEvent(this.appId, terminationContext.getId());
-
-                }*/
-
-            }
-
-            if (terminationList != null) {
-                //Checking the termination dependents status
-                for (ApplicationContext terminationContext : terminationList) {
-                    //Check whether dependent is in_active, then start to kill it
-                    monitor = this.aliasToActiveMonitorsMap.
-                            get(terminationContext.getId());
-                    //start to kill it
-                    if(monitor != null) {
-                        if (monitor.hasActiveMonitors()) {
-                            //it is a group
-                            StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
+                }
+                //Since it is reached the most independent unit and has few independent monitors,
+                // has to put the children down to terminating
+
+                if (terminationList != null) {
+                    //Checking the termination dependents status
+                    for (ApplicationContext terminationContext : terminationList) {
+                        //Check whether dependent is in_active, then start to kill it
+                        monitor = this.aliasToActiveMonitorsMap.
+                                get(terminationContext.getId());
+                        //start to kill it
+                        if (monitor != null) {
+                            if (monitor.hasActiveMonitors()) {
+                                //it is a group
+                                StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
+                            } else {
+                                StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+                                        ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+                            }
                         } else {
-                            StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
-                                    ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
-
+                            log.warn("The relevant [monitor] " + terminationContext.getId() +
+                                    "is not in the active map....");
                         }
-                    } else {
-                        log.warn("The relevant [monitor] " + terminationContext.getId() +
-                                                                    "is not in the active map....");
-                    }
 
+                    }
+                } else {
+                    log.warn("Wrong inActive event received from [Child] " + idOfEvent + "  to the [parent]"
+                            + " where child is identified as a independent");
                 }
-            } else {
-                log.warn("Wrong inActive event received from [Child] " + idOfEvent + "  to the [parent]"
-                        + " where child is identified as a independent");
             }
+
+
         }
 
     }
@@ -210,7 +213,7 @@ public abstract class ParentComponentMonitor extends Monitor {
             }
         }
 
-        if((terminationList != null && allDependentTerminated || terminationList == null) &&
+        if ((terminationList != null && allDependentTerminated || terminationList == null) &&
                 (parentContexts != null && canStart || parentContexts == null)) {
             //Find the non existent monitor by traversing dependency tree
 
@@ -249,7 +252,7 @@ public abstract class ParentComponentMonitor extends Monitor {
     public void startDependencyOnTermination() throws TopologyInConsistentException {
         //start the first dependency which went to terminated
         List<ApplicationContext> applicationContexts = this.dependencyTree.
-                                                            getStarAbleDependenciesByTermination();
+                getStarAbleDependenciesByTermination();
         startDependency(applicationContexts);
 
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/3b51d5c8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
index f6a4d18..77def36 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
@@ -176,9 +176,9 @@ public class ApplicationMonitor extends ParentComponentMonitor {
             onChildInActiveEvent(id);
             //TODO update the status of the Application as in_active when child becomes in_active
 
-        } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
+        /*} else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
             onChildTerminatingEvent(id);
-            StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+            StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);*/
 
         } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
             //Check whether all dependent goes Terminated and then start them in parallel.

http://git-wip-us.apache.org/repos/asf/stratos/blob/3b51d5c8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 261f745..e6f8495 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
@@ -88,7 +88,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
             StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
 
         } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
-            onChildTerminatingEvent(id);
+            //onChildTerminatingEvent(id);
             StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
 
         } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {