Repository: stratos
Updated Branches:
  refs/heads/master 1f7224f09 -> 8ea5eb630


fixing dependent scaling issue and adding more debug logs


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

Branch: refs/heads/master
Commit: 8ea5eb6302c5c01c3ad1cd64a0c296e7e2e2b060
Parents: 1f7224f
Author: reka <[email protected]>
Authored: Thu Dec 18 18:01:39 2014 +0530
Committer: reka <[email protected]>
Committed: Thu Dec 18 18:01:51 2014 +0530

----------------------------------------------------------------------
 .../parser/DefaultApplicationParser.java        | 44 ++++++++++++++++++++
 .../autoscaler/monitor/MonitorFactory.java      |  7 ++--
 .../monitor/component/GroupMonitor.java         |  5 +++
 .../component/ParentComponentMonitor.java       | 31 +++++++++++---
 .../autoscaler/rule/RuleTasksDelegator.java     |  4 +-
 5 files changed, 80 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/8ea5eb63/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
index 6d7db2b..7b7d487 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
@@ -471,6 +471,10 @@ public class DefaultApplicationParser implements 
ApplicationParser {
         if (startupOrders != null) {
             
dependencyOrder.setStartupOrders(ParserUtils.convertStartupOrder(startupOrders, 
groupCtxt));
         }
+        String[] scaleDependents = 
getScaleDependentForGroup(groupCtxt.getName(), serviceGroup);
+        if(scaleDependents != null) {
+            
dependencyOrder.setScalingDependents(ParserUtils.convertScalingDependentList(scaleDependents,
 groupCtxt));
+        }
         
dependencyOrder.setTerminationBehaviour(getKillbehaviour(groupCtxt.getName(),serviceGroup));
         //dependencyOrder.setScalingDependents(scalingDependents);
         group.setDependencyOrder(dependencyOrder);
@@ -547,6 +551,46 @@ public class DefaultApplicationParser implements 
ApplicationParser {
         return null;
     }
 
+
+    /**
+     * Find the scale dependent order
+     *
+     * @param serviceGroup GroupContext with Group defintion information
+     * @return Set of Startup Orders which are defined in the Group
+     *
+     * @throws ApplicationDefinitionException
+     */
+    private String [] getScaleDependentForGroup(String serviceGroupName, 
ServiceGroup serviceGroup) throws ApplicationDefinitionException {
+
+        ServiceGroup nestedServiceGroup = 
getNestedServiceGroup(serviceGroupName, serviceGroup);
+
+        if (nestedServiceGroup == null) {
+            handleError("Service Group Definition not found for name " + 
serviceGroupName);
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("parsing application ... getScaleDependentForGroup: " + 
serviceGroupName);
+        }
+
+        assert nestedServiceGroup != null;
+        if (nestedServiceGroup.getDependencies() != null) {
+            if (log.isDebugEnabled()) {
+                log.debug("parsing application ... getScaleDependentForGroup: 
dependencies != null " );
+            }
+            if (nestedServiceGroup.getDependencies().getScalingDependants() != 
null) {
+
+                String [] scalingDependants = 
nestedServiceGroup.getDependencies().getScalingDependants();
+                if (log.isDebugEnabled()) {
+                    log.debug("parsing application ... 
getScaleDependentForGroup: scalingDependants != null # of: " +  
scalingDependants.length);
+                }
+                return scalingDependants;
+            }
+        }
+
+        return null;
+    }
+
+
     /**
      * Get kill behaviour related to a Group
      *

http://git-wip-us.apache.org/repos/asf/stratos/blob/8ea5eb63/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
index 12e0794..a8721a6 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
@@ -175,8 +175,8 @@ public class MonitorFactory {
             if (application != null) {
                 applicationMonitor = new ApplicationMonitor(application);
                 applicationMonitor.setHasStartupDependents(false);
-
-
+                //starting the scheduler of the application monitor
+                applicationMonitor.startScheduler();
             } else {
                 String msg = "Application not found in the topology: 
[application-id] " + applicationId;
                 throw new TopologyInConsistentException(msg);
@@ -243,8 +243,7 @@ public class MonitorFactory {
             boolean hasScalingDependents = false;
             if(parentMonitor.getScalingDependencies() != null) {
                 for (ScalingDependentList scalingDependentList : 
parentMonitor.getScalingDependencies()) {
-                    if 
(scalingDependentList.getScalingDependentListComponents().
-                            contains("cartridge." + clusterId.substring(0, 
clusterId.indexOf('.')))) {
+                    if 
(scalingDependentList.getScalingDependentListComponents().contains(clusterId)) {
                         hasScalingDependents = true;
                     }
                 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/8ea5eb63/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 85b58d4..97af0b0 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
@@ -119,6 +119,11 @@ public class GroupMonitor extends ParentComponentMonitor {
                                 if (groupScalingEnabled) {
                                     //one of the child is loaded and max out.
                                     // Hence creating new group instance
+                                    if(log.isDebugEnabled()) {
+                                        log.debug("Handling group scaling for 
the [group] " + id +
+                                                "upon a max out event from " +
+                                                "the children");
+                                    }
                                     boolean createOnDemand = 
createInstanceOnDemand(instanceContext.
                                             getParentInstanceId());
                                     if (!createOnDemand) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/8ea5eb63/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 253aaf4..6f45a8f 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
@@ -285,6 +285,12 @@ public abstract class ParentComponentMonitor extends 
Monitor implements Runnable
 
     @Override
     public void onChildScalingOverMaxEvent(ScalingOverMaxEvent 
scalingOverMaxEvent) {
+        if (log.isDebugEnabled()) {
+            log.debug("Child Scaling max out event received to [group]: " + 
this.getId()
+                    + ", [network partition]: " + 
scalingOverMaxEvent.getNetworkPartitionId()
+                    + ", [event] " + scalingOverMaxEvent.getId() + ", " +
+                    "[group instance] " + scalingOverMaxEvent.getInstanceId());
+        }
         //adding the scaling over max event to group instance Context
         String networkPartitionId = 
scalingOverMaxEvent.getNetworkPartitionId();
         String instanceId = scalingOverMaxEvent.getInstanceId();
@@ -570,15 +576,24 @@ public abstract class ParentComponentMonitor extends 
Monitor implements Runnable
                     getScalingDependentListComponents()) {
                 ScalingEvent scalingEvent = instanceContext.
                         getScalingEvent(scalingDependentListComponent);
-                if (highestFactorEvent == null) {
-                    highestFactorEvent = scalingEvent;
-                } else {
-                    if (scalingEvent.getFactor() > 
highestFactorEvent.getFactor()) {
+                if(scalingEvent != null) {
+                    if (highestFactorEvent == null) {
                         highestFactorEvent = scalingEvent;
+                    } else {
+                        if (scalingEvent.getFactor() > 
highestFactorEvent.getFactor()) {
+                            highestFactorEvent = scalingEvent;
+                        }
                     }
                 }
             }
-            highestScalingEventOfDependencies.add(highestFactorEvent);
+            if(highestFactorEvent != null) {
+                if(log.isDebugEnabled()) {
+                    log.debug("Found the highest factor for the [dependent 
set] " +
+                            highestFactorEvent.getId() + " the factor is " +
+                            highestFactorEvent.getFactor());
+                }
+                highestScalingEventOfDependencies.add(highestFactorEvent);
+            }
         }
 
         for (ScalingEvent highestScalingEventOfChild : 
highestScalingEventOfDependencies) {
@@ -598,6 +613,12 @@ public abstract class ParentComponentMonitor extends 
Monitor implements Runnable
                                         networkPartitionContext.getId(),
                                         instanceContext.getId(),
                                         
highestScalingEventOfChild.getFactor());
+                                if(log.isDebugEnabled()) {
+                                    log.debug("Notifying the [child] " + 
scalingEvent.getId() +
+                                            " [instance] " + 
scalingEvent.getInstanceId() +
+                                            " with the highest [factor] " + 
scalingEvent.getFactor() +
+                                            " upon decision of dependent 
scaling");
+                                }
                                 monitor.onParentScalingEvent(scalingEvent);
                             }
                         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/8ea5eb63/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
index 5ad3b76..b7b50e7 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
@@ -315,7 +315,7 @@ public class RuleTasksDelegator {
                                                       int 
requiredInstanceCount, int minimumInstanceCount) {
 
         if(log.isDebugEnabled()) {
-            log.debug("Scaling dependent notification..");
+            log.debug("Scaling dependent notification is going to the 
[parentInstance] " + instanceId);
         }
         //Notify parent for checking scaling dependencies
         AbstractClusterMonitor clusterMonitor = 
AutoscalerContext.getInstance().getClusterMonitor(clusterId);
@@ -331,7 +331,7 @@ public class RuleTasksDelegator {
     public void delegateScalingOverMaxNotification(String clusterId, String 
networkPartitionId, String instanceId) {
 
         if(log.isDebugEnabled()) {
-            log.debug("Scaling dependent notification..");
+            log.debug("Scaling max out notification is going to the 
[parentInstance] " + instanceId);
         }
         //Notify parent for checking scaling dependencies
         AbstractClusterMonitor clusterMonitor = 
AutoscalerContext.getInstance().getClusterMonitor(clusterId);

Reply via email to