Changing logic to validate network partitions in deployment policy deployment


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

Branch: refs/heads/master
Commit: 4e97b3e5067086da937fce7fe01dc9fb9badcbcc
Parents: 0035407
Author: lasinducharith <[email protected]>
Authored: Thu Jun 18 10:16:05 2015 +0530
Committer: lasinducharith <[email protected]>
Committed: Thu Jun 18 10:16:05 2015 +0530

----------------------------------------------------------------------
 .../services/impl/AutoscalerServiceImpl.java        | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4e97b3e5/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 c2ee635..4e324fc 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
@@ -1054,16 +1054,20 @@ public class AutoscalerServiceImpl implements 
AutoscalerService {
             // network partition - partition id should be already added
             for (PartitionRef partitionRef : 
networkPartitionRef.getPartitionRefs()) {
                 String partitionId = partitionRef.getId();
+                boolean isPartitionFound = false;
 
                 for (Partition partition : networkPartition.getPartitions()) {
-                    if (!partition.getId().equals(partitionId)) {
-                        String msg = String.format("Partition Id is not found: 
[deployment-policy-id] %s " +
-                                        "[network-partition-id] %s 
[partition-id] %s",
-                                deploymentPolicyId, networkPartitionId, 
partitionId);
-                        log.error(msg);
-                        throw new InvalidDeploymentPolicyException(msg);
+                    if (partition.getId().equals(partitionId)) {
+                        isPartitionFound = true;
                     }
                 }
+                if (isPartitionFound == false) {
+                    String msg = String.format("Partition Id is not found: 
[deployment-policy-id] %s " +
+                                    "[network-partition-id] %s [partition-id] 
%s",
+                            deploymentPolicyId, networkPartitionId, 
partitionId);
+                    log.error(msg);
+                    throw new InvalidDeploymentPolicyException(msg);
+                }
             }
 
             // partition algorithm can't be null or empty

Reply via email to