You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/06/28 21:27:27 UTC

[43/51] [partial] initial commit to apache incubator. Here just commit WSO2 Stratos code base as it is. After that will start re-factor code to apache

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/conf/util/TenantDomainRangeContext.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/conf/util/TenantDomainRangeContext.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/conf/util/TenantDomainRangeContext.java
new file mode 100644
index 0000000..cdde5e6
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/conf/util/TenantDomainRangeContext.java
@@ -0,0 +1,149 @@
+/*
+*  Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.wso2.carbon.lb.common.conf.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+//public class TenantDomainRangeContext {
+//    
+//    private static final Log log = LogFactory.getLog(TenantDomainRangeContext.class);
+//    
+//    /**
+//     * Map is used instead of using a list, in order to minimize the lookup time.
+//     * key - host name
+//     * Value - A map with tenant id as key and TenantDomainContext object as value
+//     */
+//    private Map<String, Map<Integer, TenantDomainContext>> tenantDomainContextMap = new HashMap<String, Map<Integer, TenantDomainContext>>();
+//
+//    /**
+//     * This method will populate the {@link #tenantDomainContextMap} with <code>TenantDomainContext</code>
+//     * objects created for all the tenants covered by the given range.
+//     */
+//    public void addTenantDomain(String domain, String subDomain, String tenantRange) {
+//        
+//        String msg = "Invalid tenant range is specified for domain " + domain+" - sub domain "+subDomain;
+//
+//        String[] parsedLine = tenantRange.trim().split("-");
+//        
+//        if (parsedLine[0].equalsIgnoreCase("*")) {
+//            
+//            tenantDomainContextMap.put(0, new TenantDomainContext(0, domain, subDomain));
+//
+//        } else if (parsedLine.length == 1) {
+//            
+//            try {
+//                
+//                int tenantId = Integer.parseInt(tenantRange);
+//                
+//                tenantDomainContextMap.put(tenantId, new TenantDomainContext(tenantId, domain, subDomain));
+//                
+//            } catch (NumberFormatException e) {
+//                
+//                log.error(msg, e);
+//                throw new RuntimeException(msg, e);
+//            }
+//
+//        } else if (parsedLine.length == 2) {
+//            
+//            try {
+//                int startIndex = Integer.parseInt(parsedLine[0]);
+//                int endIndex = Integer.parseInt(parsedLine[1]);
+//                
+//                for (int tenantId = startIndex; tenantId <= endIndex; tenantId++) {
+//                    
+//                    tenantDomainContextMap.put(tenantId, new TenantDomainContext(tenantId, domain, subDomain));
+//                    
+//                }
+//            } catch (NumberFormatException e) {
+//                log.error(msg, e);
+//                throw new RuntimeException(msg, e);
+//            }
+//            
+//        } else {
+//            log.error(msg);
+//            throw new RuntimeException(msg);
+//        }
+//
+//    }
+//
+////    private void addToTenantDomainRangeContextMap(
+////                                                  String domain, String subDomain,
+////                                                  String tenantRange) {
+////
+////        Map<String, String> map ;
+////        
+////        if(tenantDomainRangeContextMap.containsKey(domain)){
+////            map = tenantDomainRangeContextMap.get(domain);
+////        }
+////        else{
+////            map = new HashMap<String, String>();
+////        }
+////        // put this tenant range
+////        map.put(subDomain, tenantRange);
+////        
+////        // update the parent map
+////        tenantDomainRangeContextMap.put(domain, map);
+////    }
+////
+////    public Map<Integer, String> getTenantIDClusterDomainMap() {
+////        return this.tenantIDClusterDomainMap;
+////    }
+////    
+////    public Map<Integer, String> getTenantIDClusterSubDomainMap() {
+////        return this.tenantIDClusterSubDomainMap;
+////    }
+//
+//    /**
+//     * Given a tenant id, this will return its domain.
+//     * @param id tenant id
+//     * @return domain which this tenant belongs to.
+//     */
+//    public String getClusterDomainFromTenantId(int id) {
+//        
+//        if(tenantDomainContextMap.get(id) == null){
+//            // if there's no specific domain for this tenant, we will redirect it to the default cluster
+//            return tenantDomainContextMap.get(0).getDomain();
+//        }
+//        
+//        return tenantDomainContextMap.get(id).getDomain();
+//        
+//    }
+//    
+//    /**
+//     * Given a tenant id, this will return its sub domain.
+//     * @param id tenant id
+//     * @return sub domain which this tenant belongs to.
+//     */
+//    public String getClusterSubDomainFromTenantId(int id) {
+//        
+//        if(tenantDomainContextMap.get(id) == null){
+//            // if there's no specific domain for this tenant, we will redirect it to the default cluster
+//            return tenantDomainContextMap.get(0).getSubDomain();
+//        }
+//        
+//        return tenantDomainContextMap.get(id).getSubDomain();
+//    }
+//
+//    public Map<Integer, TenantDomainContext> getTenantDomainContextMap() {
+//        return tenantDomainContextMap;
+//    }
+//}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/group/mgt/SubDomainAwareGroupManagementAgent.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/group/mgt/SubDomainAwareGroupManagementAgent.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/group/mgt/SubDomainAwareGroupManagementAgent.java
new file mode 100644
index 0000000..570a5d7
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/group/mgt/SubDomainAwareGroupManagementAgent.java
@@ -0,0 +1,57 @@
+/*
+*  Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.wso2.carbon.lb.common.group.mgt;
+
+import org.apache.axis2.clustering.Member;
+import org.apache.axis2.clustering.management.DefaultGroupManagementAgent;
+import org.apache.synapse.endpoints.dispatch.SALSessions;
+import org.wso2.carbon.lb.common.conf.util.Constants;
+
+/**
+ * This GroupManagementAgent can handle group membership based on cluster sub-domains.
+ */
+public class SubDomainAwareGroupManagementAgent extends DefaultGroupManagementAgent {
+
+    private String subDomain;
+
+    public SubDomainAwareGroupManagementAgent(String subDomain) {
+        this.subDomain = subDomain;
+    }
+
+    @Override
+    public void applicationMemberAdded(Member member) {
+        String subDomain = member.getProperties().getProperty("subDomain");
+        if ((subDomain == null && Constants.DEFAULT_SUB_DOMAIN.equals(this.subDomain)) ||
+            subDomain.equals(this.subDomain)) {
+            super.applicationMemberAdded(member);
+        }
+    }
+
+    @Override
+    public void applicationMemberRemoved(Member member) {
+        
+        // remove the sessions bound with this member
+        SALSessions.getInstance().removeSessionsOfMember(member);
+        
+        String subDomain = member.getProperties().getProperty("subDomain");
+        if ((subDomain == null && Constants.DEFAULT_SUB_DOMAIN.equals(this.subDomain)) ||
+            subDomain.equals(this.subDomain)) {
+            super.applicationMemberRemoved(member);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/replication/RequestTokenReplicationCommand.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/replication/RequestTokenReplicationCommand.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/replication/RequestTokenReplicationCommand.java
new file mode 100644
index 0000000..24562f5
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/replication/RequestTokenReplicationCommand.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * 
+ * WSO2 Inc. 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.wso2.carbon.lb.common.replication;
+
+import org.apache.axis2.clustering.ClusteringCommand;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.ClusteringMessage;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+
+/**
+ * This is the notification message a primary load balancer will send to all other load balancers
+ * in the cluster, to replicate its state. When the other load balancers received this message, 
+ * they will set their states to the state of primary load balancer.
+ */
+public class RequestTokenReplicationCommand extends ClusteringMessage {
+
+    private static final long serialVersionUID = -7897961078018830555L;
+    private static final Log log = LogFactory.getLog(RequestTokenReplicationCommand.class);
+    private Map<String, Map<String, ?>> appDomainContexts;
+
+    public Map<String, Map<String, ?>> getAppDomainContexts() {
+        return appDomainContexts;
+    }
+
+    public void setAppDomainContexts(Map<String, Map<String, ?>> appDomainContexts) {
+        this.appDomainContexts = appDomainContexts;
+    }
+
+    public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+        // set the appDomainContexts map
+        configurationContext.setNonReplicableProperty("autoscale.app.domain.contexts",
+                                          getAppDomainContexts());
+        
+        log.info("Request Tokens Replicated! ");
+    }
+
+    public String toString() {
+        return "Replication message sent!";
+    }
+
+    @Override
+    public ClusteringCommand getResponse() {
+        return new ClusteringCommand() {
+            
+            private static final long serialVersionUID = -8271265673996681347L;
+
+            @Override
+            public void execute(ConfigurationContext arg0) throws ClusteringFault {
+                // do nothing
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/LoadBalancerConfigurationService.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/LoadBalancerConfigurationService.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/LoadBalancerConfigurationService.java
new file mode 100644
index 0000000..9499b20
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/LoadBalancerConfigurationService.java
@@ -0,0 +1,79 @@
+/*
+*  Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.wso2.carbon.lb.common.service;
+
+import java.util.Map;
+
+import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
+import org.wso2.carbon.lb.common.conf.util.HostContext;
+
+/**
+ * This service provides a way to consume details in loadbalancer.conf file.
+ * Also to update the runtime object model of loadbalancer conf.
+ */
+public interface LoadBalancerConfigurationService {
+
+    /**
+     * Provides a reference to the runtime object model of loadbalancer.conf
+     * @return {@link Object} which is an instance of {@link LoadBalancerConfiguration} 
+     */
+    public Object getLoadBalancerConfig();
+    
+//    /**
+//     * Return a {@link Map} of {@link HostContext} objects, built using the given config.
+//     * @param config service configuration.
+//     * @return {@link Map} {@link Object}
+//     */
+//    public Object getHostContext(String config);
+    
+    /**
+     * Return a {@link Map} of {@link HostContext} objects, built using the given configuration.
+     * @param config service configuration diff. This can be in following format.
+     * 
+     * <p/>
+     * appserver {
+     * hosts                   appserver.cloud-test.wso2.com;
+     * domains   {
+     * 		wso2.as1.domain {
+     * 			tenant_range    1-100;
+     * 		}
+     *		wso2.as2.domain {
+     * 			tenant_range    101-200;
+     * 		}
+     * 		wso2.as3.domain {
+     *	 		tenant_range    *;
+     * 		}
+     * 	}
+     * } 
+     * <p/>
+     * esb {
+     * hosts                   esb.cloud-test.wso2.com;
+     * domains   {
+     * 		wso2.esb.domain {
+     *	 		tenant_range    *;
+     * 		}
+     * 	}
+     * }
+     * <p/>
+     * @return a {@link Map} of {@link HostContext} objects.
+     * key - host name
+     * Value - {@link HostContext}
+     */
+    public Object getHostContexts(String config) ;
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/impl/LoadBalancerConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/impl/LoadBalancerConfigurationServiceImpl.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/impl/LoadBalancerConfigurationServiceImpl.java
new file mode 100644
index 0000000..532c94d
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/service/impl/LoadBalancerConfigurationServiceImpl.java
@@ -0,0 +1,61 @@
+/*
+*  Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.wso2.carbon.lb.common.service.impl;
+
+import java.util.Map;
+
+import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
+import org.wso2.carbon.lb.common.conf.structure.Node;
+import org.wso2.carbon.lb.common.conf.structure.NodeBuilder;
+import org.wso2.carbon.lb.common.conf.util.Constants;
+import org.wso2.carbon.lb.common.conf.util.HostContext;
+import org.wso2.carbon.lb.common.service.LoadBalancerConfigurationService;
+import com.google.common.collect.MapDifference;
+import com.google.common.collect.Maps;
+
+public class LoadBalancerConfigurationServiceImpl implements LoadBalancerConfigurationService {
+
+    @Override
+    public Object getLoadBalancerConfig() {
+        return LoadBalancerConfiguration.getInstance();
+    }
+
+	@Override
+    public Object getHostContexts(String config) {
+
+		// build a Node object for whole loadbalancer.conf
+        Node rootNode = new Node();
+        rootNode.setName(Constants.SERVICES_ELEMENT);
+        rootNode = NodeBuilder.buildNode(rootNode, config);
+		
+        Map<String, HostContext> oldMap = LoadBalancerConfiguration.getInstance().getHostContextMap();
+        LoadBalancerConfiguration.getInstance().createServicesConfig(rootNode);
+        
+//        MapDifference<String, HostContext> diff = Maps.difference(LoadBalancerConfiguration.getInstance().getHostContextMap(),
+//                                                             oldMap );
+//		
+//		return diff.entriesOnlyOnLeft();
+        return LoadBalancerConfiguration.getInstance().getHostContextMap();
+    }
+
+//	@Override
+//    public Object getHostContext(String config) {
+//	    return null;
+//    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/util/DomainMapping.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/util/DomainMapping.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/util/DomainMapping.java
new file mode 100644
index 0000000..d543b05
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/java/org/wso2/carbon/lb/common/util/DomainMapping.java
@@ -0,0 +1,22 @@
+package org.wso2.carbon.lb.common.util;
+
+/**
+ *
+ */
+public class DomainMapping {
+    private String mapping;
+    private String actualHost;
+
+    public DomainMapping(String mapping) {
+        this.mapping = mapping;
+    }
+
+    public String getActualHost() {
+        return actualHost;
+    }
+
+    public void setActualHost(String actualHost) {
+        this.actualHost = actualHost;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/resources/META-INF/services.xml b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..b50b721
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/main/resources/META-INF/services.xml
@@ -0,0 +1,9 @@
+<serviceGroup>
+    <service name="LoadBalancerConfigurationService" scope="application">
+        <parameter name="ServiceClass">org.wso2.carbon.lb.common.service.impl.LoadBalancerConfigurationServiceImpl</parameter>
+        <messageReceivers>
+        <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
+        <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
+    </messageReceivers>
+    </service>
+</serviceGroup> 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/AgentPersistenceManagerTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/AgentPersistenceManagerTest.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/AgentPersistenceManagerTest.java
new file mode 100644
index 0000000..c49cf37
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/AgentPersistenceManagerTest.java
@@ -0,0 +1,267 @@
+//package org.wso2.carbon.lb.common.test;
+//
+//import java.sql.SQLException;
+//
+//import org.testng.Assert;
+//import org.testng.annotations.Test;
+//import org.testng.annotations.BeforeMethod;
+//import org.testng.annotations.AfterMethod;
+//import org.testng.annotations.DataProvider;
+//import org.testng.annotations.BeforeClass;
+//import org.testng.annotations.AfterClass;
+//import org.testng.annotations.BeforeTest;
+//import org.testng.annotations.AfterTest;
+//import org.testng.annotations.BeforeSuite;
+//import org.testng.annotations.AfterSuite;
+//import org.wso2.carbon.lb.common.dto.Bridge;
+//import org.wso2.carbon.lb.common.dto.HostMachine;
+//import org.wso2.carbon.lb.common.dto.Zone;
+//
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+//import org.wso2.carbon.lb.common.persistence.AgentPersistenceManager;
+//
+///**
+// * This test class is there to test the database access methods. There is a testng.xml to run these
+// * tests as a suit. It's located at test/resources. Currently it is disabled by commenting the class
+// * element at the xml file. Mysql driver dependancy at pom.xml is also disabled and it should be
+// * uncommented to support database activities.
+// */
+//public class AgentPersistenceManagerTest {
+//	
+//	private static final Log log = LogFactory.getLog(AgentPersistenceManagerTest.class);;
+//	
+////  @Test(dataProvider = "dp")
+////  public void f(Integer n, String s) {
+////  }
+//  @BeforeMethod
+//  public void beforeMethod() {
+//  }
+//
+//  @AfterMethod
+//  public void afterMethod() {
+//  }
+//
+//
+//  @DataProvider
+//  public Object[][] dataProviderForDAO() {
+//  
+//	  String epr = "epr4";
+//	  String zoneName = "zone1";
+//      Bridge[] bridges = new Bridge[3];
+//      bridges[0] = new Bridge();
+//      bridges[1] = new Bridge();
+//      bridges[2] = new Bridge();
+//
+//      bridges[0].setBridgeIp("168.192.1.0");
+//      bridges[0].setAvailable(true);
+//      bridges[0].setCurrentCountIps(0);
+//      bridges[0].setMaximumCountIps(100);
+//      bridges[0].setNetGateway("net_gateway");
+//      bridges[0].setNetMask("net_mask");
+//      bridges[0].setHostMachine(epr);
+//
+//      bridges[1].setBridgeIp("168.192.2.0");
+//      bridges[1].setAvailable(true);
+//      bridges[1].setCurrentCountIps(0);
+//      bridges[1].setMaximumCountIps(100);
+//      bridges[1].setNetGateway("net_gateway");
+//      bridges[1].setNetMask("net_mask");
+//      bridges[1].setHostMachine(epr);
+//
+//      bridges[2].setBridgeIp("168.192.3.0");
+//      bridges[2].setAvailable(true);
+//      bridges[2].setCurrentCountIps(0);
+//      bridges[2].setMaximumCountIps(100);
+//      bridges[2].setNetGateway("net_gateway");
+//      bridges[2].setNetMask("net_mask");
+//      bridges[2].setHostMachine(epr);
+//
+//
+//      HostMachine hostMachine = new HostMachine();
+//      hostMachine.setAvailable(true);
+//      hostMachine.setContainerRoot("ContainerRoot");
+//      hostMachine.setIp("ip");
+//      hostMachine.setZone(zoneName);
+//      hostMachine.setBridges(bridges);
+//      hostMachine.setEpr(epr);
+//      
+//      String[] domains = new String[2];
+//      domains[0] = "domian1";
+//      domains[1] = "domain2";
+//      
+//      
+//    return new Object[][] {
+//      new Object[] { hostMachine, domains },
+//    };
+//  }
+//  @BeforeClass
+//  public void beforeClass() {
+//  }
+//
+//  @AfterClass
+//  public void afterClass() {
+//  }
+//
+//  @BeforeTest
+//  public void beforeTest() {
+//  }
+//
+//  @AfterTest
+//  public void afterTest() {
+//  }
+//
+//  @BeforeSuite
+//  public void beforeSuite() {
+//  }
+//
+//  @AfterSuite
+//  public void afterSuite() {
+//  }
+//
+//
+////  @Test
+////  public void addContainer() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+//  
+//  @Test(dataProvider="dataProviderForDAO")
+//  public void addZone(HostMachine hostMachine, String[] domains)  {
+//	  AgentPersistenceManager agentPersistenceManager = AgentPersistenceManager.getPersistenceManager();
+//	  boolean isAdded = false;
+//	  boolean zoneExists = false;
+//      try {
+//    	  zoneExists = agentPersistenceManager.isZoneExist(hostMachine.getZone());
+//		if (!zoneExists) {
+//		      String msg = "Zone does not exists ";
+//		      System.out.println(msg);
+//		      Zone zone = new Zone();
+//		      zone.setName(hostMachine.getZone());
+//		      zone.setAvailable(true);
+//		      isAdded = agentPersistenceManager.addZone(zone, domains);
+//		  } else {
+//		      String msg = "Zone exist";
+//		      System.out.println(msg);
+//		  }
+//	} catch (SQLException e) {
+//		  String msg = "Test failure while adding zone";
+//		  log.error(msg);
+//	}
+//      System.out.println("zone added " + isAdded);
+//      if(!zoneExists){
+//    	  Assert.assertEquals(isAdded, true);
+//      }else{
+//    	  Assert.assertEquals(isAdded, false );
+//      }
+//  }
+//  
+//  @Test(dataProvider="dataProviderForDAO")
+//  public void addHostMachine(HostMachine hostMachine, String[] domains)  {
+//
+//
+//
+//	  AgentPersistenceManager agentPersistenceManager = AgentPersistenceManager.getPersistenceManager();
+//      boolean isAdded = false;
+//	  try {
+//		  isAdded = agentPersistenceManager.addHostMachine(hostMachine, domains);
+//	  } catch (SQLException e) {
+//		  String msg = "Test failure while adding host machine";
+//		  log.error(msg);
+//	  }
+//      System.out.println(" HM added " + isAdded);
+//      Assert.assertEquals(isAdded, true);
+//
+//  }
+//
+//    @Test(dataProvider="dataProviderForDAO")
+//    public void deleteHostMachine(HostMachine hostMachine) {
+//        AgentPersistenceManager agentPersistenceManager = AgentPersistenceManager.getPersistenceManager();
+//        boolean isDeleted = false;
+//
+//        try {
+//            isDeleted = agentPersistenceManager.deleteHostMachine(hostMachine.getEpr());
+//        } catch (SQLException e) {
+//            String msg = "Test failure while deleting host machine";
+//            log.error(msg);
+//        }
+//
+//    }
+////
+////  @Test
+////  public void addInstance() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+//  
+////
+////  @Test
+////  public void changeContainerState() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void changeHostMachineAvailability() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void deleteContainer() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+//
+////
+////  @Test
+////  public void getPersistenceManager() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void isDomainExist() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void isHostMachineExist() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void isHostMachinesAvailableInDomain() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void isZoneExist() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void retrieveAgentToContainerRootMap() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void retrieveAvailableContainerInformation() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void retrieveContainerIdToAgentMap() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void retrieveDomainToInstanceIdsMap() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void retrieveInstanceIdToAdapterMap() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+////
+////  @Test
+////  public void updateDomainConfigs() {
+////    throw new RuntimeException("Test not implemented");
+////  }
+//}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/LoadBalancerConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/LoadBalancerConfigurationTest.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/LoadBalancerConfigurationTest.java
new file mode 100644
index 0000000..124d552
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/LoadBalancerConfigurationTest.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * 
+ * WSO2 Inc. 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.wso2.carbon.lb.common.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
+import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration.ServiceConfiguration;
+import org.wso2.carbon.lb.common.conf.util.HostContext;
+
+import junit.framework.TestCase;
+
+public class LoadBalancerConfigurationTest extends TestCase {
+    
+    private LoadBalancerConfiguration lbConfig ;
+    private LoadBalancerConfiguration lbConfig1;
+    
+    
+    @Override
+    protected void setUp() throws Exception {
+
+        LoadBalancerConfiguration.setInstance(null);
+        File f = new File("src/test/resources/loadbalancer.conf");
+        System.setProperty("loadbalancer.conf", f.getAbsolutePath());
+        lbConfig = LoadBalancerConfiguration.getInstance();
+    }
+    
+    public final void testCreateLoadBalancerConfig() {
+
+        LoadBalancerConfiguration.LBConfiguration loadBalancerConfig =
+            lbConfig.getLoadBalancerConfig();
+        
+        assertEquals(1, loadBalancerConfig.getInstances());
+        assertEquals(5000, loadBalancerConfig.getAutoscalerTaskInterval());
+        assertEquals(15000, loadBalancerConfig.getServerStartupDelay());
+    }
+
+    public final void testCreateServicesConfig() {
+
+        /* Tests relavant to loadbalancer.conf file */
+        
+        ServiceConfiguration asServiceConfig =
+                                               lbConfig.getServiceConfig("wso2.as1.domain",
+                                                                         "worker");
+
+        assertEquals(1, asServiceConfig.getInstancesPerScaleUp());
+        assertEquals(5, asServiceConfig.getMaxAppInstances());
+        assertEquals(0, asServiceConfig.getMinAppInstances());
+        assertEquals(60000, asServiceConfig.getMessageExpiryTime());
+        assertEquals(400, asServiceConfig.getMaxRequestsPerSecond());
+        assertEquals(0.65, asServiceConfig.getAlarmingUpperRate());
+        assertEquals(10, asServiceConfig.getRoundsToAverage());
+        assertEquals("worker", asServiceConfig.getSubDomain());
+
+        asServiceConfig = lbConfig.getServiceConfig("wso2.as2.domain", "worker1");
+        assertEquals("worker1", asServiceConfig.getSubDomain());
+
+        asServiceConfig = lbConfig.getServiceConfig("wso2.esb.domain", "mgt");
+        assertEquals("mgt", asServiceConfig.getSubDomain());
+
+        assertEquals(2, lbConfig.getHostNamesTracker().keySet().size());
+        assertEquals(3, lbConfig.getHostNamesTracker().get("appserver").size());
+        assertEquals(2, lbConfig.getHostNamesTracker().get("esb").size());
+
+        for (HostContext ctx : lbConfig.getHostContextMap().values()) {
+
+            if (ctx.getHostName().equals("appserver.cloud-test.wso2.com")) {
+
+                assertEquals("nirmal", ctx.getSubDomainFromTenantId(30));
+                assertEquals(18, ctx.getTenantDomainContexts().size());
+            } else if (ctx.getHostName().equals("as2.cloud-test.wso2.com")) {
+                assertEquals("worker", ctx.getSubDomainFromTenantId(2));
+            } else if (ctx.getHostName().equals("esb.cloud-test.wso2.com")) {
+                assertEquals("mgt", ctx.getSubDomainFromTenantId(5));
+            }
+        }
+        
+        /* tests relevant to loadbalancer1.conf file */
+        
+        File f = new File("src/test/resources/loadbalancer2.conf");
+        System.setProperty("loadbalancer.conf", f.getAbsolutePath());
+        
+        LoadBalancerConfiguration.setInstance(null);
+        lbConfig1 = LoadBalancerConfiguration.getInstance();
+        
+        for (HostContext ctx : lbConfig1.getHostContextMap().values()) {
+
+            if (ctx.getHostName().equals("appserver.cloud-test.wso2.com")) {
+
+                assertEquals("nirmal", ctx.getSubDomainFromTenantId(30));
+                assertEquals("wso2.as1.domain", ctx.getDomainFromTenantId(5));
+                assertEquals("wso2.as.domain", ctx.getDomainFromTenantId(8));
+                assertEquals("wso2.as.domain", ctx.getDomainFromTenantId(2));
+                assertEquals(4, ctx.getTenantDomainContexts().size());
+                
+            } else if (ctx.getHostName().equals("esb.cloud-test.wso2.com")) {
+                
+                assertEquals("mgt", ctx.getSubDomainFromTenantId(5));
+            }
+        }
+
+    }
+
+    public final void testGetServiceDomains() throws Exception {
+
+        setUp();
+        String[] serviceDomains = lbConfig.getServiceDomains();
+        assertEquals(4, serviceDomains.length);
+        
+        assertTrue("wso2.as1.domain".equals(serviceDomains[0]) ||
+            "wso2.as1.domain".equals(serviceDomains[1]) ||
+            "wso2.as1.domain".equals(serviceDomains[2]) ||
+            "wso2.as1.domain".equals(serviceDomains[3]));
+        
+        assertTrue("wso2.as2.domain".equals(serviceDomains[0]) ||
+            "wso2.as2.domain".equals(serviceDomains[1]) ||
+            "wso2.as2.domain".equals(serviceDomains[2]) ||
+            "wso2.as2.domain".equals(serviceDomains[3]));
+        
+        assertTrue("wso2.as3.domain".equals(serviceDomains[0]) ||
+            "wso2.as3.domain".equals(serviceDomains[1]) ||
+            "wso2.as3.domain".equals(serviceDomains[2]) ||
+            "wso2.as3.domain".equals(serviceDomains[3]));
+        
+        assertTrue("wso2.esb.domain".equals(serviceDomains[0]) ||
+                   "wso2.esb.domain".equals(serviceDomains[1]) ||
+                   "wso2.esb.domain".equals(serviceDomains[2]) ||
+                   "wso2.esb.domain".equals(serviceDomains[3]));
+        
+    }
+    
+    public final void testGetServiceSubDomains() throws Exception {
+
+        setUp();
+        String[] serviceSubDomains = lbConfig.getServiceSubDomains("wso2.as3.domain");
+        assertEquals(2, serviceSubDomains.length);
+        
+        assertTrue("nirmal".equals(serviceSubDomains[0]) ||
+            "nirmal".equals(serviceSubDomains[1]));
+        
+        assertTrue("nirmal2".equals(serviceSubDomains[0]) ||
+            "nirmal2".equals(serviceSubDomains[1]));
+        
+        serviceSubDomains = lbConfig.getServiceSubDomains("wso2.esb.domain");
+        assertEquals(2, serviceSubDomains.length);
+        
+        serviceSubDomains = lbConfig.getServiceSubDomains("wso2.as1.domain");
+        assertEquals(1, serviceSubDomains.length);
+        
+        
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/NodeBuilderTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/NodeBuilderTest.java b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/NodeBuilderTest.java
new file mode 100644
index 0000000..a75484b
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/java/org/wso2/carbon/lb/common/test/NodeBuilderTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * 
+ * WSO2 Inc. 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.wso2.carbon.lb.common.test;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.wso2.carbon.lb.common.conf.structure.Node;
+import org.wso2.carbon.lb.common.conf.structure.NodeBuilder;
+
+public class NodeBuilderTest extends TestCase {
+
+    String content;
+
+    public void setUp() throws Exception {
+    }
+
+    public final void testBuildNode() {
+
+        // Testing a node only has properties
+        Node a = new Node();
+        a.setName("loadbalancer");
+
+        content =
+            "securityGroups      stratos-appserver-lb;\ninstanceType        m1.large;\n"
+                + "instances           1;\nelasticIP           ${ELASTIC_IP};\n"
+                + "availabilityZone    us-east-1c;\npayload             /mnt/payload.zip;";
+
+        a = NodeBuilder.buildNode(a, content);
+
+        Assert.assertEquals("loadbalancer", a.getName());
+        Assert.assertEquals("stratos-appserver-lb", a.getProperty("securityGroups"));
+        Assert.assertEquals("${ELASTIC_IP}", a.getProperty("elasticIP"));
+        Assert.assertEquals("/mnt/payload.zip", a.getProperty("payload"));
+        Assert.assertNull(a.getProperty("payloader"));
+
+        // Testing a node has sub nodes and properties
+        a = new Node();
+        a.setName("appserver");
+
+        content =
+            "hosts                   appserver.cloud-test.wso2.com,as.cloud-test.wso2.com;\n"
+                + "domains   {\n" + "wso2.as1.domain {\n" + "tenant_range    1-100;\n" + "}\n"
+                + "wso2.as2.domain {\n" + "tenant_range    101-200;\n" + "}\n"
+                + "wso2.as3.domain { # domain\n" + "tenant_range    *;\n" + "}\n" + "}\n"
+                + "# line comment \n"
+                + "payload                 resources/cluster_node.zip;# payload\n"
+                + "availability_zone       us-east-1c;\n";
+
+        a = NodeBuilder.buildNode(a, content);
+
+        Assert.assertEquals("appserver", a.getName());
+        Assert.assertEquals(1, a.getChildNodes().size());
+        Assert.assertEquals("domains", a.getChildNodes().get(0).getName());
+        Assert.assertEquals("appserver.cloud-test.wso2.com,as.cloud-test.wso2.com",
+                            a.getProperty("hosts"));
+        Assert.assertEquals("resources/cluster_node.zip", a.getProperty("payload"));
+        Assert.assertEquals(null, a.getProperty("payloader"));
+
+        Node b = a.getChildNodes().get(0);
+
+        Assert.assertEquals(3, b.getChildNodes().size());
+        Assert.assertEquals(null, b.getProperty("payload"));
+
+        Node c = b.getChildNodes().get(0);
+
+        Assert.assertEquals(0, c.getChildNodes().size());
+        Assert.assertEquals("1-100", c.getProperty("tenant_range"));
+
+        c = b.getChildNodes().get(2);
+
+        Assert.assertEquals(0, c.getChildNodes().size());
+        Assert.assertEquals("*", c.getProperty("tenant_range"));
+        
+        String nodeStr = "appserver {\n" +
+                "\thosts\tappserver.cloud-test.wso2.com,as.cloud-test.wso2.com;\n" +
+                "\tpayload\tresources/cluster_node.zip;\n" +
+        		"\tavailability_zone\tus-east-1c;\n" +
+        		"\tdomains {\n" +
+        		"\t\twso2.as1.domain {\n" +
+        		"\t\t\ttenant_range\t1-100;\n" +
+        		"\t\t}\n" +
+        		"\t\twso2.as2.domain {\n" +
+        		"\t\t\ttenant_range\t101-200;\n" +
+        		"\t\t}\n" +
+        		"\t\twso2.as3.domain {\n" +
+        		"\t\t\ttenant_range\t*;\n" +
+        		"\t\t}\n" +
+        		"\t}\n" +
+        		"}";
+        
+        assertEquals(nodeStr, a.toString());
+        
+        // test equals method
+        assertEquals(true, a.equals(a));
+        assertEquals(false, a.equals(b));
+        assertEquals(false, c.equals(b));
+        
+        // test buildNode(String)
+        c = NodeBuilder.buildNode(nodeStr);
+        
+        assertEquals(c.getName(), "appserver");
+        assertEquals(c.getChildNodes().size(), 1);
+        assertEquals(c.getProperty("availability_zone"), "us-east-1c");
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer.conf
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer.conf b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer.conf
new file mode 100644
index 0000000..b2fd44f
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer.conf
@@ -0,0 +1,64 @@
+loadbalancer {
+    instances	1;
+    enable_autoscaler	true;
+    # interval between two task executions in milliseconds
+    autoscaler_task_interval	5000;
+    # after an instance booted up, task will wait till this much of time and let the server started up
+    server_startup_delay		15000; #default will be 60000ms
+}
+
+services {
+    defaults {
+        min_app_instances 1;
+        max_app_instances       5;
+        max_requests_per_second   400;
+        alarming_upper_rate 0.65;
+        alarming_lower_rate 0.2;
+        scale_down_factor 0.25;
+        rounds_to_average       10;
+        instances_per_scale_up  1;
+        message_expiry_time     60000;
+    }
+
+    appserver {
+        hosts                   appserver.cloud-test.wso2.com, as.cloud-test.wso2.com;
+        sub_domain      worker1;
+        domains   {
+            wso2.as1.domain {
+            	hosts as2.cloud-test.wso2.com;
+            	  min_app_instances   0;
+            	  sub_domain      worker;
+                tenant_range    1-5;
+            }
+            wso2.as2.domain {
+                tenant_range    7;
+            }
+            wso2.as3.domain {
+                sub_domain nirmal;
+                tenant_range    10-20;
+            }
+            
+            wso2.as3.domain {
+                sub_domain nirmal2;
+                tenant_range    21-25;
+            }
+            
+            wso2.esb.domain {
+            	sub_domain nirmal;
+                tenant_range    *;
+            }
+        }
+    }
+    
+    esb {
+        hosts                   esb.cloud-test.wso2.com,mgt.as.cloud-test.wso2.com;
+        domains   {
+            wso2.esb.domain {
+                sub_domain      mgt;
+                tenant_range    *;
+            }
+        }
+    }
+
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer1.conf
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer1.conf b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer1.conf
new file mode 100644
index 0000000..8b87a32
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer1.conf
@@ -0,0 +1,39 @@
+loadbalancer {
+    instances	1;
+    enable_autoscaler	true;
+    # interval between two task executions in milliseconds
+    autoscaler_task_interval	5000;
+    # after an instance booted up, task will wait till this much of time and let the server started up
+    server_startup_delay		15000; #default will be 60000ms
+}
+
+services {
+
+    appserver {
+        hosts                   appserver.cloud-test.wso2.com, as.cloud-test.wso2.com;
+        sub_domain      worker1;
+        domains   {
+            
+            wso2.as.domain {
+            	sub_domain nirmal;
+                tenant_range    *;
+            }
+            wso2.as1.domain {
+            	sub_domain nirmal;
+                tenant_range    5-7;
+            }
+        }
+    }
+    
+    esb {
+        hosts                   esb.cloud-test.wso2.com, mgt.as.cloud-test.wso2.com;
+        domains   {
+            wso2.esb.domain {
+                sub_domain      mgt;
+                tenant_range    *;
+            }
+        }
+    }
+
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer2.conf
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer2.conf b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer2.conf
new file mode 100644
index 0000000..718d881
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/loadbalancer2.conf
@@ -0,0 +1,30 @@
+services {
+
+    appserver {
+        hosts                   appserver.cloud-test.wso2.com, as.cloud-test.wso2.com;
+        sub_domain      worker1;
+        domains   {
+            
+            wso2.as.domain {
+            	sub_domain nirmal;
+                tenant_range    *;
+            }
+            wso2.as1.domain {
+            	sub_domain nirmal;
+                tenant_range    5-7;
+            }
+        }
+    }
+    
+    esb {
+        hosts                   esb.cloud-test.wso2.com, mgt.as.cloud-test.wso2.com;
+        domains   {
+            wso2.esb.domain {
+                sub_domain      mgt;
+                tenant_range    *;
+            }
+        }
+    }
+
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/testng.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/testng.xml b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/testng.xml
new file mode 100644
index 0000000..44b9822
--- /dev/null
+++ b/components/load-balancer/org.wso2.carbon.lb.common/4.1.3/src/test/resources/testng.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="Default suite">
+  <test verbose="2" name="Default test">
+    <classes>
+      <!--class name="org.wso2.carbon.lb.common.test.AgentPersistenceManagerTest">
+          <methods>
+            <include name="addZone" />
+              <include name="addHostMachine" />
+              <include name="deleteHostMachine" />
+          </methods>
+      </class-->
+    </classes>
+  </test>
+</suite>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/load-balancer/pom.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/pom.xml b/components/load-balancer/pom.xml
new file mode 100644
index 0000000..4c60b77
--- /dev/null
+++ b/components/load-balancer/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~  Copyright (c) 2005-2010, WSO2 Inc. (http://wso2.com) All Rights Reserved.
+  ~
+  ~  WSO2 Inc. 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.wso2.carbon</groupId>
+        <artifactId>carbon-components</artifactId>
+        <version>4.1.0</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.wso2.carbon</groupId>
+    <artifactId>loadbalancer-components</artifactId>
+    <packaging>pom</packaging>
+    <version>4.1.0</version>
+    <name>WSO2 Carbon Loadbalancer Components</name>
+    <description>Carbon Components specifically used in Loadbalancer</description>
+    <url>http://wso2.com</url>
+
+    <modules>
+        <module>org.wso2.carbon.lb.common/4.1.0</module>
+        <!--module>lb-endpoint</module-->
+        <module>autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0</module>
+        <!--module>jvm-autoscaler-agent</module-->
+        <module>autoscaler/org.wso2.carbon.mediator.autoscale/4.1.0</module>
+        <!--module>autoscaler-service/jvmagentmgtservice/4.1.0</module>
+        <module>autoscaler-service/autoscalerservice/4.1.0</module>
+        <module>jvm-autoscaler-agent/jvmagentclient/4.1.0</module>
+        <module>jvm-autoscaler-agent/jvmagent</module-->
+    </modules>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.wso2.carbon</groupId>
+                <artifactId>org.wso2.carbon.utils</artifactId>
+                <version>${wso2carbon.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.wso2.carbon</groupId>
+                <artifactId>org.wso2.carbon.core</artifactId>
+                <version>${wso2carbon.version}</version>
+            </dependency>
+            <dependency>
+              <groupId>junit</groupId>
+              <artifactId>junit</artifactId>
+              <version>${junit.version}</version>
+              <scope>test</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+</project>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/pom.xml b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/pom.xml
new file mode 100644
index 0000000..b48a810
--- /dev/null
+++ b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+#
+# Licensed 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.wso2.carbon</groupId>
+        <artifactId>account-mgt-parent</artifactId>
+        <version>2.1.0</version>
+<relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.wso2.carbon.account.mgt.ui</artifactId>
+    <version>2.1.0</version>
+    <packaging>bundle</packaging>
+    <name>WSO2 Stratos - Account Managment - User Interface</name>
+
+    <build>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            org.wso2.carbon.account.mgt.ui.*,
+                        </Export-Package>
+                        <Import-Package>
+                            org.wso2.carbon.tenant.mgt.stub.*; version="${carbon.platform.package.import.version.range}",
+                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
+                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+                            org.wso2.carbon.account.mgt.stub.*; version="${carbon.platform.package.import.version.range}",
+                            *;resolution:=optional
+                        </Import-Package>
+                        <Carbon-Component>UIBundle</Carbon-Component>
+                    </instructions>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.ui</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.account.mgt.stub</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.tenant.mgt.stub</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.stratos.common</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.json.wso2</groupId>
+          <artifactId>json</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.stratos.common.stub</artifactId>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java
new file mode 100644
index 0000000..7f944df
--- /dev/null
+++ b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/AccountMgtClient.java
@@ -0,0 +1,176 @@
+/*
+*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.wso2.carbon.account.mgt.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.account.mgt.stub.beans.xsd.AccountInfoBean;
+import org.wso2.carbon.account.mgt.stub.services.AccountMgtServiceStub;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.utils.ServerConstants;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+
+public class AccountMgtClient {
+    private static final Log log = LogFactory.getLog(AccountMgtClient.class);
+
+    private AccountMgtServiceStub stub;
+    private String epr;
+
+    public AccountMgtClient(String cookie, String backendServerURL,
+            ConfigurationContext configContext) throws RegistryException {
+
+        epr = backendServerURL + "AccountMgtService";
+
+        try {
+            stub = new AccountMgtServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate AccountMgt service client.";
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public AccountMgtClient(ServletConfig config, HttpSession session) throws RegistryException {
+
+        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+        ConfigurationContext configContext =
+                (ConfigurationContext) config.getServletContext().getAttribute(
+                        CarbonConstants.CONFIGURATION_CONTEXT);
+        epr = backendServerURL + "AccountMgtService";
+
+        try {
+            stub = new AccountMgtServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate AccountMgt service client.";
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public void updateContact(String contactEmail) throws RegistryException {
+        try {
+            stub.updateContact(contactEmail);
+        } catch (Exception e) {
+            String msg = "Failed to update contact.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public String getContact() throws RegistryException {
+        try {
+            return stub.getContact();
+        } catch (Exception e) {
+            String msg = "Failed to get contact.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+   public boolean updateFullname(AccountInfoBean fullname) throws RegistryException {
+        try {
+            return stub.updateFullname(fullname);
+        } catch (Exception e) {
+            String msg = "Failed to update Fullname.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public AccountInfoBean getFullname() throws RegistryException {
+        try {
+            return stub.getFullname();
+        } catch (Exception e) {
+            String msg = "Failed to get administrator full name.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public void deactivate() throws RegistryException {
+        try {
+            stub.deactivate();
+        } catch (Exception e) {
+            String msg = "Failed to deactivate.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public boolean isDomainValidated() throws RegistryException {
+        try {
+            return stub.isDomainValidated();
+        } catch (Exception e) {
+            String msg = "Failed to check the domain validation.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public boolean finishedDomainValidation(String validatedDomain, String successKey)
+            throws RegistryException {
+        try {
+            return stub.finishedDomainValidation(validatedDomain, successKey);
+        } catch (Exception e) {
+            String msg = "Failed to finish the domain validation.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public boolean checkDomainAvailability(String domainName) throws RegistryException {
+        try {
+            return stub.checkDomainAvailability(domainName);
+        } catch (Exception e) {
+            String msg = "Failed to finish the domain availability.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public boolean isEmailValidated() throws RegistryException {
+        try {
+            return stub.isEmailValidated();
+        } catch (Exception e) {
+            String msg = "Failed to check the email validation.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java
new file mode 100644
index 0000000..20aeb8d
--- /dev/null
+++ b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/EmailValidationClient.java
@@ -0,0 +1,95 @@
+/*
+*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.wso2.carbon.account.mgt.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.account.mgt.stub.services.EmailValidationServiceStub;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.utils.ServerConstants;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+
+public class EmailValidationClient {
+     private static final Log log = LogFactory.getLog(EmailValidationClient.class);
+
+    private EmailValidationServiceStub stub;
+    private String epr;
+
+    public EmailValidationClient(
+            String cookie, String backendServerURL, ConfigurationContext configContext)
+            throws RegistryException {
+
+        epr = backendServerURL + "EmailValidationService";
+
+        try {
+            stub = new EmailValidationServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate EmailValidationService service client.";
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public EmailValidationClient(ServletConfig config, HttpSession session)
+            throws RegistryException {
+
+        String cookie = (String)session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+        ConfigurationContext configContext = (ConfigurationContext) config.
+                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+        epr = backendServerURL + "EmailValidationService";
+
+        try {
+            stub = new EmailValidationServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate EmailValidationService service client.";
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public void proceedUpdateContact(String domain, String email, String confirmationKey) throws RegistryException {
+        try {
+            stub.proceedUpdateContact(domain, email, confirmationKey);
+        } catch (Exception e) {
+            String msg = "Failed to proceed update contacts.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java
new file mode 100644
index 0000000..adc1576
--- /dev/null
+++ b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/PackageInfoServiceClient.java
@@ -0,0 +1,97 @@
+/*<!--
+~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+~
+~ WSO2 Inc. 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.wso2.carbon.account.mgt.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.stratos.common.packages.stub.PackageInfoServiceStub;
+import org.wso2.carbon.stratos.common.packages.stub.PackageInfo;
+
+/**
+ * PackageInfoService client
+ */
+public class PackageInfoServiceClient {
+
+    private static Log log = LogFactory.getLog(PackageInfoServiceClient.class);
+
+    private PackageInfoServiceStub stub;
+    private String epr;
+
+    public PackageInfoServiceClient(
+            String cookie, String backendServerURL, ConfigurationContext configContext)
+            throws Exception {
+
+        epr = backendServerURL + "PackageInfoService";
+
+        try {
+            stub = new PackageInfoServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate PackageInfoService client. " + axisFault.getMessage();
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public PackageInfo[] getBillingPackages() throws Exception {
+
+        try {
+            return stub.getPackageInfos();
+        } catch (Exception e) {
+            String msg = "Failed to get package information: " + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+    }
+
+    public JSONArray getBillingPackagesJsonArray() throws Exception {
+
+        try {
+            PackageInfo[] packageInfoArray = stub.getPackageInfos();
+            JSONArray jsonPackageInfoArray = new JSONArray();
+            for (PackageInfo packageInfo : packageInfoArray) {
+                JSONObject packageInfoObj = new JSONObject();
+                packageInfoObj.put("name", packageInfo.getName());
+                int subscriptionCharge = packageInfo.getSubscriptionCharge();
+                //TODO https://wso2.org/jira/browse/STRATOS-1819
+                StringBuffer charge = new StringBuffer("$" + subscriptionCharge);
+                packageInfoObj.put("subscriptionCharge", charge.toString());
+                jsonPackageInfoArray.put(packageInfoObj);
+            }
+            return jsonPackageInfoArray;
+        } catch (Exception e) {
+            String msg = "Failed to get package information: " + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java
new file mode 100644
index 0000000..f5970ca
--- /dev/null
+++ b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/clients/UsagePlanClient.java
@@ -0,0 +1,104 @@
+/*
+*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.wso2.carbon.account.mgt.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.account.mgt.stub.services.BillingDataAccessServiceStub;
+import org.wso2.carbon.account.mgt.stub.services.beans.xsd.Subscription;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.utils.ServerConstants;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+
+public class UsagePlanClient {
+    private BillingDataAccessServiceStub stub;
+    private static final Log log = LogFactory.getLog(UsagePlanClient.class);
+
+    public UsagePlanClient(ServletConfig config, HttpSession session)
+            throws RegistryException {
+
+        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+        ConfigurationContext configContext = (ConfigurationContext) config.
+                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+        String epr = backendServerURL + "BillingDataAccessService";
+
+        try {
+            stub = new BillingDataAccessServiceStub(configContext, epr);
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate Add Services service client. " + axisFault.getMessage();
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+
+    public boolean updateUsagePlan(String usagePlanName) {
+        try {
+            stub.changeSubscriptionByTenant(usagePlanName);
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+    public String getUsagePlanName(String tenantDomain) throws Exception{
+        Subscription subscription;
+        try {
+            subscription=stub.getActiveSubscriptionOfCustomerByTenant();
+            if(subscription!=null){
+                return subscription.getSubscriptionPlan();
+            } else {
+                return "";
+            }
+        } catch (Exception e) {
+            String msg = "Error occurred while getting the usage plan for tenant: " + tenantDomain;
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+    }
+
+    public boolean deactivateActiveUsagePlan(String tenantDomain){
+        log.info("Deactivating tenant domain: " + tenantDomain);
+        boolean deactivated = false;
+        try{
+            deactivated = stub.deactivateActiveSubscriptionByTenant();
+            if(deactivated){
+                log.info("Active subscription deactivated after deactivating the tenant: " + tenantDomain);
+            }
+        }catch (Exception e){
+            log.error("Error occurred while deactivating active subscription of: " +
+                        tenantDomain + " " + e.getMessage(), e);
+        }
+
+        return deactivated;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java
new file mode 100644
index 0000000..6c263ae
--- /dev/null
+++ b/components/stratos/account-mgt/org.wso2.carbon.account.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/account/mgt/ui/utils/Util.java
@@ -0,0 +1,117 @@
+/*
+ *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. 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.wso2.carbon.account.mgt.ui.utils;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.account.mgt.stub.beans.xsd.AccountInfoBean;
+import org.wso2.carbon.account.mgt.ui.clients.AccountMgtClient;
+import org.wso2.carbon.account.mgt.ui.clients.UsagePlanClient;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.StringReader;
+import java.util.Iterator;
+
+public class Util {
+    private static final Log log = LogFactory.getLog(Util.class);
+    
+    public static HttpServletRequest readIntermediateData(HttpServletRequest request,String data){
+        try{
+            XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(data));
+            StAXOMBuilder builder = new StAXOMBuilder(parser);
+            OMElement documentElement =  builder.getDocumentElement();
+            Iterator it = documentElement.getChildElements();
+            while(it.hasNext()){
+                OMElement element = (OMElement)it.next();
+                if ("admin".equals(element.getLocalName())) {
+                    request.setAttribute("admin",element.getText());
+                } else if ("email".equals(element.getLocalName())) {
+                    request.setAttribute("email",element.getText());
+                } else if ("tenantDomain".equals(element.getLocalName())
+                           && request.getAttribute("tenantDomain") == null) {
+                    request.setAttribute("tenantDomain",element.getText());
+                } else if ("confirmationKey".equals(element.getLocalName())) {
+                    request.setAttribute("confirmationKey",element.getText());
+                }
+            }
+        }catch(Exception e){
+            log.error("Error parsing xml",e);
+        }
+        return request;
+    }
+
+    public static boolean updateFullname(
+            HttpServletRequest request,
+            ServletConfig config,
+            HttpSession session) throws Exception {
+
+        AccountInfoBean accountInfoBean = new AccountInfoBean();
+        String firstname = "", lastname = "";
+        try {
+            firstname = request.getParameter("firstname");
+            lastname = request.getParameter("lastname");
+            accountInfoBean.setFirstname(firstname);
+            accountInfoBean.setLastname(lastname);
+            AccountMgtClient client = new AccountMgtClient(config, session);
+            return client.updateFullname(accountInfoBean);
+        } catch (Exception e) {
+            String msg = "Failed to update tenant with firstname: " + firstname;
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+    }
+    public static String getUsagePlanName(ServletConfig config,
+                                           HttpSession session) throws Exception {
+        try{
+            String tenantDomain=(String)session.getAttribute("tenantDomain");
+            UsagePlanClient client=new UsagePlanClient(config, session);
+            return client.getUsagePlanName(tenantDomain);         
+        }
+        catch (Exception e){
+            String msg = "Failed to get usage plan for tenant";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+    }
+
+    public static boolean updateUsagePlan( HttpServletRequest request, ServletConfig config,
+                                           HttpSession session) throws Exception {
+        boolean updated = false;
+        String tenantDomain="";
+        try{
+            tenantDomain=(String)session.getAttribute("tenantDomain");
+            String usagePlanName=(String)request.getParameter("selectedUsagePlan");
+            UsagePlanClient client=new UsagePlanClient(config, session);
+            updated = client.updateUsagePlan(usagePlanName);
+        }
+       catch (Exception e){
+            String msg = "Failed to update the usage plan for tenant: " + tenantDomain;
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        return updated;
+    }
+    
+}