Updated Branches:
  refs/heads/master 2e6084c20 -> 361d5c74a

fixing issue with groupId generation, more logs, refactoring IPAllocator


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

Branch: refs/heads/master
Commit: d1b7170d49950b416de91f3fe2018519748a2f43
Parents: 5bc7f7e
Author: Nirmal Fernando <[email protected]>
Authored: Tue Jan 14 11:32:25 2014 +0530
Committer: Nirmal Fernando <[email protected]>
Committed: Tue Jan 14 11:32:25 2014 +0530

----------------------------------------------------------------------
 .../impl/CloudControllerServiceImpl.java        | 26 +++++++-------------
 .../controller/util/CloudControllerUtil.java    | 12 ++++++++-
 2 files changed, 20 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d1b7170d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 57ef924..88075bf 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -249,7 +249,9 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             String msg =
                          "Instance start-up failed. " + 
memberContext.toString() + ". " +
                                  "There's no IaaS provided for the partition: 
" + partitionId +
-                                 " and for the Cartridge type: " + 
cartridgeType;
+                                 " and for the Cartridge type: " + 
cartridgeType+". Only following "
+                                               + "partitions can be found in 
this Cartridge: "
+                                 
+cartridge.getPartitionToIaasProvider().keySet().toString();
             log.fatal(msg);
             throw new CloudControllerException(msg);
         }
@@ -333,7 +335,7 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             // name.
             // Should have lower-case ASCII letters, numbers, or dashes.
             // Should have a length between 3-15
-            String str = clusterId.substring(0, 10);
+            String str = clusterId.length() > 10 ? clusterId.substring(0, 10) 
: clusterId.substring(0, clusterId.length());
             String group = str.replaceAll("[^a-z0-9-]", "");
             NodeMetadata node;
 
@@ -346,7 +348,7 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             //Start allocating ip as a new job
 
             ThreadExecutor exec = ThreadExecutor.getInstance();
-            exec.execute(new IpAllocator(memberContext, computeService, 
template, iaasProvider, cartridgeType, node));
+            exec.execute(new IpAllocator(memberContext, iaasProvider, 
cartridgeType, node));
 
 
             // node id
@@ -490,17 +492,13 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     private class IpAllocator implements Runnable {
 
         private MemberContext memberContext;
-        private ComputeService computeService;
-        private Template template;
         private IaasProvider iaasProvider;
         private String cartridgeType;
         NodeMetadata node;
 
-        public IpAllocator(MemberContext memberContext, ComputeService 
computeService, Template template,
-                           IaasProvider iaasProvider, String cartridgeType, 
NodeMetadata node) {
+        public IpAllocator(MemberContext memberContext, IaasProvider 
iaasProvider, 
+                       String cartridgeType, NodeMetadata node) {
             this.memberContext = memberContext;
-            this.computeService = computeService;
-            this.template = template;
             this.iaasProvider = iaasProvider;
             this.cartridgeType = cartridgeType;
             this.node = node;
@@ -513,13 +511,6 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             String clusterId = memberContext.getClusterId();
             Partition partition = memberContext.getPartition();
 
-            // generate the group id from domain name and sub domain
-            // name.
-            // Should have lower-case ASCII letters, numbers, or dashes.
-            // Should have a length between 3-15
-            String str = clusterId.substring(0, 10);
-            String group = str.replaceAll("[^a-z0-9-]", "");
-
             try{
 
                 String autoAssignIpProp =
@@ -974,7 +965,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         // if and only if the deployment policy valid
         cartridge.addIaasProviders(partitionToIaasProviders);
         
-        log.info("All partitions were validated successfully, against the 
Cartridge: "+cartridgeType);
+        log.info("All partitions 
"+CloudControllerUtil.getPartitionIds(partitions)+
+                       " were validated successfully, against the Cartridge: 
"+cartridgeType);
         
         return true;
     }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d1b7170d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
index fa2a143..7381ed7 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
@@ -20,6 +20,7 @@ package org.apache.stratos.cloud.controller.util;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
 import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.persist.Deserializer;
 import org.apache.stratos.cloud.controller.pojo.AppType;
@@ -36,7 +37,6 @@ import org.apache.stratos.messaging.domain.topology.Topology;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
 import java.util.Arrays;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -275,4 +275,14 @@ public class CloudControllerUtil {
                log.error(msg);
                throw new CloudControllerException(msg);
        }
+
+       public static String getPartitionIds(Partition[] partitions) {
+               StringBuilder str = new StringBuilder("");
+               for (Partition partition : partitions) {
+                       str.append(partition.getId()+", ");
+               }
+               
+               String partitionStr = str.length() == 0 ? str.toString() : 
str.substring(0, str.length()-2);
+               return "[" +partitionStr+ "]";
+       }
 }

Reply via email to