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

[3/5] stratos git commit: Adding the logic to check whether monitor has scaling dependents

Adding the logic to check whether monitor has scaling dependents


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

Branch: refs/heads/4.1.0-test
Commit: 5ee5b1eb18db7200984caadaa9f4a7ee03a25f6d
Parents: 35f80b4
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Sun Dec 14 16:52:19 2014 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Sun Dec 14 17:04:48 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/monitor/MonitorFactory.java      | 50 +++++++++++++-------
 1 file changed, 32 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/5ee5b1eb/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 3f83741..86ed237 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
@@ -24,10 +24,7 @@ import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationChildContext;
 import org.apache.stratos.autoscaler.applications.dependency.context.ClusterChildContext;
 import org.apache.stratos.autoscaler.applications.dependency.context.GroupChildContext;
-import org.apache.stratos.autoscaler.client.CloudControllerClient;
 import org.apache.stratos.autoscaler.context.AutoscalerContext;
-import org.apache.stratos.autoscaler.context.cluster.ClusterContextFactory;
-import org.apache.stratos.autoscaler.context.cluster.VMClusterContext;
 import org.apache.stratos.autoscaler.exception.application.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.application.TopologyInConsistentException;
 import org.apache.stratos.autoscaler.exception.partition.PartitionValidationException;
@@ -38,15 +35,10 @@ import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
 import org.apache.stratos.autoscaler.monitor.component.GroupMonitor;
 import org.apache.stratos.autoscaler.monitor.component.ParentComponentMonitor;
-import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.Group;
-import org.apache.stratos.messaging.domain.instance.ApplicationInstance;
-import org.apache.stratos.messaging.domain.instance.ClusterInstance;
-import org.apache.stratos.messaging.domain.instance.GroupInstance;
-import org.apache.stratos.messaging.domain.instance.Instance;
+import org.apache.stratos.messaging.domain.applications.ScalingDependentList;
 import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
 import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
@@ -113,7 +105,19 @@ public class MonitorFactory {
         try {
             Group group = ApplicationHolder.getApplications().
                     getApplication(appId).getGroupRecursively(context.getId());
-            groupMonitor = new GroupMonitor(group, appId, instanceIds);
+
+
+            boolean hasScalingDependents = false;
+
+            for (ScalingDependentList scalingDependentList : parentMonitor.getScalingDependencies()){
+
+                if(scalingDependentList.getScalingDependentListComponents().contains(context.getId())){
+
+                    hasScalingDependents = true;
+                }
+            }
+
+            groupMonitor = new GroupMonitor(group, appId, instanceIds, hasScalingDependents);
             groupMonitor.setAppId(appId);
             if (parentMonitor != null) {
                 groupMonitor.setParent(parentMonitor);
@@ -130,8 +134,8 @@ public class MonitorFactory {
             if (group.isGroupScalingEnabled()) {
                 groupMonitor.setGroupScalingEnabled(true);
             } else if (parentMonitor instanceof GroupMonitor) {
-                /*if (parentMonitor.hasGroupScalingDependent() || parentMonitor.getList --> not empty) {
-                    groupMonitor.setHasGroupScalingDependent(true);
+                /*if (parentMonitor.hasScalingDependents() || parentMonitor.getList --> not empty) {
+                    groupMonitor.setHasScalingDependents(true);
                 }*/
             }
         } finally {
@@ -250,7 +254,17 @@ public class MonitorFactory {
                 String msg = "[Service] " + serviceName + " cannot be found in the Topology";
                 throw new TopologyInConsistentException(msg);
             }
-            AbstractClusterMonitor clusterMonitor = ClusterMonitorFactory.getMonitor(cluster);
+
+            boolean hasScalingDependents = false;
+
+            for (ScalingDependentList scalingDependentList : parentMonitor.getScalingDependencies()){
+
+                if(scalingDependentList.getScalingDependentListComponents().contains(clusterId)){
+
+                    hasScalingDependents = true;
+                }
+            }
+            AbstractClusterMonitor clusterMonitor = ClusterMonitorFactory.getMonitor(cluster, hasScalingDependents);
             //Setting the parent of the cluster monitor
             clusterMonitor.setParent(parentMonitor);
             clusterMonitor.setId(clusterId);
@@ -264,11 +278,11 @@ public class MonitorFactory {
             }
 
             //setting the scaling dependent behaviour of the cluster monitor
-            if (parentMonitor.hasGroupScalingDependent() || (context.isGroupScalingEnabled())) {
-                clusterMonitor.setHasGroupScalingDependent(true);
-            } else {
-                clusterMonitor.setHasGroupScalingDependent(false);
-            }
+//            if (parentMonitor.hasScalingDependents() || (context.isGroupScalingEnabled())) {
+//                clusterMonitor.setHasScalingDependents(true);
+//            } else {
+//                clusterMonitor.setHasScalingDependents(false);
+//            }
             //Creating the instance of the cluster
             ((VMClusterMonitor)clusterMonitor).createClusterInstance(parentInstanceIds, cluster);
             //add it to autoscaler context