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

[1/2] stratos git commit: changing application policy schema, implementing network partition algorithms

Repository: stratos
Updated Branches:
  refs/heads/master e3552c469 -> 9f564f29d


http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
index f273e29..0eeb193 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
@@ -1,11 +1,11 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://common.stratos.apache.org/xsd" xmlns:ax27="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax25="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax23="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax219="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://io.java/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax213="http://rmi.java/xsd" xmlns:ax222="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax211="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="ht
 tp://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://common.stratos.apache.org/xsd" xmlns:ax27="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax25="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax23="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://io.java/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax216="http://rmi.java/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax220="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax213="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax223="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax211="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="ht
 tp://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
     <wsdl:documentation>AutoscalerService</wsdl:documentation>
     <wsdl:types>
-        <xs:schema xmlns:ax215="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://rmi.java/xsd">
+        <xs:schema xmlns:ax218="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://rmi.java/xsd">
             <xs:import namespace="http://io.java/xsd"></xs:import>
             <xs:complexType name="RemoteException">
                 <xs:complexContent>
-                    <xs:extension base="ax214:IOException">
+                    <xs:extension base="ax217:IOException">
                         <xs:sequence>
                             <xs:element minOccurs="0" name="cause" nillable="true" type="xs:anyType"></xs:element>
                             <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
@@ -22,7 +22,7 @@
                     <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="instanceRoundingFactor" type="xs:float"></xs:element>
                     <xs:element minOccurs="0" name="isPublic" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax23:LoadThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax25:LoadThresholds"></xs:element>
                     <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
                 </xs:sequence>
             </xs:complexType>
@@ -34,13 +34,13 @@
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax220="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
+        <xs:schema xmlns:ax214="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
             <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
             <xs:complexType name="ApplicationContext">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="components" nillable="true" type="ax219:ComponentContext"></xs:element>
+                    <xs:element minOccurs="0" name="components" nillable="true" type="ax213:ComponentContext"></xs:element>
                     <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="multiTenant" type="xs:boolean"></xs:element>
                     <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
@@ -53,10 +53,10 @@
             </xs:complexType>
             <xs:complexType name="ComponentContext">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationClusterContexts" nillable="true" type="ax219:ApplicationClusterContext"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax219:CartridgeContext"></xs:element>
-                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax219:DependencyContext"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax219:GroupContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationClusterContexts" nillable="true" type="ax213:ApplicationClusterContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax213:CartridgeContext"></xs:element>
+                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax213:DependencyContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax213:GroupContext"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ApplicationClusterContext">
@@ -77,14 +77,14 @@
                 <xs:sequence>
                     <xs:element minOccurs="0" name="cartridgeMax" type="xs:int"></xs:element>
                     <xs:element minOccurs="0" name="cartridgeMin" type="xs:int"></xs:element>
-                    <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax219:SubscribableInfoContext"></xs:element>
+                    <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax213:SubscribableInfoContext"></xs:element>
                     <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="SubscribableInfoContext">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="artifactRepositoryContext" nillable="true" type="ax219:ArtifactRepositoryContext"></xs:element>
+                    <xs:element minOccurs="0" name="artifactRepositoryContext" nillable="true" type="ax213:ArtifactRepositoryContext"></xs:element>
                     <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"></xs:element>
                     <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
@@ -112,9 +112,9 @@
             <xs:complexType name="GroupContext">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax219:CartridgeContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax213:CartridgeContext"></xs:element>
                     <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax219:GroupContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax213:GroupContext"></xs:element>
                     <xs:element minOccurs="0" name="groupMaxInstances" type="xs:int"></xs:element>
                     <xs:element minOccurs="0" name="groupMinInstances" type="xs:int"></xs:element>
                     <xs:element minOccurs="0" name="groupScalingEnabled" type="xs:boolean"></xs:element>
@@ -126,8 +126,8 @@
             <xs:complexType name="ServiceGroup">
                 <xs:sequence>
                     <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
-                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax222:Dependencies"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax222:ServiceGroup"></xs:element>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax223:Dependencies"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax223:ServiceGroup"></xs:element>
                     <xs:element minOccurs="0" name="groupscalingEnabled" type="xs:boolean"></xs:element>
                     <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
@@ -140,54 +140,38 @@
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
+        <xs:schema xmlns:ax221="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
             <xs:complexType name="ApplicationPolicy">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="algorithm" nillable="true" type="xs:string"></xs:element>
                     <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkPartitionReferences" nillable="true" type="ax217:ApplicationPolicyNetworkPartitionReference"></xs:element>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="ApplicationPolicyNetworkPartitionReference">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="activeByDefault" type="xs:boolean"></xs:element>
-                    <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkPartitions" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax29:Properties"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax221="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax28="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax210="http://common.stratos.apache.org/xsd" xmlns:ax223="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax216="http://rmi.java/xsd" xmlns:ax218="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
-            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
+        <xs:schema xmlns:ax215="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax222="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax28="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax210="http://common.stratos.apache.org/xsd" xmlns:ax224="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax219="http://rmi.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
             <xs:import namespace="http://policy.exception.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://rmi.java/xsd"></xs:import>
             <xs:import namespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"></xs:import>
             <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
-            <xs:element name="getAutoScalingPolicies">
-                <xs:complexType>
-                    <xs:sequence></xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="getAutoScalingPoliciesResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
             <xs:element name="AutoscalerServiceInvalidPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax25:InvalidPolicyException"></xs:element>
+                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax23:InvalidPolicyException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="addAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax25:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -201,7 +185,7 @@
             <xs:element name="updateAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax25:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -284,112 +268,124 @@
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceInvalidApplicationPolicyException">
+            <xs:element name="getAutoScalingPolicies">
                 <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidApplicationPolicyException" nillable="true" type="ax212:InvalidApplicationPolicyException"></xs:element>
-                    </xs:sequence>
+                    <xs:sequence></xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceRemoteException">
+            <xs:element name="getAutoScalingPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ax216:RemoteException"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax25:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceApplicatioinPolicyNotExistsException">
+            <xs:element name="AutoscalerServiceApplicationDefinitionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="ApplicatioinPolicyNotExistsException" nillable="true" type="ax25:ApplicatioinPolicyNotExistsException"></xs:element>
+                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax212:ApplicationDefinitionException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="updateApplicationPolicy">
+            <xs:element name="addApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax217:ApplicationPolicy"></xs:element>
+                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax215:ApplicationContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationPolicies">
+            <xs:element name="getApplications">
                 <xs:complexType>
                     <xs:sequence></xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationPoliciesResponse">
+            <xs:element name="getApplicationsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax217:ApplicationPolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax215:ApplicationContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceApplicationDefinitionException">
+            <xs:element name="deployApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax212:ApplicationDefinitionException"></xs:element>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addApplication">
+            <xs:element name="deployApplicationResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="AutoscalerServiceRemoteException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax219:ApplicationContext"></xs:element>
+                        <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ax216:RemoteException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplications">
+            <xs:element name="AutoscalerServiceInvalidApplicationPolicyException">
                 <xs:complexType>
-                    <xs:sequence></xs:sequence>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="InvalidApplicationPolicyException" nillable="true" type="ax212:InvalidApplicationPolicyException"></xs:element>
+                    </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationsResponse">
+            <xs:element name="addApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax219:ApplicationContext"></xs:element>
+                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax220:ApplicationPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployApplication">
+            <xs:element name="getApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
                         <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployApplicationResponse">
+            <xs:element name="getApplicationPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax220:ApplicationPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addApplicationPolicy">
+            <xs:element name="getApplicationPolicies">
+                <xs:complexType>
+                    <xs:sequence></xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getApplicationPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax217:ApplicationPolicy"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax220:ApplicationPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationPolicy">
+            <xs:element name="removeApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationPolicyResponse">
+            <xs:element name="AutoscalerServiceApplicatioinPolicyNotExistsException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax217:ApplicationPolicy"></xs:element>
+                        <xs:element minOccurs="0" name="ApplicatioinPolicyNotExistsException" nillable="true" type="ax23:ApplicatioinPolicyNotExistsException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="removeApplicationPolicy">
+            <xs:element name="updateApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax220:ApplicationPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -424,7 +420,7 @@
             <xs:element name="getAutoscalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax25:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -445,7 +441,7 @@
             <xs:element name="getApplicationResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:ApplicationContext"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax215:ApplicationContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -459,7 +455,7 @@
             <xs:element name="addServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax222:ServiceGroup"></xs:element>
+                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax223:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -480,7 +476,7 @@
             <xs:element name="getServiceGroupResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax222:ServiceGroup"></xs:element>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax223:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
@@ -492,18 +488,18 @@
             <xs:element name="getServiceGroupsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax222:ServiceGroup"></xs:element>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax223:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://application.exception.autoscaler.stratos.apache.org/xsd">
-            <xs:complexType name="InvalidApplicationPolicyException">
+            <xs:complexType name="ApplicationDefinitionException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-            <xs:complexType name="ApplicationDefinitionException">
+            <xs:complexType name="InvalidApplicationPolicyException">
                 <xs:sequence>
                     <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
