stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [16/50] [abbrv] git commit: fixing wrongly used topology events and fixing issue while inactivation of group and cluster
Date Thu, 30 Oct 2014 04:13:40 GMT
fixing wrongly used topology events and fixing issue while inactivation of 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/d7d226cb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d7d226cb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d7d226cb

Branch: refs/heads/docker-grouping-merge
Commit: d7d226cb5e0c81b0f0629e8f1c843611b3cb6784
Parents: 4f6b5fe
Author: reka <rthirunavukkarasu23@gmail.com>
Authored: Tue Oct 28 00:08:46 2014 +0530
Committer: reka <rthirunavukkarasu23@gmail.com>
Committed: Tue Oct 28 00:08:46 2014 +0530

----------------------------------------------------------------------
 .../grouping/dependency/DependencyTree.java     |  1 +
 .../stratos/autoscaler/monitor/Monitor.java     | 11 ++++
 .../monitor/ParentComponentMonitor.java         | 57 ++++++++++++++------
 .../autoscaler/monitor/group/GroupMonitor.java  |  9 +++-
 .../ApplicationStatusTopicReceiver.java         |  8 +++
 ...tatusApplicationCreatedMessageProcessor.java |  8 +--
 ...StatusClusterTerminatedMessageProcessor.java |  5 +-
 7 files changed, 73 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/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 48ba7b7..1ec686b 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
@@ -195,6 +195,7 @@ public class DependencyTree {
         if (this.killDependent) {
             //finding the ApplicationContext of the given id
             //finding all the children of the found application context
+            allChildrenOfAppContext.add(applicationContext);
             findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
                     allChildrenOfAppContext);
             return allChildrenOfAppContext;

http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
----------------------------------------------------------------------
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 b1e2eb3..2088351 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
@@ -93,4 +93,15 @@ public abstract class Monitor implements EventHandler {
     public void setHasDependent(boolean hasDependent) {
         this.hasDependent = hasDependent;
     }
+
+    public boolean hasInDependentChild() {
+        boolean hasInDepChild = false;
+        for(Monitor monitor : this.aliasToActiveMonitorsMap.values()) {
+            if(!monitor.isDependent()) {
+                hasInDepChild = true;
+                break;
+            }
+        }
+        return hasInDepChild;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/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 4eb4bcb..9f3417d 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,6 +30,7 @@ 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;
@@ -114,30 +115,52 @@ public abstract class ParentComponentMonitor extends Monitor {
     protected void onChildInActiveEvent(String idOfEvent) {
         List<ApplicationContext> terminationList;
         Monitor monitor;
-        terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent);
         //Temporarily move the group/cluster to inactive list
         this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent));
 
-        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.hasActiveMonitors()) {
-                    //it is a group
-                    StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
-                } else {
-                    StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
-                            ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+        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) {
+                    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());
+                        } else {
+                            StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+                                    ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+
+                        }
+                    } 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");
         }
+
     }
 
     protected void onChildTerminatedEvent(String idOfEvent) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/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 161d9b4..3123782 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
@@ -95,7 +95,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
             //Check whether all dependent goes Terminated and then start them in parallel.
             this.aliasToInActiveMonitorsMap.remove(id);
             if (this.status != GroupStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty()
&&
-                                !this.aliasToActiveMonitorsMap.isEmpty()) {
+                    !this.aliasToActiveMonitorsMap.isEmpty()) {
                 onChildTerminatedEvent(id);
             } else {
                 StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
@@ -143,6 +143,11 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
                 "on its state change from %s to %s", id, this.status, status));
         this.status = status;
         //notifying the parent
-        MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+        if (status == GroupStatus.Inactive && !this.hasDependent) {
+            log.info("[Group] " + this.id + "is not notifying the parent, " +
+                    "since it is identified as the independent unit");
+        } else {
+            MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index ca93dce..4d52fce 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -116,6 +116,14 @@ public class ApplicationStatusTopicReceiver implements Runnable {
             }
         });
 
+        statusEventReceiver.addEventListener(new AppStatusGroupInactivateEventListener()
{
+            @Override
+            protected void onEvent(Event event) {
+                TopologyBuilder.handleGroupInActiveEvent((AppStatusGroupInactivateEvent)
event);
+
+            }
+        });
+
         statusEventReceiver.addEventListener(new AppStatusApplicationActivatedEventListener()
{
 
             @Override

http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
index 4e2f97f..29fce0a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
@@ -20,7 +20,7 @@ package org.apache.stratos.messaging.message.processor.application.status;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.util.Util;
 
@@ -39,10 +39,10 @@ public class AppStatusApplicationCreatedMessageProcessor extends MessageProcesso
 
     @Override
     public boolean process(String type, String message, Object object) {
-        if (ApplicationCreatedEvent.class.getName().equals(type)) {
+        if (AppStatusApplicationCreatedEvent.class.getName().equals(type)) {
             // Parse complete message and build event
-            ApplicationCreatedEvent event =
-                    (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
+            AppStatusApplicationCreatedEvent event =
+                    (AppStatusApplicationCreatedEvent) Util.jsonToObject(message, AppStatusApplicationCreatedEvent.class);
 
             if (log.isDebugEnabled()) {
                 log.debug("Received ApplicationCreated Event in application status topic:
" + event.toString());

http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
index 6cdde51..55cec80 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
@@ -21,7 +21,6 @@ package org.apache.stratos.messaging.message.processor.application.status;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatedEvent;
-import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent;
 import org.apache.stratos.messaging.message.processor.MessageProcessor;
 import org.apache.stratos.messaging.util.Util;
 
@@ -40,9 +39,9 @@ public class AppStatusClusterTerminatedMessageProcessor extends MessageProcessor
         if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) {
             // Parse complete message and build event
             AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util.
-                                                jsonToObject(message, AppStatusClusterTerminatedEvent.class);
+                    jsonToObject(message, AppStatusClusterTerminatedEvent.class);
 
-            if(log.isDebugEnabled()) {
+            if (log.isDebugEnabled()) {
                 log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString());
             }
             // Notify event listeners


Mime
View raw message