Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping a70bf6489 -> 0a22c7bba


fixing hierarchical monitor issue


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

Branch: refs/heads/4.0.0-grouping
Commit: 9934c2ab7a20a42cbee5226d2aec7a9a088db838
Parents: f11401a
Author: reka <rthirunavukkaras...@gmail.com>
Authored: Thu Oct 9 19:26:45 2014 +0530
Committer: reka <rthirunavukkaras...@gmail.com>
Committed: Thu Oct 9 19:26:45 2014 +0530

----------------------------------------------------------------------
 .../grouping/dependency/DependencyBuilder.java  | 85 +++++++++++---------
 .../context/ApplicationContextFactory.java      |  4 +-
 .../AutoscalerTopologyEventReceiver.java        |  3 +-
 .../stratos/autoscaler/monitor/Monitor.java     | 10 ++-
 .../messaging/domain/topology/Group.java        |  2 +-
 5 files changed, 56 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/9934c2ab/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
index 30709e7..275b8c3 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
@@ -84,56 +84,61 @@ public class DependencyBuilder {
             //Parsing the start up order
             Set<StartupOrder> startupOrders = 
dependencyOrder.getStartupOrders();
             ApplicationContext foundContext;
-            if (startupOrders == null) {
+            ApplicationContext parentContext;
+            /*if (startupOrders == null) {
                if (log.isDebugEnabled()) {
                     log.debug("startupOrders is null, returning default 
dependency tree (empty)");
                 }
-               
-               return dependencyTree;
-            }
-            for (StartupOrder startupOrder : startupOrders) {
-
-                foundContext = null;
-
-                for (String start : startupOrder.getStartList())  {
-
-                    if (start != null) {
-                        ApplicationContext applicationContext = 
ApplicationContextFactory.
-                                getApplicationContext(start, component, 
dependencyTree.isKillDependent());
-                        String id = applicationContext.getId(); //TODO change 
the id
-
-                        ApplicationContext existingApplicationContext =
-                                
dependencyTree.findApplicationContextWithId(id);
-                        if (existingApplicationContext == null) {
-                            if (foundContext != null) {
-                                //appending the start up order to existing 
group/cluster
-                                
foundContext.addApplicationContext(applicationContext);
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Found an existing [dependency] 
" + foundContext.getId() +
-                                            " and adding the [dependency] " + 
id + " as the child");
+                return dependencyTree;
+            }*/
+            if (startupOrders != null) {
+                for (StartupOrder startupOrder : startupOrders) {
+                    foundContext = null;
+                    parentContext = null;
+                    for (String start : startupOrder.getStartList()) {
+
+                        if (start != null) {
+                            ApplicationContext applicationContext = 
ApplicationContextFactory.
+                                    getApplicationContext(start, component, 
dependencyTree.isKillDependent());
+                            String id = applicationContext.getId();
+
+                            ApplicationContext existingApplicationContext =
+                                    
dependencyTree.findApplicationContextWithId(id);
+                            if (existingApplicationContext == null) {
+                                if (parentContext != null) {
+                                    //appending the start up order to already 
added parent group/cluster
+                                    
parentContext.addApplicationContext(applicationContext);
+                                    parentContext = applicationContext;
+                                    if (log.isDebugEnabled()) {
+                                        log.debug("Found an existing 
[dependency] " + parentContext.getId() +
+                                                " and adding the [dependency] 
" + id + " as the child");
+                                    }
+                                } else {
+                                    //adding list of startup order to the 
dependency tree
+                                    
dependencyTree.addApplicationContext(applicationContext);
+                                    parentContext = applicationContext;
                                 }
                             } else {
-                                //adding list of startup order to the 
dependency tree
-                                
dependencyTree.addApplicationContext(applicationContext);
-                            }
-                        } else {
-                            if (foundContext == null) {
-                                //assigning the found context to the later use.
-                                foundContext = existingApplicationContext;
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Found an existing [dependency] 
" + id + " and setting it " +
-                                            "for the next dependency to 
follow");
+                                if (foundContext == null) {
+                                    //if existing context found, add it to 
child of existing context and
+                                    //set the existing context as the next 
parent
+                                    
existingApplicationContext.addApplicationContext(applicationContext);
+                                    parentContext = existingApplicationContext;
+                                    if (log.isDebugEnabled()) {
+                                        log.debug("Found an existing 
[dependency] " + id + " and setting it " +
+                                                "for the next dependency to 
follow");
+                                    }
+                                } else {
+                                    String msg = "Startup order is not 
consistent. It contains the group/cluster " +
+                                            "which has been used more than one 
in another startup order";
+                                    throw new DependencyBuilderException(msg);
                                 }
-                            } else {
-                                String msg = "Startup order is not consistent. 
It contains the group/cluster " +
-                                        "which has been used more than one in 
another startup order";
-                                throw new DependencyBuilderException(msg);
-                            }
 
+                            }
                         }
                     }
-                }
 
+                }
             }
             //TODO need to parser the scalable dependencies
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9934c2ab/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
index 6e10633..685f131 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
@@ -42,12 +42,12 @@ public class ApplicationContextFactory {
                                                            boolean 
isKillDependent) {
         String id;
         ApplicationContext applicationContext = null;
-        if (startOrder.contains(Constants.GROUP)) {
+        if (startOrder.startsWith(Constants.GROUP + ".")) {
             //getting the group alias
             id = getGroupFromStartupOrder(startOrder);
             applicationContext = new GroupContext(id,
                     isKillDependent);
-        } else if (startOrder.contains(Constants.CARTRIDGE)) {
+        } else if (startOrder.startsWith(Constants.CARTRIDGE + ".")) {
             //getting the cluster alias
             id = getClusterFromStartupOrder(startOrder);
             //getting the cluster-id from cluster alias

http://git-wip-us.apache.org/repos/asf/stratos/blob/9934c2ab/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 df9a3c3..91189fb 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
@@ -624,9 +624,8 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
                     applicationMonitor = 
AutoscalerUtil.getApplicationMonitor(application);
 
                     long end = System.currentTimeMillis();
-                    log.info("Time taken to start Napp monitor: " + (end - 
start) / 1000);
+                    log.info("Time taken to start app monitor: " + (end - 
start) / 1000);
                     success = true;
-                    //TODO exception handling
                 } catch (DependencyBuilderException e) {
                     String msg = "Application monitor creation failed for 
Application: ";
                     log.warn(msg, e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/9934c2ab/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 65ab790..800ed64 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
@@ -122,9 +122,13 @@ public abstract class Monitor implements EventHandler {
             if (context instanceof GroupContext) {
                 startGroupMonitor(this, context.getId(), component);
             } else if (context instanceof ClusterContext) {
-                ClusterDataHolder clusterDataHolder = 
component.getClusterData(context.getId());
-                String clusterId = clusterDataHolder.getClusterId();
-                String serviceName = clusterDataHolder.getServiceType();
+                String clusterId = context.getId();
+                String serviceName = null;
+                for(ClusterDataHolder dataHolder : 
component.getClusterDataMap().values()) {
+                    if(dataHolder.getClusterId().equals(clusterId)) {
+                        serviceName = dataHolder.getServiceType();
+                    }
+                }
                 Cluster cluster;
                 //acquire read lock for the service and cluster
                 TopologyManager.acquireReadLockForCluster(clusterId, 
serviceName);

http://git-wip-us.apache.org/repos/asf/stratos/blob/9934c2ab/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
index 17e1a90..9b5a29e 100644
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java
@@ -42,7 +42,7 @@ public class Group extends ParentComponent {
     }
 
     public String getUniqueIdentifier() {
-        return name;
+        return alias;
     }
 
     public String getAlias() {

Reply via email to