@@ -559,6 +555,12 @@
             </xs:complexType>
         </xs:schema>
     </wsdl:types>
+    <wsdl:message name="getAutoScalingPoliciesRequest">
+        <wsdl:part name="parameters" element="ns:getAutoScalingPolicies"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="getAutoScalingPoliciesResponse">
+        <wsdl:part name="parameters" element="ns:getAutoScalingPoliciesResponse"></wsdl:part>
+    </wsdl:message>
     <wsdl:message name="removeAutoScalingPolicyRequest">
         <wsdl:part name="parameters" element="ns:removeAutoScalingPolicy"></wsdl:part>
     </wsdl:message>
@@ -568,11 +570,11 @@
     <wsdl:message name="AutoscalerServiceInvalidPolicyException">
         <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidPolicyException"></wsdl:part>
     </wsdl:message>
-    <wsdl:message name="getAutoScalingPoliciesRequest">
-        <wsdl:part name="parameters" element="ns:getAutoScalingPolicies"></wsdl:part>
+    <wsdl:message name="getApplicationPoliciesRequest">
+        <wsdl:part name="parameters" element="ns:getApplicationPolicies"></wsdl:part>
     </wsdl:message>
-    <wsdl:message name="getAutoScalingPoliciesResponse">
-        <wsdl:part name="parameters" element="ns:getAutoScalingPoliciesResponse"></wsdl:part>
+    <wsdl:message name="getApplicationPoliciesResponse">
+        <wsdl:part name="parameters" element="ns:getApplicationPoliciesResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addApplicationPolicyRequest">
         <wsdl:part name="parameters" element="ns:addApplicationPolicy"></wsdl:part>
@@ -583,12 +585,6 @@
     <wsdl:message name="AutoscalerServiceInvalidApplicationPolicyException">
         <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidApplicationPolicyException"></wsdl:part>
     </wsdl:message>
-    <wsdl:message name="getApplicationPoliciesRequest">
-        <wsdl:part name="parameters" element="ns:getApplicationPolicies"></wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="getApplicationPoliciesResponse">
-        <wsdl:part name="parameters" element="ns:getApplicationPoliciesResponse"></wsdl:part>
-    </wsdl:message>
     <wsdl:message name="getServiceGroupsRequest">
         <wsdl:part name="parameters" element="ns:getServiceGroups"></wsdl:part>
     </wsdl:message>
@@ -704,14 +700,18 @@
         <wsdl:part name="parameters" element="ns:getApplicationPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:portType name="AutoscalerServicePortType">
+        <wsdl:operation name="getAutoScalingPolicies">
+            <wsdl:input message="ns:getAutoScalingPoliciesRequest" wsaw:Action="urn:getAutoScalingPolicies"></wsdl:input>
+            <wsdl:output message="ns:getAutoScalingPoliciesResponse" wsaw:Action="urn:getAutoScalingPoliciesResponse"></wsdl:output>
+        </wsdl:operation>
         <wsdl:operation name="removeAutoScalingPolicy">
             <wsdl:input message="ns:removeAutoScalingPolicyRequest" wsaw:Action="urn:removeAutoScalingPolicy"></wsdl:input>
             <wsdl:output message="ns:removeAutoScalingPolicyResponse" wsaw:Action="urn:removeAutoScalingPolicyResponse"></wsdl:output>
             <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:removeAutoScalingPolicyAutoscalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getAutoScalingPolicies">
-            <wsdl:input message="ns:getAutoScalingPoliciesRequest" wsaw:Action="urn:getAutoScalingPolicies"></wsdl:input>
-            <wsdl:output message="ns:getAutoScalingPoliciesResponse" wsaw:Action="urn:getAutoScalingPoliciesResponse"></wsdl:output>
+        <wsdl:operation name="getApplicationPolicies">
+            <wsdl:input message="ns:getApplicationPoliciesRequest" wsaw:Action="urn:getApplicationPolicies"></wsdl:input>
+            <wsdl:output message="ns:getApplicationPoliciesResponse" wsaw:Action="urn:getApplicationPoliciesResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addApplicationPolicy">
             <wsdl:input message="ns:addApplicationPolicyRequest" wsaw:Action="urn:addApplicationPolicy"></wsdl:input>
@@ -719,10 +719,6 @@
             <wsdl:fault message="ns:AutoscalerServiceInvalidApplicationPolicyException" name="AutoscalerServiceInvalidApplicationPolicyException" wsaw:Action="urn:addApplicationPolicyAutoscalerServiceInvalidApplicationPolicyException"></wsdl:fault>
             <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:addApplicationPolicyAutoscalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getApplicationPolicies">
-            <wsdl:input message="ns:getApplicationPoliciesRequest" wsaw:Action="urn:getApplicationPolicies"></wsdl:input>
-            <wsdl:output message="ns:getApplicationPoliciesResponse" wsaw:Action="urn:getApplicationPoliciesResponse"></wsdl:output>
-        </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
             <wsdl:input message="ns:getServiceGroupsRequest" wsaw:Action="urn:getServiceGroups"></wsdl:input>
             <wsdl:output message="ns:getServiceGroupsResponse" wsaw:Action="urn:getServiceGroupsResponse"></wsdl:output>
@@ -814,15 +810,6 @@
     </wsdl:portType>
     <wsdl:binding name="AutoscalerServiceSoap11Binding" type="ns:AutoscalerServicePortType">
         <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
-        <wsdl:operation name="getAutoScalingPolicies">
-            <soap:operation soapAction="urn:getAutoScalingPolicies" style="document"></soap:operation>
-            <wsdl:input>
-                <soap:body use="literal"></soap:body>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"></soap:body>
-            </wsdl:output>
-        </wsdl:operation>
         <wsdl:operation name="removeAutoScalingPolicy">
             <soap:operation soapAction="urn:removeAutoScalingPolicy" style="document"></soap:operation>
             <wsdl:input>
@@ -835,8 +822,8 @@
                 <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getApplicationPolicies">
-            <soap:operation soapAction="urn:getApplicationPolicies" style="document"></soap:operation>
+        <wsdl:operation name="getAutoScalingPolicies">
+            <soap:operation soapAction="urn:getAutoScalingPolicies" style="document"></soap:operation>
             <wsdl:input>
                 <soap:body use="literal"></soap:body>
             </wsdl:input>
@@ -859,6 +846,15 @@
                 <soap:fault use="literal" name="AutoscalerServiceInvalidApplicationPolicyException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
+        <wsdl:operation name="getApplicationPolicies">
+            <soap:operation soapAction="urn:getApplicationPolicies" style="document"></soap:operation>
+            <wsdl:input>
+                <soap:body use="literal"></soap:body>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"></soap:body>
+            </wsdl:output>
+        </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
             <soap:operation soapAction="urn:getServiceGroups" style="document"></soap:operation>
             <wsdl:input>
@@ -1063,15 +1059,6 @@
     </wsdl:binding>
     <wsdl:binding name="AutoscalerServiceSoap12Binding" type="ns:AutoscalerServicePortType">
         <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap12:binding>
-        <wsdl:operation name="getAutoScalingPolicies">
-            <soap12:operation soapAction="urn:getAutoScalingPolicies" style="document"></soap12:operation>
-            <wsdl:input>
-                <soap12:body use="literal"></soap12:body>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"></soap12:body>
-            </wsdl:output>
-        </wsdl:operation>
         <wsdl:operation name="removeAutoScalingPolicy">
             <soap12:operation soapAction="urn:removeAutoScalingPolicy" style="document"></soap12:operation>
             <wsdl:input>
@@ -1084,8 +1071,8 @@
                 <soap12:fault use="literal" name="AutoscalerServiceInvalidPolicyException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getApplicationPolicies">
-            <soap12:operation soapAction="urn:getApplicationPolicies" style="document"></soap12:operation>
+        <wsdl:operation name="getAutoScalingPolicies">
+            <soap12:operation soapAction="urn:getAutoScalingPolicies" style="document"></soap12:operation>
             <wsdl:input>
                 <soap12:body use="literal"></soap12:body>
             </wsdl:input>
@@ -1108,6 +1095,15 @@
                 <soap12:fault use="literal" name="AutoscalerServiceInvalidApplicationPolicyException"></soap12:fault>
             </wsdl:fault>
         </wsdl:operation>
+        <wsdl:operation name="getApplicationPolicies">
+            <soap12:operation soapAction="urn:getApplicationPolicies" style="document"></soap12:operation>
+            <wsdl:input>
+                <soap12:body use="literal"></soap12:body>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"></soap12:body>
+            </wsdl:output>
+        </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
             <soap12:operation soapAction="urn:getServiceGroups" style="document"></soap12:operation>
             <wsdl:input>
@@ -1312,8 +1308,8 @@
     </wsdl:binding>
     <wsdl:binding name="AutoscalerServiceHttpBinding" type="ns:AutoscalerServicePortType">
         <http:binding verb="POST"></http:binding>
-        <wsdl:operation name="getAutoScalingPolicies">
-            <http:operation location="getAutoScalingPolicies"></http:operation>
+        <wsdl:operation name="removeAutoScalingPolicy">
+            <http:operation location="removeAutoScalingPolicy"></http:operation>
             <wsdl:input>
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
@@ -1321,8 +1317,8 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:output>
         </wsdl:operation>
