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 2015/05/13 19:46:18 UTC

[5/7] stratos git commit: Refactor and update some varibles

Refactor and update some varibles


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

Branch: refs/heads/master
Commit: d4d0059b4ae880c1aff216f11ca75b2441b1992c
Parents: d09a909
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed May 13 17:13:01 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed May 13 23:16:04 2015 +0530

----------------------------------------------------------------------
 .../context/cluster/ClusterContext.java         | 18 ++++++-------
 .../autoscaler/monitor/MonitorFactory.java      | 12 ++++-----
 .../monitor/component/GroupMonitor.java         |  8 +++---
 .../policy/deployment/DeploymentPolicy.java     |  6 ++---
 .../services/impl/AutoscalerServiceImpl.java    | 28 ++++++++++----------
 5 files changed, 36 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d0059b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
index 5d728f4..100ae23 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
@@ -188,10 +188,10 @@ public class ClusterContext extends AbstractClusterContext {
                 .getNetworkPartitionRefs();
         PartitionRef[] partitions = null;
         if (networkPartitions != null && networkPartitions.length != 0) {
-            for (NetworkPartitionRef networkPartition : networkPartitions) {
-                if (networkPartition.getId().equals(
+            for (NetworkPartitionRef networkPartitionRef : networkPartitions) {
+                if (networkPartitionRef.getId().equals(
                         clusterLevelNetworkPartitionContext.getId())) {
-                    partitions = networkPartition.getPartitions();
+                    partitions = networkPartitionRef.getPartitionRefs();
                 }
             }
         }
@@ -205,22 +205,22 @@ public class ClusterContext extends AbstractClusterContext {
         }
 
         // Retrieving the ChildLevelNetworkPartition and create NP Context
-        NetworkPartitionRef networkPartition = null;
+        NetworkPartitionRef networkPartitionRef = null;
         if (networkPartitions != null && networkPartitions.length != 0) {
             for (NetworkPartitionRef networkPartition2 : networkPartitions) {
                 if (networkPartition2.getId().equals(
                         clusterInstance.getNetworkPartitionId())) {
-                    networkPartition = networkPartition2;
+                    networkPartitionRef = networkPartition2;
                 }
             }
         }
 
         // Fill cluster instance context with child level partitions
-        if (networkPartition != null) {
-            for (PartitionRef partition : networkPartition
-                    .getPartitions()) {
+        if (networkPartitionRef != null) {
+            for (PartitionRef partitionRef : networkPartitionRef
+                    .getPartitionRefs()) {
                 addPartition(clusterInstance, cluster,
-                        clusterLevelNetworkPartitionContext, partition,
+                        clusterLevelNetworkPartitionContext, partitionRef,
                         hasGroupScalingDependent, groupScalingEnabledSubtree);
             }
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d0059b/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 3afd61c..4713403 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
@@ -242,19 +242,19 @@ public class MonitorFactory {
             }
 
             List<PartitionRef> partitionList = new ArrayList<PartitionRef>();
-            for (NetworkPartitionRef networkPartition : deploymentPolicy.getNetworkPartitionRefs()) {
+            for (NetworkPartitionRef networkPartitionRef : deploymentPolicy.getNetworkPartitionRefs()) {
 
-                if (networkPartition != null) {
-                    Collections.addAll(partitionList, networkPartition.getPartitions());
+                if (networkPartitionRef != null) {
+                    Collections.addAll(partitionList, networkPartitionRef.getPartitionRefs());
                     try {
 
                         CloudControllerServiceClient.getInstance().
                                 validateNetworkPartitionOfDeploymentPolicy(serviceName,
-                                        networkPartition.getId());
+                                        networkPartitionRef.getId());
                     } catch (Exception e) {
                         String msg = String.format("Error while validating deployment policy " +
-                                "from cloud controller [network-partition-id] %s",
-                                networkPartition.getId());
+                                        "from cloud controller [network-partition-id] %s",
+                                networkPartitionRef.getId());
                         log.error(msg, e);
                         throw new RuntimeException(msg, e);
                     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d0059b/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 2349809..c2b88bd 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
@@ -706,18 +706,18 @@ public class GroupMonitor extends ParentComponentMonitor {
         } else {
 
             NetworkPartitionRef[] networkPartitions = deploymentPolicy.getNetworkPartitionRefs();
-            NetworkPartitionRef networkPartition = null;
+            NetworkPartitionRef networkPartitionRef = null;
             if (networkPartitions != null && networkPartitions.length != 0) {
                 for (NetworkPartitionRef i : networkPartitions) {
                     if (i.getId().equals(networkPartitionId)) {
-                        networkPartition = i;
+                        networkPartitionRef = i;
                     }
                 }
             }
 
-            if (networkPartition != null) {
+            if (networkPartitionRef != null) {
                 if (networkPartitionContext.getPartitionCtxts().isEmpty()) {
-                    PartitionRef[] partitions = networkPartition.getPartitions();
+                    PartitionRef[] partitions = networkPartitionRef.getPartitionRefs();
                     if (partitions != null && partitions.length != 0) {
                         for (PartitionRef partition : partitions) {
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d0059b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/DeploymentPolicy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/DeploymentPolicy.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/DeploymentPolicy.java
index 8cc2b5e..56d1f15 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/DeploymentPolicy.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/DeploymentPolicy.java
@@ -76,9 +76,9 @@ public class DeploymentPolicy implements Serializable {
      */
     public PartitionRef[] getPartitionsByNetworkPartitionId(String networkPartitionId) {
         if (networkPartitionRefs != null) {
-            for (NetworkPartitionRef networkPartition : networkPartitionRefs) {
-                if (networkPartition.getId().equals(networkPartitionId)) {
-                    return networkPartition.getPartitions();
+            for (NetworkPartitionRef networkPartitionRef : networkPartitionRefs) {
+                if (networkPartitionRef.getId().equals(networkPartitionId)) {
+                    return networkPartitionRef.getPartitionRefs();
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d4d0059b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index 9fa1613..43dfcb9 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -906,10 +906,10 @@ public class AutoscalerServiceImpl implements AutoscalerService {
         }
 
         // validate each network partition references
-        for (NetworkPartitionRef networkPartition : deploymentPolicy.getNetworkPartitionRefs()) {
+        for (NetworkPartitionRef networkPartitionRef : deploymentPolicy.getNetworkPartitionRefs()) {
 
             // network partition id can't be null or empty
-            if (null == networkPartition.getId() || networkPartition.getId().isEmpty()) {
+            if (null == networkPartitionRef.getId() || networkPartitionRef.getId().isEmpty()) {
                 String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
                                 + "Cause -> Invalid network partition id in network partition references section",
                         deploymentPolicy.getDeploymentPolicyID());
@@ -918,38 +918,38 @@ public class AutoscalerServiceImpl implements AutoscalerService {
             }
 
             // network partitions should be already added
-            if (null == CloudControllerServiceClient.getInstance().getNetworkPartition(networkPartition.getId())) {
+            if (null == CloudControllerServiceClient.getInstance().getNetworkPartition(networkPartitionRef.getId())) {
                 String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
                                 + "Cause -> Network partition is not added - [network-partition-id] %s",
-                        deploymentPolicy.getDeploymentPolicyID(), networkPartition.getId());
+                        deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId());
                 log.error(msg);
                 throw new InvalidDeploymentPolicyException(msg);
             }
 
             // partition algorithm can't be null or empty
-            if (null == networkPartition.getPartitionAlgo() || networkPartition.getPartitionAlgo().isEmpty()) {
+            if (null == networkPartitionRef.getPartitionAlgo() || networkPartitionRef.getPartitionAlgo().isEmpty()) {
                 String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
                                 + "Cause -> Invalid partition algorithm - [network-partition-id] %s [partition-algo] %s",
-                        deploymentPolicy.getDeploymentPolicyID(), networkPartition.getId(), networkPartition.getPartitionAlgo());
+                        deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId(), networkPartitionRef.getPartitionAlgo());
                 log.error(msg);
                 throw new InvalidDeploymentPolicyException(msg);
             }
 
             // partition algorithm should be either one-after-another or round-robin
-            if (!StratosConstants.PARTITION_ROUND_ROBIN_ALGORITHM_ID.equals(networkPartition.getPartitionAlgo())
-                    && !StratosConstants.PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(networkPartition.getPartitionAlgo())) {
+            if (!StratosConstants.PARTITION_ROUND_ROBIN_ALGORITHM_ID.equals(networkPartitionRef.getPartitionAlgo())
+                    && !StratosConstants.PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(networkPartitionRef.getPartitionAlgo())) {
                 String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
                                 + "Cause -> Invalid partition algorithm - [network-partition-id] %s [partition-algo] %s",
-                        deploymentPolicy.getDeploymentPolicyID(), networkPartition.getId(), networkPartition.getPartitionAlgo());
+                        deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId(), networkPartitionRef.getPartitionAlgo());
                 log.error(msg);
                 throw new InvalidDeploymentPolicyException(msg);
             }
 
             // a network partition reference should contain at least one partition reference
-            if (null == networkPartition.getPartitions() || networkPartition.getPartitions().length == 0) {
+            if (null == networkPartitionRef.getPartitionRefs() || networkPartitionRef.getPartitionRefs().length == 0) {
                 String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
                         + "Cause -> Network partition reference doesn't have at lease one partition reference - "
-                        + "[network-partition-id] %s", deploymentPolicy.getDeploymentPolicyID(), networkPartition.getId());
+                        + "[network-partition-id] %s", deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId());
                 log.error(msg);
                 throw new InvalidDeploymentPolicyException(msg);
             }
@@ -1065,13 +1065,13 @@ public class AutoscalerServiceImpl implements AutoscalerService {
     }
 
     private void addNewPartitionsToClusterMonitor(ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext,
-                                                  NetworkPartitionRef networkPartition, String deploymentPolicyID,
+                                                  NetworkPartitionRef networkPartitionRef, String deploymentPolicyID,
                                                   String cartridgeType) throws RemoteException,
             CloudControllerServiceInvalidPartitionExceptionException,
             CloudControllerServiceInvalidCartridgeTypeExceptionException {
 
         boolean validationOfNetworkPartitionRequired = false;
-        for (PartitionRef partition : networkPartition.getPartitions()) {
+        for (PartitionRef partition : networkPartitionRef.getPartitionRefs()) {
 
             //Iterating through instances
             for (InstanceContext instanceContext : clusterLevelNetworkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
@@ -1081,7 +1081,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
 
                     //It has found that this partition which is in deployment policy/network partition is new
                     ClusterLevelPartitionContext clusterLevelPartitionContext = new ClusterLevelPartitionContext(
-                            partition, networkPartition.getId(), deploymentPolicyID);
+                            partition, networkPartitionRef.getId(), deploymentPolicyID);
                     validationOfNetworkPartitionRequired = true;
                     clusterInstanceContext.addPartitionCtxt(clusterLevelPartitionContext);
                 }