You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2013/12/01 11:58:55 UTC

[01/12] git commit: cleaning up Topology POJOs

Updated Branches:
  refs/heads/master 71e3b1b6c -> 96db3160a


cleaning up Topology POJOs


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

Branch: refs/heads/master
Commit: 12dbd29a7e30e100a527eeb6a6b3afdbb6cb0370
Parents: faca016
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 20:23:42 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 20:23:42 2013 +0530

----------------------------------------------------------------------
 .../messaging/domain/topology/Cluster.java      | 18 -------------
 .../messaging/domain/topology/Member.java       | 28 ++++----------------
 .../event/topology/InstanceSpawnedEvent.java    | 21 ++++++++-------
 3 files changed, 16 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/12dbd29a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
index 5af1c04..16ec972 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
@@ -45,14 +45,12 @@ public class Cluster implements Serializable {
     // Key: Member.memberId
     private Map<String, Member> memberMap;
     private Properties properties;
-    private Map<String, Member> membertoNodeIdMap;
 
     public Cluster(String serviceName, String clusterId, String autoscalePolicyName) {
         this.serviceName = serviceName;
         this.clusterId = clusterId;
         this.autoscalePolicyName = autoscalePolicyName;
         this.memberMap = new HashMap<String, Member>();
-        this.membertoNodeIdMap = new HashMap<String, Member>();
     }
 
     public String getServiceName() {
@@ -140,22 +138,6 @@ public class Cluster implements Serializable {
         this.autoscalePolicyName = autoscalePolicyName;
     }
 
-    public void addMemberToIaasNodeId(Member member) {
-           membertoNodeIdMap.put(member.getIaasNodeId(), member);
-       }
-
-       public void removeMemberFromIaasNodeId(Member member) {
-           membertoNodeIdMap.remove(member.getIaasNodeId());
-       }
-
-       public Member getMemberFromIaasNodeId(String iaasNodeId) {
-           return membertoNodeIdMap.get(iaasNodeId);
-       }
-
-       public boolean memberExistsFromIaasNodeId(String iaasNodeId) {
-           return this.membertoNodeIdMap.containsKey(iaasNodeId);
-       }
-
 	public String getDeploymentPolicyName() {
 		return deploymentPolicyName;
 	}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/12dbd29a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
index 98f08c4..dfe9ec5 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
@@ -35,12 +35,10 @@ public class Member implements Serializable {
     private String clusterId;
     private String memberId;
     private MemberStatus status;
-    private float loadAverage;
-    private float memoryConsumption;
     private String memberIp;
     private Map<String, Port> portMap;
     private Properties properties;
-    private String iaasNodeId;
+    private String partitionId;
 
     public Member(String serviceName, String clusterId, String memberId) {
         this.serviceName = serviceName;
@@ -119,28 +117,12 @@ public class Member implements Serializable {
 	    this.memberIp = memberIp;
     }
 
-    public float getLoadAverage() {
-        return loadAverage;
+    public String getPartitionId() {
+        return partitionId;
     }
 
-    public void setLoadAverage(float loadAverage) {
-        this.loadAverage = loadAverage;
-    }
-
-    public float getMemoryConsumption() {
-        return memoryConsumption;
-    }
-
-    public void setMemoryConsumption(float memoryConsumption) {
-        this.memoryConsumption = memoryConsumption;
-    }
-
-     public String getIaasNodeId() {
-        return iaasNodeId;
-    }
-
-    public void setIaasNodeId(String iaasNodeId) {
-        this.iaasNodeId = iaasNodeId;
+    public void setPartitionId(String partitionId) {
+        this.partitionId = partitionId;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/12dbd29a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java
index 4b872a8..153f78c 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java
@@ -30,13 +30,22 @@ public class InstanceSpawnedEvent extends TopologyEvent implements Serializable
     private String serviceName;
     private String clusterId;
     private String memberId;
-    private String iaasNodeId;
+    private String partitionId;
+
 
     public InstanceSpawnedEvent(String serviceName, String clusterId, String memberId, String iaasNodeId) {
         this.serviceName = serviceName;
         this.clusterId = clusterId;
         this.memberId = memberId;
-        this.iaasNodeId = iaasNodeId;
+        this.partitionId = iaasNodeId;
+    }
+    
+    public String getPartitionId() {
+        return partitionId;
+    }
+    
+    public void setPartitionId(String partitionId) {
+        this.partitionId = partitionId;
     }
 
     public String getServiceName() {
@@ -51,12 +60,4 @@ public class InstanceSpawnedEvent extends TopologyEvent implements Serializable
         return memberId;
     }
 
-    public String getIaasNodeId() {
-        return iaasNodeId;
-    }
-
-    public void setIaasNodeId(String iaasNodeId) {
-        this.iaasNodeId = iaasNodeId;
-    }
-
 }


[11/12] git commit: changes to drools rule

Posted by ni...@apache.org.
changes to drools rule


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

Branch: refs/heads/master
Commit: ad402b59f500233c6d00932650b167622a140a5c
Parents: d6a16c1
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sun Dec 1 16:27:43 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sun Dec 1 16:27:43 2013 +0530

----------------------------------------------------------------------
 .../src/test/resources/autoscaler-old.drl       | 79 ++++++++++++++++++++
 1 file changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ad402b59/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl b/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl
new file mode 100644
index 0000000..7881efe
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one 
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+ * KIND, either express or implied.  See the License for the 
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.rule;
+
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.autoscaler.AutoscalerContext;
+import org.apache.stratos.autoscaler.ClusterContext;
+import org.apache.stratos.autoscaler.Constants;
+import org.apache.stratos.autoscaler.policy.PolicyManager;
+import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+import org.apache.stratos.autoscaler.policy.model.RequestsInFlight;
+import org.apache.stratos.autoscaler.policy.model.LoadThresholds;
+import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
+import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
+import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
+import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+import org.apache.stratos.autoscaler.PartitionContext;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
+import org.apache.commons.logging.Log;
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.partition.PartitionGroup;
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+import org.apache.stratos.cloud.controller.pojo.MemberContext;
+
+
+global org.apache.stratos.autoscaler.policy.PolicyManager $manager;
+global org.apache.stratos.autoscaler.AutoscalerContext $context; 
+global org.apache.commons.logging.Log log;
+global org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator $evaluator;
+global org.apache.stratos.messaging.domain.topology.Topology $topology;
+global java.util.Map partitionCtxts;
+global java.lang.String clusterId;
+
+import function org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator.delegateSpawn;
+import function org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator.delegateTerminate;
+
+rule "Minimum Rule"
+dialect "mvel"
+       when
+	       $ctxt : PartitionContext ()
+	       eval($ctxt.getCurrentMemberCount() < $ctxt.getMinimumMemberCount())
+
+       then
+	       memberContext = delegateSpawn($ctxt.getPartition(),clusterId);
+           if(memberContext != null) {
+	            $ctxt.addPendingMember(memberContext); 
+           }
+	       
+end
+
+rule "Terminate Obsoleted Instances"
+dialect "mvel"
+        when
+            $ctxt : PartitionContext ()
+            eval($ctxt.getObsoletedMembers().size() > 0)
+            memberId : String() from $ctxt.getObsoletedMembers()
+            eval($ctxt.removeObsoleteMember(memberId))
+        then
+            delegateTerminate(memberId);
+end
\ No newline at end of file


[10/12] git commit: WSDL change over partition validation API change

Posted by ni...@apache.org.
WSDL change over partition validation API change


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

Branch: refs/heads/master
Commit: d6a16c125e073b5e44655eea9a1f0987d7f2f6c2
Parents: cdc02a6
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sun Dec 1 16:24:21 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sun Dec 1 16:24:21 2013 +0530

----------------------------------------------------------------------
 .../main/resources/CloudControllerService.wsdl  | 104 ++++---------------
 1 file changed, 18 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d6a16c12/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
index 5d23869..8dd1cf5 100644
--- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
+++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
@@ -1,9 +1,11 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://policy.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ns="http://impl.controller.cloud.stratos.apache.org" xmlns:ax25="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax26="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://exception.controller.cloud.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://impl.controller.cloud.stratos.apache.org" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax25="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax26="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax23="http://exception.controller.cloud.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
     <wsdl:documentation>CloudControllerService</wsdl:documentation>
     <wsdl:types>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.controller.cloud.stratos.apache.org/xsd">
             <xs:complexType name="InvalidPartitionException">
-                <xs:sequence/>
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                </xs:sequence>
             </xs:complexType>
             <xs:complexType name="InvalidCartridgeTypeException">
                 <xs:sequence/>
@@ -21,10 +23,9 @@
                 <xs:sequence/>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax213="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax28="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax211="http://policy.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax24="http://exception.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
+        <xs:schema xmlns:ax28="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax210="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax24="http://exception.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
             <xs:import namespace="http://exception.controller.cloud.stratos.apache.org/xsd"/>
             <xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://policy.deployment.controller.cloud.stratos.apache.org/xsd"/>
             <xs:import namespace="http://pojo.controller.cloud.stratos.apache.org/xsd"/>
             <xs:element name="CloudControllerServiceInvalidPartitionException">
                 <xs:complexType>
@@ -58,7 +59,7 @@
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="ax29:DeploymentPolicy"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax28:Partition"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -128,21 +129,21 @@
             <xs:element name="startInstance">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="member" nillable="true" type="ax213:MemberContext"/>
+                        <xs:element minOccurs="0" name="member" nillable="true" type="ax210:MemberContext"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="startInstanceResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax213:MemberContext"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax210:MemberContext"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="registerService">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="registrant" nillable="true" type="ax213:Registrant"/>
+                        <xs:element minOccurs="0" name="registrant" nillable="true" type="ax210:Registrant"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -165,20 +166,6 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getPendingInstanceCount">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getPendingInstanceCountResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
             <xs:element name="getCartridgeInfo">
                 <xs:complexType>
                     <xs:sequence>
@@ -189,23 +176,12 @@
             <xs:element name="getCartridgeInfoResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax213:CartridgeInfo"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax210:CartridgeInfo"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
         </xs:schema>
-        <xs:schema xmlns:ax210="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.deployment.controller.cloud.stratos.apache.org/xsd">
-            <xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"/>
-            <xs:complexType name="DeploymentPolicy">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="allPartitions" nillable="true" type="xs:anyType"/>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroup" nillable="true" type="ax210:PartitionGroup"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitionGroups" nillable="true" type="ax210:PartitionGroup"/>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax212="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.controller.cloud.stratos.apache.org/xsd">
+        <xs:schema xmlns:ax29="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.controller.cloud.stratos.apache.org/xsd">
             <xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"/>
             <xs:complexType name="Properties">
                 <xs:sequence>
@@ -226,7 +202,7 @@
                     <xs:element minOccurs="0" name="initTime" type="xs:long"/>
                     <xs:element minOccurs="0" name="memberId" nillable="true" type="xs:string"/>
                     <xs:element minOccurs="0" name="nodeId" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="partition" nillable="true" type="ax212:Partition"/>
+                    <xs:element minOccurs="0" name="partition" nillable="true" type="ax29:Partition"/>
                     <xs:element minOccurs="0" name="privateIpAddress" nillable="true" type="xs:string"/>
                     <xs:element minOccurs="0" name="publicIpAddress" nillable="true" type="xs:string"/>
                 </xs:sequence>
@@ -283,21 +259,8 @@
                     <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="PartitionGroup">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="partitionAlgo" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="partitions" nillable="true" type="ax25:Partition"/>
-                </xs:sequence>
-            </xs:complexType>
         </xs:schema>
     </wsdl:types>
-    <wsdl:message name="getPendingInstanceCountRequest">
-        <wsdl:part name="parameters" element="ns:getPendingInstanceCount"/>
-    </wsdl:message>
-    <wsdl:message name="getPendingInstanceCountResponse">
-        <wsdl:part name="parameters" element="ns:getPendingInstanceCountResponse"/>
-    </wsdl:message>
     <wsdl:message name="validatePartitionRequest">
         <wsdl:part name="parameters" element="ns:validatePartition"/>
     </wsdl:message>
@@ -365,10 +328,6 @@
         <wsdl:part name="parameters" element="ns:startInstanceResponse"/>
     </wsdl:message>
     <wsdl:portType name="CloudControllerServicePortType">
-        <wsdl:operation name="getPendingInstanceCount">
-            <wsdl:input message="ns:getPendingInstanceCountRequest" wsaw:Action="urn:getPendingInstanceCount"/>
-            <wsdl:output message="ns:getPendingInstanceCountResponse" wsaw:Action="urn:getPendingInstanceCountResponse"/>
-        </wsdl:operation>
         <wsdl:operation name="validatePartition">
             <wsdl:input message="ns:validatePartitionRequest" wsaw:Action="urn:validatePartition"/>
             <wsdl:output message="ns:validatePartitionResponse" wsaw:Action="urn:validatePartitionResponse"/>
@@ -431,15 +390,6 @@
                 <soap:fault use="literal" name="CloudControllerServiceInvalidPartitionException"/>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getPendingInstanceCount">
-            <soap:operation soapAction="urn:getPendingInstanceCount" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-        </wsdl:operation>
         <wsdl:operation name="validateDeploymentPolicy">
             <soap:operation soapAction="urn:validateDeploymentPolicy" style="document"/>
             <wsdl:input>
@@ -557,15 +507,6 @@
                 <soap12:fault use="literal" name="CloudControllerServiceInvalidPartitionException"/>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getPendingInstanceCount">
-            <soap12:operation soapAction="urn:getPendingInstanceCount" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-        </wsdl:operation>
         <wsdl:operation name="validateDeploymentPolicy">
             <soap12:operation soapAction="urn:validateDeploymentPolicy" style="document"/>
             <wsdl:input>
@@ -680,15 +621,6 @@
                 <mime:content type="text/xml" part="parameters"/>
             </wsdl:output>
         </wsdl:operation>
-        <wsdl:operation name="getPendingInstanceCount">
-            <http:operation location="getPendingInstanceCount"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
         <wsdl:operation name="validateDeploymentPolicy">
             <http:operation location="validateDeploymentPolicy"/>
             <wsdl:input>
@@ -755,22 +687,22 @@
     </wsdl:binding>
     <wsdl:service name="CloudControllerService">
         <wsdl:port name="CloudControllerServiceHttpSoap11Endpoint" binding="ns:CloudControllerServiceSoap11Binding">
-            <soap:address location="http://10.100.1.154:9764/services/CloudControllerService.CloudControllerServiceHttpSoap11Endpoint/"/>
+            <soap:address location="http://192.168.1.2:9764/services/CloudControllerService.CloudControllerServiceHttpSoap11Endpoint/"/>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpsSoap11Endpoint" binding="ns:CloudControllerServiceSoap11Binding">
-            <soap:address location="https://10.100.1.154:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap11Endpoint/"/>
+            <soap:address location="https://192.168.1.2:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap11Endpoint/"/>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpSoap12Endpoint" binding="ns:CloudControllerServiceSoap12Binding">
-            <soap12:address location="http://10.100.1.154:9764/services/CloudControllerService.CloudControllerServiceHttpSoap12Endpoint/"/>
+            <soap12:address location="http://192.168.1.2:9764/services/CloudControllerService.CloudControllerServiceHttpSoap12Endpoint/"/>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpsSoap12Endpoint" binding="ns:CloudControllerServiceSoap12Binding">
-            <soap12:address location="https://10.100.1.154:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap12Endpoint/"/>
+            <soap12:address location="https://192.168.1.2:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap12Endpoint/"/>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpEndpoint" binding="ns:CloudControllerServiceHttpBinding">
-            <http:address location="http://10.100.1.154:9764/services/CloudControllerService.CloudControllerServiceHttpEndpoint/"/>
+            <http:address location="http://192.168.1.2:9764/services/CloudControllerService.CloudControllerServiceHttpEndpoint/"/>
         </wsdl:port>
         <wsdl:port name="CloudControllerServiceHttpsEndpoint" binding="ns:CloudControllerServiceHttpBinding">
-            <http:address location="https://10.100.1.154:9444/services/CloudControllerService.CloudControllerServiceHttpsEndpoint/"/>
+            <http:address location="https://192.168.1.2:9444/services/CloudControllerService.CloudControllerServiceHttpsEndpoint/"/>
         </wsdl:port>
     </wsdl:service>
 </wsdl:definitions>
\ No newline at end of file


[12/12] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos

Posted by ni...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos


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

Branch: refs/heads/master
Commit: 96db3160a4d4ccbe42e0751d13fdd29a58ca675e
Parents: ad402b5 71e3b1b
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sun Dec 1 16:28:18 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sun Dec 1 16:28:18 2013 +0530

----------------------------------------------------------------------
 .../load-balancer/modules/distribution/src/main/assembly/bin.xml    | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------



[02/12] cleaning up CC, find bug amendments, removing deprecated classes

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LocationScope.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LocationScope.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LocationScope.java
deleted file mode 100644
index 777cf3b..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LocationScope.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.pojo;
-
-/**
- * this contains the scope of a IaaS spanned across the geography.
- */
-public class LocationScope {
-    private String zone;
-    private String network;
-    private String host;
-    private String region;
-    private String cloud;
-
-    public String getZone() {
-        return zone;
-    }
-
-    public void setZone(String zone) {
-        this.zone = zone;
-    }
-
-    public String getNetwork() {
-        return network;
-    }
-
-    public void setNetwork(String network) {
-        this.network = network;
-    }
-
-    public String getHost() {
-        return host;
-    }
-
-    public void setHost(String host) {
-        this.host = host;
-    }
-
-    public String getRegion() {
-        return region;
-    }
-
-    public void setRegion(String region) {
-        this.region = region;
-    }
-
-    public String getCloud() {
-        return cloud;
-    }
-
-    public void setCloud(String cloud) {
-        this.cloud = cloud;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
index 11ebb8a..8eb4103 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
@@ -18,6 +18,8 @@
  */
 package org.apache.stratos.cloud.controller.pojo;
 
+import java.io.Serializable;
+
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
 
 /**
@@ -25,8 +27,9 @@ import org.apache.stratos.cloud.controller.deployment.partition.Partition;
  * @author nirmal
  *
  */
-public class MemberContext {
+public class MemberContext implements Serializable{
 
+    private static final long serialVersionUID = -388327475844701869L;
     // id of the member
     private String memberId;
     // corresponding jclouds node id

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java
index a13ad12..3d21200 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java
@@ -18,12 +18,15 @@
  */
 package org.apache.stratos.cloud.controller.pojo;
 
+import java.io.Serializable;
+
 /**
  * Had to wrap {@link Property} array using a class, since there's a bug in current 
  * stub generation.
  */
-public class Properties {
+public class Properties implements Serializable{
 
+    private static final long serialVersionUID = 1986895299288322592L;
     private Property[] properties;
 
     public Property[] getProperties() {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
index 1ffddad..d7c1ebf 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
@@ -18,11 +18,14 @@
  */
 package org.apache.stratos.cloud.controller.pojo;
 
+import java.io.Serializable;
+
 /**
  * Holds a property 
  */
-public class Property {
+public class Property implements Serializable{
     
+    private static final long serialVersionUID = -2191782657999410197L;
     private String name;
     private String value;
     

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Region.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Region.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Region.java
deleted file mode 100644
index fb1558f..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Region.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.stratos.cloud.controller.pojo;
-
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.Template;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class Region extends IaasProvider {
-    private String imageId;
-    private String identity;
-    private String credential;
-    private String id;
-    private String type;
-    private List<Zone> listOfZones;
-
-    private transient ComputeService computeService;
-
-    private transient Template template;
-
-    private Map<String, String> properties = new HashMap<String, String>();
-
-    public String getProperty(String key) {
-        if(getProperties().get(key) != null) {
-            return getProperties().get(key);
-        } else {
-            return super.getProperty(key);
-        }
-    }
-
-    public Map<String, String> getProperties() {
-        return properties;
-    }
-
-    public void setProperty(String key, String value) {
-
-        if (key != null && value != null) {
-            getProperties().put(key, value);
-        }
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-
-
-    public String getImageId() {
-        return imageId;
-    }
-
-    public void setImageId(String imageId) {
-        this.imageId = imageId;
-    }
-
-    public String getIdentity() {
-        if(identity == null) {
-            return super.getIdentity();
-        }
-        return identity;
-    }
-
-    public void setIdentity(String identity) {
-        this.identity = identity;
-    }
-
-    public String getCredential() {
-        if(credential == null) {
-            return super.getCredential();
-        }
-        return credential;
-    }
-
-    public void setCredential(String credential) {
-        this.credential = credential;
-    }
-
-    public ComputeService getComputeService() {
-        return computeService;
-    }
-
-    public void setComputeService(ComputeService computeService) {
-        this.computeService = computeService;
-    }
-
-    public Template getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(Template template) {
-        this.template = template;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public List<Zone> getListOfZones() {
-        return listOfZones;
-    }
-
-    public void setListOfZones(List<Zone> listOfZones) {
-        this.listOfZones = listOfZones;
-    }
-
-    public void addZone(Zone zone) {
-        this.listOfZones.add(zone);
-    }
-
-    public void removeZone(Zone zone) {
-        this.listOfZones.remove(zone);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceContext.java
deleted file mode 100644
index df025f9..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceContext.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.pojo;
-
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.exception.CloudControllerException;
-import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.io.*;
-import java.util.*;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-/**
- * We keep information regarding a service (i.e. a cartridge instance)
- * in this object.
- */
-public class ServiceContext implements Serializable{
-    private static Log log = LogFactory.getLog(ServiceContext.class);
-
-    private static final long serialVersionUID = -6740964802890082678L;
-    private File file;
-	private String clusterId;
-    private String tenantRange;
-    private String hostName;
-    private String payloadFilePath = "/tmp/" + CloudControllerConstants.PAYLOAD_NAME + ".zip";
-    private String cartridgeType;
-    private Cartridge cartridge;
-    private StringBuilder payload;
-    private String autoScalerPolicyName;
-
-    /**
-     * Key - Value pair.
-     */
-    private Map<String, String> properties = new HashMap<String, String>();
-    /**
-     * Key - IaaS Type
-     * Value - {@link IaasContext} object
-     */
-    private Map<String, IaasContext> iaasCtxts = new HashMap<String, IaasContext>();
-
-    public Map<String, IaasContext> getIaasCtxts() {
-    	return iaasCtxts;
-    }
-
-	public String getClusterId() {
-        return clusterId;
-    }
-
-    public boolean setClusterId(String domainName) {
-        if (!"".equals(domainName)) {
-            this.clusterId = domainName;
-            return true;
-        }
-
-        return false;
-    }
-
-    public void setProperty(String key, String value) {
-        properties.put(key, value);
-    }
-
-    public String getProperty(String key) {
-
-        if(properties.containsKey(key)){
-            return properties.get(key);
-        }
-
-        return "";
-    }
-
-    public Map<String, String> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-
-
-    public Cartridge getCartridge() {
-        return cartridge;
-    }
-
-    public void setCartridge(Cartridge cartridge) {
-        this.cartridge = cartridge;
-    }
-
-	public String getTenantRange() {
-	    return tenantRange;
-    }
-
-	public void setTenantRange(String tenantRange) {
-	    this.tenantRange = tenantRange;
-    }
-
-	public IaasContext addIaasContext(String iaasType){
-		IaasContext ctxt = new IaasContext(iaasType);
-		iaasCtxts.put(iaasType, ctxt);
-		return ctxt;
-	}
-
-	public IaasContext getIaasContext(String type){
-		return iaasCtxts.get(type);
-	}
-
-	public void setIaasContextMap(Map<String, IaasContext> map){
-		iaasCtxts = map;
-	}
-
-	public String getPayloadFile() {
-	    return payloadFilePath;
-    }
-
-	public void setPayloadFile(String payloadFile) {
-	    this.payloadFilePath = payloadFile;
-    }
-
-	public String getHostName() {
-		if(cartridge != null && (hostName == null || hostName.isEmpty())){
-			return cartridge.getHostName();
-		}
-	    return hostName;
-    }
-
-	public void setHostName(String hostName) {
-	    this.hostName = hostName;
-    }
-
-	public String getCartridgeType() {
-	    return cartridgeType;
-    }
-
-	public void setCartridgeType(String cartridgeType) {
-	    this.cartridgeType = cartridgeType;
-    }
-
-	public StringBuilder getPayload() {
-	    return payload;
-    }
-
-	public void setPayload(StringBuilder payload) {
-	    this.payload = payload;
-    }
-
-	public File getFile() {
-		return file;
-	}
-
-	public void setFile(File file) {
-		this.file = file;
-	}
-
-    public String toXml() {
-		String str = "<service domain=\"" + clusterId +
-		                                    "\" tenantRange=\"" + tenantRange + "\" policyName=\"" + autoScalerPolicyName + "\">\n" +
-		                                    "\t<cartridge type=\"" + cartridgeType +
-		                                    "\"/>\n"  + "\t<host>" + hostName +
-		                                    "</host>\n" + "\t<payload>" + payload +
-		                                    "</payload>\n" +
-		                                    propertiesToXml() +
-		                                    "</service>";
-		return str;
-	}
-
-    public String propertiesToXml() {
-		StringBuilder builder = new StringBuilder("");
-		for (Iterator<Map.Entry<String, String>> iterator = getProperties().entrySet().iterator(); iterator.hasNext();) {
-			Map.Entry<String, String> prop = iterator.next();
-
-			String key = prop.getKey();
-			String value = prop.getValue();
-			if (key != null) {
-				builder.append("\t<property name=\""+key +"\" value=\"" + (value == null ? "" : value) +"\"/>\n");
-			}
-
-		}
-
-		return builder.toString();
-	}
-
-    public byte[] generatePayload() {
-        String payloadStringTempFile = "launch-params";
-
-        FileWriter fstream;
-        try {
-            fstream = new FileWriter(payloadStringTempFile);
-
-        } catch (IOException e) {
-            log.error(e.getMessage());
-           throw new CloudControllerException(e.getMessage(), e);
-        }
-        BufferedWriter out = new BufferedWriter(fstream);
-       try {
-            out.write(payload.toString());
-           out.close();
-
-       } catch (IOException e) {
-            log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-
-
-        FileInputStream fis;
-        try {
-            fis = new FileInputStream(payloadStringTempFile);
-        } catch (FileNotFoundException e) {
-             String msg = "Failed while persisting the payload of clusterId : "
-						+ clusterId;
-				log.error(msg, e);
-				throw new CloudControllerException(msg, e);
-        }
-        FileOutputStream fos = null;
-        try {
-            fos = new FileOutputStream(this.payloadFilePath);
-
-        } catch (FileNotFoundException e) {
-            log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-
-        ZipOutputStream zos = new ZipOutputStream(fos);
-        addToZipFile(System.getProperty("user.dir"), payloadStringTempFile, zos);
-
-        File folder = new File(CarbonUtils.getCarbonHome() + File.separator
-               + "repository" + File.separator + "resources" + File.separator
-                + "user-data");
-
-       if(folder != null && folder.exists()) {
-            for (File fileEntry : folder.listFiles()) {
-                if (fileEntry != null && !fileEntry.isDirectory()) {
-                    addToZipFile(folder.getPath(), fileEntry.getName(), zos);
-                }
-            }
-       }
-
-        try {
-            zos.close();
-           fos.close();
-
-        } catch (IOException e) {
-            log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-        byte [] payloadData = null;
-        File file = null;
-        FileInputStream fileInputStream = null;
-        try {
-            file = new File(payloadFilePath);
-            payloadData = new byte[(int)file.length()];
-            fileInputStream = new FileInputStream(file);
-            try {
-                fileInputStream.read(payloadData);
-            } catch (IOException e) {
-                 log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-            }
-        } catch (FileNotFoundException e) {
-             log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-        try {
-            fileInputStream.close();
-            file.delete();
-        } catch (IOException e) {
-             log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-
-        return payloadData;
-    }
-
-      /**
-     * Adds content to a zip file
-     *
-     * @param dir Name of directory
-     * @param fileName Name of file to add
-     * @param zos ZipOutputStream subscription to write
-     * @throws CloudControllerException in an error
-     */
-    private void addToZipFile(String dir, String fileName, ZipOutputStream zos) throws CloudControllerException {
-
-        log.info("Writing '" + fileName + "' to zip file");
-
-        File file = new File(dir + File.separator + fileName);
-        FileInputStream fis;
-        try {
-            fis = new FileInputStream(file);
-
-        } catch (FileNotFoundException e) {
-            log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-
-        ZipEntry zipEntry = new ZipEntry(fileName);
-        try {
-            zos.putNextEntry(zipEntry);
-
-        } catch (IOException e) {
-            log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-
-        byte[] bytes = new byte[1024];
-        int length;
-
-            try {
-                while ((length = fis.read(bytes)) >= 0) {
-                    zos.write(bytes, 0, length);
-                }
-            } catch (IOException e) {
-                log.error(e.getMessage());
-                throw new CloudControllerException(e.getMessage(), e);
-            }
-
-        try {
-            zos.closeEntry();
-            fis.close();
-
-        } catch (IOException e) {
-            log.error(e.getMessage());
-            throw new CloudControllerException(e.getMessage(), e);
-        }
-    }
-
-  	public boolean equals(Object obj) {
-		if (obj instanceof ServiceContext) {
-			return this.clusterId.equals(((ServiceContext) obj).getClusterId());
-		}
-		return false;
-	}
-
-    public int hashCode() {
-        return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers
-            append(clusterId).
-                toHashCode();
-    }
-
-    public String getAutoScalerPolicyName() {
-        return autoScalerPolicyName;
-    }
-
-    public void setAutoScalerPolicyName(String autoScalerPolicyName) {
-        this.autoScalerPolicyName = autoScalerPolicyName;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Zone.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Zone.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Zone.java
deleted file mode 100644
index 803bef5..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Zone.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.apache.stratos.cloud.controller.pojo;
-
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.Template;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class Zone extends Region {
-    private String id;
-    private String type;
-    private List<Host> listOfHosts;
-
-    private Map<String, String> properties = new HashMap<String, String>();
-    private transient ComputeService computeService;
-
-    private transient Template template;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public Map<String, String> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-
-     public void setProperty(String key, String value) {
-
-        if (key != null && value != null) {
-            getProperties().put(key, value);
-        }
-    }
-
-    public String getProperty(String key) {
-        if(getProperties().get(key) != null) {
-            return getProperties().get(key);
-        } else {
-            return super.getProperty(key);
-        }
-    }
-
-    public List<Host> getListOfHosts() {
-        return listOfHosts;
-    }
-
-    public void setListOfHosts(List<Host> listOfHosts) {
-        this.listOfHosts = listOfHosts;
-    }
-
-    public void addHost(Host host) {
-        this.listOfHosts.add(host);
-    }
-
-    public void removeHost(Host host) {
-        this.listOfHosts.remove(host);
-    }
-
-     public ComputeService getComputeService() {
-        return computeService;
-    }
-
-    public void setComputeService(ComputeService computeService) {
-        this.computeService = computeService;
-    }
-
-    public Template getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(Template template) {
-        this.template = template;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/publisher/CartridgeInstanceDataPublisherTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/publisher/CartridgeInstanceDataPublisherTask.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/publisher/CartridgeInstanceDataPublisherTask.java
index 80cfe8f..72c5210 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/publisher/CartridgeInstanceDataPublisherTask.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/publisher/CartridgeInstanceDataPublisherTask.java
@@ -18,23 +18,12 @@
  */
 package org.apache.stratos.cloud.controller.publisher;
 
-import com.google.common.collect.MapDifference;
-import com.google.common.collect.MapDifference.ValueDifference;
-import com.google.common.collect.Maps;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.pojo.CartridgeInstanceData;
-import org.apache.stratos.cloud.controller.pojo.IaasContext;
-import org.apache.stratos.cloud.controller.pojo.IaasProvider;
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.*;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.ComputeMetadata;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.internal.NodeMetadataImpl;
 import org.wso2.carbon.base.ServerConfiguration;
 import org.wso2.carbon.databridge.agent.thrift.Agent;
 import org.wso2.carbon.databridge.agent.thrift.DataPublisher;
@@ -64,6 +53,7 @@ public class CartridgeInstanceDataPublisherTask implements Task{
         publish();
     }
     
+    @SuppressWarnings("deprecation")
     public static void publish(){
         if(FasterLookUpDataHolder.getInstance().isPublisherRunning() ||
                 // this is a temporary fix to avoid task execution - limitation with ntask
@@ -189,7 +179,7 @@ public class CartridgeInstanceDataPublisherTask implements Task{
         }
         
         // replace old map with new one only if data is published
-        FasterLookUpDataHolder.getInstance().setNodeIdToStatusMap(newNodeToStateMap);
+//        FasterLookUpDataHolder.getInstance().setNodeIdToStatusMap(newNodeToStateMap);
         
         //TODO remove
 //        CassandraDataRetriever.init();
@@ -291,178 +281,178 @@ public class CartridgeInstanceDataPublisherTask implements Task{
         
     }
     
-    private static void bundleData(String key, String val, ServiceContext serviceCtxt) {
-        
-        CartridgeInstanceData instanceData = new CartridgeInstanceData();
-        instanceData.setNodeId(key);
-        instanceData.setStatus(val);
-        instanceData.setDomain(serviceCtxt.getClusterId());
-        instanceData.setAlias("".equals(serviceCtxt.getProperty(CloudControllerConstants.ALIAS_PROPERTY))
-            ? "NULL"
-                : serviceCtxt.getProperty(CloudControllerConstants.ALIAS_PROPERTY));
-        instanceData.setTenantRange("".equals(serviceCtxt.getProperty(CloudControllerConstants.TENANT_ID_PROPERTY))
-            ? serviceCtxt.getTenantRange()
-                : serviceCtxt.getProperty(CloudControllerConstants.TENANT_ID_PROPERTY));
-        
-        if (serviceCtxt.getCartridge() != null) {
-            instanceData.setMultiTenant(serviceCtxt.getCartridge().isMultiTenant());
-
-            for (IaasProvider iaas : serviceCtxt.getCartridge().getIaases()) {
-
-                IaasContext ctxt = null;
-                if ((ctxt = serviceCtxt.getIaasContext(iaas.getType())) == null) {
-                    ctxt = serviceCtxt.addIaasContext(iaas.getType());
-                }
-
-                if (ctxt.didISpawn(key)) {
-                    instanceData.setIaas(iaas.getType());
-                    instanceData.setMetaData(ctxt.getNode(key));
-
-                    // clear to be removed data
-                    ctxt.removeToBeRemovedNodeId(key);
-
-                    // if the node is terminated
-                    if (val.equals(NodeStatus.TERMINATED.toString())) {
-                        // since this node is terminated
-                        FasterLookUpDataHolder.getInstance().removeNodeId(key);
-
-                        // remove node meta data
-                        ctxt.removeNodeMetadata(ctxt.getNode(key));
-                    }
-
-                    break;
-                }
-            }
-
-            instanceData.setType(serviceCtxt.getCartridge().getType());
-        } else {
-            log.warn("Cartridge is null for Service Context : (domain: " +
-                serviceCtxt.getClusterId() +
-                    ")");
-        }
-        
-        dataToBePublished.add(instanceData);
-        
-    }
+//    private static void bundleData(String key, String val, ServiceContext serviceCtxt) {
+//        
+//        CartridgeInstanceData instanceData = new CartridgeInstanceData();
+//        instanceData.setNodeId(key);
+//        instanceData.setStatus(val);
+//        instanceData.setDomain(serviceCtxt.getClusterId());
+//        instanceData.setAlias("".equals(serviceCtxt.getProperty(CloudControllerConstants.ALIAS_PROPERTY))
+//            ? "NULL"
+//                : serviceCtxt.getProperty(CloudControllerConstants.ALIAS_PROPERTY));
+//        instanceData.setTenantRange("".equals(serviceCtxt.getProperty(CloudControllerConstants.TENANT_ID_PROPERTY))
+//            ? serviceCtxt.getTenantRange()
+//                : serviceCtxt.getProperty(CloudControllerConstants.TENANT_ID_PROPERTY));
+//        
+//        if (serviceCtxt.getCartridge() != null) {
+//            instanceData.setMultiTenant(serviceCtxt.getCartridge().isMultiTenant());
+//
+//            for (IaasProvider iaas : serviceCtxt.getCartridge().getIaases()) {
+//
+//                IaasContext ctxt = null;
+//                if ((ctxt = serviceCtxt.getIaasContext(iaas.getType())) == null) {
+//                    ctxt = serviceCtxt.addIaasContext(iaas.getType());
+//                }
+//
+//                if (ctxt.didISpawn(key)) {
+//                    instanceData.setIaas(iaas.getType());
+//                    instanceData.setMetaData(ctxt.getNode(key));
+//
+//                    // clear to be removed data
+//                    ctxt.removeToBeRemovedNodeId(key);
+//
+//                    // if the node is terminated
+//                    if (val.equals(NodeStatus.TERMINATED.toString())) {
+//                        // since this node is terminated
+////                        FasterLookUpDataHolder.getInstance().removeNodeId(key);
+//
+//                        // remove node meta data
+//                        ctxt.removeNodeMetadata(ctxt.getNode(key));
+//                    }
+//
+//                    break;
+//                }
+//            }
+//
+//            instanceData.setType(serviceCtxt.getCartridge().getType());
+//        } else {
+//            log.warn("Cartridge is null for Service Context : (domain: " +
+//                serviceCtxt.getClusterId() +
+//                    ")");
+//        }
+//        
+//        dataToBePublished.add(instanceData);
+//        
+//    }
     
     private static Map<String, String> getNodeIdToStatusMap() throws Exception {
         
         Map<String, String> statusMap = new HashMap<String, String>();
         
-        // iterate through all ServiceContexts
-        for (Iterator<?> it1 = FasterLookUpDataHolder.getInstance().getServiceContexts().entrySet().iterator(); it1.hasNext();) {
-            @SuppressWarnings("unchecked")
-            Map.Entry<String, Map<String, ServiceContext>> entry = (Map.Entry<String, Map<String, ServiceContext>>) it1.next();
-            
-            Map<String, ServiceContext> map = (Map<String, ServiceContext>) entry.getValue();
-            
-            for (Iterator<ServiceContext> it2 = map.values().iterator(); it2.hasNext();) {
-                ServiceContext subjectedSerCtxt = (ServiceContext) it2.next();
-                
-                if (subjectedSerCtxt != null && subjectedSerCtxt.getCartridge() != null) {
-                    List<IaasProvider> iaases = subjectedSerCtxt.getCartridge().getIaases();
-
-                    for (IaasProvider iaas : iaases) {
-
-                        ComputeService computeService = iaas.getComputeService();
-                        
-                        if(computeService == null){
-                            continue;
-                        }
-                        
-                        IaasContext ctxt = null;
-                        if((ctxt = subjectedSerCtxt.getIaasContext(iaas.getType())) == null){
-                        	ctxt = subjectedSerCtxt.addIaasContext(iaas.getType());
-                        }
-
-                        // get list of node Ids
-                        List<String> nodeIds = ctxt.getAllNodeIds();
-
-                        if (nodeIds.isEmpty()) {
-                            
-                            continue;
-                        }
-                        
-                        try {
-
-                            // get all the nodes spawned by this IaasContext
-                            Set<? extends ComputeMetadata> set = computeService.listNodes();
-
-                            Iterator<? extends ComputeMetadata> iterator = set.iterator();
-
-                            // traverse through all nodes of this ComputeService object
-                            while (iterator.hasNext()) {
-                                NodeMetadata nodeMetadata = (NodeMetadataImpl) iterator.next();
-
-                                // if this node belongs to the requested domain
-                                if (nodeIds.contains(nodeMetadata.getId())) {
-
-                                    statusMap.put(nodeMetadata.getId(), nodeMetadata.getStatus()
-                                                                                    .toString());
-
-                                    ctxt.addNodeMetadata(nodeMetadata);
-                                }
-
-                            }
-
-                        }catch (Exception e) {
-                            log.error(e.getMessage(), e);
-                            throw e;
-                        }
-
-                    }
-                }
-            }
-            
-            
-        }
+//        // iterate through all ServiceContexts
+//        for (Iterator<?> it1 = FasterLookUpDataHolder.getInstance().getServiceContexts().entrySet().iterator(); it1.hasNext();) {
+//            @SuppressWarnings("unchecked")
+//            Map.Entry<String, Map<String, ServiceContext>> entry = (Map.Entry<String, Map<String, ServiceContext>>) it1.next();
+//            
+//            Map<String, ServiceContext> map = (Map<String, ServiceContext>) entry.getValue();
+//            
+//            for (Iterator<ServiceContext> it2 = map.values().iterator(); it2.hasNext();) {
+//                ServiceContext subjectedSerCtxt = (ServiceContext) it2.next();
+//                
+//                if (subjectedSerCtxt != null && subjectedSerCtxt.getCartridge() != null) {
+//                    List<IaasProvider> iaases = subjectedSerCtxt.getCartridge().getIaases();
+//
+//                    for (IaasProvider iaas : iaases) {
+//
+//                        ComputeService computeService = iaas.getComputeService();
+//                        
+//                        if(computeService == null){
+//                            continue;
+//                        }
+//                        
+//                        IaasContext ctxt = null;
+//                        if((ctxt = subjectedSerCtxt.getIaasContext(iaas.getType())) == null){
+//                        	ctxt = subjectedSerCtxt.addIaasContext(iaas.getType());
+//                        }
+//
+//                        // get list of node Ids
+//                        List<String> nodeIds = ctxt.getAllNodeIds();
+//
+//                        if (nodeIds.isEmpty()) {
+//                            
+//                            continue;
+//                        }
+//                        
+//                        try {
+//
+//                            // get all the nodes spawned by this IaasContext
+//                            Set<? extends ComputeMetadata> set = computeService.listNodes();
+//
+//                            Iterator<? extends ComputeMetadata> iterator = set.iterator();
+//
+//                            // traverse through all nodes of this ComputeService object
+//                            while (iterator.hasNext()) {
+//                                NodeMetadata nodeMetadata = (NodeMetadataImpl) iterator.next();
+//
+//                                // if this node belongs to the requested domain
+//                                if (nodeIds.contains(nodeMetadata.getId())) {
+//
+//                                    statusMap.put(nodeMetadata.getId(), nodeMetadata.getStatus()
+//                                                                                    .toString());
+//
+//                                    ctxt.addNodeMetadata(nodeMetadata);
+//                                }
+//
+//                            }
+//
+//                        }catch (Exception e) {
+//                            log.error(e.getMessage(), e);
+//                            throw e;
+//                        }
+//
+//                    }
+//                }
+//            }
+//            
+//            
+//        }
         return statusMap;
 
     }
     
     private static void populateNewlyAddedOrStateChangedNodes(Map<String, String> newMap){
         
-        MapDifference<String, String> diff = Maps.difference(newMap, 
-                                                             FasterLookUpDataHolder.getInstance().getNodeIdToStatusMap());
-        
-        // adding newly added nodes
-        Map<String, String> newlyAddedNodes = diff.entriesOnlyOnLeft();
-        
-        for (Iterator<?> it = newlyAddedNodes.entrySet().iterator(); it.hasNext();) {
-            @SuppressWarnings("unchecked")
-            Map.Entry<String, String> entry = (Map.Entry<String, String>) it.next();
-            String key = entry.getKey();
-            String val = entry.getValue();
-            ServiceContext ctxt = FasterLookUpDataHolder.getInstance().getServiceContextFromNodeId(key);
-            
-            log.debug("------ Node id: "+key+" --- node status: "+val+" -------- ctxt: "+ctxt);
-            
-            if (ctxt != null && key != null && val != null) {
-                // bundle the data to be published
-                bundleData(key, val, ctxt);
-            }   
-                    
-        }
-        
-        // adding nodes with state changes
-        Map<String, ValueDifference<String>> stateChangedNodes = diff.entriesDiffering();
-        
-        for (Iterator<?> it = stateChangedNodes.entrySet().iterator(); it.hasNext();) {
-            @SuppressWarnings("unchecked")
-            Map.Entry<String, ValueDifference<String>> entry = (Map.Entry<String, ValueDifference<String>>) it.next();
-            
-            String key = entry.getKey();
-            String newState = entry.getValue().leftValue();
-            ServiceContext ctxt = FasterLookUpDataHolder.getInstance().getServiceContextFromNodeId(key);
-            
-            log.debug("------- Node id: "+key+" --- node status: "+newState+" -------- ctxt: "+ctxt);
-            
-            if (ctxt != null && key != null && newState != null) {
-                // bundle the data to be published
-                bundleData(key, newState, ctxt);
-            }  
-            
-        }
+//        MapDifference<String, String> diff = Maps.difference(newMap, 
+//                                                             FasterLookUpDataHolder.getInstance().getNodeIdToStatusMap());
+//        
+//        // adding newly added nodes
+//        Map<String, String> newlyAddedNodes = diff.entriesOnlyOnLeft();
+//        
+//        for (Iterator<?> it = newlyAddedNodes.entrySet().iterator(); it.hasNext();) {
+//            @SuppressWarnings("unchecked")
+//            Map.Entry<String, String> entry = (Map.Entry<String, String>) it.next();
+//            String key = entry.getKey();
+//            String val = entry.getValue();
+//            ServiceContext ctxt = FasterLookUpDataHolder.getInstance().getServiceContextFromNodeId(key);
+//            
+//            log.debug("------ Node id: "+key+" --- node status: "+val+" -------- ctxt: "+ctxt);
+//            
+//            if (ctxt != null && key != null && val != null) {
+//                // bundle the data to be published
+//                bundleData(key, val, ctxt);
+//            }   
+//                    
+//        }
+//        
+//        // adding nodes with state changes
+//        Map<String, ValueDifference<String>> stateChangedNodes = diff.entriesDiffering();
+//        
+//        for (Iterator<?> it = stateChangedNodes.entrySet().iterator(); it.hasNext();) {
+//            @SuppressWarnings("unchecked")
+//            Map.Entry<String, ValueDifference<String>> entry = (Map.Entry<String, ValueDifference<String>>) it.next();
+//            
+//            String key = entry.getKey();
+//            String newState = entry.getValue().leftValue();
+//            ServiceContext ctxt = FasterLookUpDataHolder.getInstance().getServiceContextFromNodeId(key);
+//            
+//            log.debug("------- Node id: "+key+" --- node status: "+newState+" -------- ctxt: "+ctxt);
+//            
+//            if (ctxt != null && key != null && newState != null) {
+//                // bundle the data to be published
+//                bundleData(key, newState, ctxt);
+//            }  
+//            
+//        }
 
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
index 9c5c4b3..0309c0d 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
@@ -46,18 +46,15 @@ public class RegistryManager {
 
         registryService = ServiceReferenceHolder.getInstance().getRegistry();
 
-        if (registryManager == null) {
-            synchronized (RegistryManager.class) {
-                if (registryManager == null) {
-                    if (registryService == null) {
-//						log.warn("Registry Service is null. Hence unable to fetch data from registry.");
-                        return registryManager;
-                    }
-                    registryManager = new RegistryManager();
+        synchronized (RegistryManager.class) {
+            if (registryManager == null) {
+                if (registryService == null) {
+                    // log.warn("Registry Service is null. Hence unable to fetch data from registry.");
+                    return registryManager;
                 }
+                registryManager = new RegistryManager();
             }
         }
-
         return registryManager;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java
index ebdcbc4..fda88a0 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java
@@ -23,16 +23,13 @@ import org.apache.stratos.cloud.controller.pojo.ClusterContext;
 import org.apache.stratos.cloud.controller.pojo.DataPublisherConfig;
 import org.apache.stratos.cloud.controller.pojo.IaasProvider;
 import org.apache.stratos.cloud.controller.pojo.MemberContext;
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
 import org.apache.stratos.cloud.controller.pojo.TopologyConfig;
 import org.apache.stratos.cloud.controller.registry.RegistryManager;
-import org.apache.stratos.cloud.controller.util.*;
 import org.apache.stratos.messaging.broker.publish.EventPublisher;
 import org.wso2.carbon.databridge.agent.thrift.DataPublisher;
 
 import java.io.Serializable;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * This object holds all runtime data and provides faster access. This is a Singleton class.
@@ -67,28 +64,28 @@ public class FasterLookUpDataHolder implements Serializable{
 	 * Key - member id
 	 * Value - node id
 	 */
-	private Map<String, String> memberIdToNodeId;
+//	private Map<String, String> memberIdToNodeId;
 
 	/**
 	 * Key - domain
 	 * value - {@link ServiceContext}
 	 */
-	private Map<String, ServiceContext> serviceCtxts;
+//	private Map<String, ServiceContext> serviceCtxts;
 	
 	/**
 	 * To make data retrieval from registry faster.
 	 */
-	private List<ServiceContext> serviceCtxtList;
+//	private List<ServiceContext> serviceCtxtList;
 
-	public List<ServiceContext> getServiceCtxtList() {
-    	return serviceCtxtList;
-    }
+//	public List<ServiceContext> getServiceCtxtList() {
+//    	return serviceCtxtList;
+//    }
 
 	/**
 	 * Key - node id
 	 * Value - {@link ServiceContext}
 	 */
-	private Map<String, ServiceContext> nodeIdToServiceCtxt;
+//	private Map<String, ServiceContext> nodeIdToServiceCtxt;
 	
 	/**
 	 * List of registered {@link Cartridge}s
@@ -112,14 +109,14 @@ public class FasterLookUpDataHolder implements Serializable{
 	 * Value - Status of the instance
 	 * This map is only used by BAM data publisher in CC.
 	 */
-	private Map<String, String> nodeIdToStatusMap = new HashMap<String, String>();
+//	private Map<String, String> nodeIdToStatusMap = new HashMap<String, String>();
 	
 	/**
 	 * Key - iaas type
 	 * Value - # of running instance count
 	 * This map will be used to track the running instances count in each IaaS
 	 */
-	private Map<String, Integer> iaasToActiveInstanceCountMap = new HashMap<String, Integer>();
+//	private Map<String, Integer> iaasToActiveInstanceCountMap = new HashMap<String, Integer>();
 	
 	/**
      * Key - name of the topic
@@ -143,13 +140,8 @@ public class FasterLookUpDataHolder implements Serializable{
 					if (obj != null) {
 						if (obj instanceof FasterLookUpDataHolder) {
 							ctxt = (FasterLookUpDataHolder) obj;
-							System.out.println("*********** FasterLookUpDataHolder ********");
-						} else {
-							System.out.println("*********** Not a FasterLookUpDataHolder *******");
 						}
-
 					} 
-					
 				}
 				if(ctxt == null) {
 					ctxt = new FasterLookUpDataHolder();
@@ -162,89 +154,89 @@ public class FasterLookUpDataHolder implements Serializable{
 
 	private FasterLookUpDataHolder() {
 
-		serviceCtxtList = new ArrayList<ServiceContext>();
-		serviceCtxts = new ConcurrentHashMap<String,ServiceContext>();
-		nodeIdToServiceCtxt = new LinkedHashMap<String, ServiceContext>();
+//		serviceCtxtList = new ArrayList<ServiceContext>();
+//		serviceCtxts = new ConcurrentHashMap<String,ServiceContext>();
+//		nodeIdToServiceCtxt = new LinkedHashMap<String, ServiceContext>();
 		cartridges = new ArrayList<Cartridge>();
-		setMemberIdToNodeId(new ConcurrentHashMap<String, String>());
-
-	}
-
-	public void addServiceContext(ServiceContext ctx) {
-
-		if (ctx == null) {
-			return;
-		}
-
-		String domain = ctx.getClusterId();
-
-
-		if (domain != null) {
-			addToServiceCtxts(domain, ctx);
-		}
-
-	}
+//		setMemberIdToNodeId(new ConcurrentHashMap<String, String>());
 
-	public void removeServiceContext(ServiceContext ctxt) {
-
-		if (ctxt == null) {
-			return;
-		}
-
-		String domain = ctxt.getClusterId();
-
-		if (domain != null) {
-			if (serviceCtxts.containsKey(domain)) {
-                serviceCtxts.remove(ctxt);
-			}
-		}
-		
-		serviceCtxtList.remove(ctxt);
-
-	}
-
-	public ServiceContext getServiceContextFromDomain(String domain) {
-
-		if (serviceCtxts.get(domain) != null) {
-			return serviceCtxts.get(domain);
-		}
-		return null;
 	}
 
-	public ServiceContext getServiceContextFromNodeId(String nodeId) {
-
-		return nodeIdToServiceCtxt.get(nodeId);
-	}
-	
-	public List<Object> getNodeIdsOfServiceCtxt(ServiceContext ctxt){
-		return CloudControllerUtil.getKeysFromValue(nodeIdToServiceCtxt, ctxt);
-	}
-
-	public Map<String, ServiceContext> getServiceContexts() {
-		return serviceCtxts;
-	}
-
-	public void addNodeId(String nodeId, ServiceContext ctxt) {
-		nodeIdToServiceCtxt.put(nodeId, ctxt);
-	}
-
-	public void removeNodeId(String nodeId) {
-		nodeIdToServiceCtxt.remove(nodeId);
-	}
-	
-	public void setNodeIdToServiceContextMap(Map<String, ServiceContext> map) {
-		nodeIdToServiceCtxt = map;
-	}
-
-	public Map<String, ServiceContext> getNodeIdToServiceContextMap() {
-		return nodeIdToServiceCtxt;
-	}
-
-	private void addToServiceCtxts(String domainName, ServiceContext ctxt) {
-        serviceCtxts.put(domainName, ctxt);
-        serviceCtxtList.add(ctxt);
-
-	}
+//	public void addServiceContext(ServiceContext ctx) {
+//
+//		if (ctx == null) {
+//			return;
+//		}
+//
+//		String domain = ctx.getClusterId();
+//
+//
+//		if (domain != null) {
+//			addToServiceCtxts(domain, ctx);
+//		}
+//
+//	}
+//
+//	public void removeServiceContext(ServiceContext ctxt) {
+//
+//		if (ctxt == null) {
+//			return;
+//		}
+//
+//		String domain = ctxt.getClusterId();
+//
+//		if (domain != null) {
+//			if (serviceCtxts.containsKey(domain)) {
+//                serviceCtxts.remove(ctxt);
+//			}
+//		}
+//		
+//		serviceCtxtList.remove(ctxt);
+//
+//	}
+//
+//	public ServiceContext getServiceContextFromDomain(String domain) {
+//
+//		if (serviceCtxts.get(domain) != null) {
+//			return serviceCtxts.get(domain);
+//		}
+//		return null;
+//	}
+//
+//	public ServiceContext getServiceContextFromNodeId(String nodeId) {
+//
+//		return nodeIdToServiceCtxt.get(nodeId);
+//	}
+//	
+//	public List<Object> getNodeIdsOfServiceCtxt(ServiceContext ctxt){
+//		return CloudControllerUtil.getKeysFromValue(nodeIdToServiceCtxt, ctxt);
+//	}
+//
+//	public Map<String, ServiceContext> getServiceContexts() {
+//		return serviceCtxts;
+//	}
+//
+//	public void addNodeId(String nodeId, ServiceContext ctxt) {
+//		nodeIdToServiceCtxt.put(nodeId, ctxt);
+//	}
+//
+//	public void removeNodeId(String nodeId) {
+//		nodeIdToServiceCtxt.remove(nodeId);
+//	}
+//	
+//	public void setNodeIdToServiceContextMap(Map<String, ServiceContext> map) {
+//		nodeIdToServiceCtxt = map;
+//	}
+//
+//	public Map<String, ServiceContext> getNodeIdToServiceContextMap() {
+//		return nodeIdToServiceCtxt;
+//	}
+//
+//	private void addToServiceCtxts(String domainName, ServiceContext ctxt) {
+//        serviceCtxts.put(domainName, ctxt);
+//        serviceCtxtList.add(ctxt);
+//
+//	}
 
 	public List<Cartridge> getCartridges() {
 		return cartridges;
@@ -261,18 +253,18 @@ public class FasterLookUpDataHolder implements Serializable{
 
 	}
 	
-	public void updateActiveInstanceCount(String iaasType, int count) {
-		int currentCount = 0;
-		if(iaasToActiveInstanceCountMap.containsKey(iaasType)){
-			currentCount = iaasToActiveInstanceCountMap.get(iaasType);
-		}
-		iaasToActiveInstanceCountMap.put(iaasType, currentCount+count);
-	}
-	
-	public int getActiveInstanceCount(String iaasType) {
-		Integer count = iaasToActiveInstanceCountMap.get(iaasType);
-		return count == null ? 0 : count;
-	}
+//	public void updateActiveInstanceCount(String iaasType, int count) {
+//		int currentCount = 0;
+//		if(iaasToActiveInstanceCountMap.containsKey(iaasType)){
+//			currentCount = iaasToActiveInstanceCountMap.get(iaasType);
+//		}
+//		iaasToActiveInstanceCountMap.put(iaasType, currentCount+count);
+//	}
+//	
+//	public int getActiveInstanceCount(String iaasType) {
+//		Integer count = iaasToActiveInstanceCountMap.get(iaasType);
+//		return count == null ? 0 : count;
+//	}
 
 //	public void addCartridges(List<Cartridge> newCartridges) {
 //		if (this.cartridges == null) {
@@ -334,13 +326,13 @@ public class FasterLookUpDataHolder implements Serializable{
 
 	
 
-	public Map<String, String> getNodeIdToStatusMap() {
-		return nodeIdToStatusMap;
-	}
-
-	public void setNodeIdToStatusMap(Map<String, String> nodeIdToStatusMap) {
-		this.nodeIdToStatusMap = nodeIdToStatusMap;
-	}
+//	public Map<String, String> getNodeIdToStatusMap() {
+//		return nodeIdToStatusMap;
+//	}
+//
+//	public void setNodeIdToStatusMap(Map<String, String> nodeIdToStatusMap) {
+//		this.nodeIdToStatusMap = nodeIdToStatusMap;
+//	}
 
 	public DataPublisher getDataPublisher() {
 		return dataPublisher;
@@ -425,7 +417,7 @@ public class FasterLookUpDataHolder implements Serializable{
         
         List<MemberContext> ctxts;
         
-        if((ctxts = clusterIdToMemberContext.get(ctxt)) == null) {
+        if((ctxts = clusterIdToMemberContext.get(ctxt.getClusterId())) == null) {
             ctxts = new ArrayList<MemberContext>();
         } 
         ctxts.add(ctxt);
@@ -449,21 +441,21 @@ public class FasterLookUpDataHolder implements Serializable{
         return clusterIdToMemberContext.get(clusterId);
     }
 
-    public void addNodeId(String memberId, String nodeId) {
-        memberIdToNodeId.put(memberId, nodeId);
-    }
-    
-    public String getNodeId(String memberId) {
-        return memberIdToNodeId.get(memberId);
-    }
-    
-    public Map<String, String> getMemberIdToNodeId() {
-        return memberIdToNodeId;
-    }
-
-    public void setMemberIdToNodeId(Map<String, String> memberIdToNodeId) {
-        this.memberIdToNodeId = memberIdToNodeId;
-    }
+//    public void addNodeId(String memberId, String nodeId) {
+//        memberIdToNodeId.put(memberId, nodeId);
+//    }
+//    
+//    public String getNodeId(String memberId) {
+//        return memberIdToNodeId.get(memberId);
+//    }
+//    
+//    public Map<String, String> getMemberIdToNodeId() {
+//        return memberIdToNodeId;
+//    }
+//
+//    public void setMemberIdToNodeId(Map<String, String> memberIdToNodeId) {
+//        this.memberIdToNodeId = memberIdToNodeId;
+//    }
 
     public Map<String, MemberContext> getMemberIdToContext() {
         return memberIdToContext;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index f87953e..7b21c10 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -25,7 +25,6 @@ import org.apache.stratos.cloud.controller.pojo.Cartridge;
 import org.apache.stratos.cloud.controller.pojo.ClusterContext;
 import org.apache.stratos.cloud.controller.pojo.PortMapping;
 import org.apache.stratos.cloud.controller.pojo.Registrant;
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.messaging.domain.topology.*;
@@ -225,11 +224,12 @@ public class TopologyBuilder {
     }
 
     public static void handleMemberSpawned(String memberId, String serviceName, String clusterId,
-                                           String iaasNodeId, Partition partition, String privateIp) {
+                                           Partition partition, String privateIp) {
         //adding the new member to the cluster after it is successfully started in IaaS.
         Topology topology = TopologyManager.getInstance().getTopology();
         Service service = topology.getService(serviceName);
         Cluster cluster = service.getCluster(clusterId);
+        String partitionId = partition.getId();
 
         if (cluster.memberExists(memberId)) {
             throw new RuntimeException(String.format("Member %s already exists", memberId));
@@ -238,16 +238,15 @@ public class TopologyBuilder {
         try {
             TopologyManager.getInstance().acquireWriteLock();
             Member member = new Member(serviceName, clusterId, memberId);
-            member.setIaasNodeId(iaasNodeId);
+            member.setPartitionId(partitionId);
             member.setStatus(MemberStatus.Created);
             member.setMemberIp(privateIp);
             cluster.addMember(member);
-            cluster.addMemberToIaasNodeId(member);
             TopologyManager.getInstance().updateTopology(topology);
         } finally {
             TopologyManager.getInstance().releaseWriteLock();
         }
-        TopologyEventSender.sendInstanceSpawnedEvent(serviceName, clusterId, memberId, iaasNodeId);
+        TopologyEventSender.sendInstanceSpawnedEvent(serviceName, clusterId, memberId, partitionId);
 
     }
 
@@ -285,18 +284,17 @@ public class TopologyBuilder {
     public static void handleMemberActivated(MemberActivatedEvent memberActivatedEvent) {
         Topology topology = TopologyManager.getInstance().getTopology();
         Service service = topology.getService(memberActivatedEvent.getServiceName());
-        Cluster cluster = service.getCluster(memberActivatedEvent.getClusterId());
-        Member member = cluster.getMember(memberActivatedEvent.getMemberId());
-
         if (service == null) {
             throw new RuntimeException(String.format("Service %s does not exist",
-                    memberActivatedEvent.getServiceName()));
+                                                     memberActivatedEvent.getServiceName()));
         }
-
+        
+        Cluster cluster = service.getCluster(memberActivatedEvent.getClusterId());
         if (cluster == null) {
             throw new RuntimeException(String.format("Cluster %s does not exist",
-                    memberActivatedEvent.getClusterId()));
+                                                     memberActivatedEvent.getClusterId()));
         }
+        Member member = cluster.getMember(memberActivatedEvent.getMemberId());
 
         if (member == null) {
             throw new RuntimeException(String.format("Member %s does not exist",
@@ -333,16 +331,15 @@ public class TopologyBuilder {
         TopologyEventSender.sendMemberActivatedEvent(memberActivatedEventTopology);
     }
 
-    public static void handleMemberTerminated(String serviceName, String clusterId, String nodeId) {
+    public static void handleMemberTerminated(String serviceName, String clusterId, String memberId) {
         Topology topology = TopologyManager.getInstance().getTopology();
         Service service = topology.getService(serviceName);
         Cluster cluster = service.getCluster(clusterId);
-        Member member = cluster.getMemberFromIaasNodeId(nodeId);
-        String memberId = member.getMemberId();
+        Member member = cluster.getMember(memberId);
 
         if (member == null) {
             throw new RuntimeException(String.format("Member with nodeID %s does not exist",
-                    nodeId));
+                    memberId));
         }
 
         try {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventSender.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventSender.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventSender.java
index 82aa692..b1f9f00 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventSender.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventSender.java
@@ -23,7 +23,6 @@ import org.apache.stratos.cloud.controller.pojo.Cartridge;
 import org.apache.stratos.cloud.controller.pojo.ClusterContext;
 import org.apache.stratos.cloud.controller.pojo.PortMapping;
 import org.apache.stratos.cloud.controller.pojo.Registrant;
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.messaging.broker.publish.EventPublisher;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
index 7c36613..7610dbb 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
@@ -53,10 +53,13 @@ public class TopologyManager {
     }
 
     public static TopologyManager getInstance() {
-        if (instance == null) {
-            instance = new TopologyManager();
+        synchronized (TopologyManager.class) {
+            if (instance == null) {
+                instance = new TopologyManager();
+            }
+            return instance;
+            
         }
-        return instance;
     }
 
     public void acquireReadLock() {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/AxiomValidationTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/AxiomValidationTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/AxiomValidationTest.java
index 42f5230..aad5b61 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/AxiomValidationTest.java
+++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/AxiomValidationTest.java
@@ -21,7 +21,6 @@ package org.apache.cartridge.autoscaler.service.axiom;
 import java.io.File;
 
 import org.apache.axiom.om.OMElement;
-import org.apache.stratos.cloud.controller.axiom.AxiomXpathParser;
 import org.apache.stratos.cloud.controller.axiom.AxiomXpathParserUtil;
 import org.xml.sax.SAXParseException;
 
@@ -29,7 +28,6 @@ import junit.framework.TestCase;
 
 public class AxiomValidationTest extends TestCase {
     
-    AxiomXpathParser util1, util2, util3, util4, util5, util6, util7, util8, util9;
     File xmlSchemaCartridges = new File("src/main/resources/cartridges.xsd");
     File xmlSchemaCartridge = new File("src/main/resources/cartridge.xsd");
     private String dir = "src/test/resources/";

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/util/ServiceContextTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/util/ServiceContextTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/util/ServiceContextTest.java
deleted file mode 100644
index b4ea101..0000000
--- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/util/ServiceContextTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cartridge.autoscaler.service.util;
-
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
-
-import junit.framework.TestCase;
-
-public class ServiceContextTest extends TestCase {
-    
-    ServiceContext ctxt = new ServiceContext();
-
-    public ServiceContextTest(String name) {
-        super(name);
-    }
-    
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctxt.setProperty("min_app_instances", "2");
-        ctxt.setProperty("max_app_instances", "5");
-        ctxt.setProperty("public_ip", null);
-    }
-
-
-    public final void testPropertiesToXml() throws Exception {
-        System.out.println(ctxt.propertiesToXml());
-        assertEquals(true, ctxt.propertiesToXml().contains("name=\"min_app_instances\" value=\"2\""));
-
-    }
-   
-}


[08/12] git commit: fixing partition deployer, few exception handling, policy parser fixes, refactoring

Posted by ni...@apache.org.
fixing partition deployer, few exception handling, policy parser fixes, refactoring


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

Branch: refs/heads/master
Commit: 50955e743c589cbbb2f28b5e2526acb3fe150d2b
Parents: 45cfecd
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sun Dec 1 16:22:46 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sun Dec 1 16:22:46 2013 +0530

----------------------------------------------------------------------
 .../stratos/autoscaler/ClusterContext.java      |  17 +-
 .../algorithm/AutoscaleAlgorithm.java           |   2 +-
 .../autoscaler/algorithm/OneAfterAnother.java   |   2 +-
 .../PartitionGroupOneAfterAnother.java          |   2 +-
 .../autoscaler/algorithm/RoundRobin.java        |   2 +-
 .../cloud/controller/CloudControllerClient.java |  10 +-
 .../deployment/policy/DeploymentPolicy.java     |  95 ++++++++++
 .../exception/InvalidPartitionException.java    |  22 +++
 .../exception/InvalidPolicyException.java       |  40 +++++
 .../exception/PolicyValidationException.java    |   4 +
 .../autoscaler/partition/PartitionGroup.java    |  87 ++++++++++
 .../partition/deployers/PartitionDeployer.java  |  38 ++--
 .../partition/deployers/PartitionReader.java    | 102 +++++------
 .../policy/InvalidPolicyException.java          |  40 -----
 .../autoscaler/policy/PolicyManager.java        |   3 +-
 .../policy/deployers/AbstractPolicyReader.java  |   5 +-
 .../deployers/AutoscalerPolicyDeployer.java     |   2 +-
 .../deployers/AutoscalerPolicyReader.java       |   2 +-
 .../deployers/DeploymentPolicyDeployer.java     |   4 +-
 .../deployers/DeploymentPolicyReader.java       |  51 ++++--
 .../stratos/autoscaler/util/AutoscalerUtil.java | 174 +++++++++++++++----
 .../stratos/autoscaler/util/ConfUtil.java       |   8 +
 .../policy/DeploymentPolicyDeployerTest.java    |   3 +-
 .../src/test/resources/deployment-policy.xml    |   2 +-
 24 files changed, 521 insertions(+), 196 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
index c1bf519..82d9d0c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
@@ -25,9 +25,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
 import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
@@ -64,26 +63,20 @@ public class ClusterContext {
     private Map<String, MemberStatsContext> memberContextMap;
     private DeploymentPolicy deploymentPolicy;
 
-    @SuppressWarnings("unchecked")
-    public ClusterContext(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy) {
+    public ClusterContext(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, List<Partition> partitions) {
 
         this.clusterId = clusterId;
         this.serviceId = serviceId;
         this.setDeploymentPolicy(deploymentPolicy);
         partitionsOfThisCluster = new ArrayList<Partition>();
-        if (deploymentPolicy != null) {
-            for (PartitionGroup group : deploymentPolicy.getPartitionGroup()) {
-                for (Partition partition : group.getPartitions()) {
-                    partitionsOfThisCluster.add(partition);
-                }
-            }
-        }
         memberContextMap = new HashMap<String, MemberStatsContext>();
         partitionCountMap = new HashMap<String, Integer>();
         
-        for (Partition partition : partitionsOfThisCluster) {
+        for (Partition partition : partitions) {
+            partitionsOfThisCluster.add(partition);
             this.addPartitionCount(partition.getId(), 0);
         }
+        
         memberCount = 0;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java
index 91d20a0..54ec855 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/AutoscaleAlgorithm.java
@@ -19,8 +19,8 @@
 
 package org.apache.stratos.autoscaler.algorithm;
 
+import org.apache.stratos.autoscaler.partition.PartitionGroup;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
index 5c33b99..9d34385 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
@@ -25,8 +25,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.ClusterContext;
+import org.apache.stratos.autoscaler.partition.PartitionGroup;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
 
 import edu.emory.mathcs.backport.java.util.Arrays;
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java
index ba35131..f954c97 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/PartitionGroupOneAfterAnother.java
@@ -26,10 +26,10 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.ClusterContext;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.autoscaler.partition.PartitionGroup;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
 
 import edu.emory.mathcs.backport.java.util.Arrays;
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
index 7de89cd..83d48bc 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
@@ -23,8 +23,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.AutoscalerContext;
 import org.apache.stratos.autoscaler.ClusterContext;
+import org.apache.stratos.autoscaler.partition.PartitionGroup;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
 
 import edu.emory.mathcs.backport.java.util.Arrays;
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
index 2b2e861..20c30bb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
@@ -29,7 +29,6 @@ import org.apache.stratos.autoscaler.exception.SpawningException;
 import org.apache.stratos.autoscaler.exception.TerminationException;
 import org.apache.stratos.autoscaler.util.ConfUtil;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceIllegalArgumentExceptionException;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidMemberExceptionException;
@@ -38,7 +37,6 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceStub;
 import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
 
 import java.rmi.RemoteException;
-import java.util.UUID;
 
 
 /**
@@ -88,10 +86,10 @@ public class CloudControllerClient {
         
     }
     
-    public boolean validateDeploymentPolicy(String cartridgeType, DeploymentPolicy policy) throws PolicyValidationException{
+    public boolean validatePartitionsOfPolicy(String cartridgeType, Partition[] partitions) throws PolicyValidationException{
         
         try {
-            return stub.validateDeploymentPolicy(cartridgeType, policy);
+            return stub.validateDeploymentPolicy(cartridgeType, partitions);
         } catch (RemoteException e) {
             log.error(e.getMessage());
             throw new PolicyValidationException(e);
@@ -101,7 +99,7 @@ public class CloudControllerClient {
         } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) {
             log.error(e.getMessage());
             throw new PolicyValidationException(e);
-        }
+        } 
     }
     
     /*
@@ -115,7 +113,7 @@ public class CloudControllerClient {
             log.error(e.getMessage());
             throw new PartitionValidationException(e);
         } catch (CloudControllerServiceInvalidPartitionExceptionException e) {
-        	throw new PartitionValidationException(e);
+        	throw new PartitionValidationException(e.getMessage(),e);
 		}
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java
new file mode 100644
index 0000000..815fbd7
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one 
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+ * KIND, either express or implied.  See the License for the 
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.deployment.policy;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stratos.autoscaler.partition.PartitionGroup;
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+
+import edu.emory.mathcs.backport.java.util.Arrays;
+
+/**
+ * The model class for Deployment-Policy definition.
+ */
+public class DeploymentPolicy implements Serializable{
+
+    private static final long serialVersionUID = 5675507196284400099L;
+    private String id;
+	private PartitionGroup[] partitionGroups;
+	private List<Partition> allPartitions;
+
+    /**
+     * Gets the value of the id property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * Sets the value of the id property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setId(String value) {
+        this.id = value;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public void setPartitionGroups(PartitionGroup[] groups) {
+        this.partitionGroups = groups;
+        if(allPartitions == null) {
+            allPartitions = new ArrayList<Partition>();
+        }
+        for (PartitionGroup partitionGroup : groups) {
+            Partition[] partitions = partitionGroup.getPartitions();
+            if(partitions != null) {
+                allPartitions.addAll(Arrays.asList(partitions));
+            }
+        }
+    }
+    
+    public List<Partition> getAllPartitions() {
+        return allPartitions;
+    }
+
+    /**
+     * Gets the value of the partition-groups.
+     */
+    public PartitionGroup[] getPartitionGroups() {
+        
+        return this.partitionGroups;
+    }
+    
+    public String toString() {
+        return "Deployment Policy: "+this.id;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPartitionException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPartitionException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPartitionException.java
new file mode 100644
index 0000000..2e7013b
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPartitionException.java
@@ -0,0 +1,22 @@
+package org.apache.stratos.autoscaler.exception;
+
+/**
+ *
+ */
+public class InvalidPartitionException extends Exception {
+
+    private static final long serialVersionUID = -7521673271244696906L;
+
+    public InvalidPartitionException(String message, Exception exception){
+        super(message, exception);
+    }
+
+
+    public InvalidPartitionException(Exception exception){
+        super(exception);
+    }
+    
+    public InvalidPartitionException(String msg){
+        super(msg);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPolicyException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPolicyException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPolicyException.java
new file mode 100644
index 0000000..a131f05
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidPolicyException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one 
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+ * KIND, either express or implied.  See the License for the 
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.exception;
+
+public class InvalidPolicyException extends Exception {
+
+	private static final long serialVersionUID = -4914522749282514366L;
+	
+	public InvalidPolicyException(String message) {
+		super(message);
+	}
+	
+	public InvalidPolicyException(String message,Throwable e) {
+		super(message,e);
+	}
+	
+	public InvalidPolicyException(Throwable e) {
+		super(e);
+	}
+	
+	
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/PolicyValidationException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/PolicyValidationException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/PolicyValidationException.java
index 0d899af..f3a30c8 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/PolicyValidationException.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/PolicyValidationException.java
@@ -16,4 +16,8 @@ public class PolicyValidationException extends Exception {
     public PolicyValidationException(Exception exception){
         super(exception);
     }
+    
+    public PolicyValidationException(String msg){
+        super(msg);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java
new file mode 100644
index 0000000..893f3aa
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.partition;
+
+import java.io.Serializable;
+
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+
+/**
+ * The model class for PartitionGroup definition.
+ */
+public class PartitionGroup implements Serializable{
+
+    private static final long serialVersionUID = -8043298009352097370L;
+    private String id;
+    private String partitionAlgo;
+    private Partition[] partitions;
+
+    /**
+     * Gets the value of the partitionAlgo property.
+     *
+     * @return
+     *     possible object is
+     *     {@link String }
+     *
+     */
+    public String getPartitionAlgo() {
+        return partitionAlgo;
+    }
+
+    /**
+     * Sets the value of the partitionAlgo property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *
+     */
+    public void setPartitionAlgo(String value) {
+        this.partitionAlgo = value;
+    }
+    
+    public void setPartitions(Partition[] partitions) {
+        this.partitions = partitions;
+    }
+
+    /**
+     * Gets the value of the partitions.
+     */
+    public Partition[] getPartitions() {
+        if (partitions == null) {
+            partitions = new Partition[0];
+        }
+        return this.partitions;
+    }
+
+    /**
+     * Gets the value of the id.
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * sets the value of the id.
+     */
+    public void setId(String id) {
+        this.id = id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java
index 9149a45..eb869aa 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java
@@ -73,7 +73,7 @@ public class PartitionDeployer extends AbstractDeployer {
 	public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
 
 		File partitionFile = deploymentFileData.getFile();
-		log.debug("Started to deploy the policy: " + partitionFile);
+		log.debug("Started to deploy the partitions of file: " + partitionFile);
 
 		try {
 			
@@ -82,25 +82,29 @@ public class PartitionDeployer extends AbstractDeployer {
 			List<Partition> partitionList = reader.getPartitionList();
 			Iterator<Partition> it = partitionList.iterator();
 			
-			while(it.hasNext()){
-				Partition partition = it.next();
-				if(PartitionManager.getInstance().partitionExist(partition.getId())){
-					log.warn("Partition already exists in the system " + partition.getId());
-					continue;
-				}
-				
-				boolean isValid = CloudControllerClient.getInstance().validatePartition(partition);
-				if(!isValid){
-					log.error("Partition is not valid " + partition.getId());
-					continue;					
-				}
-				PartitionManager.getInstance().addPartition(partition.getId(), partition);
-			}			
+            while (it.hasNext()) {
+                Partition partition = it.next();
+                try {
+                    if (PartitionManager.getInstance().partitionExist(partition.getId())) {
+                        log.warn("Partition already exists in the system " + partition.getId());
+                        continue;
+                    }
+
+                    CloudControllerClient.getInstance().validatePartition(partition);
+                    PartitionManager.getInstance().addPartition(partition.getId(), partition);
+                    log.info("Partition :" + partition.getId() + " is deployed successfully.");
+                } catch (Exception e) {
+                    String msg =
+                                 "Invalid partition: " + partition.getId() + " in file: " +
+                                         partitionFile.getAbsolutePath()+". Cause: "+e.getMessage();
+                    log.error(msg, e);
+                    continue;
+                }
+            }			
 
-			log.info("Successfully deployed the partition specified at "+ deploymentFileData.getAbsolutePath());
 			 
 		} catch (Exception e) {
-			String msg = "Invalid partition artifact at " + deploymentFileData.getAbsolutePath();
+			String msg = "Invalid partition definition file: " + deploymentFileData.getAbsolutePath();
 			// back up the file
 			File fileToBeRenamed = partitionFile;
 			fileToBeRenamed.renameTo(new File(deploymentFileData.getAbsolutePath() + ".back"));

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java
index ec6e3fd..085f39f 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java
@@ -23,6 +23,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMElement;
@@ -33,8 +34,8 @@ 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.pojo.Properties;
-import org.apache.stratos.cloud.controller.pojo.Property;
 import org.apache.stratos.autoscaler.util.AutoScalerConstants;
+import org.apache.stratos.autoscaler.util.AutoscalerUtil;
 import org.jaxen.JaxenException;
 
 /**
@@ -53,47 +54,53 @@ public class PartitionReader{
 	
 	public List<Partition> getPartitionList(){
 			this.parse(this.partitionFIle);
-			String partitionXpath = AutoScalerConstants.PARTITIONS_ELEMENT + "/"+AutoScalerConstants.PARTITION_ELEMENT;
+			String partitionXpath = "/"+AutoScalerConstants.PARTITIONS_ELEMENT + "/"+AutoScalerConstants.PARTITION_ELEMENT;
 			List<OMNode> partitionXMLNodes = getMatchingNodes(partitionXpath);
 			Iterator<OMNode> itr = partitionXMLNodes.iterator();
 			List<Partition> partitonList = new ArrayList<Partition>();
-			while(itr.hasNext()){
-				 OMNode node  = itr.next();
-				 //System.out.println("node " + node);
-				 partitonList.add(this.getPartition(node));
-			 }
+        while (itr.hasNext()) {
+            OMNode node = itr.next();
+            Partition partition = this.getPartition(node);
+            if (partition != null) {
+                partitonList.add(partition);
+            }
+        }
 		return partitonList;
 	}
 	
 	private  Partition getPartition(final OMNode item) {
         Partition partition = null;
-        String id = null;
 
         if (item.getType() == OMNode.ELEMENT_NODE) {
 
-            OMElement iaasElt = (OMElement) item;
-            Iterator<?> it =
-                    iaasElt.getChildrenWithName(new QName(AutoScalerConstants.ID_ELEMENT));
-
-            if (it.hasNext()) {
-                OMElement providerElt = (OMElement) it.next();
-                id = providerElt.getText();
-            }
-
-            if (it.hasNext()) {
-                log.warn( " contains more than one " + AutoScalerConstants.ID_ELEMENT +
-                        " elements!" + " Elements other than the first will be neglected.");
-            }
-
-            if (id == null) {
+            OMElement partitionElt = (OMElement) item;
+            String partitionId = partitionElt.getAttributeValue(new QName("id"));
+            
+            if (partitionId == null) {
                 String msg ="Essential " + AutoScalerConstants.ID_ELEMENT + "element " +
-                                "has not specified in ";
-                // handleException(msg);
+                                "has not specified.";
+                log.warn("Partition is ignored. "+msg);
+                return null;
             }         
             	
             partition = new Partition();               
-            partition.setId(id);
-            partition.setProperties(getProperties(iaasElt)); 
+            partition.setId(partitionId);
+            Properties properties = AutoscalerUtil.getProperties(partitionElt);
+            if (properties != null) {
+                partition.setProperties(properties);
+            }
+            String providerValue = readValue(partitionElt, "provider");
+            if (providerValue != null) {
+                partition.setProvider(providerValue);
+            }
+            String maxValue = readValue(partitionElt, "max");
+            if (maxValue != null) {
+                partition.setPartitionMax(Integer.valueOf(maxValue));
+            }
+            String minValue = readValue(partitionElt, "min");
+            if (minValue != null) {
+                partition.setPartitionMin(Integer.valueOf(minValue));
+            }
                                     
         }
         return partition;
@@ -134,37 +141,14 @@ public class PartitionReader{
         return nodeList;
     }
     
-    private Properties getProperties(final OMElement elt) {
-    	
-    	        Iterator<?> it = elt.getChildrenWithName(new QName(AutoScalerConstants.PROPERTY_ELEMENT));
-    	        ArrayList<Property> propertyList = new ArrayList<Property>();
-    	        
-    	        while (it.hasNext()) {
-    	            OMElement prop = (OMElement) it.next();
-    	
-    	            if (prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_NAME_ATTR)) == null ||
-    	                    prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_VALUE_ATTR)) == null) {
-    	
-    	                String msg =
-    	                        "Property element's, name and value attributes should be specified " +
-    	                                "in ";
-    	
-    	                //handleException(msg);
-    	            }
-    	            
-    	            String name = prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_NAME_ATTR)).getAttributeValue();
-    	            String value = prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_VALUE_ATTR)).getAttributeValue();
-    	            
-    	            Property property = new Property();
-    	            property.setName(name);
-    	            property.setValue(value);    	            
-    	            propertyList.add(property);
-    	        }
-
-    	        Property[] propertyArray = propertyList.toArray(new Property[propertyList.size()]);    	        
-    	        Properties preoperties = new Properties();
-    	        preoperties.setProperties(propertyArray);
-    	        return preoperties;
-    	    }
+   
 
+    protected String readValue(OMElement ele, String qName) {
+        OMElement valueContainer = ele.getFirstChildWithName(new QName(qName));
+        if(valueContainer == null) {
+            return null;
+        }
+        String value = valueContainer.getText();
+        return value;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/InvalidPolicyException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/InvalidPolicyException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/InvalidPolicyException.java
deleted file mode 100644
index 5df3b24..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/InvalidPolicyException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.autoscaler.policy;
-
-public class InvalidPolicyException extends Exception {
-
-	private static final long serialVersionUID = -4914522749282514366L;
-	
-	public InvalidPolicyException(String message) {
-		super(message);
-	}
-	
-	public InvalidPolicyException(String message,Throwable e) {
-		super(message,e);
-	}
-	
-	public InvalidPolicyException(Throwable e) {
-		super(e);
-	}
-	
-	
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
index 27000f1..f2ab9ae 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
@@ -28,8 +28,9 @@ import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
 
 /**
  * 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java
index 06d6c62..52efa90 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java
@@ -31,7 +31,7 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.policy.InvalidPolicyException;
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
 
 /**
  * Abstract super-class, with some common logic, for reading policies. The only
@@ -83,6 +83,9 @@ public abstract class AbstractPolicyReader<T> {
 
 	protected String readValue(OMElement ele, String qName) {
 		OMElement valueContainer = ele.getFirstChildWithName(new QName(qName));
+		if(valueContainer == null) {
+            return null;
+        }
 		String value = valueContainer.getText();
 		return value;
 	}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyDeployer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyDeployer.java
index 7579f46..141e95b 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyDeployer.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyDeployer.java
@@ -27,7 +27,7 @@ import org.apache.axis2.deployment.DeploymentException;
 import org.apache.axis2.deployment.repository.util.DeploymentFileData;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.policy.InvalidPolicyException;
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyReader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyReader.java
index 8d71a5d..c0c79a9 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyReader.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AutoscalerPolicyReader.java
@@ -27,7 +27,7 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axis2.deployment.DeploymentException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.policy.InvalidPolicyException;
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.policy.model.LoadAverage;
 import org.apache.stratos.autoscaler.policy.model.LoadThresholds;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java
index 5c126e7..d56c4c0 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java
@@ -27,9 +27,9 @@ import org.apache.axis2.deployment.DeploymentException;
 import org.apache.axis2.deployment.repository.util.DeploymentFileData;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.policy.InvalidPolicyException;
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
 
 /**
  * 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java
index 59689aa..7587f33 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java
@@ -30,11 +30,12 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axis2.deployment.DeploymentException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.partition.PartitionManager;
-import org.apache.stratos.autoscaler.policy.InvalidPolicyException;
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
+import org.apache.stratos.autoscaler.partition.PartitionGroup;
+import org.apache.stratos.autoscaler.util.AutoscalerUtil;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.cloud.controller.pojo.Properties;
 /**
  * 
  * The Reader class for Deployment-policy definitions.
@@ -72,21 +73,33 @@ public class DeploymentPolicyReader  extends AbstractPolicyReader<DeploymentPoli
 						while(partitionItr.hasNext()){
 							Object next = partitionItr.next();
 							if(next instanceof OMElement){
-								OMElement partitionEle = (OMElement) next;
+								OMElement partitionElt = (OMElement) next;
 								
-								String partitionId = partitionEle.getAttributeValue(new QName("id"));
-								/*
-								Partition partition = PartitionManager.getInstance().getPartitionById(partitionId);
-								 If a partition with this name does not exist in the partition list.
-								if(partition == null)
-									log.info("No Partition found with matching ID " + partitionId);
-								*/
-								Partition partition = new Partition();
-								partition.setId(partitionId);
-								partition.setPartitionMax(Integer.valueOf(readValue(partitionEle, "max")));
-								partition.setPartitionMin(Integer.valueOf(readValue(partitionEle, "min")));
-//								partition.setProvider(readValue(partitionEle, "provider"));
-								partitions.add(partition);
+								String partitionId = partitionElt.getAttributeValue(new QName("id"));
+                                if (partitionId != null) {
+                                    Partition partition = new Partition();
+                                    partition.setId(partitionId);
+                                    String maxValue = readValue(partitionElt, "max");
+                                    if (maxValue != null) {
+                                        partition.setPartitionMax(Integer.valueOf(maxValue));
+                                    }
+                                    String minValue = readValue(partitionElt, "min");
+                                    if (minValue != null) {
+                                        partition.setPartitionMin(Integer.valueOf(minValue));
+                                    }
+                                    String providerValue = readValue(partitionElt, "provider");
+                                    if (providerValue != null) {
+                                        partition.setProvider(providerValue);
+                                    }
+                                    
+                                    Properties properties = AutoscalerUtil.getProperties(partitionElt);
+                                    if (properties != null) {
+                                        partition.setProperties(properties);
+                                    }
+                                    partitions.add(partition);
+                                } else {
+                                    log.warn("Invalid Partition id: null. Partition will be ignored.");
+                                }
 							}
 						}
 						if(group.getPartitions() == null) {
@@ -98,7 +111,7 @@ public class DeploymentPolicyReader  extends AbstractPolicyReader<DeploymentPoli
 					if(policy.getPartitionGroups() == null) {
                         policy.setPartitionGroups(new PartitionGroup[0]);
                     }
-					policy.setPartitionGroup(partitionGroups.toArray(policy.getPartitionGroups()));
+					policy.setPartitionGroups(partitionGroups.toArray(policy.getPartitionGroups()));
 				}
 			} else{
 				throw new DeploymentException("File is not a valid deployment policy");

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
index af2841e..7136eb7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
@@ -1,76 +1,118 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
  * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 
 package org.apache.stratos.autoscaler.util;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.ClusterContext;
 import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.InvalidPartitionException;
 import org.apache.stratos.autoscaler.exception.PolicyValidationException;
+import org.apache.stratos.autoscaler.partition.PartitionManager;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.policy.model.LoadThresholds;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+import org.apache.stratos.cloud.controller.pojo.Properties;
+import org.apache.stratos.cloud.controller.pojo.Property;
 import org.apache.stratos.messaging.domain.topology.Cluster;
 
-
 /**
  * This class contains utility methods used by Autoscaler.
  */
 public class AutoscalerUtil {
-    
+
     private static final Log log = LogFactory.getLog(AutoscalerUtil.class);
 
-	private AutoscalerUtil() {
-
-	}
-	
-	/**
-	 * Updates ClusterContext for given cluster
-	 * @param cluster
-	 * @return ClusterContext - Updated ClusterContext
-	 * @throws PolicyValidationException 
-	 */
-    public static ClusterContext getClusterContext(Cluster cluster) throws PolicyValidationException {
+    private AutoscalerUtil() {
+
+    }
+
+    /**
+     * Updates ClusterContext for given cluster
+     * 
+     * @param cluster
+     * @return ClusterContext - Updated ClusterContext
+     * @throws PolicyValidationException
+     */
+    public static ClusterContext
+        getClusterContext(Cluster cluster) throws PolicyValidationException {
         // FIXME fix the following code to correctly update
         // AutoscalerContext context = AutoscalerContext.getInstance();
         if (null == cluster) {
             return null;
         }
 
-        log.info("Deployment policy name: "+cluster.getDeploymentPolicyName());
-        log.info("Autoscaler policy name: "+cluster.getAutoscalePolicyName());
-        
+        String autoscalePolicyName = cluster.getAutoscalePolicyName();
+        String deploymentPolicyName = cluster.getDeploymentPolicyName();
+
+        if (log.isDebugEnabled()) {
+            log.debug("Deployment policy name: " + deploymentPolicyName);
+            log.debug("Autoscaler policy name: " + autoscalePolicyName);
+        }
+
         AutoscalePolicy policy =
                                  PolicyManager.getInstance()
-                                              .getAutoscalePolicy(cluster.getAutoscalePolicyName());
+                                              .getAutoscalePolicy(autoscalePolicyName);
         DeploymentPolicy deploymentPolicy =
                                             PolicyManager.getInstance()
-                                                         .getDeploymentPolicy(cluster.getDeploymentPolicyName());
+                                                         .getDeploymentPolicy(deploymentPolicyName);
+
+        if (deploymentPolicy == null) {
+            String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName;
+            log.error(msg);
+            throw new PolicyValidationException(msg);
+        }
+
+        List<Partition> allPartitions = deploymentPolicy.getAllPartitions();
+        if (allPartitions == null) {
+            String msg =
+                         "Deployment Policy's Partitions are null. Policy name: " +
+                                 deploymentPolicyName;
+            log.error(msg);
+            throw new PolicyValidationException(msg);
+        }
 
-        log.info("Autoscaler policy: "+policy+" Deployment Policy: "+deploymentPolicy);
-            CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy);
+        try {
+            validateExistenceOfPartions(allPartitions);
+        } catch (InvalidPartitionException e) {
+            String msg = "Deployment Policy is invalid. Policy name: " + deploymentPolicyName;
+            log.error(msg, e);
+            throw new PolicyValidationException(msg, e);
+        }
+
+        CloudControllerClient.getInstance()
+                             .validatePartitionsOfPolicy(cluster.getServiceName(),
+                                                         allPartitions.toArray(new Partition[0]));
         ClusterContext clusterContext =
                                         new ClusterContext(cluster.getClusterId(),
                                                            cluster.getServiceName(),
-                                                           deploymentPolicy);
+                                                           deploymentPolicy, allPartitions);
 
         if (policy != null) {
 
@@ -89,4 +131,76 @@ public class AutoscalerUtil {
         return clusterContext;
     }
 
+    private static void validateExistenceOfPartions(List<Partition> partitions) throws InvalidPartitionException {
+        PartitionManager partitionMgr = PartitionManager.getInstance();
+        for (Partition partition : partitions) {
+            String partitionId = partition.getId();
+            if (partitionId == null || !partitionMgr.partitionExist(partitionId)) {
+                String msg =
+                             "Non existing Partition defined. Partition id: " + partitionId + ". " +
+                                     "Please define the partition in the partition definition file.";
+                log.error(msg);
+                throw new InvalidPartitionException(msg);
+            }
+            fillPartition(partition, partitionMgr.getPartitionById(partitionId));
+        }
+    }
+
+    private static void fillPartition(Partition destPartition, Partition srcPartition) {
+
+        if (!destPartition.isProviderSpecified()) {
+            destPartition.setProvider(srcPartition.getProvider());
+        }
+        if (!destPartition.isPartitionMaxSpecified()) {
+            destPartition.setPartitionMax(srcPartition.getPartitionMax());
+        }
+        if (!destPartition.isPartitionMinSpecified()) {
+            destPartition.setPartitionMin(srcPartition.getPartitionMin());
+        }
+        if (!destPartition.isPropertiesSpecified()) {
+            destPartition.setProperties(srcPartition.getProperties());
+        }
+    }
+
+    public static Properties getProperties(final OMElement elt) {
+
+        Iterator<?> it = elt.getChildrenWithName(new QName(AutoScalerConstants.PROPERTY_ELEMENT));
+        ArrayList<Property> propertyList = new ArrayList<Property>();
+
+        while (it.hasNext()) {
+            OMElement prop = (OMElement) it.next();
+
+            if (prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_NAME_ATTR)) == null ||
+                prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_VALUE_ATTR)) == null) {
+
+                String msg =
+                             "Property element's, name and value attributes should be specified. "
+                                     + "Property: ";
+                log.warn(msg + prop.toString());
+
+            }
+
+            String name =
+                          prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_NAME_ATTR))
+                              .getAttributeValue();
+            String value =
+                           prop.getAttribute(new QName(AutoScalerConstants.PROPERTY_VALUE_ATTR))
+                               .getAttributeValue();
+
+            Property property = new Property();
+            property.setName(name);
+            property.setValue(value);
+            propertyList.add(property);
+        }
+        
+        if(propertyList.isEmpty()) {
+            return null;
+        }
+
+        Property[] propertyArray = propertyList.toArray(new Property[propertyList.size()]);
+        Properties properties = new Properties();
+        properties.setProperties(propertyArray);
+        return properties;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ConfUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ConfUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ConfUtil.java
index 200d6b3..ddc3cb5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ConfUtil.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ConfUtil.java
@@ -19,14 +19,21 @@
 
 package org.apache.stratos.autoscaler.util;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.Constants;
+import org.apache.stratos.cloud.controller.pojo.Properties;
+import org.apache.stratos.cloud.controller.pojo.Property;
 import org.wso2.carbon.utils.CarbonUtils;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
 
 /**
  * This class contains utility methods for read Autoscaler configuration file.
@@ -60,4 +67,5 @@ public class ConfUtil {
     public XMLConfiguration getConfiguration(){
         return config;
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java
index aa581e3..b7ef179 100644
--- a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java
+++ b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java
@@ -22,9 +22,8 @@ import static org.junit.Assert.*;
 
 import java.io.File;
 
-import org.apache.stratos.autoscaler.policy.InvalidPolicyException;
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
 import org.apache.stratos.autoscaler.policy.deployers.DeploymentPolicyReader;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/50955e74/components/org.apache.stratos.autoscaler/src/test/resources/deployment-policy.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/deployment-policy.xml b/components/org.apache.stratos.autoscaler/src/test/resources/deployment-policy.xml
index 81e7865..e4ca79e 100644
--- a/components/org.apache.stratos.autoscaler/src/test/resources/deployment-policy.xml
+++ b/components/org.apache.stratos.autoscaler/src/test/resources/deployment-policy.xml
@@ -4,7 +4,7 @@
                         <partitionAlgo>one-after-another</partitionAlgo>
                         <partition id="P1" >
                                 <provider>ec2</provider>
-                                <property name="region">ap-southeast-1</property>
+                                <property name="region" value="ap-southeast-1"/>
                                 <max>3</max>
                                 <min>1</min>
                         </partition>


[04/12] git commit: cleaning up CC, find bug amendments, removing deprecated classes

Posted by ni...@apache.org.
cleaning up CC, find bug amendments, removing deprecated classes


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

Branch: refs/heads/master
Commit: c883ee2a83925ec132cca31402086f290c4f1afc
Parents: 12dbd29
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 20:25:16 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 20:25:16 2013 +0530

----------------------------------------------------------------------
 .../controller/axiom/AxiomXpathParser.java      | 1776 ------------------
 .../controller/axiom/AxiomXpathParserUtil.java  |    1 -
 .../parser/CloudControllerConfigParser.java     |   10 -
 .../axiom/parser/ServiceConfigParser.java       |  563 ------
 .../controller/deployers/CartridgeDeployer.java |   33 +-
 .../deployers/CloudControllerDeployer.java      |    1 -
 .../controller/deployers/ServiceDeployer.java   |  152 --
 .../deployment/partition/PartitionGroup.java    |    2 -
 .../cloud/controller/iaases/AWSEC2Iaas.java     |    7 +-
 .../controller/iaases/OpenstackNovaIaas.java    |   11 +-
 .../impl/CloudControllerServiceImpl.java        |  499 ++---
 .../cloud/controller/persist/Deserializer.java  |   32 +-
 .../cloud/controller/persist/Serializer.java    |   36 +-
 .../cloud/controller/pojo/ClusterContext.java   |    5 +-
 .../controller/pojo/DataPublisherConfig.java    |    5 +-
 .../stratos/cloud/controller/pojo/Host.java     |   73 -
 .../cloud/controller/pojo/IaasContext.java      |  162 --
 .../cloud/controller/pojo/IaasProvider.java     |   21 -
 .../cloud/controller/pojo/LocationScope.java    |   70 -
 .../cloud/controller/pojo/MemberContext.java    |    5 +-
 .../cloud/controller/pojo/Properties.java       |    5 +-
 .../stratos/cloud/controller/pojo/Property.java |    5 +-
 .../stratos/cloud/controller/pojo/Region.java   |  125 --
 .../cloud/controller/pojo/ServiceContext.java   |  366 ----
 .../stratos/cloud/controller/pojo/Zone.java     |   90 -
 .../CartridgeInstanceDataPublisherTask.java     |  336 ++--
 .../controller/registry/RegistryManager.java    |   15 +-
 .../runtime/FasterLookUpDataHolder.java         |  254 ++-
 .../controller/topology/TopologyBuilder.java    |   27 +-
 .../topology/TopologyEventSender.java           |    1 -
 .../controller/topology/TopologyManager.java    |    9 +-
 .../service/axiom/AxiomValidationTest.java      |    2 -
 .../service/util/ServiceContextTest.java        |   47 -
 33 files changed, 555 insertions(+), 4191 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java
deleted file mode 100644
index 0c08332..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java
+++ /dev/null
@@ -1,1776 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.axiom;
-
-import com.google.gson.Gson;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
-import org.apache.axiom.om.impl.dom.ElementImpl;
-import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.exception.CloudControllerException;
-import org.apache.stratos.cloud.controller.exception.MalformedConfigurationFileException;
-import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
-import org.apache.stratos.cloud.controller.topology.TopologyManager;
-import org.apache.stratos.cloud.controller.util.*;
-import org.apache.stratos.messaging.domain.topology.Scope;
-import org.jaxen.JaxenException;
-import org.w3c.dom.Element;
-import org.wso2.securevault.SecretResolver;
-import org.wso2.securevault.SecretResolverFactory;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-import java.io.File;
-import java.util.*;
-
-/**
- * This class is parsing configuration files using Axiom Xpath.
- */
-public class AxiomXpathParser {
-
-//    private static final Log log = LogFactory.getLog(AxiomXpathParser.class);
-//    private OMElement documentElement;
-//    private final File xmlSource;
-//
-//    public AxiomXpathParser(final File xmlFile) {
-//        xmlSource = xmlFile;
-//    }
-//
-//    /**
-//     * @param cartridgeElementString Cartridges section as a {@link String}
-//     * @param aCartridge             {@link org.apache.stratos.cloud.controller.util.Cartridge} instance.
-//     * @param appTypesNodes          nodes of App types.
-//     */
-//    private void getAppTypes(String cartridgeElementString, Cartridge aCartridge,
-//                             List<?> appTypesNodes) {
-//        Object nodeObj;
-//        if (!appTypesNodes.isEmpty()) {
-//            if ((nodeObj = appTypesNodes.get(0)) instanceof OMNode) {
-//                OMNode appTypeNode = (OMNode) nodeObj;
-//
-//                if (appTypeNode.getType() == OMNode.ELEMENT_NODE) {
-//
-//                    OMElement appTypesElt = (OMElement) appTypeNode;
-//
-//                    for (Iterator<?> iterator =
-//                                 appTypesElt.getChildrenWithName(new QName(
-//                                         CloudControllerConstants.APP_TYPE_ELEMENT)); iterator.hasNext();) {
-//                        OMElement appElt = (OMElement) iterator.next();
-//
-//                        String name =
-//                                appElt.getAttributeValue(new QName(
-//                                        CloudControllerConstants.NAME_ATTR));
-//                        String appSpecificMapping =
-//                                appElt.getAttributeValue(new QName(
-//                                        CloudControllerConstants.APP_SPECIFIC_MAPPING_ATTR));
-//
-//                        AppType appType;
-//
-//                        if (appSpecificMapping == null) {
-//                            appType = new AppType(name);
-//                        } else {
-//                            appType =
-//                                    new AppType(name,
-//                                            Boolean.valueOf(appSpecificMapping));
-//                        }
-//
-//                        aCartridge.addAppType(appType);
-//                    }
-//
-//                } else {
-//                    String msg =
-//                            "Essential '" + CloudControllerConstants.APP_TYPE_ELEMENT +
-//                                    "' element cannot" + " be found in " +
-//                                    cartridgeElementString + " of " +
-//                                    xmlSource;
-//                    handleException(msg);
-//                }
-//
-//            }
-//        }
-//    }
-//
-//    /**
-//     * @return a List of {@link Cartridge}s.
-//     */
-//    public List<Cartridge> getCartridgesList() {
-//
-//        FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
-//
-//        List<IaasProvider> iaasProviders = dataHolder.getIaasProviders();
-//
-//        if (iaasProviders == null) {
-//            dataHolder.setIaasProviders((iaasProviders = new ArrayList<IaasProvider>()));
-//        }
-//
-//        List<Cartridge> cartridges = new ArrayList<Cartridge>();
-//
-//        String xpath = CloudControllerConstants.CARTRIDGES_ELEMENT_XPATH;
-//
-//        // cartridges can be found from this XPATH
-//        List<?> cartridgeNodes = getMatchingNodes(xpath, documentElement);
-//
-//        if (cartridgeNodes == null || cartridgeNodes.isEmpty()) {
-//            // or from this XPATH
-//            xpath = CloudControllerConstants.CARTRIDGE_ELEMENT_XPATH;
-//            cartridgeNodes = getMatchingNodes(xpath, documentElement);
-//        }
-//
-//        if (cartridgeNodes == null || cartridgeNodes.isEmpty()) {
-//            log.warn("No cartridge found in this configuration file : " + xmlSource.getPath());
-//            return cartridges;
-//        }
-//
-//        for (Object obj : cartridgeNodes) {
-//
-//            if (obj instanceof OMNode) {
-//                OMNode cartridgeNode = (OMNode) obj;
-//
-//                if (cartridgeNode.getType() == OMNode.ELEMENT_NODE) {
-//
-//                    OMElement cartridgeElement = (OMElement) cartridgeNode;
-//
-//                    // retrieve Attributes of a Cartridge definition
-//                    String type = cartridgeElement.getAttributeValue(new QName(
-//                            CloudControllerConstants.TYPE_ATTR));
-//                    String host = cartridgeElement.getAttributeValue(new QName(
-//                            CloudControllerConstants.HOST_ATTR));
-//                    String provider = cartridgeElement.getAttributeValue(new QName(
-//                            CloudControllerConstants.PROVIDER_ATTR));
-//
-//                    String version =
-//                            cartridgeElement.getAttributeValue(new QName(
-//                                    CloudControllerConstants.VERSION_ATTR));
-//
-//                    boolean multiTenant = Boolean.valueOf(cartridgeElement.getAttributeValue(new QName(
-//                            CloudControllerConstants.MULTI_TENANT_ATTR)));
-//
-//                    Cartridge aCartridge;
-//
-//                    if ((aCartridge = dataHolder.getCartridge(type)) == null) {
-//
-//                        aCartridge = new Cartridge(type, host, provider, version, multiTenant);
-//                    }
-//
-//                    // read displayName
-//                    Iterator<?> itName =
-//                            cartridgeElement.getChildrenWithName(new QName(
-//                                    CloudControllerConstants.DISPLAY_NAME_ELEMENT));
-//
-//                    if (itName.hasNext()) {
-//                        OMElement name = (OMElement) itName.next();
-//
-//                        aCartridge.setDisplayName(name.getText());
-//                    }
-//
-//                    // read description
-//                    Iterator<?> it =
-//                            cartridgeElement.getChildrenWithName(new QName(
-//                                    CloudControllerConstants.DESCRIPTION_ELEMENT));
-//
-//                    if (it.hasNext()) {
-//                        OMElement desc = (OMElement) it.next();
-//
-//                        aCartridge.setDescription(desc.getText());
-//                    }
-//
-//                    // load properties of this cartridge
-//                    loadProperties(cartridgeElement, aCartridge.getProperties());
-//
-//                    // retrieve the list of IaaS providers
-//                    List<?> iaasProviderNodes = getMatchingNodes(xpath + CloudControllerConstants.IAAS_PROVIDER_ELEMENT_XPATH,
-//                            cartridgeElement);
-//
-//                    getIaasProviders(iaasProviders, cartridgeElement.toString(), aCartridge, iaasProviderNodes);
-//
-//                    // load dirs
-//                    List<?> deploymentNodes = getMatchingNodes(xpath + CloudControllerConstants.DEPLOYMENT_ELEMENT_XPATH,
-//                            cartridgeElement);
-//                    setDeploymentDirs(cartridgeElement.toString(), aCartridge, deploymentNodes);
-//
-//                    // load port mappings
-//                    List<?> portMappingNodes =
-//                            getMatchingNodes(xpath +
-//                                    CloudControllerConstants.PORT_MAPPING_ELEMENT_XPATH,
-//                                    cartridgeElement);
-//                    getPortMappings(cartridgeElement.toString(), aCartridge, portMappingNodes);
-//
-//                    // load appTypes
-//                    List<?> appTypesNodes =
-//                            getMatchingNodes(xpath +
-//                                    CloudControllerConstants.APP_TYPES_ELEMENT_XPATH,
-//                                    cartridgeElement);
-//                    getAppTypes(cartridgeElement.toString(), aCartridge, appTypesNodes);
-//
-//                    cartridges.add(aCartridge);
-//
-//                    if (dataHolder.getCartridge(type) == null) {
-//                        dataHolder.addCartridge(aCartridge);
-//                    }
-//                }
-//            }
-//        }
-//
-//        return cartridges;
-//
-//    }
-//
-//    /**
-//     * @param iaasProviders
-//     * @param cartridgeElementString
-//     * @param aCartridge
-//     * @param iaasProviderNodes
-//     */
-//    private void getIaasProviders(List<IaasProvider> iaasProviders,
-//                                  String cartridgeElementString, Cartridge aCartridge,
-//                                  List<?> iaasProviderNodes) {
-//        for (Object nodeObj : iaasProviderNodes) {
-//            if (nodeObj instanceof OMNode) {
-//                OMNode iaasProviderNode = (OMNode) nodeObj;
-//
-//                if (iaasProviderNode.getType() == OMNode.ELEMENT_NODE) {
-//
-//                    OMElement iaasElt = (OMElement) iaasProviderNode;
-//
-//                    // add the IaasProvider to this cartridge
-//                    aCartridge.addIaasProvider(getIaasProvider(iaasElt, iaasProviders));
-//
-//                } else {
-//                    String msg =
-//                            "Essential '" +
-//                                    CloudControllerConstants.IAAS_PROVIDER_ELEMENT +
-//                                    "' element cannot" + " be found in " +
-//                                    cartridgeElementString + " of " +
-//                                    xmlSource;
-//                    handleException(msg);
-//                }
-//
-//            }
-//        }
-//    }
-//
-//    private Element getDOMElement(final OMElement omElement) {
-//
-//        // Get the StAX reader from the created element
-//        XMLStreamReader llomReader = omElement.getXMLStreamReader();
-//
-//        // Create the DOOM OMFactory
-//        OMFactory doomFactory = DOOMAbstractFactory.getOMFactory();
-//
-//        // Create the new builder
-//        StAXOMBuilder doomBuilder = new StAXOMBuilder(doomFactory, llomReader);
-//
-//        // Get the document element
-//        OMElement newElem = doomBuilder.getDocumentElement();
-//
-//        return newElem instanceof Element ? (Element) newElem : null;
-//    }
-//
-//    private OMElement getElement(final Object obj) {
-//        OMNode node;
-//        if ((obj instanceof OMNode) && (node = (OMNode) obj).getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement element = (OMElement) node;
-//
-//            return element;
-//
-//        }
-//
-//        return null;
-//    }
-//
-//    private OMElement getElement(final OMElement rootElt, final String eltStr, final String xpath) {
-//        List<?> nodes = getMatchingNodes(xpath, rootElt);
-//        neglectingWarn(eltStr, nodes.size());
-//        OMElement element = getElement(nodes.get(0));
-//        return element;
-//    }
-//
-//    private OMElement getFirstChildElement(final OMElement root, final String childName) {
-//        Iterator<?> it = root.getChildrenWithName(new QName(childName));
-//        if (it.hasNext()) {
-//            return (OMElement) it.next();
-//        }
-//
-//        return null;
-//    }
-//
-//    /**
-//     * @param xpath XPATH expression to be read.
-//     * @param elt   OMElement to be used for the search.
-//     * @return List matching OMNode list
-//     */
-//    @SuppressWarnings("unchecked")
-//    public OMNode getFirstMatchingNode(final String xpath, final OMElement elt) {
-//
-//        AXIOMXPath axiomXpath;
-//        List<OMNode> nodeList = null;
-//        try {
-//            axiomXpath = new AXIOMXPath(xpath);
-//            nodeList = axiomXpath.selectNodes(elt);
-//        } catch (JaxenException e) {
-//            String msg = "Error occurred while reading the Xpath (" + xpath + ")";
-//            log.error(msg, e);
-//            throw new CloudControllerException(msg, e);
-//        }
-//
-//        return nodeList != null ? nodeList.get(0) : null;
-//    }
-//
-//    private IaasProvider getIaasProvider(final OMNode item, List<IaasProvider> iaases) {
-//
-//        IaasProvider iaas = null;
-//
-//        if (item.getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement iaasElt = (OMElement) item;
-//
-//            if (iaases != null) {
-//                // check whether this is a reference to a predefined IaaS.
-//                for (IaasProvider iaasProvider : iaases) {
-//                    if (iaasProvider.getType()
-//                            .equals(iaasElt.getAttribute(new QName(
-//                                    CloudControllerConstants.TYPE_ATTR))
-//                                    .getAttributeValue())) {
-//                        iaas = new IaasProvider(iaasProvider);
-//                        break;
-//                    }
-//                }
-//            }
-//
-//            if (iaas == null) {
-//                iaas = new IaasProvider();
-//            }
-//
-//            if (iaas.getType() == null) {
-//                iaas.setType(iaasElt.getAttribute(new QName(CloudControllerConstants.TYPE_ATTR))
-//                        .getAttributeValue());
-//            }
-//
-//            if ("".equals(iaas.getType())) {
-//                String msg =
-//                        "'" + CloudControllerConstants.IAAS_PROVIDER_ELEMENT + "' element's '" +
-//                                CloudControllerConstants.TYPE_ATTR +
-//                                "' attribute should be specified!";
-//
-//                handleException(msg);
-//
-//            }
-//
-//            // this is not mandatory
-//            String name =
-//                    (iaasElt.getAttribute(new QName(CloudControllerConstants.NAME_ATTR)) == null)
-//                            ? iaas.getName()
-//                            : iaasElt.getAttributeValue(new QName(
-//                            CloudControllerConstants.NAME_ATTR));
-//
-//            iaas.setName(name);
-//
-//            String xpath = CloudControllerConstants.IAAS_PROVIDER_ELEMENT_XPATH;
-//
-//            // load other elements
-//            loadClassName(iaas, iaasElt);
-//            loadProvider(iaas, iaasElt);
-//            //load region
-//            loadRegion(iaas);
-////			loadMaxInstanceLimit(iaas, iaasElt);
-//            loadProperties(iaasElt, iaas.getProperties());
-//            loadTemplate(iaas, iaasElt);
-////			loadScalingOrders(iaas, iaasElt);
-//            loadIdentity(iaas, iaasElt);
-//            loadCredentials(iaas, iaasElt, xpath);
-//        }
-//
-//        return iaas;
-//    }
-//
-//    private Partition getPartition(final OMNode item) {
-//        Partition partition = null;
-//        Partition oldPartition = null;
-//        String id = null;
-//        String type = null;
-//
-//        if (item.getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement iaasElt = (OMElement) item;
-//            Iterator<?> it =
-//                    iaasElt.getChildrenWithName(new QName(CloudControllerConstants.ID_ELEMENT));
-//
-//            if (it.hasNext()) {
-//                OMElement providerElt = (OMElement) it.next();
-//                id = providerElt.getText();
-//            }
-//
-//            if (it.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.ID_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (id == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.ID_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//            oldPartition = TopologyManager.getInstance().getTopology().getPartition(id);
-//            Iterator<?> it1 =
-//                    iaasElt.getChildrenWithName(new QName(CloudControllerConstants.SCOPE_ELEMENT));
-//
-//            if (it1.hasNext()) {
-//                OMElement providerElt = (OMElement) it1.next();
-//                type = providerElt.getText();
-//            }
-//
-//            if (it1.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.SCOPE_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (type == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.SCOPE_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//
-//
-//            if (oldPartition != null) {
-//                //load region id
-//                if (oldPartition.getId().equals(id)) {
-//                    partition = oldPartition;
-//                }
-//            }
-//
-//            if (partition == null) {
-//                partition = new Partition();
-//                partition.setId(id);
-//                partition.setScope(Scope.valueOf(type));
-//                loadProperties(iaasElt, partition.getProperties());
-//                //handle partition created event
-//                TopologyBuilder.handlePartitionCreated(partition);
-//
-//            } else {
-//                Partition partition1 = new Partition();
-//                partition1.setId(id);
-//                partition1.setScope(Scope.valueOf(type));
-//                loadProperties(iaasElt, partition1.getProperties());
-//                Gson gson = new Gson();
-//                String partitionS = gson.toJson(partition);
-//                String partition1S = gson.toJson(partition1);
-//                if (!partitionS.endsWith(partition1S)) {
-//                    partition.setId(id);
-//                    partition.setScope(Scope.valueOf(type));
-//                    loadProperties(iaasElt, partition.getProperties());
-//                    //handle update partition event
-//                    TopologyBuilder.handlePartitionUpdated(partition, oldPartition);
-//
-//                }
-//
-//            }
-//
-//        }
-//        return partition;
-//    }
-//
-//    private Region getRegion(final OMNode item, List<Region> regions, IaasProvider provider) {
-//
-//        Region region = null;
-//        String type = null;
-//
-//        if (item.getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement regionElm = (OMElement) item;
-//
-//            OMElement iaasElt = (OMElement) regionElm.getParent();
-//            if (!iaasElt.getAttribute(new QName(CloudControllerConstants.TYPE_ATTR))
-//                    .getAttributeValue().equals(provider.getType())) {
-//                return region;
-//            }
-//
-//            Iterator<?> it =
-//                    regionElm.getChildrenWithName(new QName(CloudControllerConstants.TYPE_ELEMENT));
-//
-//            if (it.hasNext()) {
-//                OMElement providerElt = (OMElement) it.next();
-//                type = providerElt.getText();
-//            }
-//
-//            if (it.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.TYPE_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (type == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.TYPE_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//
-//            if (regions != null) {
-//                // check whether this is a reference to a predefined Region.
-//                for (Region region1 : regions) {
-//                    //load region id
-//
-//                    if (region1.getType().equals(type)) {
-//                        region = region1;
-//                        break;
-//                    }
-//                }
-//            }
-//            if (region == null) {
-//                region = new Region();
-//                region.setType(type);
-//            }
-//
-//            Iterator<?> it1 =
-//                    regionElm.getChildrenWithName(new QName(CloudControllerConstants.ID_ELEMENT));
-//
-//            if (it1.hasNext()) {
-//                OMElement providerElt = (OMElement) it1.next();
-//                region.setId(providerElt.getText());
-//            }
-//
-//            if (it1.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.TYPE_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (region.getId() == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.TYPE_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//
-//            if (provider.getCredential() != null) {
-//                log.warn("Provider credential will be overwritten by region credential");
-//            }
-//            loadCredentials(region, regionElm);
-//
-//            if (provider.getIdentity() != null) {
-//                log.warn("Provider identity will be overwritten by region credential");
-//            }
-//            loadIdentity(region, regionElm);
-//            loadProperties(regionElm, region.getProperties());
-//            //load zone
-//            loadZone(region);
-//
-//        }
-//        return region;
-//    }
-//
-//    private Zone getZone(final OMNode item, List<Zone> zones, Region region) {
-//
-//        Zone zone = null;
-//        String type = null;
-//        String typeRegion = null;
-//
-//        if (item.getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement zoneElm = (OMElement) item;
-//
-//            OMElement regionElt = (OMElement) zoneElm.getParent();
-//
-//            Iterator<?> it2 =
-//                    regionElt.getChildrenWithName(new QName(CloudControllerConstants.TYPE_ELEMENT));
-//
-//            if (it2.hasNext()) {
-//                OMElement providerElt = (OMElement) it2.next();
-//                typeRegion = providerElt.getText();
-//            }
-//            if (!region.getType().equals(typeRegion)) {
-//                return zone;
-//            }
-//            Iterator<?> it =
-//                    zoneElm.getChildrenWithName(new QName(CloudControllerConstants.TYPE_ELEMENT));
-//
-//            if (it.hasNext()) {
-//                OMElement providerElt = (OMElement) it.next();
-//                type = providerElt.getText();
-//            }
-//
-//            if (it.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.TYPE_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (type == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.TYPE_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//
-//            if (zones != null) {
-//                // check whether this is a reference to a predefined Region.
-//                for (Zone zone1 : zones) {
-//                    //load region id
-//
-//                    if (zone1.getType().equals(type)) {
-//                        zone = zone1;
-//                        break;
-//                    }
-//                }
-//            }
-//            if (zone == null) {
-//                zone = new Zone();
-//                zone.setType(type);
-//            }
-//
-//            Iterator<?> it1 =
-//                    zoneElm.getChildrenWithName(new QName(CloudControllerConstants.ID_ELEMENT));
-//
-//            if (it1.hasNext()) {
-//                OMElement providerElt = (OMElement) it1.next();
-//                zone.setId(providerElt.getText());
-//            }
-//
-//            if (it1.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.TYPE_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (region.getId() == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.TYPE_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//            loadProperties(zoneElm, zone.getProperties());
-//            //load Host
-//            loadHost(zone);
-//
-//        }
-//        return zone;
-//    }
-//
-//    private Host getHost(final OMNode item, List<Host> hosts, Zone zone) {
-//
-//        Host host = null;
-//        String type = null;
-//        String typeZone = null;
-//
-//        if (item.getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement hostElt = (OMElement) item;
-//
-//            OMElement zoneElt = (OMElement) hostElt.getParent();
-//
-//            Iterator<?> it2 =
-//                    zoneElt.getChildrenWithName(new QName(CloudControllerConstants.TYPE_ELEMENT));
-//
-//            if (it2.hasNext()) {
-//                OMElement providerElt = (OMElement) it2.next();
-//                typeZone = providerElt.getText();
-//            }
-//            if (!zone.getType().equals(typeZone)) {
-//                return host;
-//            }
-//            Iterator<?> it =
-//                    hostElt.getChildrenWithName(new QName(CloudControllerConstants.TYPE_ELEMENT));
-//
-//            if (it.hasNext()) {
-//                OMElement providerElt = (OMElement) it.next();
-//                type = providerElt.getText();
-//            }
-//
-//            if (it.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.TYPE_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (type == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.TYPE_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//
-//            if (hosts != null) {
-//                // check whether this is a reference to a predefined Region.
-//                for (Host host1 : hosts) {
-//                    //load region id
-//
-//                    if (host1.getType().equals(type)) {
-//                        host = host1;
-//                        break;
-//                    }
-//                }
-//            }
-//            if (host == null) {
-//                host = new Host();
-//                host.setType(type);
-//            }
-//
-//            Iterator<?> it1 =
-//                    hostElt.getChildrenWithName(new QName(CloudControllerConstants.ID_ELEMENT));
-//
-//            if (it1.hasNext()) {
-//                OMElement providerElt = (OMElement) it1.next();
-//                host.setId(providerElt.getText());
-//            }
-//
-//            if (it1.hasNext()) {
-//                log.warn(xmlSource + " contains more than one " + CloudControllerConstants.TYPE_ELEMENT +
-//                        " elements!" + " Elements other than the first will be neglected.");
-//            }
-//
-//            if (host.getId() == null) {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.TYPE_ELEMENT + "' element " +
-//                                "has not specified in " + xmlSource;
-//                handleException(msg);
-//            }
-//            loadProperties(hostElt, host.getProperties());
-//
-//        }
-//        return host;
-//    }
-//
-//    /**
-//     * @param xpath XPATH expression to be read.
-//     * @return List matching OMNode list
-//     */
-//    @SuppressWarnings("unchecked")
-//    public List<OMNode> getMatchingNodes(final String xpath) {
-//
-//        AXIOMXPath axiomXpath;
-//        List<OMNode> nodeList = null;
-//        try {
-//            axiomXpath = new AXIOMXPath(xpath);
-//            nodeList = axiomXpath.selectNodes(documentElement);
-//        } catch (JaxenException e) {
-//            String msg = "Error occurred while reading the Xpath (" + xpath + ")";
-//            log.error(msg, e);
-//            throw new CloudControllerException(msg, e);
-//        }
-//
-//        return nodeList;
-//    }
-//
-//
-//    /**
-//     * @param xpath XPATH expression to be read.
-//     * @param elt   OMElement to be used for the search.
-//     * @return List matching OMNode list
-//     */
-//    @SuppressWarnings("unchecked")
-//    public List<OMNode> getMatchingNodes(final String xpath, final OMElement elt) {
-//
-//        AXIOMXPath axiomXpath;
-//        List<OMNode> nodeList = null;
-//        try {
-//            axiomXpath = new AXIOMXPath(xpath);
-//            nodeList = axiomXpath.selectNodes(elt);
-//        } catch (JaxenException e) {
-//            String msg = "Error occurred while reading the Xpath (" + xpath + ")";
-//            log.error(msg, e);
-//            throw new CloudControllerException(msg, e);
-//        }
-//
-//        return nodeList;
-//    }
-//
-//    /**
-//     * @param cartridgeElementString Cartridges section as a {@link String}
-//     * @param aCartridge             {@link Cartridge} instance.
-//     * @param portMappingNodes       nodes of port mapping elements
-//     */
-//    private void getPortMappings(String cartridgeElementString, Cartridge aCartridge,
-//                                 List<?> portMappingNodes) {
-//        Object nodeObj;
-//        if (!portMappingNodes.isEmpty()) {
-//            if ((nodeObj = portMappingNodes.get(0)) instanceof OMNode) {
-//                OMNode portMappingNode = (OMNode) nodeObj;
-//
-//                if (portMappingNode.getType() == OMNode.ELEMENT_NODE) {
-//
-//                    OMElement portMappingElt = (OMElement) portMappingNode;
-//
-//                    for (Iterator<?> iterator =
-//                                 portMappingElt.getChildrenWithName(new QName(
-//                                         CloudControllerConstants.HTTP_ELEMENT)); iterator.hasNext();) {
-//                        OMElement httpElt = (OMElement) iterator.next();
-//
-//                        String port =
-//                                httpElt.getAttributeValue(new QName(
-//                                        CloudControllerConstants.PORT_ATTR));
-//                        String proxyPort =
-//                                httpElt.getAttributeValue(new QName(
-//                                        CloudControllerConstants.PROXY_PORT_ATTR));
-//
-//                        PortMapping mapping =
-//                                new PortMapping(
-//                                        CloudControllerConstants.HTTP_ELEMENT,
-//                                        port, proxyPort);
-//
-//                        aCartridge.addPortMapping(mapping);
-//                    }
-//
-//                    for (Iterator<?> iterator =
-//                                 portMappingElt.getChildrenWithName(new QName(
-//                                         CloudControllerConstants.HTTPS_ELEMENT)); iterator.hasNext();) {
-//                        OMElement httpsElt = (OMElement) iterator.next();
-//
-//                        String port =
-//                                httpsElt.getAttributeValue(new QName(
-//                                        CloudControllerConstants.PORT_ATTR));
-//                        String proxyPort =
-//                                httpsElt.getAttributeValue(new QName(
-//                                        CloudControllerConstants.PROXY_PORT_ATTR));
-//
-//                        PortMapping mapping =
-//                                new PortMapping(
-//                                        CloudControllerConstants.HTTPS_ELEMENT,
-//                                        port, proxyPort);
-//
-//                        aCartridge.addPortMapping(mapping);
-//                    }
-//
-//                } else {
-//                    String msg =
-//                            "Essential '" +
-//                                    CloudControllerConstants.PORT_MAPPING_ELEMENT +
-//                                    "' element cannot" + " be found in " +
-//                                    cartridgeElementString + " of " +
-//                                    xmlSource;
-//                    handleException(msg);
-//                }
-//
-//            }
-//        }
-//    }
-//
-//    public List<ServiceContext> getServiceContexts() {
-//
-//        List<ServiceContext> serviceContextList = new ArrayList<ServiceContext>();
-//
-//        // services can be found from this XPATH
-//        String xpath = CloudControllerConstants.SERVICES_ELEMENT_XPATH;
-//        List<?> serviceNodes = getMatchingNodes(xpath, documentElement);
-//
-//        if (serviceNodes == null || serviceNodes.isEmpty()) {
-//            // or from this XPATH
-//            xpath = CloudControllerConstants.SERVICE_ELEMENT_XPATH;
-//            serviceNodes = getMatchingNodes(xpath, documentElement);
-//        }
-//
-//        if (serviceNodes == null || serviceNodes.isEmpty()) {
-//            log.warn("No service found in this configuration file : " + xmlSource.getPath());
-//            return serviceContextList;
-//        }
-//
-//        for (Object obj : serviceNodes) {
-//            ServiceContext serviceCtxt = new ServiceContext();
-//
-//            // set the definition file
-//            serviceCtxt.setFile(xmlSource);
-//
-//            if (obj instanceof OMNode) {
-//                OMNode serviceNode = (OMNode) obj;
-//
-//                if (serviceNode.getType() == OMNode.ELEMENT_NODE) {
-//
-//                    OMElement node = (OMElement) serviceNode;
-//
-//                    if (node.getAttribute(new QName(CloudControllerConstants.SERVICE_DOMAIN_ATTR)) == null) {
-//                        String msg =
-//                                "Essential '" + CloudControllerConstants.SERVICE_DOMAIN_ATTR + "' " +
-//                                        "attribute of '" + CloudControllerConstants.SERVICE_ELEMENT +
-//                                        "' element cannot be found in " + xmlSource;
-//
-//                        handleException(msg);
-//                    }
-//
-//                    // set domain name
-//                    serviceCtxt.setClusterId(node.getAttribute(new QName(
-//                            CloudControllerConstants.SERVICE_DOMAIN_ATTR))
-//                            .getAttributeValue());
-//                    // set tenant range
-//                    serviceCtxt.setTenantRange(node.getAttribute(new QName(
-//                            CloudControllerConstants.SERVICE_TENANT_RANGE_ATTR))
-//                            .getAttributeValue());
-//
-//                    serviceCtxt.setAutoScalerPolicyName(node.getAttribute(new QName(
-//                            CloudControllerConstants.POLICY_NAME))
-//                            .getAttributeValue());
-//
-//                    OMNode cartridgeNode =
-//                            getFirstMatchingNode(xpath +
-//                                    CloudControllerConstants.CARTRIDGE_ELEMENT_XPATH,
-//                                    node);
-//
-//                    if (cartridgeNode != null && cartridgeNode.getType() == OMNode.ELEMENT_NODE) {
-//
-//                        OMElement cartridgeElt = (OMElement) cartridgeNode;
-//
-//                        String type =
-//                                cartridgeElt.getAttribute(new QName(CloudControllerConstants.TYPE_ATTR))
-//                                        .getAttributeValue();
-//
-//                        if ("".equals(type)) {
-//                            String msg =
-//                                    "Essential '" + CloudControllerConstants.TYPE_ATTR + "' " +
-//                                            " attribute of '" +
-//                                            CloudControllerConstants.CARTRIDGE_ELEMENT + "' of '" +
-//                                            CloudControllerConstants.SERVICE_ELEMENT +
-//                                            "' element cannot be found in " + xmlSource;
-//
-//                            handleException(msg);
-//                        }
-//
-//                        // set Cartridge type
-//                        serviceCtxt.setCartridgeType(type);
-//
-//                    }
-//                    if (serviceCtxt.getCartridgeType() == null) {
-//                        String msg =
-//                                "Essential '" + CloudControllerConstants.CARTRIDGE_ELEMENT +
-//                                        "' element" + " has not specified in " + xmlSource;
-//                        handleException(msg);
-//                    }
-//
-//                    // load payload
-//                    loadPayload(getMatchingNodes(xpath + CloudControllerConstants.PAYLOAD_ELEMENT_XPATH,
-//                            node), serviceCtxt);
-//
-//                    // load host name
-//                    loadHostName(getMatchingNodes(xpath + CloudControllerConstants.HOST_ELEMENT_XPATH,
-//                            node), serviceCtxt);
-//
-//                    // load properties
-//                    loadProperties(node, serviceCtxt.getProperties());
-//
-//                }
-//            }
-//
-//            FasterLookUpDataHolder.getInstance().addServiceContext(serviceCtxt);
-//            // add each domain specific template to list
-//            serviceContextList.add(serviceCtxt);
-//        }
-//
-//        return serviceContextList;
-//
-//    }
-//
-//    public File getXmlSource() {
-//        return xmlSource;
-//    }
-//
-//    private void handleException(final String msg) {
-//        log.error(msg);
-//        throw new MalformedConfigurationFileException(msg);
-//    }
-//
-//    private void handleException(final String msg, final Exception e) {
-//        log.error(msg, e);
-//        throw new MalformedConfigurationFileException(msg, e);
-//    }
-//
-//    private void loadClassName(final IaasProvider iaas, final OMElement iaasElt) {
-//
-//        Iterator<?> it =
-//                iaasElt.getChildrenWithName(new QName(
-//                        CloudControllerConstants.CLASS_NAME_ELEMENT));
-//
-//        if (it.hasNext()) {
-//            OMElement classNameElt = (OMElement) it.next();
-//            iaas.setClassName(classNameElt.getText());
-//        }
-//
-//        if (it.hasNext()) {
-//            log.warn(xmlSource + " contains more than one " +
-//                    CloudControllerConstants.CLASS_NAME_ELEMENT + " elements!" +
-//                    " Elements other than the first will be neglected.");
-//        }
-//
-//        if (iaas.getClassName() == null) {
-//            String msg =
-//                    "Essential '" + CloudControllerConstants.CLASS_NAME_ELEMENT + "' element " +
-//                            "has not specified in " + xmlSource;
-//            handleException(msg);
-//        }
-//
-//    }
-//
-//    private void loadCredentials(final IaasProvider iaas, final OMElement iaasElt,
-//                                 final String xpath) {
-//
-//        Iterator<?> it =
-//                iaasElt.getChildrenWithName(new QName(
-//                        CloudControllerConstants.CREDENTIAL_ELEMENT));
-//
-//        if (it.hasNext()) {
-//            OMElement credentialElt = (OMElement) it.next();
-//
-//            // retrieve the value using secure vault
-//            SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);
-//            String alias =
-//                    credentialElt.getAttributeValue(new QName(
-//                            CloudControllerConstants.ALIAS_ATTRIBUTE));
-//
-//            // retrieve the secured password
-//            if (secretResolver != null && secretResolver.isInitialized() &&
-//                    secretResolver.isTokenProtected(alias)) {
-//
-//                iaas.setCredential(secretResolver.resolve(alias));
-//
-//            }
-//
-//            // if we still cannot find a value, we try to assign the value which
-//            // is specified
-//            // in the element, if any
-//            if (iaas.getCredential() == null) {
-//                log.warn("Unable to find a value for " + CloudControllerConstants.CREDENTIAL_ELEMENT +
-//                        " element from Secure Vault." +
-//                        "Hence we will try to assign the plain text value (if specified).");
-//                iaas.setCredential(credentialElt.getText());
-//            }
-//        }
-//
-//        if (it.hasNext()) {
-//            log.warn(xmlSource + " contains more than one " +
-//                    CloudControllerConstants.CREDENTIAL_ELEMENT + " elements!" +
-//                    " Elements other than the first will be neglected.");
-//        }
-//
-//        if (iaas.getCredential() == null) {
-//            String msg =
-//                    "Essential '" + CloudControllerConstants.CREDENTIAL_ELEMENT + "' element" +
-//                            " has not specified in " + xmlSource;
-//            handleException(msg);
-//        }
-//
-//    }
-//
-//    private void loadCredentials(Region region, final OMElement iaasElt) {
-//
-//        Iterator<?> it =
-//                iaasElt.getChildrenWithName(new QName(
-//                        CloudControllerConstants.CREDENTIAL_ELEMENT));
-//
-//        if (it.hasNext()) {
-//            OMElement credentialElt = (OMElement) it.next();
-//
-//            // retrieve the value using secure vault
-//            SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);
-//            String alias =
-//                    credentialElt.getAttributeValue(new QName(
-//                            CloudControllerConstants.ALIAS_ATTRIBUTE));
-//
-//            // retrieve the secured password
-//            if (secretResolver != null && secretResolver.isInitialized() &&
-//                    secretResolver.isTokenProtected(alias)) {
-//
-//                region.setCredential(secretResolver.resolve(alias));
-//
-//            }
-//
-//            // if we still cannot find a value, we try to assign the value which
-//            // is specified
-//            // in the element, if any
-//            if (region.getCredential() == null) {
-//                log.warn("Unable to find a value for " + CloudControllerConstants.CREDENTIAL_ELEMENT +
-//                        " element from Secure Vault." +
-//                        "Hence we will try to assign the plain text value (if specified).");
-//                region.setCredential(credentialElt.getText());
-//            }
-//        }
-//
-//        if (it.hasNext()) {
-//            log.warn(xmlSource + " contains more than one " +
-//                    CloudControllerConstants.CREDENTIAL_ELEMENT + " elements!" +
-//                    " Elements other than the first will be neglected.");
-//        }
-//
-//        if (region.getCredential() == null) {
-//            String msg =
-//                    "Essential '" + CloudControllerConstants.CREDENTIAL_ELEMENT + "' element" +
-//                            " has not specified in " + xmlSource;
-//            handleException(msg);
-//        }
-//
-//    }
-//
-//    private void loadHostName(final List<OMNode> nodes, final ServiceContext serviceCtxt) {
-//
-//        if (nodes == null || nodes.isEmpty()) {
-//            return;
-//        }
-//
-//        // read host element
-//        if (nodes.get(0).getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement node = (OMElement) nodes.get(0);
-//
-//            if (node.getText() != null) {
-//                serviceCtxt.setHostName(node.getText());
-//            }
-//
-//        }
-//    }
-//
-//    private void loadIdentity(final IaasProvider iaas, final OMElement iaasElt) {
-//
-//        Iterator<?> it =
-//                iaasElt.getChildrenWithName(new QName(CloudControllerConstants.IDENTITY_ELEMENT));
-//
-//        if (it.hasNext()) {
-//            OMElement identityElt = (OMElement) it.next();
-//
-//            // retrieve the value using secure vault
-//            SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);
-//            String alias =
-//                    identityElt.getAttributeValue(new QName(
-//                            CloudControllerConstants.ALIAS_ATTRIBUTE));
-//
-//            // retrieve the secured password
-//            if (secretResolver != null && secretResolver.isInitialized() &&
-//                    secretResolver.isTokenProtected(alias)) {
-//
-//                iaas.setIdentity(secretResolver.resolve(alias));
-//
-//            }
-//
-//            // if we still cannot find a value, we try to assign the value which
-//            // is specified
-//            // in the element, if any
-//            if (iaas.getIdentity() == null) {
-//                log.warn("Unable to find a value for " + CloudControllerConstants.IDENTITY_ELEMENT +
-//                        " element from Secure Vault." +
-//                        "Hence we will try to assign the plain text value (if specified).");
-//                iaas.setIdentity(identityElt.getText());
-//            }
-//        }
-//
-//        if (it.hasNext()) {
-//            log.warn(xmlSource + " contains more than one " + CloudControllerConstants.IDENTITY_ELEMENT +
-//                    " elements!" + " Elements other than the first will be neglected.");
-//        }
-//
-//        if (iaas.getIdentity() == null) {
-//            String msg =
-//                    "Essential '" + CloudControllerConstants.IDENTITY_ELEMENT + "' element" +
-//                            " has not specified in " + xmlSource;
-//            handleException(msg);
-//        }
-//
-//    }
-//
-//    private void loadIdentity(final Region region, final OMElement iaasElt) {
-//
-//        Iterator<?> it =
-//                iaasElt.getChildrenWithName(new QName(CloudControllerConstants.IDENTITY_ELEMENT));
-//
-//        if (it.hasNext()) {
-//            OMElement identityElt = (OMElement) it.next();
-//
-//            // retrieve the value using secure vault
-//            SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);
-//            String alias =
-//                    identityElt.getAttributeValue(new QName(
-//                            CloudControllerConstants.ALIAS_ATTRIBUTE));
-//
-//            // retrieve the secured password
-//            if (secretResolver != null && secretResolver.isInitialized() &&
-//                    secretResolver.isTokenProtected(alias)) {
-//
-//                region.setIdentity(secretResolver.resolve(alias));
-//
-//            }
-//
-//            // if we still cannot find a value, we try to assign the value which
-//            // is specified
-//            // in the element, if any
-//            if (region.getIdentity() == null) {
-//                log.warn("Unable to find a value for " + CloudControllerConstants.IDENTITY_ELEMENT +
-//                        " element from Secure Vault." +
-//                        "Hence we will try to assign the plain text value (if specified).");
-//                region.setIdentity(identityElt.getText());
-//            }
-//        }
-//
-//        if (it.hasNext()) {
-//            log.warn(xmlSource + " contains more than one " + CloudControllerConstants.IDENTITY_ELEMENT +
-//                    " elements!" + " Elements other than the first will be neglected.");
-//        }
-//
-//        if (region.getIdentity() == null) {
-//            String msg =
-//                    "Essential '" + CloudControllerConstants.IDENTITY_ELEMENT + "' element" +
-//                            " has not specified in " + xmlSource;
-//            handleException(msg);
-//        }
-//
-//    }
-//
-//    /*private void loadMaxInstanceLimit(IaasProvider iaas, final OMElement iaasElt) {
-//
-//         Iterator<?> it =
-//                          iaasElt.getChildrenWithName(new QName(
-//                                                                CloudControllerConstants.MAX_INSTANCE_LIMIT_ELEMENT));
-//
-//         if (it.hasNext()) {
-//             OMElement maxInstanceLimitElt = (OMElement) it.next();
-//
-//             try {
-//                 iaas.setMaxInstanceLimit(Integer.parseInt(maxInstanceLimitElt.getText()));
-//             } catch (NumberFormatException e) {
-//                 String msg =
-//                              CloudControllerConstants.MAX_INSTANCE_LIMIT_ELEMENT +
-//                                      " element contained" + " in " + xmlSource + "" +
-//                                      " has a value which is not an Integer value.";
-//                 handleException(msg, e);
-//             }
-//
-//         }
-//
-//         if (it.hasNext()) {
-//             log.warn(xmlSource + " contains more than one " +
-//                      CloudControllerConstants.MAX_INSTANCE_LIMIT_ELEMENT + " elements!" +
-//                      " Elements other than the first will be neglected.");
-//         }
-//
-//     }*/
-//
-//    private void loadPayload(final List<OMNode> nodes, final ServiceContext serviceCtxt) {
-//
-//        if (nodes == null || nodes.isEmpty()) {
-//            return;
-//        }
-//
-//        // read payload element
-//        if (nodes.get(0).getType() == OMNode.ELEMENT_NODE) {
-//
-//            OMElement node = (OMElement) nodes.get(0);
-//
-//            if (node.getText() != null) {
-//                StringBuilder payload = new StringBuilder(node.getText());
-//                serviceCtxt.setPayload(payload);
-//
-//            }
-//
-//        }
-//
-//    }
-//
-//    private void loadProperties(final OMElement elt, final Map<String, String> propertyMap) {
-//
-//        Iterator<?> it =
-//                elt.getChildrenWithName(new QName(CloudControllerConstants.PROPERTY_ELEMENT));
-//
-//        while (it.hasNext()) {
-//            OMElement prop = (OMElement) it.next();
-//
-//            if (prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_NAME_ATTR)) == null ||
-//                    prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_VALUE_ATTR)) == null) {
-//
-//                String msg =
-//                        "Property element's, name and value attributes should be specified " +
-//                                "in " + xmlSource;
-//
-//                handleException(msg);
-//            }
-//
-//            propertyMap.put(prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_NAME_ATTR))
-//                    .getAttributeValue(),
-//                    prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_VALUE_ATTR))
-//                            .getAttributeValue());
-//        }
-//
-//    }
-//
-//    private void loadProvider(final IaasProvider iaas, final OMElement iaasElt) {
-//
-//        Iterator<?> it =
-//                iaasElt.getChildrenWithName(new QName(CloudControllerConstants.PROVIDER_ELEMENT));
-//
-//        if (it.hasNext()) {
-//            OMElement providerElt = (OMElement) it.next();
-//            iaas.setProvider(providerElt.getText());
-//        }
-//
-//        if (it.hasNext()) {
-//            log.warn(xmlSource + " contains more than one " + CloudControllerConstants.PROVIDER_ELEMENT +
-//                    " elements!" + " Elements other than the first will be neglected.");
-//        }
-//
-//        if (iaas.getProvider() == null) {
-//            String msg =
-//                    "Essential '" + CloudControllerConstants.PROVIDER_ELEMENT + "' element " +
-//                            "has not specified in " + xmlSource;
-//            handleException(msg);
-//        }
-//
-//    }
-//
-//    private void loadRegion(final IaasProvider iaas) {
-//        List<Region> regions = iaas.getListOfRegions();
-//
-//        if (regions == null) {
-//            iaas.setListOfRegions((regions = new ArrayList<Region>()));
-//        }
-//
-//        List<OMNode> nodeList = getMatchingNodes(CloudControllerConstants.REGION_XPATH);
-//
-//        // this is a valid scenario. User can have 0..1 iaas provider elements
-//        // in cloud-controller xml.
-//        if (nodeList == null || nodeList.isEmpty()) {
-//            return;
-//        }
-//
-//        for (OMNode node : nodeList) {
-//            regions.add(getRegion(node, regions, iaas));
-//        }
-//    }
-//
-//    private void loadZone(final Region region) {
-//        List<Zone> zones = region.getListOfZones();
-//
-//        if (zones == null) {
-//            region.setListOfZones((zones = new ArrayList<Zone>()));
-//        }
-//
-//        List<OMNode> nodeList = getMatchingNodes(CloudControllerConstants.ZONE_XPATH);
-//
-//        // this is a valid scenario. User can have 0..1 iaas provider elements
-//        // in cloud-controller xml.
-//        if (nodeList == null || nodeList.isEmpty()) {
-//            return;
-//        }
-//
-//        for (OMNode node : nodeList) {
-//            zones.add(getZone(node, zones, region));
-//        }
-//    }
-//
-//    private void loadHost(final Zone zone) {
-//        List<Host> hosts = zone.getListOfHosts();
-//
-//        if (hosts == null) {
-//            zone.setListOfHosts((hosts = new ArrayList<Host>()));
-//        }
-//
-//        List<OMNode> nodeList = getMatchingNodes(CloudControllerConstants.HOST_XPATH);
-//
-//        // this is a valid scenario. User can have 0..1 iaas provider elements
-//        // in cloud-controller xml.
-//        if (nodeList == null || nodeList.isEmpty()) {
-//            return;
-//        }
-//
-//        for (OMNode node : nodeList) {
-//            hosts.add(getHost(node, hosts, zone));
-//        }
-//    }
-//
-//    /* Have to handle at the autoscaler level...
-//     private void loadScalingOrders(final IaasProvider iaas, final OMElement iaasElt) {
-//         // set scale up order
-//         Iterator<?> it =
-//                          iaasElt.getChildrenWithName(new QName(
-//                                                                CloudControllerConstants.SCALE_UP_ORDER_ELEMENT));
-//
-//         if (it.hasNext()) {
-//             OMElement scaleUpOrderElt = (OMElement) it.next();
-//
-//             try {
-//                 iaas.setScaleUpOrder(Integer.parseInt(scaleUpOrderElt.getText()));
-//             } catch (NumberFormatException e) {
-//                 String msg =
-//                              CloudControllerConstants.SCALE_UP_ORDER_ELEMENT + " element contained" +
-//                                      " in " + xmlSource + "" +
-//                                      " has a value which is not an Integer value.";
-//                 handleException(msg, e);
-//             }
-//         }
-//
-//         if (it.hasNext()) {
-//             log.warn(xmlSource + " contains more than one " +
-//                      CloudControllerConstants.SCALE_UP_ORDER_ELEMENT + " elements!" +
-//                      " Elements other than the first will be neglected.");
-//         }
-//
-//         if (iaas.getScaleUpOrder() == -1) {
-//             String msg =
-//                          "Essential '" + CloudControllerConstants.SCALE_UP_ORDER_ELEMENT + "' element" +
-//                                  " has not specified in " + xmlSource;
-//             handleException(msg);
-//         }
-//
-//         // set scale down order
-//         it = iaasElt.getChildrenWithName(new QName(CloudControllerConstants.SCALE_DOWN_ORDER_ELEMENT));
-//
-//         if (it.hasNext()) {
-//             OMElement scaleDownElt = (OMElement) it.next();
-//
-//             try {
-//                 iaas.setScaleDownOrder(Integer.parseInt(scaleDownElt.getText()));
-//             } catch (NumberFormatException e) {
-//                 String msg =
-//                              CloudControllerConstants.SCALE_DOWN_ORDER_ELEMENT + " element contained" +
-//                                      " in " + xmlSource + "" +
-//                                      " has a value which is not an Integer value.";
-//                 handleException(msg, e);
-//             }
-//         }
-//
-//         if (it.hasNext()) {
-//             log.warn(xmlSource + " contains more than one " +
-//                      CloudControllerConstants.SCALE_DOWN_ORDER_ELEMENT + " elements!" +
-//                      " Elements other than the first will be neglected.");
-//         }
-//
-//         if (iaas.getScaleDownOrder() == -1) {
-//             String msg =
-//                          "Essential '" + CloudControllerConstants.SCALE_DOWN_ORDER_ELEMENT + "' element" +
-//                                  " has not specified in " + xmlSource;
-//             handleException(msg);
-//         }
-//
-//     }*/
-//
-//    private void loadTemplate(final IaasProvider iaas, final OMElement iaasElt) {
-//
-//        Iterator<?> it =
-//                iaasElt.getChildrenWithName(new QName(CloudControllerConstants.IMAGE_ID_ELEMENT));
-//
-//        if (it.hasNext()) {
-//            OMElement imageElt = (OMElement) it.next();
-//            iaas.setImage(imageElt.getText());
-//        }
-//
-//        if (it.hasNext()) {
-//            log.warn(xmlSource + " contains more than one " + CloudControllerConstants.IMAGE_ID_ELEMENT +
-//                    " elements!" + " Elements other than the first will be neglected.");
-//        }
-//
-//    }
-//
-//    private void neglectingWarn(final String elt, final int size) {
-//        if (size > 1) {
-//            log.warn(xmlSource + " contains more than one " + elt + " elements!" +
-//                    " Elements other than the first will be neglected.");
-//        }
-//    }
-//
-//    public void parse() {
-//
-//        if (xmlSource.exists()) {
-//            try {
-//                documentElement = new StAXOMBuilder(xmlSource.getPath()).getDocumentElement();
-//
-//            } catch (Exception ex) {
-//                String msg = "Error occurred when parsing the " + xmlSource.getPath() + ".";
-//                handleException(msg, ex);
-//            }
-//        } else {
-//            String msg = "Configuration file cannot be found : " + xmlSource.getPath();
-//            handleException(msg);
-//        }
-//    }
-//
-//    private void plainTextWarn(final String elt) {
-//        log.warn("Unable to find a value for " + elt + " element from Secure Vault." +
-//                "Hence we will try to assign the plain text value (if specified).");
-//    }
-//
-//    private String resolveSecret(final OMElement elt) {
-//        // retrieve the value using secure vault
-//        SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);
-//
-//        String alias = elt.getAttributeValue(new QName(CloudControllerConstants.ALIAS_ATTRIBUTE));
-//
-//        // retrieve the secured password
-//        if (secretResolver != null && secretResolver.isInitialized() &&
-//                secretResolver.isTokenProtected(alias)) {
-//
-//            return secretResolver.resolve(alias);
-//
-//        }
-//
-//        return null;
-//    }
-//
-//    public void setDataPublisherRelatedData() {
-//
-//        String eltStr = CloudControllerConstants.DATA_PUBLISHER_ELEMENT;
-//        // get dataPublisher element
-//        OMElement element =
-//                getElement(documentElement, eltStr,
-//                        CloudControllerConstants.DATA_PUBLISHER_XPATH);
-//
-//        if (element == null) {
-//            return;
-//        }
-//
-//        FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
-//        // get enable attribute
-//        boolean isEnable =
-//                Boolean.parseBoolean(element.getAttributeValue(new QName(
-//                        CloudControllerConstants.ENABLE_ATTR)));
-//        dataHolder.setEnableBAMDataPublisher(isEnable);
-//
-//        if (isEnable) {
-//            // get bam server info
-//            OMElement childElement =
-//                    getFirstChildElement(element,
-//                            CloudControllerConstants.BAM_SERVER_ELEMENT);
-//            OMElement elt;
-//
-//            if (childElement != null) {
-//                // set bam user name
-//                elt =
-//                        getFirstChildElement(childElement,
-//                                CloudControllerConstants.BAM_SERVER_ADMIN_USERNAME_ELEMENT);
-//                if (elt != null) {
-//                    dataHolder.setBamUsername(elt.getText());
-//                }
-//                // set bam password
-//                elt =
-//                        getFirstChildElement(childElement,
-//                                CloudControllerConstants.BAM_SERVER_ADMIN_PASSWORD_ELEMENT);
-//                if (elt != null) {
-//                    String password = resolveSecret(elt);
-//                    if (password == null) {
-//                        plainTextWarn(CloudControllerConstants.BAM_SERVER_ADMIN_PASSWORD_ELEMENT);
-//                        password = elt.getText();
-//                    }
-//
-//                    if (password != null) {
-//                        dataHolder.setBamPassword(password);
-//                    }
-//                }
-//            }
-//
-//            // set cron
-//            childElement = getFirstChildElement(element, CloudControllerConstants.CRON_ELEMENT);
-//            if (childElement != null) {
-//                dataHolder.setDataPublisherCron(childElement.getText());
-//            }
-//
-//            // set cassandra info
-//            childElement = getFirstChildElement(element, CloudControllerConstants.CASSANDRA_INFO_ELEMENT);
-//
-//            if (childElement != null) {
-//                // set connection url
-//                elt = getFirstChildElement(childElement, CloudControllerConstants.CONNECTION_URL_ELEMENT);
-//                if (elt != null) {
-//                    dataHolder.setCassandraConnUrl(elt.getText());
-//                }
-//
-//                // set user name
-//                elt = getFirstChildElement(childElement, CloudControllerConstants.USER_NAME_ELEMENT);
-//                if (elt != null) {
-//                    dataHolder.setCassandraUser(elt.getText());
-//                }
-//                // set password
-//                elt = getFirstChildElement(childElement, CloudControllerConstants.PASSWORD_ELEMENT);
-//                if (elt != null) {
-//                    String password = resolveSecret(elt);
-//                    if (password == null) {
-//                        plainTextWarn(CloudControllerConstants.PASSWORD_ELEMENT);
-//                        password = elt.getText();
-//                    }
-//
-//                    if (password != null) {
-//                        dataHolder.setCassandraPassword(password);
-//                    }
-//                }
-//            }
-//
-//        }
-//
-//    }
-//
-//    /**
-//     * @param cartridgeElementString Cartridges section as a {@link String}
-//     * @param aCartridge             {@link Cartridge} instance.
-//     * @param deploymentNodes        list of deployment directory nodes
-//     */
-//    private void setDeploymentDirs(String cartridgeElementString, Cartridge aCartridge,
-//                                   List<?> deploymentNodes) {
-//        Object nodeObj;
-//        if ((nodeObj = deploymentNodes.get(0)) instanceof OMNode) {
-//            OMNode deploymentNode = (OMNode) nodeObj;
-//
-//            if (deploymentNode.getType() == OMNode.ELEMENT_NODE) {
-//
-//                OMElement deployElt = (OMElement) deploymentNode;
-//
-//                if (deployElt.getAttributeValue(new QName(
-//                        CloudControllerConstants.BASE_DIR_ATTR)) != null) {
-//
-//                    aCartridge.setBaseDir(deployElt.getAttributeValue(new QName(
-//                            CloudControllerConstants.BASE_DIR_ATTR)));
-//                }
-//
-//                for (Iterator<?> iterator =
-//                             deployElt.getChildrenWithName(new QName(
-//                                     CloudControllerConstants.DIRECTORY_ELEMENT)); iterator.hasNext();) {
-//                    OMElement dir = (OMElement) iterator.next();
-//                    aCartridge.addDeploymentDir(dir.getText());
-//                }
-//
-//            } else {
-//                String msg =
-//                        "Essential '" + CloudControllerConstants.DEPLOYMENT_ELEMENT +
-//                                "' element cannot" + " be found in " +
-//                                cartridgeElementString + " of " + xmlSource;
-//                handleException(msg);
-//            }
-//
-//        }
-//    }
-//
-//    public void setIaasProvidersList() {
-//
-//        List<IaasProvider> iaasProviders = FasterLookUpDataHolder.getInstance().getIaasProviders();
-//
-//        if (iaasProviders == null) {
-//            FasterLookUpDataHolder.getInstance()
-//                    .setIaasProviders((iaasProviders = new ArrayList<IaasProvider>()));
-//        }
-//
-//        List<OMNode> nodeList = getMatchingNodes(CloudControllerConstants.IAAS_PROVIDER_XPATH);
-//
-//        // this is a valid scenario. User can have 0..1 iaas provider elements
-//        // in cloud-controller xml.
-//        if (nodeList == null || nodeList.isEmpty()) {
-//            return;
-//        }
-//
-//        for (OMNode node : nodeList) {
-//            iaasProviders.add(getIaasProvider(node, iaasProviders));
-//        }
-//
-//    }
-//
-//    public void setPartitionsList() {
-//        Set<String> partitionIds = TopologyManager.getInstance().getTopology().getPartitionMap().keySet();
-//        List<String> ids = new ArrayList<String>();
-//
-//        List<OMNode> nodeList = getMatchingNodes(CloudControllerConstants.PARTITION_XPATH);
-//
-//        // this is a valid scenario. User can have 0..1 iaas provider elements
-//        // in cloud-controller xml.
-//        if (nodeList == null || nodeList.isEmpty()) {
-//            return;
-//        }
-//
-//        for (OMNode node : nodeList) {
-//            ids.add(getPartition(node).getId());
-//
-//        }
-//        //have to remove the non existing partition from the map
-//        boolean isFound;
-//        for (String parId : partitionIds) {
-//            isFound = false;
-//            for (String id : ids) {
-//                if (parId.equals(id)) {
-//                    isFound = true;
-//                    break;
-//                }
-//            }
-//            if (!isFound) {
-//                //have to remove the partition id from the Topology
-//                TopologyBuilder.handlePartitionRemoved(TopologyManager.getInstance().getTopology().getPartition(parId));
-//            }
-//        }
-//    }
-//
-//
-//    public void setTopologySyncRelatedData() {
-//
-//        String eltStr = CloudControllerConstants.TOPOLOGY_SYNC_ELEMENT;
-//        // get topologySync element
-//        OMElement element =
-//                getElement(documentElement, eltStr,
-//                        CloudControllerConstants.TOPOLOGY_SYNC_XPATH);
-//
-//        if (element == null) {
-//            return;
-//        }
-//
-//        // get enable attribute
-//        boolean isEnable =
-//                Boolean.parseBoolean(element.getAttributeValue(new QName(
-//                        CloudControllerConstants.ENABLE_ATTR)));
-//
-//        FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
-//
-//        dataHolder.setEnableTopologySync(isEnable);
-//
-//        if (isEnable) {
-//            TopologyConfig topologyConfig = new TopologyConfig();
-//            // load properties
-//            loadProperties(element, topologyConfig.getProperties());
-//
-//            dataHolder.setTopologyConfig(topologyConfig);
-//        }
-//
-//
-//    }
-//
-//    public boolean validate(final File schemaFile) throws Exception {
-//        validate(documentElement, schemaFile);
-//        return true;
-//    }
-//
-//    public void validate(final OMElement omElement, final File schemaFile) throws Exception {
-//
-//        Element sourceElement;
-//
-//        // if the OMElement is created using DOM implementation use it
-//        if (omElement instanceof ElementImpl) {
-//            sourceElement = (Element) omElement;
-//        } else { // else convert from llom to dom
-//            sourceElement = getDOMElement(omElement);
-//        }
-//
-//        // Create a SchemaFactory capable of understanding WXS schemas.
-//
-//        // Load a WXS schema, represented by a Schema instance.
-//        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-//        Source source = new StreamSource(schemaFile);
-//
-//        // Create a Validator object, which can be used to validate
-//        // an instance document.
-//        Schema schema = factory.newSchema(source);
-//        Validator validator = schema.newValidator();
-//
-//        // Validate the DOM tree.
-//        validator.validate(new DOMSource(sourceElement));
-//    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParserUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParserUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParserUtil.java
index cc78501..f10e4cc 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParserUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParserUtil.java
@@ -27,7 +27,6 @@ import org.apache.axiom.om.impl.dom.ElementImpl;
 import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.exception.MalformedConfigurationFileException;
 import org.apache.stratos.cloud.controller.util.*;
 import org.jaxen.JaxenException;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/CloudControllerConfigParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/CloudControllerConfigParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/CloudControllerConfigParser.java
index 9b2cb5e..980fe99 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/CloudControllerConfigParser.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/CloudControllerConfigParser.java
@@ -19,10 +19,7 @@
 package org.apache.stratos.cloud.controller.axiom.parser;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMElement;
@@ -36,8 +33,6 @@ import org.apache.stratos.cloud.controller.pojo.IaasProvider;
 import org.apache.stratos.cloud.controller.pojo.TopologyConfig;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.wso2.securevault.SecretResolver;
-import org.wso2.securevault.SecretResolverFactory;
 
 /**
  * Parse the cloud-controller.xml
@@ -197,9 +192,4 @@ public class CloudControllerConfigParser {
         }
     }
     
-    private static void handleException(final String msg) throws MalformedConfigurationFileException{
-        log.error(msg);
-        throw new MalformedConfigurationFileException(msg);
-    }
-
 }


[06/12] git commit: correcting set method of DeploymentPolicy bean

Posted by ni...@apache.org.
correcting set method of DeploymentPolicy bean


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

Branch: refs/heads/master
Commit: 192627bddfb7331e6a621a9883f503430063da1e
Parents: 40272be
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 22:29:32 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 22:29:32 2013 +0530

----------------------------------------------------------------------
 .../cloud/controller/deployment/policy/DeploymentPolicy.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/192627bd/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java
index d8f7ff3..7b36eba 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java
@@ -60,7 +60,7 @@ public class DeploymentPolicy implements Serializable{
         this.id = value;
     }
     
-    public void setPartitionGroup(PartitionGroup[] groups) {
+    public void setPartitionGroups(PartitionGroup[] groups) {
         this.partitionGroups = groups;
     }
 


[05/12] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos

Posted by ni...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos


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

Branch: refs/heads/master
Commit: 40272be6f4d044bcb2ae45d547c6f9999172a6bd
Parents: c883ee2 8838a2a
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 20:25:59 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 20:25:59 2013 +0530

----------------------------------------------------------------------
 .../cloud/controller/CloudControllerClient.java |  16 ++
 .../exception/PartitionValidationException.java |  19 +++
 .../exception/TerminationException.java         |   8 +-
 .../autoscaler/partition/PartitionManager.java  |  76 +++++++++
 .../partition/deployers/PartitionDeployer.java  | 120 +++++++++++++
 .../partition/deployers/PartitionReader.java    | 170 +++++++++++++++++++
 .../deployers/DeploymentPolicyReader.java       |  38 ++---
 .../autoscaler/util/AutoScalerConstants.java    |  33 ++++
 .../src/main/resources/META-INF/component.xml   |   5 +
 .../distribution/src/main/conf/autoscaler.drl   |  89 +++++-----
 10 files changed, 495 insertions(+), 79 deletions(-)
----------------------------------------------------------------------



[09/12] git commit: test case to test the partition deployer/parser

Posted by ni...@apache.org.
test case to test the partition deployer/parser


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

Branch: refs/heads/master
Commit: cdc02a691df3ad7982b363721d9e07f26916eaca
Parents: 50955e7
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sun Dec 1 16:23:30 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sun Dec 1 16:23:30 2013 +0530

----------------------------------------------------------------------
 .../policy/PartitionDeployerTest.java           | 66 ++++++++++++++++++++
 .../src/test/resources/partition.xml            | 10 +++
 .../src/test/resources/partitions.xml           | 15 +++++
 3 files changed, 91 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cdc02a69/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java
new file mode 100644
index 0000000..081161c
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one 
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+ * KIND, either express or implied.  See the License for the 
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.autoscaler.deployment.policy;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
+import org.apache.stratos.autoscaler.partition.deployers.PartitionReader;
+import org.apache.stratos.autoscaler.policy.deployers.DeploymentPolicyReader;
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author nirmal
+ *
+ */
+public class PartitionDeployerTest {
+    
+    PartitionReader reader, reader1;
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        reader = new PartitionReader(new File("src/test/resources/partitions.xml"));
+        reader1 = new PartitionReader(new File("src/test/resources/partition.xml"));
+    }
+
+    @Test
+    public void testPartitionCount() throws InvalidPolicyException {
+        
+        assertEquals(2, reader.getPartitionList().size());
+    }
+    
+    @Test
+    public void testPartition() throws InvalidPolicyException {
+        
+        assertEquals(1, reader1.getPartitionList().size());
+        
+        Partition p = reader1.getPartitionList().get(0);
+        assertEquals("P1", p.getId());
+        assertEquals(3, p.getPartitionMax());
+        assertEquals(2, p.getProperties().getProperties().length);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cdc02a69/components/org.apache.stratos.autoscaler/src/test/resources/partition.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/partition.xml b/components/org.apache.stratos.autoscaler/src/test/resources/partition.xml
new file mode 100644
index 0000000..8377abc
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/test/resources/partition.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<partitions>
+                        <partition id="P1" >
+                                <provider>ec2</provider>
+                                <property name="region" value="ap-southeast-1"/>
+                                <property name="zone" value="ap-southeast-1-a"/>
+                                <max>3</max>
+                                <min>1</min>
+                        </partition>
+</partitions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cdc02a69/components/org.apache.stratos.autoscaler/src/test/resources/partitions.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/partitions.xml b/components/org.apache.stratos.autoscaler/src/test/resources/partitions.xml
new file mode 100644
index 0000000..a41d633
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/test/resources/partitions.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<partitions>
+                        <partition id="P1" >
+                                <provider>ec2</provider>
+                                <property name="region" value="ap-southeast-1"/>
+                                <max>3</max>
+                                <min>1</min>
+                        </partition>
+                        <partition id="P2" >
+                        	<provider>openstack</provider>
+                                <property name="region" value="region-1"/>
+                                <max>5</max>
+                                <min>1</min>
+                        </partition>
+</partitions>
\ No newline at end of file


[03/12] cleaning up CC, find bug amendments, removing deprecated classes

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/ServiceConfigParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/ServiceConfigParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/ServiceConfigParser.java
deleted file mode 100644
index 540ec2c..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/parser/ServiceConfigParser.java
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.axiom.parser;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNode;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.axiom.AxiomXpathParserUtil;
-import org.apache.stratos.cloud.controller.exception.MalformedConfigurationFileException;
-import org.apache.stratos.cloud.controller.pojo.AppType;
-import org.apache.stratos.cloud.controller.pojo.Cartridge;
-import org.apache.stratos.cloud.controller.pojo.IaasProvider;
-import org.apache.stratos.cloud.controller.pojo.PortMapping;
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
-import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-
-/**
- * Parse the cartridge definition files.
- * 
- * @author nirmal
- * 
- */
-public class ServiceConfigParser {
-    private static final Log log = LogFactory.getLog(ServiceConfigParser.class);
-
-    /**
-     * Parse the config file.
-     * 
-     * @param elt
-     *            document element.
-     * @throws MalformedConfigurationFileException
-     */
-    public static List<Cartridge>
-        parse(String file, OMElement elt) throws MalformedConfigurationFileException {
-
-        return extractCartridges(file, elt);
-    }
-
-    public static List<ServiceContext> extractServiceContexts(File file, OMElement elt) {
-
-        String fileName = file.getAbsolutePath();
-        List<ServiceContext> serviceContextList = new ArrayList<ServiceContext>();
-
-        // services can be found from this XPATH
-        String xpath = CloudControllerConstants.SERVICES_ELEMENT_XPATH;
-        List<?> serviceNodes = AxiomXpathParserUtil.getMatchingNodes(xpath, elt);
-
-        if (serviceNodes == null || serviceNodes.isEmpty()) {
-            // or from this XPATH
-            xpath = CloudControllerConstants.SERVICE_ELEMENT_XPATH;
-            serviceNodes = AxiomXpathParserUtil.getMatchingNodes(xpath, elt);
-        }
-
-        if (serviceNodes == null || serviceNodes.isEmpty()) {
-            log.warn("No service found in this configuration file : " + fileName);
-            return serviceContextList;
-        }
-
-        for (Object obj : serviceNodes) {
-            ServiceContext serviceCtxt = new ServiceContext();
-
-            // set the definition file
-            serviceCtxt.setFile(file);
-
-            if (obj instanceof OMNode) {
-                OMNode serviceNode = (OMNode) obj;
-
-                if (serviceNode.getType() == OMNode.ELEMENT_NODE) {
-
-                    OMElement node = (OMElement) serviceNode;
-
-                    if (node.getAttribute(new QName(CloudControllerConstants.SERVICE_DOMAIN_ATTR)) == null) {
-                        String msg =
-                                     "Essential '" + CloudControllerConstants.SERVICE_DOMAIN_ATTR +
-                                             "' " + "attribute of '" +
-                                             CloudControllerConstants.SERVICE_ELEMENT +
-                                             "' element cannot be found in " + fileName;
-
-                        handleException(msg);
-                    }
-
-                    // set domain name
-                    serviceCtxt.setClusterId(node.getAttribute(new QName(
-                                                                         CloudControllerConstants.SERVICE_DOMAIN_ATTR))
-                                                 .getAttributeValue());
-                    // set tenant range
-                    serviceCtxt.setTenantRange(node.getAttribute(new QName(
-                                                                           CloudControllerConstants.SERVICE_TENANT_RANGE_ATTR))
-                                                   .getAttributeValue());
-
-                    serviceCtxt.setAutoScalerPolicyName(node.getAttribute(new QName(
-                                                                                    CloudControllerConstants.POLICY_NAME))
-                                                            .getAttributeValue());
-
-                    OMNode cartridgeNode =
-                                           AxiomXpathParserUtil.getFirstMatchingNode(xpath +
-                                                                                             CloudControllerConstants.CARTRIDGE_ELEMENT_XPATH,
-                                                                                     node);
-
-                    if (cartridgeNode != null && cartridgeNode.getType() == OMNode.ELEMENT_NODE) {
-
-                        OMElement cartridgeElt = (OMElement) cartridgeNode;
-
-                        String type =
-                                      cartridgeElt.getAttribute(new QName(
-                                                                          CloudControllerConstants.TYPE_ATTR))
-                                                  .getAttributeValue();
-
-                        if ("".equals(type)) {
-                            String msg =
-                                         "Essential '" + CloudControllerConstants.TYPE_ATTR + "' " +
-                                                 " attribute of '" +
-                                                 CloudControllerConstants.CARTRIDGE_ELEMENT +
-                                                 "' of '" +
-                                                 CloudControllerConstants.SERVICE_ELEMENT +
-                                                 "' element cannot be found in " + fileName;
-
-                            handleException(msg);
-                        }
-
-                        // set Cartridge type
-                        serviceCtxt.setCartridgeType(type);
-
-                    }
-                    if (serviceCtxt.getCartridgeType() == null) {
-                        String msg =
-                                     "Essential '" + CloudControllerConstants.CARTRIDGE_ELEMENT +
-                                             "' element" + " has not specified in " + fileName;
-                        handleException(msg);
-                    }
-
-                    // load payload
-                    loadPayload(AxiomXpathParserUtil.getMatchingNodes(xpath +
-                                                                              CloudControllerConstants.PAYLOAD_ELEMENT_XPATH,
-                                                                      node), serviceCtxt);
-
-                    // load host name
-                    loadHostName(AxiomXpathParserUtil.getMatchingNodes(xpath +
-                                                                               CloudControllerConstants.HOST_ELEMENT_XPATH,
-                                                                       node), serviceCtxt);
-
-                    // load properties
-                    IaasProviderConfigParser.loadProperties(fileName, node,
-                                                            serviceCtxt.getProperties());
-
-                }
-            }
-
-            FasterLookUpDataHolder.getInstance().addServiceContext(serviceCtxt);
-            // add each domain specific template to list
-            serviceContextList.add(serviceCtxt);
-        }
-
-        return serviceContextList;
-
-    }
-
-    private static void loadHostName(final List<OMNode> nodes, final ServiceContext serviceCtxt) {
-
-        if (nodes == null || nodes.isEmpty()) {
-            return;
-        }
-
-        // read host element
-        if (nodes.get(0).getType() == OMNode.ELEMENT_NODE) {
-
-            OMElement node = (OMElement) nodes.get(0);
-
-            if (node.getText() != null) {
-                serviceCtxt.setHostName(node.getText());
-            }
-
-        }
-    }
-
-    private static void loadPayload(final List<OMNode> nodes, final ServiceContext serviceCtxt) {
-
-        if (nodes == null || nodes.isEmpty()) {
-            return;
-        }
-
-        // read payload element
-        if (nodes.get(0).getType() == OMNode.ELEMENT_NODE) {
-
-            OMElement node = (OMElement) nodes.get(0);
-
-            if (node.getText() != null) {
-                StringBuilder payload = new StringBuilder(node.getText());
-                serviceCtxt.setPayload(payload);
-
-            }
-
-        }
-
-    }
-
-    private static List<Cartridge>
-        extractCartridges(String file, OMElement elt) throws MalformedConfigurationFileException {
-
-        FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance();
-
-        List<IaasProvider> iaasProviders = dataHolder.getIaasProviders();
-
-        if (iaasProviders == null) {
-            dataHolder.setIaasProviders((iaasProviders = new ArrayList<IaasProvider>()));
-        }
-
-        List<Cartridge> cartridges = new ArrayList<Cartridge>();
-
-        String xpath = CloudControllerConstants.CARTRIDGES_ELEMENT_XPATH;
-
-        // cartridges can be found from this XPATH
-        List<?> cartridgeNodes = AxiomXpathParserUtil.getMatchingNodes(xpath, elt);
-
-        if (cartridgeNodes == null || cartridgeNodes.isEmpty()) {
-            // or from this XPATH
-            xpath = CloudControllerConstants.CARTRIDGE_ELEMENT_XPATH;
-            cartridgeNodes = AxiomXpathParserUtil.getMatchingNodes(xpath, elt);
-        }
-
-        if (cartridgeNodes == null || cartridgeNodes.isEmpty()) {
-            log.warn("No cartridge found in this configuration file : " + file);
-            return cartridges;
-        }
-
-        for (Object obj : cartridgeNodes) {
-
-            if (obj instanceof OMNode) {
-                OMNode cartridgeNode = (OMNode) obj;
-
-                if (cartridgeNode.getType() == OMNode.ELEMENT_NODE) {
-
-                    OMElement cartridgeElement = (OMElement) cartridgeNode;
-
-                    // retrieve Attributes of a Cartridge definition
-                    String type =
-                                  cartridgeElement.getAttributeValue(new QName(
-                                                                               CloudControllerConstants.TYPE_ATTR));
-                    String host =
-                                  cartridgeElement.getAttributeValue(new QName(
-                                                                               CloudControllerConstants.HOST_ATTR));
-                    String provider =
-                                      cartridgeElement.getAttributeValue(new QName(
-                                                                                   CloudControllerConstants.PROVIDER_ATTR));
-
-                    String version =
-                                     cartridgeElement.getAttributeValue(new QName(
-                                                                                  CloudControllerConstants.VERSION_ATTR));
-
-                    boolean multiTenant =
-                                          Boolean.valueOf(cartridgeElement.getAttributeValue(new QName(
-                                                                                                       CloudControllerConstants.MULTI_TENANT_ATTR)));
-
-                    Cartridge aCartridge;
-
-                    if ((aCartridge = dataHolder.getCartridge(type)) == null) {
-
-                        aCartridge = new Cartridge(type, host, provider, version, multiTenant);
-                    }
-
-                    // read displayName
-                    Iterator<?> itName =
-                                         cartridgeElement.getChildrenWithName(new QName(
-                                                                                        CloudControllerConstants.DISPLAY_NAME_ELEMENT));
-
-                    if (itName.hasNext()) {
-                        OMElement name = (OMElement) itName.next();
-
-                        aCartridge.setDisplayName(name.getText());
-                    }
-
-                    // read description
-                    Iterator<?> it =
-                                     cartridgeElement.getChildrenWithName(new QName(
-                                                                                    CloudControllerConstants.DESCRIPTION_ELEMENT));
-
-                    if (it.hasNext()) {
-                        OMElement desc = (OMElement) it.next();
-
-                        aCartridge.setDescription(desc.getText());
-                    }
-
-                    // load properties of this cartridge
-                    IaasProviderConfigParser.loadProperties(file, cartridgeElement,
-                                                            aCartridge.getProperties());
-
-                    // retrieve the list of IaaS providers
-                    List<?> iaasProviderNodes =
-                                                AxiomXpathParserUtil.getMatchingNodes(xpath +
-                                                                                              CloudControllerConstants.IAAS_PROVIDER_ELEMENT_XPATH,
-                                                                                      cartridgeElement);
-
-                    getIaasProviders(file, elt, iaasProviders, cartridgeElement.toString(),
-                                     aCartridge, iaasProviderNodes);
-
-                    // load dirs
-                    List<?> deploymentNodes =
-                                              AxiomXpathParserUtil.getMatchingNodes(xpath +
-                                                                                            CloudControllerConstants.DEPLOYMENT_ELEMENT_XPATH,
-                                                                                    cartridgeElement);
-                    setDeploymentDirs(file, cartridgeElement.toString(), aCartridge,
-                                      deploymentNodes);
-
-                    // load port mappings
-                    List<?> portMappingNodes =
-                                               AxiomXpathParserUtil.getMatchingNodes(xpath +
-                                                                                             CloudControllerConstants.PORT_MAPPING_ELEMENT_XPATH,
-                                                                                     cartridgeElement);
-                    getPortMappings(file, cartridgeElement.toString(), aCartridge, portMappingNodes);
-
-                    // load appTypes
-                    List<?> appTypesNodes =
-                                            AxiomXpathParserUtil.getMatchingNodes(xpath +
-                                                                                          CloudControllerConstants.APP_TYPES_ELEMENT_XPATH,
-                                                                                  cartridgeElement);
-                    getAppTypes(file, cartridgeElement.toString(), aCartridge, appTypesNodes);
-
-                    cartridges.add(aCartridge);
-
-                    if (dataHolder.getCartridge(type) == null) {
-                        dataHolder.addCartridge(aCartridge);
-                    }
-                }
-            }
-        }
-
-        return cartridges;
-    }
-
-    /**
-     * @param iaasProviders
-     * @param cartridgeElementString
-     * @param aCartridge
-     * @param iaasProviderNodes
-     */
-    private static void getIaasProviders(final String fileName, final OMElement elt,
-        List<IaasProvider> iaasProviders, String cartridgeElementString, Cartridge aCartridge,
-        List<?> iaasProviderNodes) {
-        for (Object nodeObj : iaasProviderNodes) {
-            if (nodeObj instanceof OMNode) {
-                OMNode iaasProviderNode = (OMNode) nodeObj;
-
-                if (iaasProviderNode.getType() == OMNode.ELEMENT_NODE) {
-
-                    OMElement iaasElt = (OMElement) iaasProviderNode;
-
-                    // add the IaasProvider to this cartridge
-                    aCartridge.addIaasProvider(IaasProviderConfigParser.getIaasProvider(fileName,
-                                                                                        elt,
-                                                                                        iaasElt,
-                                                                                        iaasProviders));
-
-                } else {
-                    String msg =
-                                 "Essential '" + CloudControllerConstants.IAAS_PROVIDER_ELEMENT +
-                                         "' element cannot" + " be found in " +
-                                         cartridgeElementString + " of " + fileName;
-                    handleException(msg);
-                }
-
-            }
-        }
-    }
-
-    /**
-     * @param cartridgeElementString
-     *            Cartridges section as a {@link String}
-     * @param aCartridge
-     *            {@link Cartridge} instance.
-     * @param deploymentNodes
-     *            list of deployment directory nodes
-     */
-    private static void setDeploymentDirs(String fileName, String cartridgeElementString,
-        Cartridge aCartridge, List<?> deploymentNodes) {
-        Object nodeObj;
-        if ((nodeObj = deploymentNodes.get(0)) instanceof OMNode) {
-            OMNode deploymentNode = (OMNode) nodeObj;
-
-            if (deploymentNode.getType() == OMNode.ELEMENT_NODE) {
-
-                OMElement deployElt = (OMElement) deploymentNode;
-
-                if (deployElt.getAttributeValue(new QName(CloudControllerConstants.BASE_DIR_ATTR)) != null) {
-
-                    aCartridge.setBaseDir(deployElt.getAttributeValue(new QName(
-                                                                                CloudControllerConstants.BASE_DIR_ATTR)));
-                }
-
-                for (Iterator<?> iterator =
-                                            deployElt.getChildrenWithName(new QName(
-                                                                                    CloudControllerConstants.DIRECTORY_ELEMENT)); iterator.hasNext();) {
-                    OMElement dir = (OMElement) iterator.next();
-                    aCartridge.addDeploymentDir(dir.getText());
-                }
-
-            } else {
-                String msg =
-                             "Essential '" + CloudControllerConstants.DEPLOYMENT_ELEMENT +
-                                     "' element cannot" + " be found in " + cartridgeElementString +
-                                     " of " + fileName;
-                handleException(msg);
-            }
-
-        }
-    }
-
-    /**
-     * @param cartridgeElementString
-     *            Cartridges section as a {@link String}
-     * @param aCartridge
-     *            {@link Cartridge} instance.
-     * @param portMappingNodes
-     *            nodes of port mapping elements
-     */
-    private static void getPortMappings(final String fileName, String cartridgeElementString,
-        Cartridge aCartridge, List<?> portMappingNodes) {
-        Object nodeObj;
-        if (!portMappingNodes.isEmpty()) {
-            if ((nodeObj = portMappingNodes.get(0)) instanceof OMNode) {
-                OMNode portMappingNode = (OMNode) nodeObj;
-
-                if (portMappingNode.getType() == OMNode.ELEMENT_NODE) {
-
-                    OMElement portMappingElt = (OMElement) portMappingNode;
-
-                    for (Iterator<?> iterator =
-                                                portMappingElt.getChildrenWithName(new QName(
-                                                                                             CloudControllerConstants.HTTP_ELEMENT)); iterator.hasNext();) {
-                        OMElement httpElt = (OMElement) iterator.next();
-
-                        String port =
-                                      httpElt.getAttributeValue(new QName(
-                                                                          CloudControllerConstants.PORT_ATTR));
-                        String proxyPort =
-                                           httpElt.getAttributeValue(new QName(
-                                                                               CloudControllerConstants.PROXY_PORT_ATTR));
-
-                        PortMapping mapping =
-                                              new PortMapping(
-                                                              CloudControllerConstants.HTTP_ELEMENT,
-                                                              port, proxyPort);
-
-                        aCartridge.addPortMapping(mapping);
-                    }
-
-                    for (Iterator<?> iterator =
-                                                portMappingElt.getChildrenWithName(new QName(
-                                                                                             CloudControllerConstants.HTTPS_ELEMENT)); iterator.hasNext();) {
-                        OMElement httpsElt = (OMElement) iterator.next();
-
-                        String port =
-                                      httpsElt.getAttributeValue(new QName(
-                                                                           CloudControllerConstants.PORT_ATTR));
-                        String proxyPort =
-                                           httpsElt.getAttributeValue(new QName(
-                                                                                CloudControllerConstants.PROXY_PORT_ATTR));
-
-                        PortMapping mapping =
-                                              new PortMapping(
-                                                              CloudControllerConstants.HTTPS_ELEMENT,
-                                                              port, proxyPort);
-
-                        aCartridge.addPortMapping(mapping);
-                    }
-
-                } else {
-                    String msg =
-                                 "Essential '" + CloudControllerConstants.PORT_MAPPING_ELEMENT +
-                                         "' element cannot" + " be found in " +
-                                         cartridgeElementString + " of " + fileName;
-                    handleException(msg);
-                }
-
-            }
-        }
-    }
-
-    /**
-     * @param cartridgeElementString
-     *            Cartridges section as a {@link String}
-     * @param aCartridge
-     *            {@link org.apache.stratos.cloud.controller.pojo.Cartridge} instance.
-     * @param appTypesNodes
-     *            nodes of App types.
-     */
-    private static void getAppTypes(final String fileName, String cartridgeElementString,
-        Cartridge aCartridge, List<?> appTypesNodes) {
-        Object nodeObj;
-        if (!appTypesNodes.isEmpty()) {
-            if ((nodeObj = appTypesNodes.get(0)) instanceof OMNode) {
-                OMNode appTypeNode = (OMNode) nodeObj;
-
-                if (appTypeNode.getType() == OMNode.ELEMENT_NODE) {
-
-                    OMElement appTypesElt = (OMElement) appTypeNode;
-
-                    for (Iterator<?> iterator =
-                                                appTypesElt.getChildrenWithName(new QName(
-                                                                                          CloudControllerConstants.APP_TYPE_ELEMENT)); iterator.hasNext();) {
-                        OMElement appElt = (OMElement) iterator.next();
-
-                        String name =
-                                      appElt.getAttributeValue(new QName(
-                                                                         CloudControllerConstants.NAME_ATTR));
-                        String appSpecificMapping =
-                                                    appElt.getAttributeValue(new QName(
-                                                                                       CloudControllerConstants.APP_SPECIFIC_MAPPING_ATTR));
-
-                        AppType appType;
-
-                        if (appSpecificMapping == null) {
-                            appType = new AppType(name);
-                        } else {
-                            appType = new AppType(name, Boolean.valueOf(appSpecificMapping));
-                        }
-
-                        aCartridge.addAppType(appType);
-                    }
-
-                } else {
-                    String msg =
-                                 "Essential '" + CloudControllerConstants.APP_TYPE_ELEMENT +
-                                         "' element cannot" + " be found in " +
-                                         cartridgeElementString + " of " + fileName;
-                    handleException(msg);
-                }
-
-            }
-        }
-    }
-
-    private static void
-        handleException(final String msg) throws MalformedConfigurationFileException {
-        log.error(msg);
-        throw new MalformedConfigurationFileException(msg);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
index d2c50fa..4e087b6 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
@@ -25,7 +25,6 @@ import org.apache.axis2.deployment.DeploymentException;
 import org.apache.axis2.deployment.repository.util.DeploymentFileData;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.axiom.AxiomXpathParser;
 import org.apache.stratos.cloud.controller.axiom.AxiomXpathParserUtil;
 import org.apache.stratos.cloud.controller.axiom.parser.CartridgeConfigParser;
 import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor;
@@ -33,13 +32,9 @@ import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.exception.MalformedConfigurationFileException;
 import org.apache.stratos.cloud.controller.interfaces.Iaas;
 import org.apache.stratos.cloud.controller.pojo.Cartridge;
-import org.apache.stratos.cloud.controller.pojo.Host;
 import org.apache.stratos.cloud.controller.pojo.IaasProvider;
-import org.apache.stratos.cloud.controller.pojo.Region;
-import org.apache.stratos.cloud.controller.pojo.Zone;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
-import org.apache.stratos.cloud.controller.util.*;
 import org.wso2.carbon.utils.CarbonUtils;
 
 import java.io.File;
@@ -186,20 +181,20 @@ public class CartridgeDeployer extends AbstractDeployer{
 					Iaas iaas = (Iaas) Class.forName(iaasProvider.getClassName()).newInstance();
 					iaas.buildComputeServiceAndTemplate(iaasProvider);
 					iaasProvider.setIaas(iaas);
-                    if(iaasProvider.getListOfRegions() != null) {
-                        for(Region region : iaasProvider.getListOfRegions()) {
-                            iaas.buildComputeServiceAndTemplate(region);
-                            for(Zone zone : region.getListOfZones()) {
-                                zone.setComputeService(region.getComputeService());
-                                iaas.buildTemplate(zone);
-                                for(Host host: zone.getListOfHosts()) {
-                                    host.setComputeService(region.getComputeService());
-                                    iaas.buildTemplate(host);
-                                }
-                            }
-
-                        }
-                    }
+//                    if(iaasProvider.getListOfRegions() != null) {
+//                        for(Region region : iaasProvider.getListOfRegions()) {
+//                            iaas.buildComputeServiceAndTemplate(region);
+//                            for(Zone zone : region.getListOfZones()) {
+//                                zone.setComputeService(region.getComputeService());
+//                                iaas.buildTemplate(zone);
+//                                for(Host host: zone.getListOfHosts()) {
+//                                    host.setComputeService(region.getComputeService());
+//                                    iaas.buildTemplate(host);
+//                                }
+//                            }
+//
+//                        }
+//                    }
 					
 				} catch (Exception e) {
 					rename();

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CloudControllerDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CloudControllerDeployer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CloudControllerDeployer.java
index 82ffddb..0b60e97 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CloudControllerDeployer.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CloudControllerDeployer.java
@@ -25,7 +25,6 @@ import org.apache.axis2.deployment.DeploymentException;
 import org.apache.axis2.deployment.repository.util.DeploymentFileData;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.axiom.AxiomXpathParser;
 import org.apache.stratos.cloud.controller.axiom.AxiomXpathParserUtil;
 import org.apache.stratos.cloud.controller.axiom.parser.CloudControllerConfigParser;
 import org.apache.stratos.cloud.controller.pojo.IaasProvider;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/ServiceDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/ServiceDeployer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/ServiceDeployer.java
deleted file mode 100644
index 2875ce5..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/ServiceDeployer.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.deployers;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.deployment.AbstractDeployer;
-import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.deployment.repository.util.DeploymentFileData;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.axiom.AxiomXpathParser;
-import org.apache.stratos.cloud.controller.axiom.AxiomXpathParserUtil;
-import org.apache.stratos.cloud.controller.axiom.parser.ServiceConfigParser;
-import org.apache.stratos.cloud.controller.exception.MalformedConfigurationFileException;
-import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
-import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * All the {@link org.apache.stratos.cloud.controller.util.Cartridge}s will get deployed / undeployed / updated via this class.
- */
-//public class ServiceDeployer extends AbstractDeployer{
-    
-//    private static final Log log = LogFactory.getLog(ServiceDeployer.class);
-//    
-//    private FasterLookUpDataHolder serviceContextLookUpStructure;
-//    private Map<String, List<ServiceContext>> fileToServiceContextListMap;
-//    private File servicesSchema, serviceSchema;
-//
-//    @Override
-//    public void init(ConfigurationContext arg0) {
-//        fileToServiceContextListMap = new ConcurrentHashMap<String, List<ServiceContext>>();
-//        String etcDir = CarbonUtils.getCarbonConfigDirPath() + File.separator + "etc" + File.separator;
-//        servicesSchema = new File(etcDir+"services.xsd");
-//        serviceSchema = new File(etcDir+"service.xsd");
-//    }
-//
-//    @Override
-//    public void setDirectory(String arg0) {
-//        // component xml handles this
-//    }
-//
-//    @Override
-//    public void setExtension(String arg0) {
-//        // component xml handles this
-//    }
-//    
-//    public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
-//
-//        File file = deploymentFileData.getFile();
-//        log.debug("Started to deploy the deployment artefact: " + file);
-//        serviceContextLookUpStructure = FasterLookUpDataHolder.getInstance();
-//
-//        try {
-//            OMElement docElt = AxiomXpathParserUtil.parse(file);
-//            String fileName = file.getAbsolutePath();
-//            
-//            // validate
-//            validateService(docElt, fileName);
-//
-//            // deploy
-//            List<ServiceContext> services = ServiceConfigParser.extractServiceContexts(file, docElt);
-//
-//            // update map
-//            fileToServiceContextListMap.put(deploymentFileData.getAbsolutePath(),
-//                                            new ArrayList<ServiceContext>(services));
-//
-//            log.info("Successfully deployed the Service definition specified at " +
-//                     deploymentFileData.getAbsolutePath());
-//        } catch (Exception e) {
-//            String msg = "Invalid deployment artefact at " + deploymentFileData.getAbsolutePath();
-//            // back up the file
-//            File f = file;
-//            f.renameTo(new File(deploymentFileData.getAbsolutePath() + ".back"));
-//            log.error(msg, e);
-//            throw new DeploymentException(msg, e);
-//        }
-//    }
-//    
-//    private void validateService(final OMElement elt, final String fileName) throws Exception {
-//        boolean validated = false;
-//        Exception firstException = null;
-//
-//        try{
-//            // first try to validate using services schema
-//            AxiomXpathParserUtil.validate(elt, servicesSchema);
-//            validated = true;
-//            log.debug("Service validation was successful.");
-//            
-//        }catch (Exception e) {
-//            firstException = e;
-//        }
-//        
-//        if(!validated){
-//            try{
-//                // Now try to validate using service schema
-//                AxiomXpathParserUtil.validate(elt, serviceSchema);
-//                validated = true;
-//                log.debug("Service validation was successful.");
-//                
-//            }catch (Exception e) {
-//                String msg = "Service XML validation failed. Invalid Service XML: "+fileName;
-//                log.error(msg, firstException);
-//                throw new MalformedConfigurationFileException(msg, firstException);
-//            }
-//        }
-//        
-//        
-//    }
-//
-//    public void undeploy(String file) throws DeploymentException {
-//
-//        serviceContextLookUpStructure = FasterLookUpDataHolder.getInstance();
-//
-//        // grab the entry from Map
-//        if(fileToServiceContextListMap.containsKey(file)){
-//            // remove 'em all
-//            for (ServiceContext ctxt : fileToServiceContextListMap.get(file)) {
-//                serviceContextLookUpStructure.removeServiceContext(ctxt);
-//                TopologyBuilder.handleClusterRemoved(ctxt);
-//                // remove from the topology
-//            }
-//            log.info("Successfully undeployed the Service definition specified at "+file);
-//        }
-//        
-//    }
-
-//}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java
index 2a74c0a..18dd0ce 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java
@@ -20,8 +20,6 @@
 package org.apache.stratos.cloud.controller.deployment.partition;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * The model class for PartitionGroup definition.

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
index d79c266..92d4cd6 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
@@ -45,18 +45,19 @@ import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
 import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.ec2.EC2Api;
 import org.jclouds.ec2.EC2ApiMetadata;
 import org.jclouds.ec2.EC2Client;
 import org.jclouds.ec2.domain.AvailabilityZoneInfo;
 import org.jclouds.ec2.domain.KeyPair;
 import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
 import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi;
+import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Set;
 
+@SuppressWarnings("deprecation")
 public class AWSEC2Iaas extends Iaas {
 
 	private static final Log log = LogFactory.getLog(AWSEC2Iaas.class);
@@ -292,7 +293,7 @@ public class AWSEC2Iaas extends Iaas {
 			log.info("Successfully associated public IP ");
 			return true;
 		} catch (Exception e) {
-			log.error("Exception in associating public IP " + e.getMessage());
+			log.debug("Exception in associating public IP " + e.getMessage());
 			return false;
 		}
 	}
@@ -353,7 +354,7 @@ public class AWSEC2Iaas extends Iaas {
                                                         .get();
         Set<AvailabilityZoneInfo> availabilityZones =
                                                       zoneRegionApi.describeAvailabilityZonesInRegion(region,
-                                                                                                      null);
+                                                                                                      new DescribeAvailabilityZonesOptions[0]);
         for (AvailabilityZoneInfo zoneInfo : availabilityZones) {
             String configuredZone = zoneInfo.getZone();
             if (zone.equalsIgnoreCase(configuredZone)) {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
index 6e445a3..070c356 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
@@ -177,7 +177,8 @@ public class OpenstackNovaIaas extends Iaas {
 
 		ComputeServiceContext context = iaasInfo.getComputeService()
 				.getContext();
-		NovaApi novaApi = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
+		@SuppressWarnings("deprecation")
+        NovaApi novaApi = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
 
 		KeyPairApi api = novaApi.getKeyPairExtensionForZone(region).get();
 
@@ -204,7 +205,8 @@ public class OpenstackNovaIaas extends Iaas {
 		ComputeServiceContext context = iaasInfo.getComputeService()
 				.getContext();
 
-		NovaApi novaClient = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
+		@SuppressWarnings("deprecation")
+        NovaApi novaClient = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
 		String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
 
 		FloatingIPApi floatingIp = novaClient.getFloatingIPExtensionForZone(
@@ -273,7 +275,8 @@ public class OpenstackNovaIaas extends Iaas {
 		ComputeServiceContext context = iaasInfo.getComputeService()
 				.getContext();
 
-		NovaApi novaApi = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
+		@SuppressWarnings("deprecation")
+        NovaApi novaApi = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
 		String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
 
 		FloatingIPApi floatingIPApi = novaApi
@@ -309,6 +312,7 @@ public class OpenstackNovaIaas extends Iaas {
         }
         
         ComputeServiceContext context = iaasInfo.getComputeService().getContext();
+        @SuppressWarnings("deprecation")
         NovaApi api = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
         for (String configuredZone : api.getConfiguredZones()) {
             if (region.equalsIgnoreCase(configuredZone)) {
@@ -342,6 +346,7 @@ public class OpenstackNovaIaas extends Iaas {
             throw new InvalidHostException(msg);
         }
         ComputeServiceContext context = iaasInfo.getComputeService().getContext();
+        @SuppressWarnings("deprecation")
         NovaApi api = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
         HostAggregateApi hostApi = api.getHostAggregateExtensionForZone(zone).get();
         for (HostAggregate hostAggregate : hostApi.list()) {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/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 2785df0..372cc58 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
@@ -18,9 +18,6 @@
  */
 package org.apache.stratos.cloud.controller.impl;
 
-import com.google.common.collect.Lists;
-
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor;
@@ -36,39 +33,27 @@ import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeExcept
 import org.apache.stratos.cloud.controller.exception.UnregisteredClusterException;
 import org.apache.stratos.cloud.controller.interfaces.CloudControllerService;
 import org.apache.stratos.cloud.controller.interfaces.Iaas;
-import org.apache.stratos.cloud.controller.persist.Deserializer;
 import org.apache.stratos.cloud.controller.pojo.Cartridge;
 import org.apache.stratos.cloud.controller.pojo.CartridgeInfo;
 import org.apache.stratos.cloud.controller.pojo.ClusterContext;
-import org.apache.stratos.cloud.controller.pojo.IaasContext;
 import org.apache.stratos.cloud.controller.pojo.IaasProvider;
 import org.apache.stratos.cloud.controller.pojo.MemberContext;
 import org.apache.stratos.cloud.controller.pojo.Registrant;
-import org.apache.stratos.cloud.controller.pojo.ServiceContext;
 import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisherTask;
-import org.apache.stratos.cloud.controller.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
 import org.apache.stratos.cloud.controller.topic.TopologySynchronizerTask;
 import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
 import org.apache.stratos.cloud.controller.topology.TopologyEventMessageDelegator;
-import org.apache.stratos.cloud.controller.topology.TopologyManager;
 import org.apache.stratos.cloud.controller.util.*;
 import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator;
 import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.ComputeMetadata;
 import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
 import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.domain.internal.NodeMetadataImpl;
 import org.wso2.carbon.ntask.common.TaskException;
 import org.wso2.carbon.ntask.core.TaskInfo;
 import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo;
 import org.wso2.carbon.ntask.core.TaskManager;
 import org.wso2.carbon.ntask.core.service.TaskService;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-
-import java.io.File;
-import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.Lock;
@@ -285,206 +270,194 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 	}
 
     @Override
-	public MemberContext startInstance(MemberContext member) throws IllegalArgumentException, UnregisteredCartridgeException {
+    public MemberContext startInstance(MemberContext member) throws IllegalArgumentException,
+        UnregisteredCartridgeException {
 
         if (member == null) {
             String msg = "Instance start-up failed. Member is null.";
             log.error(msg);
             throw new IllegalArgumentException(msg);
         }
-        
+
         String clusterId = member.getClusterId();
         Partition partition = member.getPartition();
-        
+
         log.info("Starting new instance of cluster : " + clusterId);
 
-		ComputeService computeService = null;
-		Template template = null;
-		
-		if(partition == null) {
-		    String msg = "Instance start-up failed. Specified Partition is null. Cluster id: "+clusterId;
+        ComputeService computeService = null;
+        Template template = null;
+
+        if (partition == null) {
+            String msg =
+                         "Instance start-up failed. Specified Partition is null. Cluster id: " +
+                                 clusterId;
             log.error(msg);
             throw new IllegalArgumentException(msg);
-		}
-		
+        }
+
         String partitionId = partition.getId();
         ClusterContext ctxt = dataHolder.getClusterContext(clusterId);
-        
-        if(ctxt == null) {
-            String msg = "Instance start-up failed. Invalid cluster id: "+clusterId;
+
+        if (ctxt == null) {
+            String msg = "Instance start-up failed. Invalid cluster id: " + clusterId;
             log.error(msg);
             throw new IllegalArgumentException(msg);
         }
-        
+
         String cartridgeType = ctxt.getCartridgeType();
-        
+
         Cartridge cartridge = dataHolder.getCartridge(cartridgeType);
-        
-        if(cartridge == null) {
-            String msg = "Instance start-up failed. No valid Cartridge found for type: "+cartridgeType;
+
+        if (cartridge == null) {
+            String msg =
+                         "Instance start-up failed. No valid Cartridge found for type: " +
+                                 cartridgeType;
             log.error(msg);
             throw new UnregisteredCartridgeException(msg);
         }
-        
+
         member.setCartridgeType(cartridgeType);
-        
-		final Lock lock = new ReentrantLock();
-
-		IaasProvider iaas = cartridge.getIaasProviderOfPartition(partitionId);
-            if(iaas == null) {
-                String msg = "Instance start-up failed for cluster: "+clusterId+". " +
-                        "There's no IaaS provided for the partition: "+partitionId+
-                        " and for the Cartridge type: "+cartridgeType;
-                log.fatal(msg);
+
+        final Lock lock = new ReentrantLock();
+
+        IaasProvider iaas = cartridge.getIaasProviderOfPartition(partitionId);
+        if (iaas == null) {
+            String msg =
+                         "Instance start-up failed for cluster: " + clusterId + ". " +
+                                 "There's no IaaS provided for the partition: " + partitionId +
+                                 " and for the Cartridge type: " + cartridgeType;
+            log.fatal(msg);
+            throw new CloudControllerException(msg);
+        }
+        try {
+            // generating the Unique member ID...
+            String memberID = generateMemberId(clusterId);
+            member.setMemberId(memberID);
+            // have to add memberID to the payload
+            StringBuilder payload = new StringBuilder(ctxt.getPayload());
+            payload.append(",");
+            payload.append("MEMBER_ID=" + memberID);
+            if (log.isDebugEnabled()) {
+                log.debug("Payload: " + payload.toString());
+            }
+            // reloading the payload with memberID
+            iaas.setPayload(payload.toString().getBytes());
+
+            iaas.getIaas().setDynamicPayload(iaas);
+            // get the pre built ComputeService from provider or region or zone or host
+            computeService = iaas.getComputeService();
+            template = iaas.getTemplate();
+
+            if (template == null) {
+                String msg =
+                             "Failed to start an instance in " +
+                                     iaas.getType() +
+                                     ". Reason : Template is null. You have not specify a matching service " +
+                                     "element in the configuration file of Autoscaler.\n Hence, will try to " +
+                                     "start in another IaaS if available.";
+                log.error(msg);
                 throw new CloudControllerException(msg);
             }
-                try {
-                    //generating the Unique member ID...
-                    String memberID = generateMemberId(clusterId);
-                    member.setMemberId(memberID);
-                    //have to add memberID to the payload
-                    StringBuilder payload = new StringBuilder(ctxt.getPayload());
-                    payload.append(",");
-                    payload.append("MEMBER_ID=" + memberID);
-                    //reloading the payload with memberID
-                    iaas.setPayload(payload.toString().getBytes());
-
-                    iaas.getIaas().setDynamicPayload(iaas);
-                    // get the pre built ComputeService from provider or region or zone or host
-                    computeService = iaas.getComputeService();
-                    template = iaas.getTemplate();
-                    
-                    if (template == null) {
-                        String msg = "Failed to start an instance in "
-                                + iaas.getType()
-                                + ". Reason : Template is null. You have not specify a matching service "
-                                + "element in the configuration file of Autoscaler.\n Hence, will try to "
-                                + "start in another IaaS if available.";
-                        log.error(msg);
-                        throw new CloudControllerException(msg);
-                    }
-
-                    // 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-]", "");
-
-                    NodeMetadata node;
-
-                    // create and start a node
-                    Set<? extends NodeMetadata> nodes = computeService
-                            .createNodesInGroup(group, 1, template);
-
-                    node = nodes.iterator().next();
-
-                    String autoAssignIpProp = iaas
-                            .getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY);
-
-                    // acquire the lock
-                    lock.lock();
-
-                    try {
-                        // node id
-                        String nodeId = node.getId();
-                        if (nodeId == null) {
-                            String msg = "Node id of the starting instance is null.\n" + node.toString();
-                            log.fatal(msg);
-                            throw new CloudControllerException(msg);
-                        }
-                        
-                        member.setNodeId(nodeId);
-                        
-                        // reset ip
-                        String ip = "";
-                        // default behavior is autoIpAssign=false
-                        if (autoAssignIpProp == null || (autoAssignIpProp != null && autoAssignIpProp.equals("false"))) {
-                            // allocate an IP address - manual IP assigning mode
-                            ip = iaas.getIaas().associateAddress(iaas, node);
-                            member.setAllocatedIpAddress(ip);
-                            log.info("Allocated ip address: " + ip);
-                        }
-
-                        // public ip
-                        if (node.getPublicAddresses() != null && node.getPublicAddresses().iterator().hasNext()) {
-                            ip = node.getPublicAddresses().iterator().next();
-                            member.setPublicIpAddress(ip);
-                            log.info("Public ip address: " + ip);
-                        }
-
-                        // private IP
-                        if (node.getPrivateAddresses() != null && node.getPrivateAddresses().iterator().hasNext()) {
-                            ip = node.getPrivateAddresses().iterator().next();
-                            member.setPrivateIpAddress(ip);
-                            log.info("Private ip address: " + ip);
-                        }
-
-                        
-                        dataHolder.addMemberContext(member);
-
-                        // persist in registry
-                        persist();
-
-                        // trigger topology
-                        TopologyBuilder.handleMemberSpawned(memberID, cartridgeType, clusterId,
-                                 nodeId, partition, ip);
-
-                        //update the topology with the newly spawned member
-                        // publish data
-                        if (log.isDebugEnabled()) {
-                            log.debug("Node details: \n" + node.toString()
-                                    + "\n***************\n");
-                        }
-
-                        log.info("Instance is successfully starting up in IaaS "
-                                + iaas.getType()
-                                + ".\tIP Address(public/private): "
-                                + ip
-                                + "\tNode Id: " + nodeId);
-
-                        return member;
-
-                    } finally {
-                        // release the lock
-                        lock.unlock();
-                    }
-
-                    } catch (Exception e) {
-                        log.warn(
-                                "Failed to start an instance in "
-                                        + iaas.getType()
-                                        + ". Hence, will try to start in another IaaS if available.",
-                                e);
-                    }
-                
-                return null;
+
+            // 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-]", "");
+
+            NodeMetadata node;
+
+            // create and start a node
+            Set<? extends NodeMetadata> nodes =
+                                                computeService.createNodesInGroup(group, 1,
+                                                                                  template);
+
+            node = nodes.iterator().next();
+
+            String autoAssignIpProp =
+                                      iaas.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY);
+
+            // acquire the lock
+            lock.lock();
+
+            try {
+                // node id
+                String nodeId = node.getId();
+                if (nodeId == null) {
+                    String msg = "Node id of the starting instance is null.\n" + node.toString();
+                    log.fatal(msg);
+                    throw new CloudControllerException(msg);
+                }
+
+                member.setNodeId(nodeId);
+
+                // reset ip
+                String ip = "";
+                // default behavior is autoIpAssign=false
+                if (autoAssignIpProp == null ||
+                    (autoAssignIpProp != null && autoAssignIpProp.equals("false"))) {
+                    // allocate an IP address - manual IP assigning mode
+                    ip = iaas.getIaas().associateAddress(iaas, node);
+                    member.setAllocatedIpAddress(ip);
+                    log.info("Allocated ip address: " + ip);
+                }
+
+                // public ip
+                if (node.getPublicAddresses() != null &&
+                    node.getPublicAddresses().iterator().hasNext()) {
+                    ip = node.getPublicAddresses().iterator().next();
+                    member.setPublicIpAddress(ip);
+                    log.info("Public ip address: " + ip);
+                }
+
+                // private IP
+                if (node.getPrivateAddresses() != null &&
+                    node.getPrivateAddresses().iterator().hasNext()) {
+                    ip = node.getPrivateAddresses().iterator().next();
+                    member.setPrivateIpAddress(ip);
+                    log.info("Private ip address: " + ip);
+                }
+
+                dataHolder.addMemberContext(member);
+
+                // persist in registry
+                persist();
+
+                // trigger topology
+                TopologyBuilder.handleMemberSpawned(memberID, cartridgeType, clusterId, partition,
+                                                    ip);
+
+                // update the topology with the newly spawned member
+                // publish data
+                if (log.isDebugEnabled()) {
+                    log.debug("Node details: \n" + node.toString() + "\n***************\n");
+                }
+
+                log.info("Instance is successfully starting up in IaaS " + iaas.getType() +
+                         ".\tIP Address(public/private): " + ip + "\tNode Id: " + nodeId);
+
+                return member;
+
+            } finally {
+                // release the lock
+                lock.unlock();
             }
 
+        } catch (Exception e) {
+            log.warn("Failed to start an instance in " + iaas.getType() +
+                     ". Hence, will try to start in another IaaS if available.", e);
+        }
+
+        return null;
+    }
+
 //    @Override
 //    public String startInstances(String clusterId, Partition partition, int noOfInstancesToBeSpawned) {
 //        //TODO
 //        return null;
 //    }
 
-    /**
-	 * Appends this ip to the Service Context's
-	 * {@link CloudControllerConstants#PUBLIC_IP_PROPERTY}
-	 * 
-	 * @param ip
-	 * @param serviceCtxt
-	 */
-	private void appendToPublicIpProperty(String ip, ServiceContext serviceCtxt) {
-		String ipStr = serviceCtxt
-				.getProperty(CloudControllerConstants.PUBLIC_IP_PROPERTY);
-		if (ip != null && !"".equals(ip)) {
-			serviceCtxt.setProperty(
-					CloudControllerConstants.PUBLIC_IP_PROPERTY,
-					("".equals(ipStr) ? "" : ipStr
-							+ CloudControllerConstants.ENTRY_SEPARATOR)
-							+ ip);
-		}
-	}
 
 	/**
 	 * Persist data in registry.
@@ -506,25 +479,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
          return clusterId + memberId.toString();
     }
 
-	private Cartridge loadCartridge(String cartridgeType,
-			List<Cartridge> cartridges) {
-
-		for (Cartridge cartridge : cartridges) {
-			if (cartridge.getType().equals(cartridgeType)) {
-                return cartridge;
-			}
-		}
-
-		return null;
-	}
-
-    private void reloadPayload(Cartridge cartridge, byte[] payload) {
-        for (IaasProvider iaas : cartridge.getIaases()) {
-					iaas.setPayload(payload);
-        }
-
-    }
-    
     @Override
     public void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException, 
     IllegalArgumentException{
@@ -646,7 +600,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
                 terminate(iaas, nodeId, ctxt);
 
                 // log information
-                logTermination(nodeId, ctxt);
+                logTermination(ctxt);
 
             } catch (Exception e) {
                 String msg =
@@ -851,76 +805,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 
 	}
 
-	public int getPendingInstanceCount(String clusterId) {
-        int pendingInstanceCount = 0;
-
-		ServiceContext subjectedSerCtxt = dataHolder
-				.getServiceContextFromDomain(clusterId);
-
-		if (subjectedSerCtxt != null
-				&& subjectedSerCtxt.getCartridgeType() != null) {
-
-			// load cartridge
-			subjectedSerCtxt.setCartridge(loadCartridge(subjectedSerCtxt
-					.getCartridgeType(),
-					dataHolder.getCartridges()));
-
-			if (subjectedSerCtxt.getCartridge() == null) {
-				return pendingInstanceCount;
-			}
-
-			List<IaasProvider> iaases = subjectedSerCtxt.getCartridge()
-					.getIaases();
-
-			for (IaasProvider iaas : iaases) {
-
-				ComputeService computeService = iaas.getComputeService();
-
-				IaasContext ctxt;
-				if ((ctxt = subjectedSerCtxt.getIaasContext(iaas.getType())) == null) {
-					ctxt = subjectedSerCtxt.addIaasContext(iaas.getType());
-				}
-
-				// get list of node Ids which are belong to this domain- sub
-				// domain
-				List<String> nodeIds = ctxt.getNodeIds();
-
-				if (nodeIds.isEmpty()) {
-					log.debug("Zero nodes spawned in the IaaS "
-							+ iaas.getType() + " of domain: " + clusterId);
-					continue;
-				}
-
-				// get all the nodes spawned by this IaasContext
-				Set<? extends ComputeMetadata> set = computeService.listNodes();
-
-                // traverse through all nodes of this ComputeService object
-                for (ComputeMetadata aSet : set) {
-                    NodeMetadataImpl nodeMetadata = (NodeMetadataImpl) aSet;
-
-                    // if this node belongs to the requested domain
-                    if (nodeIds.contains(nodeMetadata.getId())) {
-
-                        // get the status of the node
-                        Status nodeStatus = nodeMetadata.getStatus();
-
-                        // count nodes that are in pending state
-                        if (nodeStatus.equals(Status.PENDING)) {
-                            pendingInstanceCount++;
-                        }
-                    }
-
-                }
-			}
-		}
-
-		log.debug("Pending instance count of domain '" + clusterId
-				+ " is "
-				+ pendingInstanceCount);
-
-		return pendingInstanceCount;
-
-	}
 
 	/**
 	 * A helper method to terminate an instance.
@@ -953,7 +837,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 		return iaasTemp;
 	}
 
-	private void logTermination(String nodeId, MemberContext ctxt) {
+	private void logTermination(MemberContext ctxt) {
 
 		// get the ip of the terminated node
 //		String ip = ctxt.getPublicIp(nodeId);
@@ -971,7 +855,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 //		serviceCtxt.setProperty(ipProp, newIpStr.length() == 0 ? "" : newIpStr
 //				.substring(0, newIpStr.length() - 1).toString());
         //updating the topology
-        TopologyBuilder.handleMemberTerminated(ctxt.getCartridgeType(), ctxt.getClusterId(), nodeId);
+        TopologyBuilder.handleMemberTerminated(ctxt.getCartridgeType(), ctxt.getClusterId(), ctxt.getMemberId());
 
 		// remove the reference
 //		ctxt.removeNodeIdToPublicIp(nodeId);
@@ -1033,7 +917,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 	    String cartridgeType = registrant.getCartridgeType();
 	    String clusterId = registrant.getClusterId();
         String payload = registrant.getPayload();
-        String hostName = registrant.getHostName();
         
         if(cartridgeType == null || clusterId == null || payload == null) {
 	        String msg = "Null Argument/s detected: Cartridge type: "+cartridgeType+", Cluster Id: "+clusterId+", Payload: "+payload;
@@ -1052,61 +935,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 	    dataHolder.addClusterContext(new ClusterContext(clusterId, cartridgeType, payload));
 	    TopologyBuilder.handleClusterCreated(registrant);
 	    
-//		// create a ServiceContext dynamically
-//		ServiceContext newServiceCtxt = new ServiceContext();
-//        newServiceCtxt.setClusterId(clusterId);
-//		//newServiceCtxt.setSubDomainName(subDomain);
-//		newServiceCtxt.setTenantRange(registrant.getTenantRange());
-//		newServiceCtxt.setHostName(registrant.getHostName());
-//        newServiceCtxt.setAutoScalerPolicyName(registrant.getAutoScalerPolicyName());
-//        newServiceCtxt.setPayload(new StringBuilder(registrant.getPayload()));
-//        Properties properties = registrant.getProperties();
-//        String cartridgeType = registrant.getCartridgeType();
-//
-//		if (properties != null && properties.getProperties() != null) {
-//			// add properties
-//			for (Property property : properties.getProperties()) {
-//				if (property != null && property.getName() != null) {
-//					newServiceCtxt.setProperty(property.getName(),
-//							property.getValue());
-//				}
-//			}
-//		}
-//
-//		newServiceCtxt.setCartridgeType(cartridgeType);
-//
-//		for (Cartridge cartridge : dataHolder
-//				.getCartridges()) {
-//			if (cartridge.getType().equals(cartridgeType)) {
-//				newServiceCtxt.setCartridge(cartridge);
-//				break;
-//			}
-//		}
-//
-//		if (newServiceCtxt.getCartridge() == null) {
-//			String msg = "Registration failed - Unregistered Cartridge type: "
-//					+ cartridgeType;
-//			log.error(msg);
-//			throw new UnregisteredCartridgeException(msg);
-//		}
-//		// persist
-//        String uniqueName = clusterId + "-"
-//                + UUID.randomUUID() + ".xml";
-//        newServiceCtxt.setPayloadFile("/tmp/" + CloudControllerConstants.PAYLOAD_NAME + ".zip");
-//        newServiceCtxt.generatePayload();
-//        dataHolder.addServiceContext(newServiceCtxt);
-//        // notify consumer by adding services
-//        TopologyBuilder.handleClusterCreated(newServiceCtxt);
-//        try {
-//            FileUtils.writeStringToFile(new File(CloudControllerConstants.SERVICES_DIR + uniqueName),
-//                                            newServiceCtxt.toXml());
-//        } catch (IOException e) {
-//            log.error("couldn't write the service definition", e);
-//            throw new CloudControllerException("couldn't write the service definition", e);
-//        }
-//        log.info("Service successfully registered! Domain - " + clusterId
-//                + ", Cartridge type - " + cartridgeType);
-
 		return true;
 	}
 
@@ -1131,17 +959,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 		return cartridgeTypes;
 	}
 
-	/*private String checkSubDomain(String subDomainName) {
-		// if sub domain is null, we assume it as default one.
-		if (subDomainName == null || "null".equalsIgnoreCase(subDomainName)) {
-			subDomainName = Constants.DEFAULT_SUB_DOMAIN;
-			log.debug("Sub domain is null, hence using the default value : "
-					+ subDomainName);
-		}
-
-		return subDomainName;
-	}*/
-
 	@Override
 	public CartridgeInfo getCartridgeInfo(String cartridgeType)
 			throws UnregisteredCartridgeException {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Deserializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Deserializer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Deserializer.java
index ef983b9..0deb947 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Deserializer.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Deserializer.java
@@ -59,8 +59,10 @@ public class Deserializer {
             log.error("Failed to deserialize the file at "+filePath , e);
             throw e;
             
-        } finally{
-            objIn.close();
+        } finally {
+            if (objIn != null) {
+                objIn.close();
+            }
         }
         
         return obj;
@@ -75,18 +77,20 @@ public class Deserializer {
      */
     public static Object deserializeFromByteArray(byte[] bytes) throws Exception {
 
-    	ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-    	ObjectInput in = null;
-    	try {
-    	  in = new ObjectInputStream(bis);
-    	  Object o = in.readObject(); 
-    	  
-    	  return o;
-    	  
-    	} finally {
-    	  bis.close();
-    	  in.close();
-    	}
+        ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
+        ObjectInput in = null;
+        try {
+            in = new ObjectInputStream(bis);
+            Object o = in.readObject();
+
+            return o;
+
+        } finally {
+            bis.close();
+            if (in != null) {
+                in.close();
+            }
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Serializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Serializer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Serializer.java
index 48ac4c7..e2d1137 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Serializer.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/persist/Serializer.java
@@ -32,7 +32,8 @@ public class Serializer {
     public static void serializeToFile(Object serializableObj, String filePath) throws IOException {
 
         File outFile = new File(filePath);
-        ObjectOutput ObjOut = null;
+        ObjectOutput objOut = null;
+        FileOutputStream fileOutputStream = null;
         
         try {
 
@@ -41,9 +42,9 @@ public class Serializer {
             } else{
                 log.debug("Serialization file is already existing at "+filePath);
             }
-            
-            ObjOut = new ObjectOutputStream(new FileOutputStream(outFile));
-            ObjOut.writeObject(serializableObj);
+            fileOutputStream = new FileOutputStream(outFile);
+            objOut = new ObjectOutputStream(fileOutputStream);
+            objOut.writeObject(serializableObj);
 
         } catch (IOException e) {
             log.error("Failed to serialize the object "+serializableObj.toString()
@@ -51,7 +52,12 @@ public class Serializer {
             throw e;
             
         } finally{
-            ObjOut.close();
+            if(objOut != null) {
+                objOut.close();
+            }
+            if(fileOutputStream != null) {
+                fileOutputStream.close();
+            }
         }
 
     }
@@ -72,10 +78,12 @@ public class Serializer {
     	  
     	  return bos.toByteArray();
     	  
-    	} finally {
-    	  out.close();
-    	  bos.close();
-    	}
+        } finally {
+            if (out != null) {
+                out.close();
+            }
+            bos.close();
+        }
 
     }
 
@@ -95,10 +103,12 @@ public class Serializer {
 
     	  return bos.toByteArray();
 
-    	} finally {
-    	  out.close();
-    	  bos.close();
-    	}
+        } finally {
+            if (out != null) {
+                out.close();
+            }
+            bos.close();
+        }
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java
index 5f2805f..01cef44 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java
@@ -18,13 +18,16 @@
  */
 package org.apache.stratos.cloud.controller.pojo;
 
+import java.io.Serializable;
+
 /**
  * Holds runtime data of a Cluster.
  * @author nirmal
  *
  */
-public class ClusterContext {
+public class ClusterContext implements Serializable{
 
+    private static final long serialVersionUID = 4830667953031229223L;
     // cluster id
     private String clusterId;
     // cartridge type

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/DataPublisherConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/DataPublisherConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/DataPublisherConfig.java
index 9e35926..34e7f04 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/DataPublisherConfig.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/DataPublisherConfig.java
@@ -18,14 +18,17 @@
  */
 package org.apache.stratos.cloud.controller.pojo;
 
+import java.io.Serializable;
+
 import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
 
 /**
  * @author nirmal
  *
  */
-public class DataPublisherConfig {
+public class DataPublisherConfig implements Serializable{
 
+    private static final long serialVersionUID = -2097472019584151205L;
     private String bamUsername = CloudControllerConstants.DEFAULT_BAM_SERVER_USER_NAME;
     private String bamPassword = CloudControllerConstants.DEFAULT_BAM_SERVER_PASSWORD;
     private String dataPublisherCron = CloudControllerConstants.PUB_CRON_EXPRESSION;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Host.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Host.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Host.java
deleted file mode 100644
index f8d586b..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Host.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.apache.stratos.cloud.controller.pojo;
-
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.Template;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Host extends Zone {
-    private String id;
-    private String type;
-    private Map<String, String> properties = new HashMap<String, String>();
-
-    private transient ComputeService computeService;
-
-    private transient Template template;
-
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-     public Map<String, String> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-
-     public void setProperty(String key, String value) {
-
-        if (key != null && value != null) {
-            getProperties().put(key, value);
-        }
-    }
-
-    public String getProperty(String key) {
-        if(getProperties().get(key) != null) {
-            return getProperties().get(key);
-        } else {
-            return super.getProperty(key);
-        }
-    }
-
-     public ComputeService getComputeService() {
-        return computeService;
-    }
-
-    public void setComputeService(ComputeService computeService) {
-        this.computeService = computeService;
-    }
-
-    public Template getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(Template template) {
-        this.template = template;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasContext.java
deleted file mode 100644
index b5d8e95..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasContext.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.pojo;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.compute.domain.NodeMetadata;
-
-/**
- * 
- * Holds runtime data of an IaaS
- */
-public class IaasContext implements Serializable{
-	
-    private static final long serialVersionUID = 3370272526949562217L;
-
-	private String type;
-	
-	private List<String> nodeIds;
-	
-	/**
-	 * Key - node id
-	 * Value - public ip
-	 */
-	private Map<String, String> nodeToPublicIp;
-	
-	/**
-	 * Key - node id
-	 * Value - NodeMetadata object which has information on this node.
-	 */
-	private transient Map<String, NodeMetadata> nodes;
-	
-	private List<String> toBeRemovedNodeIds;
-	
-	public IaasContext(String iaasType) {
-		this.type = iaasType;
-		nodeToPublicIp = new HashMap<String, String>();
-		nodeIds = new ArrayList<String>();
-		nodes = new HashMap<String, NodeMetadata>();
-		toBeRemovedNodeIds = new ArrayList<String>();
-    }
-
-	public Map<String, String> getNodeToPublicIp() {
-		return nodeToPublicIp;
-	}
-	
-	public Map<String, NodeMetadata> getNodes() {
-		return nodes;
-	}
-	
-	public void setToBeRemovedNodeIds(List<String> list) {
-		this.toBeRemovedNodeIds = list;
-	}
-	
-	public List<String> getAllNodeIds() {
-		List<String> allNodeIds = new ArrayList<String>(nodeIds);
-		allNodeIds.addAll(toBeRemovedNodeIds);
-		return allNodeIds;
-	}
-	
-	public List<String> getNodeIds() {
-		return nodeIds;
-	}
-	
-	public List<String> getToBeRemovedNodeIds() {
-		return toBeRemovedNodeIds;
-	}
-	
-	public boolean didISpawn(String nodeId) {
-		if(nodeIds.contains(nodeId) || toBeRemovedNodeIds.contains(nodeId)){
-			return true;
-		}
-		return false;
-	}
-	
-	public void addNodeId(String nodeId) {
-		nodeIds.add(nodeId);
-	}
-	
-	public void addNodeToPublicIp(String nodeId, String publicIp) {
-		nodeToPublicIp.put(nodeId, publicIp);
-	}
-	
-	public void addToBeRemovedNodeId(String nodeId) {
-		toBeRemovedNodeIds.add(nodeId);
-	}
-	
-	public void removeNodeId(String nodeId) {
-		if(nodeIds.remove(nodeId)){
-			toBeRemovedNodeIds.add(nodeId);
-		}
-	}
-	
-	public void removeToBeRemovedNodeId(String nodeId) {
-		toBeRemovedNodeIds.remove(nodeId);
-	}
-	
-	public void setNodeIds(List<String> nodeIds) {
-		this.nodeIds = nodeIds;
-	}
-	
-	public String lastlySpawnedNode() {
-		return nodeIds.get(nodeIds.size()-1);
-	}
-	
-	public void addNodeMetadata(NodeMetadata node) {
-	    if(nodes == null){
-	        nodes = new HashMap<String, NodeMetadata>();
-	    }
-		nodes.put(node.getId(), node);
-	}
-	
-    public void removeNodeMetadata(NodeMetadata node) {
-        if (nodes != null) {
-            nodes.remove(node.getId());
-        }
-    }
-	
-	public void removeNodeIdToPublicIp(String nodeId){
-		nodeToPublicIp.remove(nodeId);
-	}
-	
-	public NodeMetadata getNode(String nodeId) {
-	    if(nodes == null) {
-	        return null;
-	    }
-		return nodes.get(nodeId);
-	}
-	
-	public String getPublicIp(String nodeId){
-		return nodeToPublicIp.get(nodeId);
-	}
-
-	public String getType() {
-        return type;
-    }
-
-	public void setType(String type) {
-        this.type = type;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c883ee2a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasProvider.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasProvider.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasProvider.java
index bffd6cf..449e2d9 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasProvider.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasProvider.java
@@ -25,7 +25,6 @@ import org.jclouds.compute.domain.Template;
 
 import java.io.Serializable;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -41,8 +40,6 @@ public class IaasProvider implements Serializable{
      */
     private String type;
 
-    private List<Region>  listOfRegions;
-    
     /**
      * Fully qualified class name of an implementation of {@link org.apache.stratos.cloud.controller.interfaces.Iaas}
      */
@@ -250,22 +247,4 @@ public class IaasProvider implements Serializable{
 //    	toBeRemovedNodeIds = new ArrayList<String>();
     }
 
-    /**
-     * Partition the IaaS using different region
-     */
-    public List<Region> getListOfRegions() {
-        return listOfRegions;
-    }
-
-    public void setListOfRegions(List<Region> listOfRegions) {
-        this.listOfRegions = listOfRegions;
-    }
-
-    public void addRegion(Region region) {
-        this.listOfRegions.add(region);
-    }
-
-    public void removeRegion(Region region) {
-        this.listOfRegions.remove(region);
-    }
 }


[07/12] git commit: moving PartitionGroup and DeploymentPolicy objects to auto-scaler, refactoring policy validation API and cleaning up

Posted by ni...@apache.org.
moving PartitionGroup and DeploymentPolicy objects to auto-scaler, refactoring policy validation API and cleaning up


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

Branch: refs/heads/master
Commit: 45cfecd4b7d5d8a51c207a16ee662586cc6b0274
Parents: 192627b
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sun Dec 1 16:20:27 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sun Dec 1 16:20:27 2013 +0530

----------------------------------------------------------------------
 .../deployment/partition/PartitionGroup.java    | 85 ------------------
 .../deployment/policy/DeploymentPolicy.java     | 93 --------------------
 .../exception/InvalidPartitionException.java    |  4 +
 .../impl/CloudControllerServiceImpl.java        | 84 ++++++++++--------
 .../interfaces/CloudControllerService.java      |  3 +-
 .../validate/AWSEC2PartitionValidator.java      |  4 +-
 .../OpenstackNovaPartitionValidator.java        |  6 +-
 7 files changed, 53 insertions(+), 226 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45cfecd4/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java
deleted file mode 100644
index 18dd0ce..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/PartitionGroup.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.deployment.partition;
-
-import java.io.Serializable;
-
-/**
- * The model class for PartitionGroup definition.
- */
-public class PartitionGroup implements Serializable{
-
-    private static final long serialVersionUID = -8043298009352097370L;
-    private String id;
-    private String partitionAlgo;
-    private Partition[] partitions;
-
-    /**
-     * Gets the value of the partitionAlgo property.
-     *
-     * @return
-     *     possible object is
-     *     {@link String }
-     *
-     */
-    public String getPartitionAlgo() {
-        return partitionAlgo;
-    }
-
-    /**
-     * Sets the value of the partitionAlgo property.
-     *
-     * @param value
-     *     allowed object is
-     *     {@link String }
-     *
-     */
-    public void setPartitionAlgo(String value) {
-        this.partitionAlgo = value;
-    }
-    
-    public void setPartitions(Partition[] partitions) {
-        this.partitions = partitions;
-    }
-
-    /**
-     * Gets the value of the partitions.
-     */
-    public Partition[] getPartitions() {
-        if (partitions == null) {
-            partitions = new Partition[0];
-        }
-        return this.partitions;
-    }
-
-    /**
-     * Gets the value of the id.
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * sets the value of the id.
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45cfecd4/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java
deleted file mode 100644
index 7b36eba..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/policy/DeploymentPolicy.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.deployment.policy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
-
-/**
- * The model class for Deployment-Policy definition.
- */
-public class DeploymentPolicy implements Serializable{
-
-    private static final long serialVersionUID = 5675507196284400099L;
-    private String id;
-	private PartitionGroup[] partitionGroups;
-
-    /**
-     * Gets the value of the id property.
-     * 
-     * @return
-     *     possible object is
-     *     {@link String }
-     *     
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * Sets the value of the id property.
-     * 
-     * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
-     */
-    public void setId(String value) {
-        this.id = value;
-    }
-    
-    public void setPartitionGroups(PartitionGroup[] groups) {
-        this.partitionGroups = groups;
-    }
-
-    /**
-     * Gets the value of the partition-groups.
-     */
-    public PartitionGroup[] getPartitionGroups() {
-        
-        return this.partitionGroups;
-    }
-    
-    /**
-     * Returns all the partitions referenced by this policy.
-     * @return List of {@link Partition}
-     */
-    public List<Partition> getAllPartitions() {
-        List<Partition> partitions = new ArrayList<Partition>();
-        for (PartitionGroup group : partitionGroups) {
-            if (group != null) {
-                partitions.addAll(Arrays.asList(group.getPartitions()));
-            }
-        }
-        return partitions;
-    }
-    
-    public String toString() {
-        return "Deployment Policy: "+this.id;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45cfecd4/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidPartitionException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidPartitionException.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidPartitionException.java
index e842ad9..48755c8 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidPartitionException.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidPartitionException.java
@@ -35,4 +35,8 @@ public class InvalidPartitionException extends Exception {
     public InvalidPartitionException(String msg, Exception ex) {
         super(msg, ex);
     }
+    
+    public String getMessage() {
+        return super.getMessage();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45cfecd4/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 372cc58..373c5df 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
@@ -22,8 +22,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor;
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.partition.PartitionGroup;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException;
 import org.apache.stratos.cloud.controller.exception.InvalidClusterException;
@@ -54,6 +52,7 @@ import org.wso2.carbon.ntask.core.TaskInfo;
 import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo;
 import org.wso2.carbon.ntask.core.TaskManager;
 import org.wso2.carbon.ntask.core.service.TaskService;
+
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.Lock;
@@ -1017,51 +1016,46 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 		
 
     @Override
-    public boolean validateDeploymentPolicy(String cartridgeType, DeploymentPolicy deploymentPolicy) 
+    public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) 
             throws InvalidPartitionException, InvalidCartridgeTypeException {
 
-        Map<String, IaasProvider> partitionToIaasProviders = new ConcurrentHashMap<String, IaasProvider>();
-        
+        Map<String, IaasProvider> partitionToIaasProviders =
+                                                             new ConcurrentHashMap<String, IaasProvider>();
+
         Cartridge cartridge = dataHolder.getCartridge(cartridgeType);
-        
-        if(cartridge == null) {
-            String msg = "Invalid Cartridge Type: "+cartridgeType;
+
+        if (cartridge == null) {
+            String msg = "Invalid Cartridge Type: " + cartridgeType;
             log.error(msg);
             throw new InvalidCartridgeTypeException(msg);
         }
-        
-        if(deploymentPolicy == null) {
-            String msg = "Deployment Policy is null.";
-            log.error(msg);
-            throw new InvalidPartitionException(msg);
-        }
-        
-        for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) {
-            for (Partition partition : partitionGroup.getPartitions()) {
-                String provider = partition.getProvider();
-                IaasProvider iaasProvider = cartridge.getIaasProvider(provider);
-                
-                if(iaasProvider == null) {
-                    String msg = "Invalid Partition - "+partition.toString() +", in "+deploymentPolicy.toString()+
-                            ". Cause: Iaas Provider is null for: "+provider;
-                    log.error(msg);
-                    throw new InvalidPartitionException(msg);
-                }
-                
-                Iaas iaas = iaasProvider.getIaas();
-                PartitionValidator validator = iaas.getPartitionValidator();
-                validator.setIaasProvider(iaasProvider);
-                IaasProvider updatedIaasProvider = validator.validate(partition.getId(), 
-                                 CloudControllerUtil.toJavaUtilProperties(partition.getProperties()));
-                // add to a temporary Map
-                partitionToIaasProviders.put(partition.getId(), updatedIaasProvider);
-                
+
+        for (Partition partition : partitions) {
+            String provider = partition.getProvider();
+            IaasProvider iaasProvider = cartridge.getIaasProvider(provider);
+
+            if (iaasProvider == null) {
+                String msg =
+                             "Invalid Partition - " + partition.toString() +
+                                     ". Cause: Iaas Provider is null for: " + provider;
+                log.error(msg);
+                throw new InvalidPartitionException(msg);
             }
+
+            Iaas iaas = iaasProvider.getIaas();
+            PartitionValidator validator = iaas.getPartitionValidator();
+            validator.setIaasProvider(iaasProvider);
+            IaasProvider updatedIaasProvider =
+                                               validator.validate(partition.getId(),
+                                                                  CloudControllerUtil.toJavaUtilProperties(partition.getProperties()));
+            // add to a temporary Map
+            partitionToIaasProviders.put(partition.getId(), updatedIaasProvider);
+
         }
-        
+
         // if and only if the deployment policy valid
         cartridge.addIaasProviders(partitionToIaasProviders);
-        
+
         return true;
     }
 
@@ -1076,8 +1070,22 @@ public class CloudControllerServiceImpl implements CloudControllerService {
             log.error(msg);
             throw new InvalidPartitionException(msg);
         }
-
+        
         Iaas iaas = iaasProvider.getIaas();
+        if (iaas == null) {
+            try {
+                iaas = (Iaas) Class.forName(iaasProvider.getClassName()).newInstance();
+                iaas.buildComputeServiceAndTemplate(iaasProvider);
+                iaasProvider.setIaas(iaas);
+            } catch (Exception e) {
+                String msg =
+                             "Error while instantiating an instance of the class: " +
+                                     iaasProvider.getClassName();
+                log.error(msg, e);
+                throw new InvalidPartitionException(msg, e);
+            }
+        }
+
         PartitionValidator validator = iaas.getPartitionValidator();
         validator.setIaasProvider(iaasProvider);
         validator.validate(partition.getId(),

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45cfecd4/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
index ee71f62..b4bba09 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
@@ -19,7 +19,6 @@
 package org.apache.stratos.cloud.controller.interfaces;
 
 import org.apache.stratos.cloud.controller.deployment.partition.Partition;
-import org.apache.stratos.cloud.controller.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException;
 import org.apache.stratos.cloud.controller.exception.InvalidClusterException;
 import org.apache.stratos.cloud.controller.exception.InvalidMemberException;
@@ -53,7 +52,7 @@ public interface CloudControllerService {
      * @throws InvalidPartitionException if the policy contains at least one invalid partition.
      * @throws InvalidCartridgeTypeException if the given Cartridge type is not a valid one.
      */
-    public boolean validateDeploymentPolicy(String cartridgeType, DeploymentPolicy deploymentPolicy) 
+    public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) 
             throws InvalidPartitionException, InvalidCartridgeTypeException;
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45cfecd4/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/AWSEC2PartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/AWSEC2PartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/AWSEC2PartitionValidator.java
index dd6730c..3c5814d 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/AWSEC2PartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/AWSEC2PartitionValidator.java
@@ -73,9 +73,7 @@ public class AWSEC2PartitionValidator implements PartitionValidator {
                 
             } else {
                 
-                String msg = "Invalid Partition Detected : "+partitionId+". - "+Scope.region.toString()+" Property is not defined.";
-                log.error(msg);
-                throw new InvalidPartitionException(msg);
+                return iaasProvider;
             }
         } catch (Exception ex) {
             String msg = "Invalid Partition Detected : "+partitionId;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/45cfecd4/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/OpenstackNovaPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/OpenstackNovaPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/OpenstackNovaPartitionValidator.java
index cc8e1a2..64a3567 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/OpenstackNovaPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/validate/OpenstackNovaPartitionValidator.java
@@ -75,11 +75,7 @@ public class OpenstackNovaPartitionValidator implements PartitionValidator {
                 
             } else {
 
-                String msg =
-                        "Invalid Partition Detected : "+partitionId+". - "+Scope.zone.toString() +
-                                     " Property is not defined.";
-                log.error(msg);
-                throw new InvalidPartitionException(msg);
+                return iaasProvider;
             }
         } catch (Exception ex) {
             String msg = "Invalid Partition Detected : "+partitionId;