-        <wsdl:operation name="removeAutoScalingPolicy">
-            <http:operation location="removeAutoScalingPolicy"></http:operation>
+        <wsdl:operation name="getAutoScalingPolicies">
+            <http:operation location="getAutoScalingPolicies"></http:operation>
             <wsdl:input>
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:input>
@@ -1330,6 +1326,12 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="addApplicationPolicy">
+            <http:operation location="addApplicationPolicy"></http:operation>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"></mime:content>
+            </wsdl:input>
+        </wsdl:operation>
         <wsdl:operation name="getApplicationPolicies">
             <http:operation location="getApplicationPolicies"></http:operation>
             <wsdl:input>
@@ -1339,12 +1341,6 @@
                 <mime:content type="text/xml" part="parameters"></mime:content>
             </wsdl:output>
         </wsdl:operation>
-        <wsdl:operation name="addApplicationPolicy">
-            <http:operation location="addApplicationPolicy"></http:operation>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"></mime:content>
-            </wsdl:input>
-        </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
             <http:operation location="getServiceGroups"></http:operation>
             <wsdl:input>


[2/2] stratos git commit: changing application policy schema, implementing network partition algorithms

Posted by ra...@apache.org.
changing application policy schema, implementing network partition algorithms


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

Branch: refs/heads/master
Commit: 9f564f29d7c6c86a990ff12b90208a902132239c
Parents: e3552c4
Author: R-Rajkumar <rr...@gmail.com>
Authored: Fri Mar 6 16:44:03 2015 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Fri Mar 6 16:45:10 2015 +0530

----------------------------------------------------------------------
 .../algorithms/NetworkPartitionAlgorithm.java   |  33 +++
 .../networkpartition/AllAtOnceAlgorithm.java    |  49 ++++
 .../NetworkPartitionAlgorithmContext.java       |  51 ++++
 .../OneAfterAnotherAlgorithm.java               |  58 ++++
 .../WeightedOneAfterAnotherAlgorithm.java       |  31 +++
 .../autoscaler/context/AutoscalerContext.java   |  71 ++++-
 .../internal/AutoscalerServiceComponent.java    |   9 +
 .../monitor/component/ApplicationMonitor.java   | 265 +++++++++++++------
 .../component/ParentComponentMonitor.java       |   4 +-
 .../policy/deployment/ApplicationPolicy.java    |  24 +-
 ...licationPolicyNetworkPartitionReference.java |  44 ---
 .../autoscaler/registry/RegistryManager.java    |  53 ++++
 .../autoscaler/rule/RuleTasksDelegator.java     |   6 +-
 .../services/impl/AutoscalerServiceImpl.java    |   9 +
 .../autoscaler/util/AutoscalerConstants.java    |   1 +
 .../stratos/autoscaler/util/AutoscalerUtil.java |  36 ++-
 .../impl/CloudControllerServiceUtil.java        |   4 +-
 .../deployment/ApplicationPolicyBean.java       |  42 ++-
 .../common/constants/StratosConstants.java      |   9 +-
 .../util/converter/ObjectConverter.java         |  78 +++---
 .../application-policy.json                     |  20 +-
 .../src/main/resources/AutoscalerService.wsdl   | 256 +++++++++---------
 22 files changed, 809 insertions(+), 344 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/NetworkPartitionAlgorithm.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/NetworkPartitionAlgorithm.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/NetworkPartitionAlgorithm.java
