You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/02/17 06:00:06 UTC

[2/2] stratos git commit: updating deployment policy validation

updating deployment policy validation


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

Branch: refs/heads/4.1.0-beta-deployment-policy-fix
Commit: 3bb5835017ec56d9b679b06936a1703d66076c23
Parents: 8ff7259
Author: R-Rajkumar <rr...@gmail.com>
Authored: Tue Feb 17 10:29:11 2015 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Tue Feb 17 10:29:11 2015 +0530

----------------------------------------------------------------------
 .../impl/CloudControllerServiceUtil.java        | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/3bb58350/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
index 25b901d..4cf4814 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
@@ -41,6 +41,7 @@ import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
 import org.apache.stratos.cloud.controller.messaging.publisher.StatisticsDataPublisher;
 import org.apache.stratos.cloud.controller.messaging.topology.TopologyBuilder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.messaging.domain.topology.MemberStatus;
 
 /**
@@ -134,7 +135,8 @@ public class CloudControllerServiceUtil {
     	
     	// deployment policy id can't be null or empty
     	if (null == deploymentPolicy.getDeploymentPolicyID() || deploymentPolicy.getDeploymentPolicyID().isEmpty()) {
-			String msg = "Invalid deployment policy. Cause -> Invalid deployment policy id";
+			String msg = String.format("Invalid deployment policy. Cause -> Invalid deployment policy id [deployment-policy-id] %s", 
+					deploymentPolicy.getDeploymentPolicyID());
 			log.error(msg);
 			throw new InvalidDeploymentPolicyException(msg);
 		}
@@ -160,10 +162,10 @@ public class CloudControllerServiceUtil {
 				throw new InvalidDeploymentPolicyException(msg);
 			}
     		
-    		// network partitions should be already deployed
+    		// network partitions should be already added
     		if (null == CloudControllerContext.getInstance().getNetworkPartition(networkPartitionRef.getId())) {
 				String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
-						+ "Cause -> Network partition is not deployed - [network-partition-id] %s", 
+						+ "Cause -> Network partition is not added - [network-partition-id] %s", 
 						deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId());
 				log.error(msg);
 				throw new InvalidDeploymentPolicyException(msg);
@@ -178,6 +180,16 @@ public class CloudControllerServiceUtil {
 				throw new InvalidDeploymentPolicyException(msg);
 			}
     		
+    		// partition algorithm should be either one-after-another or round-robin
+    		if (StratosConstants.ROUND_ROBIN_ALGORITHM_ID != networkPartitionRef.getPartitionAlgo()
+    				&& StratosConstants.ONE_AFTER_ANOTHER_ALGORITHM_ID != networkPartitionRef.getPartitionAlgo()) {
+				String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
+						+ "Cause -> Invalid partition algorithm - [network-partition-id] %s", 
+						deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId());
+				log.error(msg);
+				throw new InvalidDeploymentPolicyException(msg);
+			}
+    		
     		// a network partition reference should contain at least one partition reference
     		if (null == networkPartitionRef.getPartitions() || networkPartitionRef.getPartitions().length == 0) {
 				String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
@@ -210,7 +222,7 @@ public class CloudControllerServiceUtil {
 				}
     			
     			// partition reference should have a valid max value
-    			if (partitionRef.getMax() < 0) {
+    			if (partitionRef.getMax() <= 0) {
     				String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
     						+ "Cause -> Partition max value is not valid - [network-partition-id] %s [partition-id] %s [max-value] %s", 
     						deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId(), partitionRef.getId(), partitionRef.getMax());