You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2013/07/02 08:40:59 UTC

[09/10] committing org.apache.stratos.mediator.autoscale

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Deserializer.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Deserializer.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Deserializer.java
deleted file mode 100644
index 5c0110e..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Deserializer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.autoscaler.service.io;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class Deserializer {
-    
-    private static final Log log = LogFactory.getLog(Deserializer.class);
-
-    /**
-     * We deserialize only if the path to the serialized object file is exists.
-     * @param filePath path to the serialized object file
-     * @return the object obtained after deserialization or null if file isn't valid.
-     * @throws Exception
-     */
-    public static Object deserialize(String filePath) throws Exception {
-
-        ObjectInputStream objIn = null; 
-        Object obj = null;
-        
-        if(!new File(filePath).isFile()){
-            return obj;
-        }
-        
-        try {
-
-            objIn = new ObjectInputStream(new FileInputStream(filePath));
-            obj = objIn.readObject();
-
-        } catch (IOException e) {
-            log.error("Failed to deserialize the file at "+filePath , e);
-            throw e;
-            
-        } catch (ClassNotFoundException e) {
-            log.error("Failed to deserialize the file at "+filePath , e);
-            throw e;
-            
-        } finally{
-            objIn.close();
-        }
-        
-        return obj;
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Serializer.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Serializer.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Serializer.java
deleted file mode 100644
index 31dd1eb..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/io/Serializer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.autoscaler.service.io;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class Serializer {
-    
-    private static final Log log = LogFactory.getLog(Serializer.class);
-
-    public static void serialize(Object serializableObj, String filePath) throws IOException {
-
-        File outFile = new File(filePath);
-        ObjectOutput ObjOut = null;
-        
-        try {
-
-            if(outFile.createNewFile()){
-                log.debug("Serialization file is created at "+filePath);
-            } else{
-                log.debug("Serialization file is already existing at "+filePath);
-            }
-            
-            ObjOut = new ObjectOutputStream(new FileOutputStream(outFile));
-            ObjOut.writeObject(serializableObj);
-
-        } catch (IOException e) {
-            log.error("Failed to serialize the object "+serializableObj.toString()
-                      + " to file "+filePath , e);
-            throw e;
-            
-        } finally{
-            ObjOut.close();
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/jcloud/ComputeServiceBuilder.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/jcloud/ComputeServiceBuilder.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/jcloud/ComputeServiceBuilder.java
deleted file mode 100644
index 5818ca1..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/jcloud/ComputeServiceBuilder.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-*  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.autoscaler.service.jcloud;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.jclouds.ContextBuilder;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.enterprise.config.EnterpriseConfigurationModule;
-import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.wso2.carbon.autoscaler.service.util.IaasProvider;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-/**
- * This class is responsible for creating a JClouds specific ComputeService object instances.
- */
-public class ComputeServiceBuilder {
-    
-    public static ComputeService buildComputeService(IaasProvider iaas) {
-
-        Properties properties = new Properties();
-
-        // load properties
-        for (Map.Entry<String, String> entry : iaas.getProperties().entrySet()) {
-            properties.put(entry.getKey(), entry.getValue());
-        }
-
-        // set modules
-        Iterable<Module> modules =
-            ImmutableSet.<Module> of(new SshjSshClientModule(), new SLF4JLoggingModule(),
-                                     new EnterpriseConfigurationModule());
-
-        // build context
-        ContextBuilder builder =
-            ContextBuilder.newBuilder(iaas.getProvider())
-                          .credentials(iaas.getIdentity(), iaas.getCredential()).modules(modules)
-                          .overrides(properties);
-
-        // return the compute service object
-        return builder.buildView(ComputeServiceContext.class).getComputeService();
-    }
-    
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/AutoscalerConstant.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/AutoscalerConstant.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/AutoscalerConstant.java
deleted file mode 100644
index 7373902..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/AutoscalerConstant.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-*  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.autoscaler.service.util;
-
-public final class AutoscalerConstant {
-
-    /**
-     * elastic-scaler-config XML file's elements
-     */
-    public static final String SERIALIZATION_DIR_ELEMENT = "serializationDir";
-    public static final String IAAS_PROVIDER_ELEMENT = "iaasProvider";
-    public static final String IAAS_PROVIDER_TYPE_ATTR = "type";
-    public static final String IAAS_PROVIDER_NAME_ATTR = "name";
-    public static final String PROPERTY_ELEMENT = "property";
-    public static final String PROPERTY_NAME_ATTR= "name";
-    public static final String PROPERTY_VALUE_ATTR = "value";
-    public static final String IMAGE_ID_ELEMENT = "imageId";
-    public static final String SCALE_DOWN_ORDER_ELEMENT = "scaleDownOrder";
-    public static final String SCALE_UP_ORDER_ELEMENT = "scaleUpOrder";
-    public static final String PROVIDER_ELEMENT = "provider";
-    public static final String IDENTITY_ELEMENT = "identity";
-    public static final String CREDENTIAL_ELEMENT = "credential";
-    public static final String DEFAULT_SERVICE_ELEMENT = "default";
-    public static final String SERVICE_ELEMENT = "service";
-    public static final String SERVICE_DOMAIN_ATTR = "domain";
-    public static final String SERVICE_SUB_DOMAIN_ATTR = "subDomain";
-    
-    /**
-     * Secret Manager related aliases.
-     */
-    public static final String EC2_IDENTITY_ALIAS = "elastic.scaler.ec2.identity";
-    public static final String EC2_CREDENTIAL_ALIAS = "elastic.scaler.ec2.credential";
-    public static final String OPENSTACK_IDENTITY_ALIAS = "elastic.scaler.openstack.identity";
-    public static final String OPENSTACK_CREDENTIAL_ALIAS = "elastic.scaler.openstack.credential";
-    
-    /**
-     * Serializer related constants
-     */
-    public static final String IAAS_CONTEXT_LIST_SERIALIZING_FILE = "iaas-context-list.txt";
-    public static final String LASTLY_USED_IAAS_MAP_SERIALIZING_FILE = "lastly-used-iaas.txt";
-    
-    /**
-     * Payload related constants
-     */
-    public static final String PAYLOAD_DIR = "payload";
-    public static final String PARAMS_FILE_NAME = "launch-params";
-    public static final String RESOURCES_DIR = "resources";
-    public static final String VALUE_SEPARATOR = "=";
-    public static final String ENTRY_SEPARATOR = ",";
-    public static final String APP_PATH_KEY = "APP_PATH";
-    public static final String TENANT_KEY = "TENANT";
-    
-    /**
-	 * Super tenant id
-	 */
-    public static final String SUPER_TENANT_ID = "-1234";
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasContext.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasContext.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasContext.java
deleted file mode 100644
index c2affa5..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasContext.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
-*  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.autoscaler.service.util;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.Template;
-import org.wso2.carbon.autoscaler.service.impl.AutoscalerServiceImpl.Iaases;
-
-/**
- * This object holds all IaaS related runtime data.
- */
-public class IaasContext implements Serializable{
-   
-    private static final long serialVersionUID = -922284976926131383L;
-    
-    // name of the IaaS
-    private Enum<Iaases> name;
-    
-    /* We keep following maps in order to make the look up time, low.*/
-    
-    /**
-     * Key - domain
-     * Value - is another map
-     *          key - sub domain
-     *          value - <code>InstanceContext</code>
-     */
-    private Map<String, Map<String, InstanceContext>> instanceCtxts;
-    
-    /**
-     * Key - public IP
-     * Value - <code>InstanceContext</code>
-     */
-    private Map<String, InstanceContext> publicIpToInstanceCtxt;
-    
-    /**
-     * Key - node id 
-     * Value - <code>InstanceContext</code>
-     */
-    private Map<String, InstanceContext> nodeIdToInstanceCtxt;
-    
-    
-//    private transient Map<String, Template> domainToTemplateMap;
-    private transient ComputeService computeService;
-    
-    // Since Jclouds' NodeMetadata object contains unserializable objects, I had to use 3 maps.
-//    private Map<String, String> nodeIdToDomainMap = new LinkedHashMap<String, String>();
-//    private Map<String, String> publicIpToDomainMap = new LinkedHashMap<String, String>();
-//    private Map<String, String> publicIpToNodeIdMap = new LinkedHashMap<String, String>();
-    
-    private int scaleUpOrder, scaleDownOrder;
-
-    public IaasContext(Enum<Iaases> name, ComputeService computeService) {
-        this.name = name;
-        this.computeService = computeService;
-        instanceCtxts = new LinkedHashMap<String, Map<String,InstanceContext>>();
-        publicIpToInstanceCtxt = new LinkedHashMap<String, InstanceContext>();
-        nodeIdToInstanceCtxt = new LinkedHashMap<String, InstanceContext>();
-    }
-
-    public Enum<Iaases> getName() {
-        return name;
-    }
-    
-    public void addInstanceContext(InstanceContext ctx) {
-        
-        if(ctx == null){
-            return;
-        }
-        
-        String domain = ctx.getDomain();
-        String subDomain = ctx.getSubDomain();
-        
-        if(domain != null && subDomain != null){
-            addToInstanceCtxts(domain, subDomain, ctx);
-        }
-        
-    }
-    
-    public void addNodeDetails(String domain, String subDomain, String nodeId, String ip) {
-        
-        if(getInstanceContext(domain, subDomain) != null){
-            getInstanceContext(domain, subDomain).addNode(nodeId, ip);
-            
-            nodeIdToInstanceCtxt.put(nodeId, getInstanceContext(domain, subDomain));
-            publicIpToInstanceCtxt.put(ip, getInstanceContext(domain, subDomain));
-        }
-    }
-    
-    private void addToInstanceCtxts(String domainName, String subDomainName, InstanceContext ctx) {
-
-        Map<String, InstanceContext> map;
-        
-        if(instanceCtxts.get(domainName) == null){
-            map = new HashMap<String, InstanceContext>();
-            
-        } else{
-            map = instanceCtxts.get(domainName);
-        }
-        
-        map.put(subDomainName, ctx);
-        instanceCtxts.put(domainName, map);
-        
-    }
-
-//    public void addToDomainToTemplateMap(String key, Template value) {
-//        domainToTemplateMap.put(key, value);
-//    }
-
-    public Template getTemplate(String domain, String subDomain) {
-        if(getInstanceContext(domain, subDomain) == null){
-            return null;
-        }
-        return getInstanceContext(domain, subDomain).getTemplate();
-    }
-    
-    public InstanceContext getInstanceContext(String domain, String subDomain) {
-        if (instanceCtxts.get(domain) != null) {
-            return instanceCtxts.get(domain).get(subDomain);
-        }
-        return null;
-    }
-
-    public ComputeService getComputeService() {
-        return computeService;
-    }
-    
-    public void setComputeService(ComputeService computeService) {
-        this.computeService = computeService;
-    }
-
-//    public void addNodeIdToDomainMap(String nodeId, String domain) {
-//        nodeIdToDomainMap.put(nodeId, domain);
-//    }
-//    
-//    public void addPublicIpToDomainMap(String ip, String domain) {
-//        publicIpToDomainMap.put(ip, domain);
-//    }
-//    
-//    public void addPublicIpToNodeIdMap(String ip, String nodeId) {
-//        publicIpToNodeIdMap.put(ip, nodeId);
-//    }
-
-    /**
-     * This will return the node id of the node which is belong to the
-     * requesting domain, sub domain and which is the most recently created. If it cannot find a
-     * matching node id, this will return <code>null</code>.
-     * @param domain service domain.
-     * @param subDomain service sub domain. 
-     * @return the node Id of the node
-     */
-    public String getLastMatchingNode(String domain, String subDomain) {
-        
-        InstanceContext ctx = getInstanceContext(domain, subDomain);
-        
-        if(ctx == null){
-            return null;
-        }
-        
-        // iterate in reverse order
-        ListIterator<String> iter =
-            new ArrayList<String>(ctx.getNodeIdToIpMap().keySet()).
-                                listIterator(ctx.getNodeIdToIpMap().size());
-
-        if (iter.hasPrevious()) {
-            return iter.previous();
-        }
-        
-        return null;
-    }
-    
-    /**
-     * This will return the public IP of the node which is belong to the
-     * requesting domain, sub domain and which is the most recently created. If it cannot find a
-     * matching public IP, this will return <code>null</code>.
-     * @param domain service domain. 
-     * @param subDomain service sub domain. 
-     * @return the public IP of the node
-     */
-    public String getLastMatchingPublicIp(String domain, String subDomain) {
-        
-        InstanceContext ctx = getInstanceContext(domain, subDomain);
-        
-        if(ctx == null){
-            return null;
-        }
-        
-        // iterate in reverse order
-        ListIterator<String> iter =
-            new ArrayList<String>(ctx.getNodeIdToIpMap().keySet()).
-                                listIterator(ctx.getNodeIdToIpMap().size());
-
-        while (iter.hasPrevious()) {
-            return ctx.getNodeIdToIpMap().get(iter.previous());
-        }
-        
-        return null;
-        
-//        // traverse from the last entry of the map
-//        ListIterator<Map.Entry<String, String>> iter =
-//            new ArrayList<Entry<String, String>>(publicIpToDomainMap.entrySet()).
-//                                listIterator(publicIpToDomainMap.size());
-//
-//        while (iter.hasPrevious()) {
-//            Map.Entry<String, String> entry = iter.previous();
-//            if (entry.getValue().equals(domain)) {
-//                return entry.getKey();
-//            }
-//        }
-//        
-//        return null;
-    }
-
-    /**
-     * This will return the node id of the node which is belong to the
-     * requesting domain, sub domain and which is created at first. If it cannot find a
-     * matching node id, this will return <code>null</code>.
-     * @param domain service domain.
-     * @param subDomain service sub domain.
-     * @return node id of the node
-     */
-    public String getFirstMatchingNode(String domain, String subDomain) {
-        
-        InstanceContext ctx = getInstanceContext(domain, subDomain);
-        
-        if(ctx == null){
-            return null;
-        }
-        
-        // iterate in added order
-        ListIterator<String> iter =
-            new ArrayList<String>(ctx.getNodeIdToIpMap().keySet()).
-                                listIterator(0);
-
-        while (iter.hasNext()) {
-            return iter.next();
-        }
-        
-        return null;
-        
-//        for (Entry<String, String> entry : nodeIdToDomainMap.entrySet()) {
-//            if (entry.getValue().equals(domain)) {
-//                return entry.getKey();
-//            }
-//        }
-//        return null;
-    }
-
-    /**
-     * This will return the node id of the node which has the given public IP. 
-     * If it cannot find a matching node id, this will return 
-     * <code>null</code>.
-     * @param publicIp public IP of a node.
-     * @return node id of the matching node.
-     */
-    public String getNodeWithPublicIp(String publicIp) {
-
-        InstanceContext ctx;
-
-        for (String ip : publicIpToInstanceCtxt.keySet()) {
-
-            if (ip.equals(publicIp)) {
-
-                ctx = publicIpToInstanceCtxt.get(ip);
-
-                for (String nodeId : nodeIdToInstanceCtxt.keySet()) {
-                    if (ctx.equals(nodeIdToInstanceCtxt.get(nodeId))) {
-                        return nodeId;
-                    }
-                }
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * This will return a list of node Ids that are started in this IaaS and that are 
-     * belong to the given domain, sub domain.
-     * @param domain service domain.
-     * @param subDomain service sub domain.
-     * @return List of node Ids.
-     */
-    public List<String> getNodeIds(String domain, String subDomain) {
-        
-        InstanceContext ctx = getInstanceContext(domain, subDomain);
-        
-        if(ctx == null){
-            return new ArrayList<String>();
-        }
-        
-        return new ArrayList<String>(ctx.getNodeIdToIpMap().keySet());
-        
-
-//        List<String> nodeIds = new ArrayList<String>();
-//
-//        for (Entry<String, String> entry : nodeIdToDomainMap.entrySet()) {
-//            if (entry.getValue().equals(domain)) {
-//                nodeIds.add(entry.getKey());
-//            }
-//        }
-//
-//        return nodeIds;
-    }
-
-    /**
-     * Removes a specific node id and related entries.
-     * @param node id of the node to be removed.
-     */
-    public void removeNodeId(String nodeId) {
-        
-        InstanceContext ctx;
-        
-        if(nodeIdToInstanceCtxt.containsKey(nodeId)){
-            // remove from node id map
-            ctx = nodeIdToInstanceCtxt.remove(nodeId);
-            
-            // remove from public ip map
-            publicIpToInstanceCtxt.remove(ctx.getNodeIdToIpMap().get(nodeId));
-            
-            // remove from main map
-            instanceCtxts.get(ctx.getDomain()).get(ctx.getSubDomain()).removeNode(nodeId);
-            
-        }
-    }
-
-    public boolean equals(Object obj) {
-
-        if (obj instanceof IaasContext) {
-            return new EqualsBuilder().append(getName(), ((IaasContext) obj).getName()).isEquals();
-        }
-        return false;
-
-    }
-    
-    public int hashCode() {
-        return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers
-        append(name).
-        toHashCode();
-    }
-
-    public int getScaleDownOrder() {
-        return scaleDownOrder;
-    }
-
-    public void setScaleDownOrder(int scaleDownOrder) {
-        this.scaleDownOrder = scaleDownOrder;
-    }
-
-    public int getScaleUpOrder() {
-        return scaleUpOrder;
-    }
-
-    public void setScaleUpOrder(int scaleUpOrder) {
-        this.scaleUpOrder = scaleUpOrder;
-    }
-    
-//    public void setDomainToTemplateMap(Map<String, Template> map) {
-//        domainToTemplateMap = map;
-//    }
-//    
-//    public Map<String, Template> getDomainToTemplateMap() {
-//        return domainToTemplateMap;
-//    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasProvider.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasProvider.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasProvider.java
deleted file mode 100644
index 84bb307..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/IaasProvider.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
-*  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.autoscaler.service.util;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This is the basic data structure which holds an IaaS specific details.
- */
-public class IaasProvider {
-    
-    /**
-     * Unique id to identify this IaaS provider.
-     */
-    private String type;
-    
-    /**
-     * human description of this IaaS provider
-     */
-    private String name;
-    
-    /**
-     * Property map for this IaaS provider.
-     */
-    private Map<String, String> properties = new HashMap<String, String>();
-    
-    /**
-     * Image identifier.
-     */
-    private String template;
-    
-    /**
-     * Scale up order and scale down order of the IaaS.
-     */
-    private int scaleUpOrder, scaleDownOrder;
-    
-    private String provider, identity, credential;
-    
-//    public enum SortParameter {
-//        SCALE_UP, SCALE_DOWN
-//    }
-
-    
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String id) {
-        this.type = id;
-    }
-
-    public Map<String, String> getProperties() {
-        return properties;
-    }
-    
-    public void setProperty(String key, String value) {
-        
-        if(key != null && value != null){
-            properties.put(key, value);
-        }
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-
-    public String getTemplate() {
-        return template;
-    }
-
-    public void setTemplate(String template) {
-        this.template = template;
-    }
-
-    public int getScaleUpOrder() {
-        return scaleUpOrder;
-    }
-
-    public void setScaleUpOrder(int scaleUpOrder) {
-        this.scaleUpOrder = scaleUpOrder;
-    }
-
-    public int getScaleDownOrder() {
-        return scaleDownOrder;
-    }
-
-    public void setScaleDownOrder(int scaleDownOrder) {
-        this.scaleDownOrder = scaleDownOrder;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getProvider() {
-        return provider;
-    }
-
-    public void setProvider(String provider) {
-        this.provider = provider;
-    }
-
-    public String getIdentity() {
-        return identity;
-    }
-
-    public void setIdentity(String identity) {
-        this.identity = identity;
-    }
-
-    public String getCredential() {
-        return credential;
-    }
-
-    public void setCredential(String credential) {
-        this.credential = credential;
-    }
-
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/InstanceContext.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/InstanceContext.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/InstanceContext.java
deleted file mode 100644
index 80f3883..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/InstanceContext.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-*  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.autoscaler.service.util;
-
-import java.io.Serializable;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.jclouds.compute.domain.Template;
-
-/**
- * This will hold the run-time data related to an instance.
- * Instance can be an EC2 one, Openstack one etc.
- */
-public class InstanceContext implements Serializable {
-
-    private static final long serialVersionUID = -2604902942512629140L;
-    private String domain;
-    private String subDomain;
-    private transient Template template;
-
-    /**
-     * Key - node Id
-     * Value - IP
-     */
-    private Map<String, String> nodeIdToIpMap;
-    
-    public InstanceContext(String domain, String subDomain, Template temp) {
-        this.domain = domain;
-        this.subDomain = subDomain;
-        this.template = temp;
-        nodeIdToIpMap = new LinkedHashMap<String, String>();
-    }
-//    
-//    public InstanceContext(String domain, String subDomain, Template temp, String nodeId, String publicIp) {
-//        this.domain = domain;
-//        this.subDomain = subDomain;
-//        this.template = temp;
-//        this.nodeId = nodeId;
-//        this.publicIp = publicIp;
-//    }
-
-    
-    public String getDomain() {
-        return domain;
-    }
-
-    public String getSubDomain() {
-        return subDomain;
-    }
-    
-    public Template getTemplate() {
-        return template;
-    }
-    
-    public void setTemplate(Template temp) {
-        this.template = temp;
-    }
-    
-    public void addNode(String nodeId, String ip) {
-        if("".equals(ip)){
-            ip = null;
-        }
-        nodeIdToIpMap.put(nodeId, ip);
-    }
-    
-    public void removeNode(String nodeId) {
-        nodeIdToIpMap.remove(nodeId);
-    }
-
-
-    public Map<String, String> getNodeIdToIpMap() {
-        return nodeIdToIpMap;
-    }
-
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/ServiceTemplate.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/ServiceTemplate.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/ServiceTemplate.java
deleted file mode 100644
index 0dbd6a0..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/util/ServiceTemplate.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-*  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.autoscaler.service.util;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.wso2.carbon.lb.common.conf.util.Constants;
-
-/**
- * We keep details under a service element of jcoluds configuration file,
- * in this object.
- */
-public class ServiceTemplate implements Cloneable {
-
-    private String domainName;
-    private String subDomainName = Constants.DEFAULT_SUB_DOMAIN;
-    private Map<String, String> properties = new HashMap<String, String>();
-    
-    public String getDomainName() {
-        return domainName;
-    }
-    
-    public boolean setDomainName(String domainName) {
-        if (!"".equals(domainName)) {
-            this.domainName = domainName;
-            return true;
-        }
-        
-        return false;
-    }
-    
-    public void setProperty(String key, String value) {
-        properties.put(key, value);
-    }
-    
-    public String getProperty(String key) {
-        
-        if(properties.containsKey(key)){
-            return properties.get(key);
-        }
-        
-        return "";
-    }
-
-    public Map<String, String> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, String> properties) {
-        this.properties = properties;
-    }
-    
-    public String getSubDomainName() {
-        return subDomainName;
-    }
-
-    public void setSubDomainName(String subDomainName) {
-        if(subDomainName == null || "".equals(subDomainName)){
-            return;
-        }
-        this.subDomainName = subDomainName;
-    }
-    
-    public Object clone() throws CloneNotSupportedException {
-        return super.clone();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReader.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReader.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReader.java
deleted file mode 100644
index 325da96..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReader.java
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
- *  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.autoscaler.service.xml;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.wso2.carbon.autoscaler.service.exception.MalformedConfigurationFileException;
-import org.wso2.carbon.autoscaler.service.util.AutoscalerConstant;
-import org.wso2.carbon.autoscaler.service.util.IaasProvider;
-import org.wso2.carbon.autoscaler.service.util.ServiceTemplate;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.securevault.SecretResolver;
-import org.wso2.securevault.SecretResolverFactory;
-
-/**
- * Responsible for reading the Elastic scaler configuration file.
- * Following is a sample XML.
- *
- * &lt;elasticScalerConfig&gt;
- *      &lt;iaasProviders&gt;
- *          &lt;iaasProvider name="ec2"&gt;
- *              &lt;provider&gt;aws-ec2&lt;/provider&gt;
- *              &lt;identity&gt;aaa&lt;/identity&gt;
- *              &lt;credential&gt;aaaa&lt;/credential&gt;
- *              &lt;scaleUpOrder&gt;1&lt;/scaleUpOrder&gt;
- *              &lt;scaleDownOrder&gt;2&lt;/scaleDownOrder&gt;
- *              &lt;property name="A" value="a"/&gt;
- *              &lt;property name="B" value="b"/&gt;
- *              &lt;template&gt;temp1&lt;/template&gt;
- *          &lt;/iaasProvider&gt;
- *          
- *          &lt;iaasProvider name="lxc"&gt;
- *              &lt;provider&gt;aws-ec2&lt;/provider&gt;
- *              &lt;identity&gt;aaa&lt;/identity&gt;
- *              &lt;credential&gt;aaaa&lt;/credential&gt;
- *              &lt;scaleUpOrder&gt;2&lt;/scaleUpOrder&gt;
- *              &lt;scaleDownOrder&gt;1&lt;/scaleDownOrder&gt;
- *              &lt;property name="X" value="x"/&gt;
- *              &lt;property name="Y" value="y"/&gt;
- *              &lt;template&gt;temp2&lt;/template&gt;
- *          &lt;/iaasProvider&gt;
- *      &lt;/iaasProviders&gt;
- *      $lt;services&gt;
- *          $lt;default&gt;
- *              $lt;property name="availabilityZone" value="us-east-1c"/&gt;
- *              $lt;property name="securityGroups" value="manager,cep,mb,default"/&gt;
- *              $lt;property name="instanceType" value="m1.large"/&gt;
- *              $lt;property name="keyPair" value="aa"/&gt;
- *          $lt;/default&gt;
- *          $lt;service domain="wso2.as.domain"&gt;
- *              $lt;property name="securityGroups" value="manager,default"/&gt;
- *              $lt;property name="payload" value="resources/as.zip"/&gt;
- *          $lt;/service&gt;
- *      $lt;/services&gt;
- *  &lt;/elasticScalerConfig&gt;
- */
-public class ElasticScalerConfigFileReader {
-	
-	private static final Log log = LogFactory.getLog(ElasticScalerConfigFileReader.class);
-
-	//get the factory
-	private DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-	private Document dom;
-	private Element docEle;
-
-	/**
-	 * Path to elastic-scaler-config XML file, which specifies the Iaas specific details and 
-	 * services related details.
-	 */
-	private String elasticScalerConfigFile;
-	
-	
-	public ElasticScalerConfigFileReader(){
-	    
-	    elasticScalerConfigFile = CarbonUtils.getCarbonConfigDirPath() +
-	            File.separator + "elastic-scaler-config.xml";
-	    
-		/**
-		 * Parse the configuration file.
-		 */
-		try {
-			//Using factory, get an instance of document builder
-			DocumentBuilder db = dbf.newDocumentBuilder();
-
-			//parse using builder to get DOM representation of the XML file
-			dom = db.parse(elasticScalerConfigFile);
-			
-
-		}catch(Exception ex) {
-			String msg = "Error occurred while parsing the "+elasticScalerConfigFile+".";
-			handleException(msg, ex);
-		}
-	}
-	
-	/**
-	 * Constructor to be used in the test cases.
-	 * @param file path to elastic-scaler-config xml file.
-	 */
-	public ElasticScalerConfigFileReader(String file) {
-        
-        /**
-         * Parse the configuration file.
-         */
-        try {
-            //Using factory, get an instance of document builder
-            DocumentBuilder db = dbf.newDocumentBuilder();
-            
-            //parse using builder to get DOM representation of the XML file
-            dom = db.parse(file);
-            
-
-        }catch(Exception ex) {
-            String msg = "Error occurred when parsing the "+file+".";
-            handleException(msg, ex);
-        }
-    }
-	
-	/**
-	 * Returns the serialization directory specified in the configuration file.
-	 * @return the path to the directory or an empty string if element cannot be found.
-	 */
-	public String getSerializationDir() {
-        
-	    docEle = dom.getDocumentElement();
-	    NodeList nl = docEle.getElementsByTagName(AutoscalerConstant.SERIALIZATION_DIR_ELEMENT);
-
-        // there should be only one serializationDir element, we neglect all the others
-        if (nl != null && nl.getLength() > 0) {
-            
-            if (nl.item(0).getNodeType() == Node.ELEMENT_NODE) {
-                Element prop = (Element) nl.item(0);
-
-                return prop.getTextContent();
-
-            }
-        }
-        
-        return "";
-    }
-	
-	/**
-	 * Load all IaasProviders from the configuration file and returns a list.
-	 * @return a list of IaasProvider instances.
-	 */
-	public List<IaasProvider> getIaasProvidersList() {
-	    List<IaasProvider> iaasProviders = new ArrayList<IaasProvider>();
-	    
-	    docEle = dom.getDocumentElement();
-	    NodeList nl = docEle.getElementsByTagName(AutoscalerConstant.IAAS_PROVIDER_ELEMENT);
-	    
-	    if (nl != null && nl.getLength() > 0) {
-	        
-	        for(int i=0; i< nl.getLength() ; i++){
-	            iaasProviders.add(getIaasProvider(nl.item(i)));
-	        }
-	        
-	    }
-	    else{
-	        String msg = "Essential '"+AutoscalerConstant.IAAS_PROVIDER_ELEMENT+"' element cannot" +
-	        		" be found in "+elasticScalerConfigFile;
-	        handleException(msg);
-	    }
-	    
-	    return iaasProviders;
-	    
-    }
-
-    private IaasProvider getIaasProvider(Node item) {
-
-        IaasProvider iaas = new IaasProvider();
-        
-        if (item.getNodeType() == Node.ELEMENT_NODE) {
-            Element iaasElt = (Element) item;
-            iaas.setType(iaasElt.getAttribute(AutoscalerConstant.IAAS_PROVIDER_TYPE_ATTR));
-            
-            if("".equals(iaas.getType())){
-                String msg = "'"+AutoscalerConstant.IAAS_PROVIDER_ELEMENT+"' element's '"+
-            AutoscalerConstant.IAAS_PROVIDER_TYPE_ATTR+"' attribute should be specified!";
-                
-                handleException(msg);
-
-            }
-            
-            // this is not mandatory
-            iaas.setName(iaasElt.getAttribute(AutoscalerConstant.IAAS_PROVIDER_NAME_ATTR));
-            
-            iaas.setProperties(loadProperties(iaasElt));
-            loadTemplate(iaas, iaasElt);
-            loadScalingOrders(iaas, iaasElt);
-            loadProvider(iaas, iaasElt);
-            loadIdentity(iaas, iaasElt);
-            loadCredentials(iaas, iaasElt);
-        }
-        
-        
-        return iaas;
-    }
-    
-    /**
-     * Load all ServiceTemplates from the configuration file and returns a list.
-     * @return a list of ServiceTemplate instances.
-     */
-    public List<ServiceTemplate> getTemplates() {
-        
-        List<ServiceTemplate> templates = new ArrayList<ServiceTemplate>();
-        
-        // build default template object
-        ServiceTemplate template = new ServiceTemplate();
-        
-        Element docEle = dom.getDocumentElement();
-        NodeList nl = docEle.getElementsByTagName(AutoscalerConstant.DEFAULT_SERVICE_ELEMENT);
-        
-        if (nl != null && nl.getLength() > 0) {
-
-            Node item = nl.item(0);
-
-            if (item.getNodeType() == Node.ELEMENT_NODE) {
-                Element defaultElt = (Element) item;
-                template.setProperties(loadProperties(defaultElt));
-            }
-
-        }
-        
-        // append / overwrite the default template object with values in each domain
-        nl = docEle.getElementsByTagName(AutoscalerConstant.SERVICE_ELEMENT);
-        
-        if (nl != null && nl.getLength() > 0) {
-
-            for (int i = 0; i < nl.getLength(); i++) {
-                Node item = nl.item(i);
-
-                // clone the default template to an independent object
-                try {
-                    ServiceTemplate temp = (ServiceTemplate) template.clone();
-
-                    if (item.getNodeType() == Node.ELEMENT_NODE) {
-                        Element imageElt = (Element) item;
-
-                        if ("".equals(imageElt.getAttribute(
-                                             AutoscalerConstant.SERVICE_DOMAIN_ATTR))) {
-                            String msg =
-                                "Essential '"+AutoscalerConstant.SERVICE_DOMAIN_ATTR+"' " +
-                                		"attribute of '"+AutoscalerConstant.SERVICE_ELEMENT+
-                                		"' element cannot be found in " + elasticScalerConfigFile;
-
-                            handleException(msg);
-                        }
-
-                        // set domain name
-                        temp.setDomainName(imageElt.getAttribute(AutoscalerConstant.SERVICE_DOMAIN_ATTR));
-                        
-                        // set sub domain
-                        temp.setSubDomainName(imageElt.getAttribute(
-                                              AutoscalerConstant.SERVICE_SUB_DOMAIN_ATTR));
-                        
-                        // load custom properties
-                        Map<String, String> customProperties = loadProperties(imageElt);
-                        
-                        // add custom properties (overwrite default properties where necessary)
-                        for (Entry<String, String> pair : customProperties.entrySet()) {
-                            temp.setProperty(pair.getKey(), pair.getValue());
-                        }
-
-                    }
-                    
-                    // add each domain specific template to list
-                    templates.add(temp);
-
-                } catch (CloneNotSupportedException e) {
-                    String msg = "This is extraordinary!! ";
-                    handleException(msg, e);
-                }
-            }
-        }
-        
-        return templates;
-    }
-    
-    private void loadCredentials(IaasProvider iaas, Element iaasElt) {
-
-        NodeList nl = iaasElt.getElementsByTagName(AutoscalerConstant.CREDENTIAL_ELEMENT);
-
-        // there should be only one credential element, we neglect all the others
-        if (nl != null && nl.getLength() > 0) {
-            
-            if (nl.getLength() > 1){
-                log.warn(elasticScalerConfigFile +" contains more than one "+
-                         AutoscalerConstant.CREDENTIAL_ELEMENT+" elements!" +
-                        " Elements other than the first will be neglected.");
-            }
-            
-            if (nl.item(0).getNodeType() == Node.ELEMENT_NODE) {
-
-                // retrieve the value using secure vault
-                SecretResolver secretResolver = SecretResolverFactory.create(docEle, false);
-                String alias;
-
-                // FIXME following is a hack to find the correct alias.
-                if (iaas.getProvider().contains("ec2")) {
-                    alias = AutoscalerConstant.EC2_CREDENTIAL_ALIAS;
-                } else {
-                    alias = AutoscalerConstant.OPENSTACK_CREDENTIAL_ALIAS;
-                }
-
-                // retrieve the secured password
-                if (secretResolver != null && secretResolver.isInitialized() && 
-                        secretResolver.isTokenProtected(alias)) {
-
-                    iaas.setCredential(secretResolver.resolve(alias));
-
-                }
-
-            }
-        }
-        else{
-            String msg = "Essential '"+AutoscalerConstant.CREDENTIAL_ELEMENT+"' element" +
-            		" has not specified in "+elasticScalerConfigFile;
-            handleException(msg);
-        }
-    }
-
-    private void loadIdentity(IaasProvider iaas, Element iaasElt) {
-
-        NodeList nl = iaasElt.getElementsByTagName(AutoscalerConstant.IDENTITY_ELEMENT);
-
-        // there should be only one identity element, we neglect all the others
-        if (nl != null && nl.getLength() > 0) {
-            
-            if (nl.getLength() > 1){
-                log.warn(elasticScalerConfigFile +" contains more than one "+
-                        AutoscalerConstant.IDENTITY_ELEMENT+" elements!" +
-                        " Elements other than the first will be neglected.");
-            }
-            
-            if (nl.item(0).getNodeType() == Node.ELEMENT_NODE) {
-
-                // retrieve the value using secure vault
-                SecretResolver secretResolver = SecretResolverFactory.create(docEle, false);
-                String alias;
-                
-                //FIXME following is a hack to find the correct alias.
-                if(iaas.getProvider().contains("ec2")){
-                    alias = AutoscalerConstant.EC2_IDENTITY_ALIAS;
-                }
-                else{
-                    alias = AutoscalerConstant.OPENSTACK_IDENTITY_ALIAS;
-                }
-
-                // retrieve the secured password
-                if (secretResolver != null && secretResolver.isInitialized() && 
-                        secretResolver.isTokenProtected(alias)) {
-
-                    iaas.setIdentity(secretResolver.resolve(alias));
-
-                }
-
-            }
-        }
-        else{
-            String msg = "Essential '"+AutoscalerConstant.IDENTITY_ELEMENT+"' element" +
-            		" has not specified in "+elasticScalerConfigFile;
-            handleException(msg);
-        }
-    }
-
-    private void loadProvider(IaasProvider iaas, Element iaasElt) {
-
-        NodeList nl = iaasElt.getElementsByTagName(AutoscalerConstant.PROVIDER_ELEMENT);
-
-        // there should be only one provider element, we neglect all the others
-        if (nl != null && nl.getLength() > 0) {
-            
-            if (nl.getLength() > 1){
-                log.warn(elasticScalerConfigFile +" contains more than one "+
-                        AutoscalerConstant.PROVIDER_ELEMENT+" elements!" +
-                        " Elements other than the first will be neglected.");
-            }
-            
-            if (nl.item(0).getNodeType() == Node.ELEMENT_NODE) {
-                Element prop = (Element) nl.item(0);
-
-                iaas.setProvider(prop.getTextContent());
-
-            }
-        }
-        else{
-            String msg = "Essential '"+AutoscalerConstant.PROVIDER_ELEMENT+"' element " +
-            		"has not specified in "+elasticScalerConfigFile;
-            handleException(msg);
-        }
-    }
-
-    private void loadScalingOrders(IaasProvider iaas, Element iaasElt) {
-
-        NodeList nl = iaasElt.getElementsByTagName(AutoscalerConstant.SCALE_UP_ORDER_ELEMENT);
-
-        // there should be only one scaleUpOrder element, we neglect all the others
-        if (nl != null && nl.getLength() > 0) {
-            
-            if (nl.getLength() > 1){
-                log.warn(elasticScalerConfigFile +" contains more than one "+
-                        AutoscalerConstant.SCALE_UP_ORDER_ELEMENT+" elements!" +
-                        " Elements other than the first will be neglected.");
-            }
-            
-            if (nl.item(0).getNodeType() == Node.ELEMENT_NODE) {
-                Element prop = (Element) nl.item(0);
-
-                try {
-                    iaas.setScaleUpOrder(Integer.parseInt(prop.getTextContent()));
-                }catch (NumberFormatException e) {
-                    String msg = AutoscalerConstant.SCALE_UP_ORDER_ELEMENT+" element contained" +
-                    		" in "+elasticScalerConfigFile +"" +
-                    		" has a value which is not an Integer value.";
-                    handleException(msg, e);
-                }
-
-            }
-        }
-        else{
-            String msg = "Essential '"+AutoscalerConstant.SCALE_UP_ORDER_ELEMENT+"' element" +
-            		" has not specified in "+elasticScalerConfigFile;
-            handleException(msg);
-        }
-        
-        
-        nl = iaasElt.getElementsByTagName(AutoscalerConstant.SCALE_DOWN_ORDER_ELEMENT);
-
-        // there should be only one scaleDownOrder element, we neglect all the others
-        if (nl != null && nl.getLength() > 0) {
-            
-            if (nl.getLength() > 1){
-                log.warn(elasticScalerConfigFile +" contains more than one "+
-                        AutoscalerConstant.SCALE_DOWN_ORDER_ELEMENT+" elements!" +
-                        " Elements other than the first will be neglected.");
-            }
-            
-            if (nl.item(0).getNodeType() == Node.ELEMENT_NODE) {
-                Element prop = (Element) nl.item(0);
-
-                try {
-                    iaas.setScaleDownOrder(Integer.parseInt(prop.getTextContent()));
-                }catch (NumberFormatException e) {
-                    String msg = AutoscalerConstant.SCALE_DOWN_ORDER_ELEMENT+" element contained" +
-                            " in "+elasticScalerConfigFile +"" +
-                            " has a value which is not an Integer value.";
-                    handleException(msg, e);
-                }
-
-            }
-        }
-        else{
-            String msg = "Essential '"+AutoscalerConstant.SCALE_DOWN_ORDER_ELEMENT+"' element" +
-                    " has not specified in "+elasticScalerConfigFile;
-            handleException(msg);
-        }
-    }
-
-    private void loadTemplate(IaasProvider iaas, Element iaasElt) {
-
-        NodeList nl = iaasElt.getElementsByTagName(AutoscalerConstant.IMAGE_ID_ELEMENT);
-
-        // there should be only one imageId element, we neglect all the others
-        if (nl != null && nl.getLength() > 0) {
-            
-            if (nl.getLength() > 1){
-                log.warn(elasticScalerConfigFile +" contains more than one "+
-                        AutoscalerConstant.IMAGE_ID_ELEMENT+" elements!" +
-                        " Elements other than the first will be neglected.");
-            }
-            
-            if (nl.item(0).getNodeType() == Node.ELEMENT_NODE) {
-                Element prop = (Element) nl.item(0);
-
-                iaas.setTemplate(prop.getTextContent());
-
-            }
-        }
-        else{
-            String msg = "Essential '"+AutoscalerConstant.IMAGE_ID_ELEMENT+"' element" +
-                    " has not specified in "+elasticScalerConfigFile;
-            handleException(msg);
-        }
-    }
-
-    private Map<String, String> loadProperties(Element iaasElt) {
-
-        Map<String, String> propertyMap = new HashMap<String, String>();
-        
-        NodeList nl = iaasElt.getElementsByTagName(AutoscalerConstant.PROPERTY_ELEMENT);
-        
-        if (nl != null && nl.getLength() > 0) {
-            for(int i=0; i< nl.getLength() ; i++){
-                
-                if (nl.item(i).getNodeType() == Node.ELEMENT_NODE) {
-                    Element prop = (Element) nl.item(i);
-                    
-                    if("".equals(prop.getAttribute(AutoscalerConstant.PROPERTY_NAME_ATTR)) ||
-                            "".equals(prop.getAttribute(AutoscalerConstant.PROPERTY_VALUE_ATTR))){
-                        
-                        String msg ="Property element's, name and value attributes should be specified " +
-                        		"in "+elasticScalerConfigFile;
-
-                        handleException(msg);
-                    }
-                    propertyMap.put(prop.getAttribute(AutoscalerConstant.PROPERTY_NAME_ATTR), 
-                                    prop.getAttribute(AutoscalerConstant.PROPERTY_VALUE_ATTR));
-                    
-                }
-            }
-        }
-        
-        return propertyMap;
-    }
-    
-    private void handleException(String msg){
-        log.error(msg);
-        throw new MalformedConfigurationFileException(msg);
-    }
-    
-    private void handleException(String msg, Exception e) {
-        log.error(msg, e);
-        throw new MalformedConfigurationFileException(msg, e);
-    }
-	
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml
deleted file mode 100644
index ae20622..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<serviceGroup>
-    <service name="AutoscalerService" scope="application">
-        <parameter name="ServiceClass">org.wso2.carbon.autoscaler.service.impl.AutoscalerServiceImpl</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/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextComparatorTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextComparatorTest.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextComparatorTest.java
deleted file mode 100644
index 946efb6..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextComparatorTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-*  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.autoscaler.service.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.wso2.carbon.autoscaler.service.impl.AutoscalerServiceImpl.IaasContextComparator;
-import org.wso2.carbon.autoscaler.service.impl.AutoscalerServiceImpl.Iaases;
-
-import junit.framework.TestCase;
-
-public class IaasContextComparatorTest extends TestCase {
-    
-    List<IaasContext> iaasContexts = new ArrayList<IaasContext>();
-    
-    @Override
-    protected void setUp() throws Exception {
-        IaasContext a = new IaasContext(Iaases.ec2, null);
-        a.setScaleUpOrder(1);
-        a.setScaleDownOrder(5);
-        
-        IaasContext b = new IaasContext(Iaases.openstack, null);
-        b.setScaleUpOrder(3);
-        b.setScaleDownOrder(0);
-        
-        iaasContexts.add(a);
-        iaasContexts.add(b);
-        
-        super.setUp();
-    }
-
-    public void testSort() {
-        
-        // scale up order sort test
-        Collections.sort(iaasContexts,
-                         IaasContextComparator.ascending(
-                         IaasContextComparator.getComparator(
-                         IaasContextComparator.SCALE_UP_SORT)));
-        
-        assertEquals("ec2", iaasContexts.get(0).getName().toString());
-        assertEquals("openstack", iaasContexts.get(1).getName().toString());
-        
-        // scale down order sort test
-        Collections.sort(iaasContexts,
-                         IaasContextComparator.ascending(
-                         IaasContextComparator.getComparator(
-                         IaasContextComparator.SCALE_DOWN_SORT)));
-        
-        assertEquals("openstack", iaasContexts.get(0).getName().toString());
-        assertEquals("ec2", iaasContexts.get(1).getName().toString());
-        
-        
-        IaasContext c = new IaasContext(Iaases.ec2, null);
-        c.setScaleUpOrder(0);
-        c.setScaleDownOrder(4);
-        
-        iaasContexts.add(c);
-        
-        // scale up order sort test
-        Collections.sort(iaasContexts,
-                         IaasContextComparator.ascending(
-                         IaasContextComparator.getComparator(
-                         IaasContextComparator.SCALE_UP_SORT)));
-        
-        assertEquals("ec2", iaasContexts.get(0).getName().toString());
-        assertEquals("ec2", iaasContexts.get(1).getName().toString());
-        
-        // scale down order sort test
-        Collections.sort(iaasContexts,
-                         IaasContextComparator.ascending(
-                         IaasContextComparator.getComparator(
-                         IaasContextComparator.SCALE_DOWN_SORT)));
-        
-        assertEquals("openstack", iaasContexts.get(0).getName().toString());
-        assertEquals("ec2", iaasContexts.get(1).getName().toString());
-        
-        
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextTest.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextTest.java
deleted file mode 100644
index 2805d64..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/util/IaasContextTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-*  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.autoscaler.service.util;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.wso2.carbon.autoscaler.service.impl.AutoscalerServiceImpl.Iaases;
-import org.wso2.carbon.lb.common.conf.util.Constants;
-
-import junit.framework.TestCase;
-
-public class IaasContextTest extends TestCase {
-
-    IaasContext ctx;
-    NodeMetadata node1, node2, node3, node4;
-    
-    String[] domains = {"wso2.a", "wso2.b", "wso2.c"};
-    String[] subDomains = {"mgt", "worker"};
-    String[] nodeIds = {"1", "2", "3", "4", "5"};
-    String[] ips = {"192.168.1.2", "192.168.1.3", "192.168.1.4"};
-
-    public IaasContextTest(String name) {
-        super(name);
-    }
-
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        node1 = new NodeMetadataBuilder().id("1")
-                                         .status(org.jclouds.compute.domain.NodeMetadata.Status.RUNNING)
-                                         .publicAddresses(new ArrayList<String>(Arrays.asList("192.168.1.2")))
-                                         .build();
-        node2 = new NodeMetadataBuilder().id("2")
-                                         .status(org.jclouds.compute.domain.NodeMetadata.Status.RUNNING)
-                                         .build();
-        node3 = new NodeMetadataBuilder().id("3")
-                                         .status(org.jclouds.compute.domain.NodeMetadata.Status.RUNNING)
-                                         .build();
-        node4 = new NodeMetadataBuilder().id("4")
-                                         .status(org.jclouds.compute.domain.NodeMetadata.Status.RUNNING)
-                                         .build();
-
-        ctx = new IaasContext(Iaases.ec2, null);
-        
-        
-        ctx.addInstanceContext(new InstanceContext(domains[0], subDomains[0], null));
-        ctx.addInstanceContext(new InstanceContext(domains[1], subDomains[1], null));
-        ctx.addInstanceContext(new InstanceContext(domains[2], subDomains[0], null));
-        ctx.addInstanceContext(new InstanceContext(domains[2], Constants.DEFAULT_SUB_DOMAIN, null));
-        
-        ctx.addNodeDetails(domains[0], subDomains[0], nodeIds[0], "");
-        ctx.addNodeDetails(domains[0], subDomains[0], nodeIds[1], ips[0]);
-        ctx.addNodeDetails(domains[1], subDomains[1], nodeIds[2], ips[1]);
-        ctx.addNodeDetails(domains[2], subDomains[0], nodeIds[3], ips[2]);
-        ctx.addNodeDetails(domains[2], Constants.DEFAULT_SUB_DOMAIN, nodeIds[4], "");
-        
-        
-//        ctx.addNodeIdToDomainMap(node1.getId(), "wso2.a");
-//        ctx.addPublicIpToDomainMap("192.168.1.2", "wso2.a");
-//        ctx.addPublicIpToNodeIdMap("192.168.1.2", node1.getId());
-//        ctx.addNodeIdToDomainMap(node2.getId(), "wso2.b");
-//        ctx.addNodeIdToDomainMap(node3.getId(), "wso2.a");
-//        ctx.addPublicIpToDomainMap("192.168.1.3", "wso2.a");
-//        ctx.addPublicIpToNodeIdMap("192.168.1.3", node3.getId());
-//        ctx.addNodeIdToDomainMap(node4.getId(), "wso2.c");
-    }
-
-    public final void testGetLastMatchingNode() {
-
-        assertEquals(nodeIds[1], ctx.getLastMatchingNode(domains[0], subDomains[0]));
-        ctx.removeNodeId(nodeIds[1]);
-        assertEquals(nodeIds[0], ctx.getLastMatchingNode(domains[0], subDomains[0]));
-        ctx.addNodeDetails(domains[0], subDomains[0], nodeIds[1], ips[0]);
-    }
-
-    public final void testGetFirstMatchingNode() {
-        assertEquals(nodeIds[0], ctx.getFirstMatchingNode(domains[0], subDomains[0]));
-    }
-    
-    public final void testGetLastMatchingPublicIp() {
-        assertEquals(ips[0], ctx.getLastMatchingPublicIp(domains[0], subDomains[0]));
-        assertEquals(null, ctx.getLastMatchingPublicIp(domains[2], Constants.DEFAULT_SUB_DOMAIN));
-    }
-
-    public final void testGetNodeWithPublicIp() {
-        assertEquals(nodeIds[3], ctx.getNodeWithPublicIp(ips[2]));
-    }
-
-    public final void testGetNodeIds() {
-        assertEquals(new ArrayList<String>(Arrays.asList(nodeIds[0], nodeIds[1])), ctx.getNodeIds(domains[0], subDomains[0]));
-        assertEquals(new ArrayList<String>(Arrays.asList(nodeIds[2])), ctx.getNodeIds(domains[1], subDomains[1]));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java
deleted file mode 100644
index 4a3eb74..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/java/org/wso2/carbon/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  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.autoscaler.service.xml;
-
-import java.util.List;
-import org.wso2.carbon.autoscaler.service.util.IaasProvider;
-import junit.framework.TestCase;
-
-public class ElasticScalerConfigFileReaderTest extends TestCase {
-
-    public void testGetIaasProvidersListy() throws Exception {
-        
-        String file = "src/test/resources/elastic-scaler-config.xml";
-        ElasticScalerConfigFileReader reader = new ElasticScalerConfigFileReader(file);
-        
-        List<IaasProvider> list =reader.getIaasProvidersList();
-        
-        assertEquals(2, list.size());
-        
-        assertEquals("ec2", list.get(0).getType());
-        //assertEquals("cdcd", list.get(0).getIdentity());
-        assertEquals(2, list.get(0).getScaleDownOrder());
-        assertEquals(1, list.get(0).getScaleUpOrder());
-        assertEquals("a", list.get(0).getProperties().get("A.x"));
-        assertEquals("b", list.get(0).getProperties().get("B"));
-        assertEquals(null, list.get(0).getProperties().get("AA"));
-        
-        assertEquals("openstack", list.get(1).getType());
-        //assertEquals("bebbe", list.get(1).getIdentity());
-        assertEquals(1, list.get(1).getScaleDownOrder());
-        assertEquals(2, list.get(1).getScaleUpOrder());
-        assertEquals("x", list.get(1).getProperties().get("X"));
-        assertEquals("y", list.get(1).getProperties().get("Y"));
-        assertEquals(null, list.get(1).getProperties().get("x"));
-        
-        
-        List<org.wso2.carbon.autoscaler.service.util.ServiceTemplate> temps =reader.getTemplates();
-      
-        assertEquals("wso2.as.domain", temps.get(0).getDomainName());
-        assertEquals("manager,default", temps.get(0).getProperty("securityGroups"));
-        
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml b/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml
deleted file mode 100644
index 3ef215e..0000000
--- a/components/load-balancer/autoscaler-service/org.wso2.carbon.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!--
-  ~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com)
-  ~
-  ~ 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.
-  -->
-
-<elasticScalerConfig xmlns:svns="http://org.wso2.securevault/configuration">
-
-<svns:secureVault provider="org.wso2.securevault.secret.handler.SecretManagerSecretCallbackHandler"/>
-	<iaasProviders>
-		<iaasProvider type="ec2" name="EC2 specific details">
-			<provider>aws-ec2</provider>
-			<identity svns:secretAlias="elastic.scaler.ec2.identity">cdcd</identity>
-			<credential svns:secretAlias="elastic.scaler.ec2.credential">cdccdc</credential>
-			<scaleUpOrder>1</scaleUpOrder>
-			<scaleDownOrder>2</scaleDownOrder>
-			<property name="A.x" value="a"/>
-			<property name="B" value="b"/>
-			<imageId>tempEC2</imageId>
-		</iaasProvider>
-		<iaasProvider type="openstack" >
-			<provider>lxc</provider>
-			<identity svns:secretAlias="elastic.scaler.openstack.identity">bebbe</identity>
-			<credential svns:secretAlias="elastic.scaler.openstack.credential">bebebe</credential>
-			<scaleUpOrder>2</scaleUpOrder>
-			<scaleDownOrder>1</scaleDownOrder>
-			<property name="X" value="x"/>
-			<property name="Y" value="y"/>
-			<imageId>tempLXC</imageId>
-		</iaasProvider>
-	</iaasProviders>
-	
-	<services>
-		<default>
-			<property name="availabilityZone" value="us-east-1c"/>
-			<property name="securityGroups" value="manager,cep,mb,default"/>
-            <property name="instanceType.ec2" value="m1.large"/>
-            <property name="instanceType.openstack" value="1"/>
-            <property name="minAppInstances" value="1"/>
-            <property name="maxAppInstances" value="5"/>
-            <property name="queueLengthPerNode" value="50"/>
-            <property name="roundsToAverage" value="100"/>
-            <property name="instancesPerScaleUp" value="1"/>
-            <property name="messageExpiryTime" value="60000"/>
-            <property name="keyPair" value="aa"/>
-		</default>
-		<service domain="wso2.as.domain" subDomain="mgt">
-			<property name="securityGroups" value="manager,default"/>
-            <property name="availabilityZone" value="us-east-1c"/>
-            <property name="payload" value="resources/as.zip"/>
-		</service>
-	</services>
-
-</elasticScalerConfig>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/pom.xml b/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/pom.xml
new file mode 100644
index 0000000..7b0bbbe
--- /dev/null
+++ b/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (c) 2009-2010, 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.
+-->
+
+
+<!--
+We need to modify this file since this copied from branch
+-->
+<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.apache.stratos</groupId>
+        <artifactId>loadbalancer-components</artifactId>
+        <version>4.1.0</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <version>4.1.3</version>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.stratos</groupId>
+    <artifactId>org.apache.stratos.mediator.autoscale</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Stratos - Autoscale Mediator BE</name>
+    <url>http://apache.org</url>
+
+    <build>
+        <plugins>
+			<plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>1.4.0</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            !org.org.apache.stratos.mediator.autoscale.lbautoscale.internal,
+                            org.apache.stratos.mediator.autoscale.*
+                        </Export-Package>
+                        <Private-Package>org.apache.stratos.mediator.autoscale.lbautoscale.internal</Private-Package>
+                        <Import-Package>
+                            !javax.xml.namespace,
+                            javax.xml.namespace; version=0.0.0,
+                            !org.apache.commons.logging,
+                            org.apache.commons.logging; version=0.0.0,
+                            org.apache.axis2.*,
+                            org.apache.synapse.*,
+                            org.wso2.carbon.task.*; version=0.0.0,
+                            org.wso2.carbon.core.*,
+                            org.apache.stratos.lb.common.*,
+                            org.wso2.carbon.load.balance.cartridge.autoscaler.service.stub.*; version=0.0.0,
+                            org.wso2.carbon.utils.*,
+                            org.apache.axiom.om; version="${axiom.osgi.version.range}",
+                            org.wso2.carbon.stratos.cloud.controller.*,
+                            *; resolution:=optional
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+          <groupId>org.apache.axis2.wso2</groupId>
+          <artifactId>axis2</artifactId>
+          <version>1.6.1.wso2v9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-core</artifactId>
+            <version>${synapse.core.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.load.balance.cartridge.autoscaler.service.stub</artifactId>
+            <version>4.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.core</artifactId>
+            <version>${wso2carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.utils</artifactId>
+            <version>${wso2carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.lb.common</artifactId>
+            <version>4.1.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.stratos.cloud.controller</artifactId>
+            <version>2.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.task</artifactId>
+            <version>${wso2carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-tasks</artifactId>
+            <version>2.1.1-wso2v4</version>
+        </dependency>
+
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/src/main/java/org/apache/stratos/mediator/autoscale/lbautoscale/callables/AppNodeSanityCheckCallable.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/src/main/java/org/apache/stratos/mediator/autoscale/lbautoscale/callables/AppNodeSanityCheckCallable.java b/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/src/main/java/org/apache/stratos/mediator/autoscale/lbautoscale/callables/AppNodeSanityCheckCallable.java
new file mode 100644
index 0000000..804823f
--- /dev/null
+++ b/components/load-balancer/autoscaler/org.apache.stratos.mediator.autoscale/4.1.3/src/main/java/org/apache/stratos/mediator/autoscale/lbautoscale/callables/AppNodeSanityCheckCallable.java
@@ -0,0 +1,84 @@
+/*
+*  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.apache.stratos.mediator.autoscale.lbautoscale.callables;
+
+import java.util.concurrent.Callable;
+
+import org.apache.stratos.mediator.autoscale.lbautoscale.clients.CloudControllerClient;
+import org.apache.stratos.mediator.autoscale.lbautoscale.util.AutoscaleUtil;
+import org.apache.stratos.mediator.autoscale.lbautoscale.util.AutoscalerTaskDSHolder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.lb.common.conf.LoadBalancerConfiguration.ServiceConfiguration;
+import org.apache.stratos.mediator.autoscale.lbautoscale.context.AppDomainContext;
+
+/** Performing sanity checks for each service domain, sub domain combination **/
+public class AppNodeSanityCheckCallable implements Callable<Boolean> {
+
+    private static final Log log = LogFactory.getLog(AppNodeSanityCheckCallable.class);
+    private String domain;
+    private String subDomain;
+    private CloudControllerClient client;
+    private AppDomainContext appDomainContext;
+    private ServiceConfiguration serviceConfig;
+    
+    public AppNodeSanityCheckCallable(String domain, String subDomain, CloudControllerClient client, AppDomainContext appCtxt){
+        this.domain = domain;
+        this.subDomain = subDomain;
+        this.client = client;
+        this.appDomainContext = appCtxt;
+        serviceConfig =
+                AutoscalerTaskDSHolder.getInstance().getWholeLoadBalancerConfig().getServiceConfig(this.domain,
+                    this.subDomain);
+    }
+    
+    @Override
+    public Boolean call() throws Exception {
+
+        if (appDomainContext != null) {
+            int currentInstances = 0;
+            // we're considering both running and pending instance count
+            currentInstances = appDomainContext.getInstances();
+
+            int requiredInstances = serviceConfig.getMinAppInstances();
+
+            // we try to maintain the minimum number of instances required
+            if (currentInstances < requiredInstances) {
+                log.debug("App domain Sanity check failed for " +
+                    AutoscaleUtil.domainSubDomainString(domain, subDomain) +
+                        " . Current instances: " +
+                        currentInstances +
+                        ". Required instances: " +
+                        requiredInstances);
+
+                int diff = requiredInstances - currentInstances;
+
+                // Launch diff number of App instances
+                log.debug("Launching " +
+                    diff +
+                    " App instances for " +AutoscaleUtil.domainSubDomainString(domain, subDomain));
+
+                // FIXME: should we need to consider serviceConfig.getInstancesPerScaleUp()?
+                AutoscaleUtil.runInstances(client, appDomainContext, this.domain, this.subDomain, diff);
+            }
+        }
+
+        return true;
+    }
+
+}