new file mode 100644
index 0000000..70b6286
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/NetworkPartitionAlgorithm.java
@@ -0,0 +1,33 @@
+/*
+ * 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.algorithms;
+
+import java.util.List;
+
+import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
+
+public interface NetworkPartitionAlgorithm {
+	
+	/**
+	 * Get a list network partitions in which application instances to be spawned
+	 * @param networkPartitionAlgorithmContext the {@link NetworkPartitionAlgorithmContext}
+	 * @return list of network partition ids
+	 */
+	public List<String> getNextNetworkPartitions(NetworkPartitionAlgorithmContext networkPartitionAlgorithmContext);
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/AllAtOnceAlgorithm.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/AllAtOnceAlgorithm.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/AllAtOnceAlgorithm.java
new file mode 100644
index 0000000..61dd470
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/AllAtOnceAlgorithm.java
@@ -0,0 +1,49 @@
+/*
+ * 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.algorithms.networkpartition;
+
+import java.util.List;
+
+import org.apache.stratos.autoscaler.algorithms.NetworkPartitionAlgorithm;
+import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
+
+import edu.emory.mathcs.backport.java.util.Arrays;
+
+public class AllAtOnceAlgorithm implements NetworkPartitionAlgorithm{
+
+	@Override
+	public List<String> getNextNetworkPartitions(NetworkPartitionAlgorithmContext networkPartitionAlgorithmContext) {
+		
+		if (networkPartitionAlgorithmContext == null) {
+			return null;
+		}
+		
+		ApplicationPolicy applicationPolicy = networkPartitionAlgorithmContext.getApplicationPolicy();
+		if (applicationPolicy == null) {
+			return null;
+		}
+		
+		String[] networkPartitions = applicationPolicy.getNetworkPartitions();
+		if (networkPartitions == null || networkPartitions.length ==0) {
+			return null;
+		}
+		
+		return Arrays.asList(networkPartitions);
+	}
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/NetworkPartitionAlgorithmContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/NetworkPartitionAlgorithmContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/NetworkPartitionAlgorithmContext.java
new file mode 100644
index 0000000..6e89c80
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/NetworkPartitionAlgorithmContext.java
@@ -0,0 +1,51 @@
+/*
+ * 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.algorithms.networkpartition;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
+
+public class NetworkPartitionAlgorithmContext implements Serializable{
+	
+	private static final long serialVersionUID = -1539453541207312793L;
+	private String applicationId;
+	private ApplicationPolicy applicationPolicy;
+	private AtomicInteger currentNetworkPartitionIndex;
+	
+	public NetworkPartitionAlgorithmContext(String applicationId, ApplicationPolicy applicationPolicy, 
+			int currentNetworkPartitionIndex) {
+		this.applicationId = applicationId;
+		this.applicationPolicy = applicationPolicy;
+		this.currentNetworkPartitionIndex = new AtomicInteger(currentNetworkPartitionIndex);
+	}
+
+	public AtomicInteger getCurrentNetworkPartitionIndex() {
+		return currentNetworkPartitionIndex;
+	}
+
+	public ApplicationPolicy getApplicationPolicy() {
+		return applicationPolicy;
+	}
+
+	public String getApplicationId() {
+		return applicationId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/OneAfterAnotherAlgorithm.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/OneAfterAnotherAlgorithm.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/OneAfterAnotherAlgorithm.java
new file mode 100644
index 0000000..35582d0
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/OneAfterAnotherAlgorithm.java
@@ -0,0 +1,58 @@
+/*
+ * 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.algorithms.networkpartition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stratos.autoscaler.algorithms.NetworkPartitionAlgorithm;
+import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
+
+public class OneAfterAnotherAlgorithm implements NetworkPartitionAlgorithm{
+
+	@Override
+	public List<String> getNextNetworkPartitions(NetworkPartitionAlgorithmContext networkPartitionAlgorithmContext) {
+		
+		if (networkPartitionAlgorithmContext == null) {
+			return null;
+		}
+		
+		ApplicationPolicy applicationPolicy = networkPartitionAlgorithmContext.getApplicationPolicy();
+		if (applicationPolicy == null) {
+			return null;
+		}
+		
+		String[] networkPartitions = applicationPolicy.getNetworkPartitions();
+		if (networkPartitions == null || networkPartitions.length == 0) {
+			return null;
+		}
+		
+		int totalNetworkPartitions = networkPartitions.length;
+		int currentPartitionIndex = networkPartitionAlgorithmContext.getCurrentNetworkPartitionIndex().intValue();
+		if (currentPartitionIndex >= totalNetworkPartitions) {
+			return null;
+		}
+		
+		int selectedIndex = networkPartitionAlgorithmContext.getCurrentNetworkPartitionIndex().incrementAndGet();
+		List<String> nextNetworkPartitions = new ArrayList<String>();
+		nextNetworkPartitions.add(networkPartitions[selectedIndex]);
+		
+		return nextNetworkPartitions;
+	}
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/WeightedOneAfterAnotherAlgorithm.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/WeightedOneAfterAnotherAlgorithm.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/WeightedOneAfterAnotherAlgorithm.java
new file mode 100644
index 0000000..5cea03a
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithms/networkpartition/WeightedOneAfterAnotherAlgorithm.java
@@ -0,0 +1,31 @@
+/*
+ * 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.algorithms.networkpartition;
+
+import java.util.List;
+
+import org.apache.stratos.autoscaler.algorithms.NetworkPartitionAlgorithm;
+
+public class WeightedOneAfterAnotherAlgorithm implements NetworkPartitionAlgorithm{
+
+	@Override
+	public List<String> getNextNetworkPartitions(NetworkPartitionAlgorithmContext cloudBurstAlgorithmContext) {
+		return null;
+	}
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
index 97aa5e1..af75545 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/AutoscalerContext.java
@@ -21,9 +21,16 @@
 package org.apache.stratos.autoscaler.context;
 
 import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
 import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
+import org.apache.stratos.autoscaler.exception.AutoScalerException;
+import org.apache.stratos.autoscaler.exception.policy.InvalidPolicyException;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
+import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
 import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
 import org.apache.stratos.common.clustering.DistributedObjectProvider;
@@ -36,11 +43,14 @@ import java.util.Map;
  * It holds all cluster monitors which are active in stratos.
  */
 public class AutoscalerContext {
+	
+	private static final Log log = LogFactory.getLog(AutoscalerContext.class);
 
 	private static final String AS_APPLICATION_ID_TO_APPLICATION_CTX_MAP = "AS_APPLICATION_ID_TO_APPLICATION_CTX_MAP";
 	private static final String AS_CLUSTER_ID_TO_CLUSTER_MONITOR_MAP = "AS_CLUSTER_ID_TO_CLUSTER_MONITOR_MAP";
 	private static final String AS_APPLICATION_ID_TO_APPLICATION_MONITOR_MAP = "AS_APPLICATION_ID_TO_APPLICATION_MONITOR_MAP";
 	private static final String AS_PENDING_APPLICATION_MONITOR_LIST = "AS_PENDING_APPLICATION_MONITOR_LIST";
+	private static final String AS_APPLICATIOIN_ID_TO_NETWORK_PARTITION_ALGO_CTX_MAP = "AS_APPLICATIOIN_ID_TO_NETWORK_PARTITION_ALGO_CTX_MAP";
 	private boolean clustered;
 	private boolean coordinator;
 	
@@ -55,6 +65,8 @@ public class AutoscalerContext {
     private Map<String, ApplicationMonitor> applicationMonitors;
     //pending application monitors
     private List<String> pendingApplicationMonitors;
+    // Map<ApplicationId, NetworkPartitioinContext>
+    private Map<String, NetworkPartitionAlgorithmContext> applicationIdToNetworkPartitionAlgorithmContextMap;
 
     private AutoscalerContext() {
     	// Check clustering status
@@ -73,6 +85,7 @@ public class AutoscalerContext {
         setClusterMonitors(distributedObjectProvider.getMap(AS_CLUSTER_ID_TO_CLUSTER_MONITOR_MAP));
         setApplicationMonitors(distributedObjectProvider.getMap(AS_APPLICATION_ID_TO_APPLICATION_MONITOR_MAP));
         pendingApplicationMonitors = distributedObjectProvider.getList(AS_PENDING_APPLICATION_MONITOR_LIST);//new ArrayList<String>();
+        applicationIdToNetworkPartitionAlgorithmContextMap = distributedObjectProvider.getMap(AS_APPLICATIOIN_ID_TO_NETWORK_PARTITION_ALGO_CTX_MAP);
     }
 
     private Map<String, ApplicationContext> readApplicationContextsFromRegistry() {
@@ -88,7 +101,7 @@ public class AutoscalerContext {
         }
         return applicationContextMap;
     }
-
+    
     public static AutoscalerContext getInstance() {
         return INSTANCE;
     }
@@ -183,4 +196,60 @@ public class AutoscalerContext {
     public void setCoordinator(boolean coordinator) {
         this.coordinator = coordinator;
     }
+    
+	public void addNetworkPartitionAlgorithmContext(NetworkPartitionAlgorithmContext algorithmContext) {
+		String applicationId = algorithmContext.getApplicationId();
+		if (log.isInfoEnabled()) {
+			log.info(String.format("Adding network partition algorithm context : [application-id] %s", applicationId));
+		}
+		this.addNetworkPartitionAlgorithmContextToInformationModel(algorithmContext);
+		RegistryManager.getInstance().persistNetworkPartitionAlgorithmContext(algorithmContext);
+
+		if (log.isInfoEnabled()) {
+			log.info(String.format("network partition algorithm context is added successfully: [application-policy-id] %s", applicationId));
+		}
+
+	}
+	
+	public boolean removeNetworkPartitionAlgorithmContext(String applicationId) {
+		if (StringUtils.isEmpty(applicationId)) {
+			throw new AutoScalerException("Application id cannot be empty");
+		}
+		this.removeNetworkPartitionAlgorithmContextInInformationModel(applicationId);
+		RegistryManager.getInstance().removeNetworkPartitionAlgorithmContext(applicationId);
+		if (log.isInfoEnabled()) {
+			log.info(String.format("Network partition algorithm context is removed successfully: [id] %s", applicationId));
+		}
+		return true;
+	}
+	
+	private void removeNetworkPartitionAlgorithmContextInInformationModel(String applicationId) {
+		if (applicationIdToNetworkPartitionAlgorithmContextMap.containsKey(applicationId)) {
+			if (log.isDebugEnabled()) {
+				log.debug("Removing network partition algorithm context [application-id] " + applicationId);
+			}
+			applicationIdToNetworkPartitionAlgorithmContextMap.remove(applicationId);
+		}
+		else{
+			throw new AutoScalerException("No such application id [" + applicationId + "] exists");
+		}
+	}
+
+	private void addNetworkPartitionAlgorithmContextToInformationModel(NetworkPartitionAlgorithmContext algorithmContext) {
+		String applicationId = algorithmContext.getApplicationId();
+        if (!applicationIdToNetworkPartitionAlgorithmContextMap.containsKey(applicationId)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Adding network partition algorithm context : " + applicationId);
+            }
+            applicationIdToNetworkPartitionAlgorithmContextMap.put(applicationId, algorithmContext);
+        } else {
+        	String errMsg = "Network partition algorithm context already exists : " + applicationId;
+        	log.error(errMsg);
+            throw new AutoScalerException(errMsg);
+        }
+    }
+	
+    public NetworkPartitionAlgorithmContext getNetworkPartitionAlgorithmContext(String applicationId) {
+        return applicationIdToNetworkPartitionAlgorithmContextMap.get(applicationId);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
index b2687da..3cd11ce 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServiceComponent.java
@@ -21,6 +21,7 @@ package org.apache.stratos.autoscaler.internal;
 import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
 import org.apache.stratos.autoscaler.applications.ApplicationSynchronizerTaskScheduler;
 import org.apache.stratos.autoscaler.context.AutoscalerContext;
 import org.apache.stratos.autoscaler.event.receiver.health.AutoscalerHealthStatEventReceiver;
@@ -155,6 +156,14 @@ public class AutoscalerServiceComponent {
             PolicyManager.getInstance().addApplicationPolicyToInformationModel(applicationPolicy);
         }
         
+        // Add application policies to information model
+        List<NetworkPartitionAlgorithmContext> networkPartitionAlgorithmContexts = RegistryManager.getInstance().retrieveNetworkPartitionAlgorithmContexts();
+        Iterator<NetworkPartitionAlgorithmContext> networkPartitionAlgoCtxtIterator = networkPartitionAlgorithmContexts.iterator();
+        while (networkPartitionAlgoCtxtIterator.hasNext()) {
+            NetworkPartitionAlgorithmContext algorithmContext = networkPartitionAlgoCtxtIterator.next();
+            AutoscalerContext.getInstance().addNetworkPartitionAlgorithmContext(algorithmContext);
+        }
+        
 		//starting the processor chain
 		ClusterStatusProcessorChain clusterStatusProcessorChain = new ClusterStatusProcessorChain();
 		ServiceReferenceHolder.getInstance().setClusterStatusProcessorChain(clusterStatusProcessorChain);

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
index bb8905e..c3f3ff1 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
@@ -20,8 +20,14 @@ package org.apache.stratos.autoscaler.monitor.component;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.algorithms.NetworkPartitionAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.AllAtOnceAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.OneAfterAnotherAlgorithm;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.WeightedOneAfterAnotherAlgorithm;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
+import org.apache.stratos.autoscaler.context.AutoscalerContext;
 import org.apache.stratos.autoscaler.context.InstanceContext;
 import org.apache.stratos.autoscaler.context.application.ApplicationInstanceContext;
 import org.apache.stratos.autoscaler.context.partition.network.ApplicationLevelNetworkPartitionContext;
@@ -35,9 +41,9 @@ import org.apache.stratos.autoscaler.monitor.events.*;
 import org.apache.stratos.autoscaler.monitor.events.builder.MonitorStatusEventBuilder;
 import org.apache.stratos.autoscaler.pojo.policy.PolicyManager;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
-import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicyNetworkPartitionReference;
 import org.apache.stratos.autoscaler.util.AutoscalerConstants;
 import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
+import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.common.threading.StratosThreadPool;
 import org.apache.stratos.messaging.domain.application.Application;
 import org.apache.stratos.messaging.domain.application.ApplicationStatus;
@@ -309,36 +315,74 @@ public class ApplicationMonitor extends ParentComponentMonitor {
         List<String> instanceIds = new ArrayList<String>();
         String instanceId;
 
-//        if (deploymentPolicy == null) {
-//            //FIXME for docker with deployment policy
-//            ApplicationInstance appInstance = createApplicationInstance(application, null);
-//            instanceIds.add(appInstance.getInstanceId());
-//        } else {
-        	
-        	for (ApplicationPolicyNetworkPartitionReference 
-        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getApplicationPolicyId())) {
-	            if(appPolicyNetworkPartition.isActiveByDefault()) {
-	            	ApplicationLevelNetworkPartitionContext context =
-                            new ApplicationLevelNetworkPartitionContext(appPolicyNetworkPartition.getNetworkPartitionId());
-                    //If application instances found in the ApplicationsTopology,
-                    // then have to add them first before creating new one
-                    ApplicationInstance appInstance = (ApplicationInstance) application.
-                            getInstanceByNetworkPartitionId(context.getId());
-                    if (appInstance != null) {
-                        //use the existing instance in the Topology to create the data
-                        instanceId = handleApplicationInstanceCreation(application, context, appInstance);
-                        initialStartup = false;
-                    } else {
-                        //create new app instance as it doesn't exist in the Topology
-                        instanceId = handleApplicationInstanceCreation(application, context, null);
-
-                    }
-                    instanceIds.add(instanceId);
-                    log.info("Application instance has been added for the [network partition] " +
-                    		appPolicyNetworkPartition.getNetworkPartitionId() + " [appInstanceId] " + instanceId);
+        ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(application.getApplicationPolicyId());
+        if (applicationPolicy == null) {
+			String msg = String.format("Application policy not found in registry or in-memory [application-id] %s", appId);
+			log.error(msg);
+			throw new RuntimeException(msg);
+		}
+        
+        NetworkPartitionAlgorithmContext algorithmContext = AutoscalerContext.getInstance().getNetworkPartitionAlgorithmContext(appId);
+        if (algorithmContext == null) {
+			String msg = String.format("Network partition algorithm context not found in registry or in-memory [application-id] %s", appId);
+			log.error(msg);
+			throw new RuntimeException(msg);
+		}
+        
+        String networkPartitionAlgorithmName = applicationPolicy.getAlgorithm();
+        NetworkPartitionAlgorithm algorithm = getNetworkPartitionAlgorithm(networkPartitionAlgorithmName);
+        List<String> nextNetworkPartitions = algorithm.getNextNetworkPartitions(algorithmContext);
+        if (nextNetworkPartitions == null || nextNetworkPartitions.isEmpty()) {
+			String msg = String.format("No network partitions available for application bursting [application-id] %s", appId);
+			log.warn(msg);
+			return false;
+		}
+        
+        for (String networkPartitionIds : nextNetworkPartitions) {
+        	ApplicationLevelNetworkPartitionContext context =
+                    new ApplicationLevelNetworkPartitionContext(networkPartitionIds);
+            //If application instances found in the ApplicationsTopology,
+            // then have to add them first before creating new one
+            ApplicationInstance appInstance = (ApplicationInstance) application.
+                    getInstanceByNetworkPartitionId(context.getId());
+            if (appInstance != null) {
+                //use the existing instance in the Topology to create the data
+                instanceId = handleApplicationInstanceCreation(application, context, appInstance);
+                initialStartup = false;
+            } else {
+                //create new app instance as it doesn't exist in the Topology
+                instanceId = handleApplicationInstanceCreation(application, context, null);
 
-	            }
             }
+            instanceIds.add(instanceId);
+            log.info("Application instance has been added for the [network partition] " +
+            		networkPartitionIds + " [appInstanceId] " + instanceId);
+		}
+        
+//        for (ApplicationPolicyNetworkPartitionReference 
+//        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getApplicationPolicyId())) {
+//	            if(appPolicyNetworkPartition.isActiveByDefault()) {
+//	            	ApplicationLevelNetworkPartitionContext context =
+//                            new ApplicationLevelNetworkPartitionContext(appPolicyNetworkPartition.getNetworkPartitionId());
+//                    //If application instances found in the ApplicationsTopology,
+//                    // then have to add them first before creating new one
+//                    ApplicationInstance appInstance = (ApplicationInstance) application.
+//                            getInstanceByNetworkPartitionId(context.getId());
+//                    if (appInstance != null) {
+//                        //use the existing instance in the Topology to create the data
+//                        instanceId = handleApplicationInstanceCreation(application, context, appInstance);
+//                        initialStartup = false;
+//                    } else {
+//                        //create new app instance as it doesn't exist in the Topology
+//                        instanceId = handleApplicationInstanceCreation(application, context, null);
+//
+//                    }
+//                    instanceIds.add(instanceId);
+//                    log.info("Application instance has been added for the [network partition] " +
+//                    		appPolicyNetworkPartition.getNetworkPartitionId() + " [appInstanceId] " + instanceId);
+//
+//	            }
+//            }
             
 
 //        }
@@ -346,26 +390,26 @@ public class ApplicationMonitor extends ParentComponentMonitor {
         return initialStartup;
     }
 
-	private ApplicationPolicyNetworkPartitionReference[] getNetworkPartitionReferences(
-            String applicationPolicyId) throws PolicyValidationException {
-		
-	    ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(applicationPolicyId);
-	    
-	    if(applicationPolicy == null) {
-	    	String msg = String.format("Application policy is not found [application-policy-id] %s [application-id] %s", applicationPolicyId, appId);
-	    	log.error(msg);
-	    	throw new PolicyValidationException(msg);        		
-	    }
-	    ApplicationPolicyNetworkPartitionReference[] npReference = applicationPolicy.getNetworkPartitionReferences();
-	    
-	    if(npReference == null || npReference.length <= 0) {
-	    	String msg = "Network partition references cannot be found in application policy "+ applicationPolicy+ " is not found "
-	    			+ "for application ["+ applicationPolicyId + "] ";
-	    	log.error(msg);        		
-	    	throw new PolicyValidationException(msg);  
-	    }
-	    return npReference;
-    }
+//	private ApplicationPolicyNetworkPartitionReference[] getNetworkPartitionReferences(
+//            String applicationPolicyId) throws PolicyValidationException {
+//		
+//	    ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(applicationPolicyId);
+//	    
+//	    if(applicationPolicy == null) {
+//	    	String msg = String.format("Application policy is not found [application-policy-id] %s [application-id] %s", applicationPolicyId, appId);
+//	    	log.error(msg);
+//	    	throw new PolicyValidationException(msg);        		
+//	    }
+//	    ApplicationPolicyNetworkPartitionReference[] npReference = applicationPolicy.getNetworkPartitionReferences();
+//	    
+//	    if(npReference == null || npReference.length <= 0) {
+//	    	String msg = "Network partition references cannot be found in application policy "+ applicationPolicy+ " is not found "
+//	    			+ "for application ["+ applicationPolicyId + "] ";
+//	    	log.error(msg);        		
+//	    	throw new PolicyValidationException(msg);  
+//	    }
+//	    return npReference;
+//    }
 
     private String handleApplicationInstanceCreation(Application application,
                                                      ApplicationLevelNetworkPartitionContext context,
@@ -399,47 +443,88 @@ public class ApplicationMonitor extends ParentComponentMonitor {
     public void handleApplicationBursting() throws TopologyInConsistentException,
             PolicyValidationException,
             MonitorNotFoundException {
+    	
         Application application = ApplicationHolder.getApplications().getApplication(appId);
         if (application == null) {
             String msg = "Application cannot be found in the Topology.";
             throw new TopologyInConsistentException(msg);
         }
+        
         boolean burstNPFound = false;
         String instanceId = null;
-        //Find out the inactive network partition
-//        if (deploymentPolicy == null) {
-//            //FIXME for docker with deployment policy
-//            ApplicationInstance appInstance = createApplicationInstance(application, null);
-//            instanceId = appInstance.getInstanceId();
-//
-//        } else {
-            for (ApplicationPolicyNetworkPartitionReference 
-        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getApplicationPolicyId())) {
-                //Checking whether any not active NP found
-                if (!appPolicyNetworkPartition.isActiveByDefault()) {
-
-                    if (!this.networkPartitionCtxts.containsKey(appPolicyNetworkPartition.getNetworkPartitionId())) {
-
-                        ApplicationLevelNetworkPartitionContext context =
-                                new ApplicationLevelNetworkPartitionContext(appPolicyNetworkPartition.getNetworkPartitionId());
-
-                        //Setting flags saying that it has been created by burst
-                        context.setCreatedOnBurst(true);
-                        ApplicationInstance appInstance = (ApplicationInstance) application.
-                                getInstanceByNetworkPartitionId(context.getId());
-
-                        if (appInstance == null) {
-                            instanceId = handleApplicationInstanceCreation(application, context, null);
-                        } else {
-                            log.warn("The Network partition is already associated with an " +
-                                    "[ApplicationInstance] " + appInstance.getInstanceId() +
-                                    "in the ApplicationsTopology. Hence not creating new AppInstance.");
-                            instanceId = handleApplicationInstanceCreation(application, context, appInstance);
-                        }
-                        burstNPFound = true;
-                    }
+        
+        ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(appId);
+        if (applicationPolicy == null) {
+			String msg = String.format("Application policy not found in registry or in-memory [application-id] %s", appId);
+			log.error(msg);
+			throw new RuntimeException(msg);
+		}
+        
+        NetworkPartitionAlgorithmContext algorithmContext = AutoscalerContext.getInstance().getNetworkPartitionAlgorithmContext(appId);
+        if (algorithmContext == null) {
+			String msg = String.format("Network partition algorithm context not found in registry or in-memory [application-id] %s", appId);
+			log.error(msg);
+			throw new RuntimeException(msg);
+		}
+        
+        String networkPartitionAlgorithmName = applicationPolicy.getAlgorithm();
+        NetworkPartitionAlgorithm algorithm = getNetworkPartitionAlgorithm(networkPartitionAlgorithmName);
+        List<String> nextNetworkPartitions = algorithm.getNextNetworkPartitions(algorithmContext);
+        if (nextNetworkPartitions == null || nextNetworkPartitions.isEmpty()) {
+			String msg = String.format("No network partitions available for application bursting [application-id] %s", appId);
+			log.warn(msg);
+			return;
+		}
+        
+        for (String networkPartitionId : nextNetworkPartitions) {
+            if (!this.networkPartitionCtxts.containsKey(networkPartitionId)) {
+
+                ApplicationLevelNetworkPartitionContext context = new ApplicationLevelNetworkPartitionContext(networkPartitionId);
+
+                //Setting flags saying that it has been created by burst
+                context.setCreatedOnBurst(true);
+                ApplicationInstance appInstance = (ApplicationInstance) application.
+                        getInstanceByNetworkPartitionId(context.getId());
+
+                if (appInstance == null) {
+                    instanceId = handleApplicationInstanceCreation(application, context, null);
+                } else {
+                    log.warn("The Network partition is already associated with an " +
+                            "[ApplicationInstance] " + appInstance.getInstanceId() +
+                            "in the ApplicationsTopology. Hence not creating new AppInstance.");
+                    instanceId = handleApplicationInstanceCreation(application, context, appInstance);
                 }
+                burstNPFound = true;
             }
+		}
+        
+//            for (ApplicationPolicyNetworkPartitionReference 
+//        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getApplicationPolicyId())) {
+//                //Checking whether any not active NP found
+//                if (!appPolicyNetworkPartition.isActiveByDefault()) {
+//
+//                    if (!this.networkPartitionCtxts.containsKey(appPolicyNetworkPartition.getNetworkPartitionId())) {
+//
+//                        ApplicationLevelNetworkPartitionContext context =
+//                                new ApplicationLevelNetworkPartitionContext(appPolicyNetworkPartition.getNetworkPartitionId());
+//
+//                        //Setting flags saying that it has been created by burst
+//                        context.setCreatedOnBurst(true);
+//                        ApplicationInstance appInstance = (ApplicationInstance) application.
+//                                getInstanceByNetworkPartitionId(context.getId());
+//
+//                        if (appInstance == null) {
+//                            instanceId = handleApplicationInstanceCreation(application, context, null);
+//                        } else {
+//                            log.warn("The Network partition is already associated with an " +
+//                                    "[ApplicationInstance] " + appInstance.getInstanceId() +
+//                                    "in the ApplicationsTopology. Hence not creating new AppInstance.");
+//                            instanceId = handleApplicationInstanceCreation(application, context, appInstance);
+//                        }
+//                        burstNPFound = true;
+//                    }
+//                }
+//            }
 //        }
         if (!burstNPFound) {
             log.warn("[Application] " + appId + " cannot be burst as no available resources found");
@@ -490,5 +575,21 @@ public class ApplicationMonitor extends ParentComponentMonitor {
         return false;
 
     }
-
+    
+    private NetworkPartitionAlgorithm getNetworkPartitionAlgorithm(String algorithmName) {
+    	
+    	if (algorithmName == null || algorithmName.isEmpty()) {
+			return null;
+		}
+    	
+    	if (algorithmName.equals(StratosConstants.NETWORK_PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID)) {
+			return new OneAfterAnotherAlgorithm();
+		} else if (algorithmName.equals(StratosConstants.NETWORK_PARTITION_WEIGHTED_ONE_AFTER_ANOTHER_ALGORITHM_ID)) {
+			return new WeightedOneAfterAnotherAlgorithm();
+		} else if (algorithmName.equals(StratosConstants.NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID)) {
+			return new AllAtOnceAlgorithm();
+		}
+    	
+    	return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
index 04592bd..8d24b5a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
@@ -728,10 +728,10 @@ public abstract class ParentComponentMonitor extends Monitor implements Runnable
         if (log.isDebugEnabled()) {
             log.debug(String.format("Partition algorithm is ", partitionAlgorithm));
         }
-        if (StratosConstants.ROUND_ROBIN_ALGORITHM_ID.equals(partitionAlgorithm)) {
+        if (StratosConstants.PARTITION_ROUND_ROBIN_ALGORITHM_ID.equals(partitionAlgorithm)) {
 
             autoscaleAlgorithm = new RoundRobin();
-        } else if (StratosConstants.ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(partitionAlgorithm)) {
+        } else if (StratosConstants.PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(partitionAlgorithm)) {
 
             autoscaleAlgorithm = new OneAfterAnother();
         } else {

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
index 8ac878f..1f52d60 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
@@ -20,12 +20,15 @@ package org.apache.stratos.autoscaler.pojo.policy.deployment;
 
 import java.io.Serializable;
 
+import org.apache.stratos.common.Properties;
+
 public class ApplicationPolicy implements Serializable{
 
 	private static final long serialVersionUID = -2851334419121310395L;
 	private String id;
 	private String algorithm;
-	private ApplicationPolicyNetworkPartitionReference[] networkPartitionReferences;
+	private String[] networkPartitions;
+	private Properties properties;
 	
 	public String getId() {
 		return id;
@@ -43,12 +46,19 @@ public class ApplicationPolicy implements Serializable{
 		this.algorithm = algorithm;
 	}
 
-	public ApplicationPolicyNetworkPartitionReference[] getNetworkPartitionReferences() {
-		return networkPartitionReferences;
+	public String[] getNetworkPartitions() {
+		return networkPartitions;
 	}
-	
-	public void setNetworkPartitionReferences(
-	        ApplicationPolicyNetworkPartitionReference[] networkPartitionReference) {
-		this.networkPartitionReferences = networkPartitionReference;
+
+	public void setNetworkPartitions(String[] networkPartitions) {
+		this.networkPartitions = networkPartitions;
+	}
+
+	public Properties getProperties() {
+		return properties;
+	}
+
+	public void setProperties(Properties properties) {
+		this.properties = properties;
 	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicyNetworkPartitionReference.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicyNetworkPartitionReference.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicyNetworkPartitionReference.java
deleted file mode 100644
index 4eb0fc3..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicyNetworkPartitionReference.java
+++ /dev/null
@@ -1,44 +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.pojo.policy.deployment;
-
-import java.io.Serializable;
-
-public class ApplicationPolicyNetworkPartitionReference implements Serializable {
-	
-    private static final long serialVersionUID = 7887911742533671753L;
-	private String networkPartitionId;
-	private boolean activeByDefault;
-	
-	public String getNetworkPartitionId() {
-		return networkPartitionId;
-	}
-	
-	public void setNetworkPartitionId(String networkPartitionId) {
-		this.networkPartitionId = networkPartitionId;
-	}
-	
-	public boolean isActiveByDefault() {
-		return activeByDefault;
-	}
-	
-	public void setActiveByDefault(boolean activeByDefault) {
-		this.activeByDefault = activeByDefault;
-	}	
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index ae35d18..c7d330c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -24,6 +24,7 @@ package org.apache.stratos.autoscaler.registry;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
 import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
 import org.apache.stratos.autoscaler.pojo.ServiceGroup;
@@ -444,6 +445,38 @@ public class RegistryManager {
         }
         return applicationPolicyList;
     }
+    
+    public List<NetworkPartitionAlgorithmContext> retrieveNetworkPartitionAlgorithmContexts() {
+        List<NetworkPartitionAlgorithmContext> algorithmContexts = new ArrayList<NetworkPartitionAlgorithmContext>();
+        RegistryManager registryManager = RegistryManager.getInstance();
+        String[] networkPartitionAlgoCtxtResourceList = (String[]) registryManager.retrieve(
+        		AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE);
+
+        if (networkPartitionAlgoCtxtResourceList != null) {
+        	NetworkPartitionAlgorithmContext algorithmContext;
+            for (String resourcePath : networkPartitionAlgoCtxtResourceList) {
+                Object serializedObj = registryManager.retrieve(resourcePath);
+                if (serializedObj != null) {
+                    try {
+                        Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+                        if (dataObj instanceof ApplicationPolicy) {
+                        	algorithmContext = (NetworkPartitionAlgorithmContext) dataObj;
+                            if (log.isDebugEnabled()) {
+                                log.debug(String.format("Network partition algorithm context read from registry %s", algorithmContext.toString()));
+                            }
+                            algorithmContexts.add(algorithmContext);
+                        } else {
+                            return null;
+                        }
+                    } catch (Exception e) {
+                        String msg = "Unable to retrieve data from Registry. Hence, any historical application policies will not get reflected.";
+                        log.warn(msg, e);
+                    }
+                }
+            }
+        }
+        return algorithmContexts;
+    }
 
     public ServiceGroup getServiceGroup(String name) throws Exception {
         String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.SERVICE_GROUP + "/" + name;
@@ -540,6 +573,16 @@ public class RegistryManager {
         }
 
     }
+    
+    public void removeNetworkPartitionAlgorithmContext(String applicationPolicyId) {
+        String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" +
+        		applicationPolicyId;
+        this.delete(resourcePath);
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Network partition algorithm context deleted from registry [application-policy-id] %s", applicationPolicyId));
+        }
+
+    }
 
     private void delete(String resourcePath) {
         try {
@@ -570,4 +613,14 @@ public class RegistryManager {
         }
 	    
     }
+	
+	public void persistNetworkPartitionAlgorithmContext(NetworkPartitionAlgorithmContext algorithmContext) {
+		String applicationId = algorithmContext.getApplicationId();
+		String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + 
+				AutoscalerConstants.NETWORK_PARTITION_ALGO_CTX_RESOURCE + "/" + applicationId;
+        persist(algorithmContext, resourcePath);
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Network partition algorithm context written to registry : %s", applicationId));
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
index d796d32..85bee11 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
@@ -144,14 +144,14 @@ public class RuleTasksDelegator {
 
         if(partitionAlgorithm == null) {
             //Send one after another as default
-            partitionAlgorithm = StratosConstants.ONE_AFTER_ANOTHER_ALGORITHM_ID;
+            partitionAlgorithm = StratosConstants.PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID;
         }
         if (log.isDebugEnabled()) {
             log.debug(String.format("Retrieving partition algorithm [Partition algorithm]: ", partitionAlgorithm));
         }
-        if (StratosConstants.ROUND_ROBIN_ALGORITHM_ID.equals(partitionAlgorithm)) {
+        if (StratosConstants.PARTITION_ROUND_ROBIN_ALGORITHM_ID.equals(partitionAlgorithm)) {
             autoscaleAlgorithm = new RoundRobin();
-        } else if (StratosConstants.ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(partitionAlgorithm)) {
+        } else if (StratosConstants.PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(partitionAlgorithm)) {
             autoscaleAlgorithm = new OneAfterAnother();
         } else {
             if (log.isErrorEnabled()) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index 9c52bc5..221e30b 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -21,6 +21,7 @@ package org.apache.stratos.autoscaler.services.impl;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.algorithms.networkpartition.NetworkPartitionAlgorithmContext;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.parser.ApplicationParser;
 import org.apache.stratos.autoscaler.applications.parser.DefaultApplicationParser;
@@ -185,6 +186,11 @@ public class AutoscalerServiceImpl implements AutoscalerService {
             } finally {
             	ApplicationHolder.releaseWriteLock();
             }
+            
+            // adding network partition algorithm context to registry
+            ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(applicationPolicyId);
+			NetworkPartitionAlgorithmContext algorithmContext = new NetworkPartitionAlgorithmContext(applicationId, applicationPolicy, 0);
+			AutoscalerContext.getInstance().addNetworkPartitionAlgorithmContext(algorithmContext);
 
             if(!applicationContext.isMultiTenant()) {
 			    // Add application signup for single tenant applications
@@ -392,6 +398,9 @@ public class AutoscalerServiceImpl implements AutoscalerService {
             // Remove Application SignUp(s) in stratos manager
             removeApplicationSignUp(application);
             
+            // Remove network partition algorithm context
+            AutoscalerContext.getInstance().removeNetworkPartitionAlgorithmContext(applicationId);
+            
             ApplicationBuilder.handleApplicationUndeployed(applicationId);
 
             ApplicationContext applicationContext = AutoscalerContext.getInstance().getApplicationContext(applicationId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java
index 43ccee0..f7e6370 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerConstants.java
@@ -48,6 +48,7 @@ public final class AutoscalerConstants {
     public static final String APPLICATIONS_RESOURCE = "/applications";
     public static final String APPLICATION_CONTEXTS_RESOURCE = "/applicationContexts";
     public static final String APPLICATION_POLICY_RESOURCE = "/policies/applicationPolicies";
+    public static final String NETWORK_PARTITION_ALGO_CTX_RESOURCE = "/algorithms/networkPartitionAlgorithmContext";
 
     /**
      * Cluster monitoring  interval

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/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 a92f91b..89f9c63 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
@@ -52,7 +52,6 @@ import org.apache.stratos.autoscaler.monitor.MonitorFactory;
 import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
 import org.apache.stratos.autoscaler.pojo.policy.PolicyManager;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
-import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicyNetworkPartitionReference;
 import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.stub.domain.DeploymentPolicy;
 import org.apache.stratos.cloud.controller.stub.domain.NetworkPartitionRef;
@@ -599,9 +598,8 @@ public class AutoscalerUtil {
 		}
     	
     	// application policy should contain at least one network partition reference
-    	ApplicationPolicyNetworkPartitionReference[] networkPartitionReferences = 
-    			applicationPolicy.getNetworkPartitionReferences();
-		if (null == networkPartitionReferences || networkPartitionReferences.length == 0) {
+    	String[] networkPartitionIds = applicationPolicy.getNetworkPartitions();
+		if (null == networkPartitionIds || networkPartitionIds.length == 0) {
 			String msg = "Invalid Application Policy. "
 					+ "Cause -> Application Policy is not containing any network partition reference";
 			log.error(msg);
@@ -610,13 +608,12 @@ public class AutoscalerUtil {
     	
     	// to count the number of network partitions which are active by default
     	// if the count is 0, we should raise the error
-    	int activeByDefaultNetworkPartitionsCount = 0;
+//    	int activeByDefaultNetworkPartitionsCount = 0;
     	
     	// validating all network partition references
-    	for (ApplicationPolicyNetworkPartitionReference applicationPolicyNetworkPartitionReference : networkPartitionReferences) {
+    	for (String networkPartitionId : networkPartitionIds) {
 			
     		// network-partition-id can't be null or empty
-    		String networkPartitionId = applicationPolicyNetworkPartitionReference.getNetworkPartitionId();
 			if (null == networkPartitionId || networkPartitionId.isEmpty()) {
 				String msg = String.format("Invalid Application Policy. "
 						+ "Cause -> Invalid network-partition-id : %s", networkPartitionId);
@@ -632,18 +629,18 @@ public class AutoscalerUtil {
 				throw new InvalidApplicationPolicyException(msg);
 			}
 			
-			// counting number of network partitions which are active by default
-			if (true == applicationPolicyNetworkPartitionReference.isActiveByDefault()) {
-				activeByDefaultNetworkPartitionsCount++;
-			}
+//			// counting number of network partitions which are active by default
+//			if (true == applicationPolicyNetworkPartitionReference.isActiveByDefault()) {
+//				activeByDefaultNetworkPartitionsCount++;
+//			}
 		}
     	
     	// there should be at least one network partition reference which is active by default
-    	if (activeByDefaultNetworkPartitionsCount == 0) {
-			String msg = "Invalid Application Policy. Cause -> No active by default network partitions found";
-			log.error(msg);
-			throw new InvalidApplicationPolicyException(msg);
-		}
+//    	if (activeByDefaultNetworkPartitionsCount == 0) {
+//			String msg = "Invalid Application Policy. Cause -> No active by default network partitions found";
+//			log.error(msg);
+//			throw new InvalidApplicationPolicyException(msg);
+//		}
     }
 	
 	
@@ -664,11 +661,10 @@ public class AutoscalerUtil {
 			throw new ApplicatioinPolicyNotExistsException(msg);
 		}
 		
-		ApplicationPolicyNetworkPartitionReference[] networkPartitionReferences = 
-				applicationPolicy.getNetworkPartitionReferences();
+		String[] networkPartitionIds = applicationPolicy.getNetworkPartitions();
     	
-		for (ApplicationPolicyNetworkPartitionReference applicationPolicyNetworkPartitionReference : networkPartitionReferences) {
-			String networkPartitionId = applicationPolicyNetworkPartitionReference.getNetworkPartitionId();
+		for (String applicationPolicyNetworkPartitionReference : networkPartitionIds) {
+			String networkPartitionId = applicationPolicyNetworkPartitionReference;
     		// validate application policy against the given application
     		if (!isAppUsingNetworkPartitionId(applicationId, networkPartitionId)) {
     			String msg = String.format("Invalid Application Policy. "

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
index dc492d5..9ba8876 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
@@ -176,8 +176,8 @@ public class CloudControllerServiceUtil {
 			}
     		
     		// partition algorithm should be either one-after-another or round-robin
-    		if (!StratosConstants.ROUND_ROBIN_ALGORITHM_ID.equals(networkPartitionRef.getPartitionAlgo())
-    				&& !StratosConstants.ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(networkPartitionRef.getPartitionAlgo())) {
+    		if (!StratosConstants.PARTITION_ROUND_ROBIN_ALGORITHM_ID.equals(networkPartitionRef.getPartitionAlgo())
+    				&& !StratosConstants.PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(networkPartitionRef.getPartitionAlgo())) {
 				String msg = String.format("Invalid deployment policy - [deployment-policy-id] %s. "
 						+ "Cause -> Invalid partition algorithm - [network-partition-id] %s [partition-algo] %s", 
 						deploymentPolicy.getDeploymentPolicyID(), networkPartitionRef.getId(), networkPartitionRef.getPartitionAlgo());

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
index 0eb2551..547ca95 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
@@ -19,29 +19,49 @@
 
 package org.apache.stratos.common.beans.policy.deployment;
 
+import java.util.List;
+
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.stratos.common.beans.partition.ApplicationPolicyNetworkPartitionReferenceBean;
+import org.apache.stratos.common.beans.PropertyBean;
 
 @XmlRootElement
 public class ApplicationPolicyBean {
-
+	
 	private String id;
-    private ApplicationPolicyNetworkPartitionReferenceBean[] networkPartition;
-    
+	private String algorithm;
+	String[] networkPartitions;
+	List<PropertyBean> properties;
+
 	public String getId() {
 		return id;
 	}
-
+	
 	public void setId(String id) {
 		this.id = id;
 	}
-
-	public ApplicationPolicyNetworkPartitionReferenceBean[] getNetworkPartition() {
-		return networkPartition;
+	
+	public String getAlgorithm() {
+		return algorithm;
 	}
-
-	public void setNetworkPartition(ApplicationPolicyNetworkPartitionReferenceBean[] networkPartition) {
-		this.networkPartition = networkPartition;
+	
+	public void setAlgorithm(String algorithm) {
+		this.algorithm = algorithm;
+	}
+	
+	public String[] getNetworkPartitions() {
+		return networkPartitions;
+	}
+	
+	public void setNetworkPartitions(String[] networkPartitions) {
+		this.networkPartitions = networkPartitions;
+	}
+	
+	public List<PropertyBean> getProperties() {
+		return properties;
+	}
+	
+	public void setProperties(List<PropertyBean> properties) {
+		this.properties = properties;
 	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
index 8c6a140..4ca0411 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
@@ -195,7 +195,12 @@ public class StratosConstants {
     public static final String DEFAULT_CLIENT_CONNECTION_TIMEOUT = "300000";
     
     // partition algorithm id constants
-	public static final String ROUND_ROBIN_ALGORITHM_ID = "round-robin";
-	public static final String ONE_AFTER_ANOTHER_ALGORITHM_ID = "one-after-another";
+	public static final String PARTITION_ROUND_ROBIN_ALGORITHM_ID = "round-robin";
+	public static final String PARTITION_WEIGHTED_ROUND_ROBIN_ALGORITHM_ID = "weighted-round-robin";
+	public static final String PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID = "one-after-another";
+	// network partition algorithm id constants
+	public static final String NETWORK_PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID = "one-after-another";
+	public static final String NETWORK_PARTITION_WEIGHTED_ONE_AFTER_ANOTHER_ALGORITHM_ID = "weighted-one-after-another";
+	public static final String NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID = "all-at-once";
 }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index e50b14f..b105816 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -21,7 +21,6 @@ package org.apache.stratos.rest.endpoint.util.converter;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicy;
-import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicyNetworkPartitionReference;
 import org.apache.stratos.autoscaler.stub.pojo.*;
 import org.apache.stratos.autoscaler.stub.pojo.Dependencies;
 import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
@@ -393,27 +392,23 @@ public class ObjectConverter {
             return null;
         }
     	
-    	ApplicationPolicyNetworkPartitionReference[] applicationPolicyNetworkPartitionReferences = 
-    			applicationPolicy.getNetworkPartitionReferences();
-    	if (applicationPolicyNetworkPartitionReferences == null || applicationPolicyNetworkPartitionReferences.length == 0) {
-			return null;
-		}
-    	
-    	List<ApplicationPolicyNetworkPartitionReferenceBean> applicationPolicyNetworkPartitionReferenceBeans = 
-    			new ArrayList<ApplicationPolicyNetworkPartitionReferenceBean>();
-    	
-    	for (ApplicationPolicyNetworkPartitionReference applicationPolicyNetworkPartitionReference : applicationPolicyNetworkPartitionReferences) {
-			ApplicationPolicyNetworkPartitionReferenceBean applicationPolicyNetworkPartitionReferenceBean = new ApplicationPolicyNetworkPartitionReferenceBean();
-			applicationPolicyNetworkPartitionReferenceBean.setId(applicationPolicyNetworkPartitionReference.getNetworkPartitionId());
-			applicationPolicyNetworkPartitionReferenceBean.setActiveByDefault(applicationPolicyNetworkPartitionReference.getActiveByDefault());
-			applicationPolicyNetworkPartitionReferenceBeans.add(applicationPolicyNetworkPartitionReferenceBean);
-		}
-    	
-    	ApplicationPolicyNetworkPartitionReferenceBean[] applicationPolicyNetworkPartitionReferenceBeansArray = 
-    			applicationPolicyNetworkPartitionReferenceBeans.toArray(new ApplicationPolicyNetworkPartitionReferenceBean[applicationPolicyNetworkPartitionReferenceBeans.size()]);
     	ApplicationPolicyBean applicationPolicyBean = new ApplicationPolicyBean();
-    	applicationPolicyBean.setNetworkPartition(applicationPolicyNetworkPartitionReferenceBeansArray);
+    	applicationPolicyBean.setId(applicationPolicy.getId());
+    	applicationPolicyBean.setAlgorithm(applicationPolicy.getAlgorithm());
+    	applicationPolicyBean.setNetworkPartitions(applicationPolicy.getNetworkPartitions());
     	
+        if(applicationPolicy.getProperties() != null) {
+            List<org.apache.stratos.common.beans.PropertyBean> propertyBeanList = new ArrayList<org.apache.stratos.common.beans.PropertyBean>();
+            for(org.apache.stratos.autoscaler.stub.Property stubProperty : applicationPolicy.getProperties().getProperties()) {
+                if(stubProperty != null) {
+                    org.apache.stratos.common.beans.PropertyBean propertyBean = new org.apache.stratos.common.beans.PropertyBean();
+                    propertyBean.setName(stubProperty.getName());
+                    propertyBean.setValue(String.valueOf(stubProperty.getValue()));
+                    propertyBeanList.add(propertyBean);
+                }
+            }
+            applicationPolicyBean.setProperties(propertyBeanList);
+        }
     	
     	return applicationPolicyBean;
     }
@@ -472,6 +467,29 @@ public class ObjectConverter {
 		return properties;
 	}
 	
+	public static org.apache.stratos.autoscaler.stub.Properties getASPropertiesFromCommonProperties(List<org.apache.stratos.common.beans.PropertyBean> propertyBeans) {
+		if (propertyBeans == null || propertyBeans.isEmpty()) {
+			return null;
+		}
+
+		//convert to an array
+		org.apache.stratos.common.beans.PropertyBean[] propertyBeansArray = new org.apache.stratos.common.beans.PropertyBean[propertyBeans.size()];
+		propertyBeans.toArray(propertyBeansArray);
+		org.apache.stratos.autoscaler.stub.Property[] propertyArray =
+				new org.apache.stratos.autoscaler.stub.Property[propertyBeansArray.length];
+
+		for (int j = 0; j < propertyBeansArray.length; j++) {
+			org.apache.stratos.autoscaler.stub.Property property = new org.apache.stratos.autoscaler.stub.Property();
+			property.setName(propertyBeansArray[j].getName());
+			property.setValue(propertyBeansArray[j].getValue());
+			propertyArray[j] = property;
+		}
+
+		org.apache.stratos.autoscaler.stub.Properties properties = new org.apache.stratos.autoscaler.stub.Properties();
+		properties.setProperties(propertyArray);
+		return properties;
+	}
+	
 	public static org.apache.stratos.cloud.controller.stub.Properties getCCProperties(List<PropertyBean> propertyBeans) {
 		if (propertyBeans == null || propertyBeans.isEmpty()) {
 			return null;
@@ -1727,25 +1745,19 @@ public class ObjectConverter {
 	}
 	
 	public static ApplicationPolicy convertApplicationPolicyBeanToStubAppPolicy(
-	        ApplicationPolicyBean appPolicy) {
+	        ApplicationPolicyBean applicationPolicyBean) {
 		
-		if (appPolicy == null) {
+		if (applicationPolicyBean == null) {
 			return null;
 		}
 		
-		ApplicationPolicyNetworkPartitionReferenceBean[] nps = appPolicy.getNetworkPartition();
 		ApplicationPolicy applicationPolicy = new ApplicationPolicy();
-		applicationPolicy.setId(appPolicy.getId());
-		List<ApplicationPolicyNetworkPartitionReference> nprList = new ArrayList<ApplicationPolicyNetworkPartitionReference>();
-
-		for (ApplicationPolicyNetworkPartitionReferenceBean np : nps) {
-			ApplicationPolicyNetworkPartitionReference npRef = new ApplicationPolicyNetworkPartitionReference();
-			npRef.setActiveByDefault(np.isActiveByDefault());
-			npRef.setNetworkPartitionId(np.getId());
-			nprList.add(npRef);
+		applicationPolicy.setId(applicationPolicyBean.getId());
+		applicationPolicy.setAlgorithm(applicationPolicyBean.getAlgorithm());
+		applicationPolicy.setNetworkPartitions(applicationPolicyBean.getNetworkPartitions());
+		if (applicationPolicyBean.getProperties() != null || !applicationPolicyBean.getProperties().isEmpty()) {
+			applicationPolicy.setProperties(getASPropertiesFromCommonProperties(applicationPolicyBean.getProperties()));
 		}
-		applicationPolicy.setNetworkPartitionReferences(nprList
-		        .toArray(new ApplicationPolicyNetworkPartitionReference[nprList.size()]));
 		return applicationPolicy;
 	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9f564f29/samples/application-policies/application-policy.json
----------------------------------------------------------------------
diff --git a/samples/application-policies/application-policy.json b/samples/application-policies/application-policy.json
index 2c24d46..2e231b2 100644
--- a/samples/application-policies/application-policy.json
+++ b/samples/application-policies/application-policy.json
@@ -1,9 +1,15 @@
 {
-   "id" : "application-policy-1",
-   "networkPartition":[
-      {
-         "id":"network-partition-1",
-         "activeByDefault":"true"
-      }
-   ]
+    "id": "application-policy-1",
+    "algorithm":"all-at-once",
+    "networkPartitions":[
+        "network-partition-1"
+    ],
+    "properties":[
+        { 
+            "key1" : "value1" 
+        },
+        {
+            "key2" : "value2"
+        }
+    ]
 }