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/01 15:47:27 UTC
[07/12] changing package structure to org.apache.stratos
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/util/ServiceTemplate.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/util/ServiceTemplate.java b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/util/ServiceTemplate.java
new file mode 100644
index 0000000..40a456c
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/util/ServiceTemplate.java
@@ -0,0 +1,83 @@
+/*
+* 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.autoscaler.service.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.stratos.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/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReader.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReader.java b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReader.java
new file mode 100644
index 0000000..cfde2b2
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReader.java
@@ -0,0 +1,556 @@
+/*
+ * 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.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.apache.stratos.autoscaler.service.exception.MalformedConfigurationFileException;
+import org.apache.stratos.autoscaler.service.util.AutoscalerConstant;
+import org.apache.stratos.autoscaler.service.util.IaasProvider;
+import org.apache.stratos.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.
+ *
+ * <elasticScalerConfig>
+ * <iaasProviders>
+ * <iaasProvider name="ec2">
+ * <provider>aws-ec2</provider>
+ * <identity>aaa</identity>
+ * <credential>aaaa</credential>
+ * <scaleUpOrder>1</scaleUpOrder>
+ * <scaleDownOrder>2</scaleDownOrder>
+ * <property name="A" value="a"/>
+ * <property name="B" value="b"/>
+ * <template>temp1</template>
+ * </iaasProvider>
+ *
+ * <iaasProvider name="lxc">
+ * <provider>aws-ec2</provider>
+ * <identity>aaa</identity>
+ * <credential>aaaa</credential>
+ * <scaleUpOrder>2</scaleUpOrder>
+ * <scaleDownOrder>1</scaleDownOrder>
+ * <property name="X" value="x"/>
+ * <property name="Y" value="y"/>
+ * <template>temp2</template>
+ * </iaasProvider>
+ * </iaasProviders>
+ * $lt;services>
+ * $lt;default>
+ * $lt;property name="availabilityZone" value="us-east-1c"/>
+ * $lt;property name="securityGroups" value="manager,cep,mb,default"/>
+ * $lt;property name="instanceType" value="m1.large"/>
+ * $lt;property name="keyPair" value="aa"/>
+ * $lt;/default>
+ * $lt;service domain="wso2.as.domain">
+ * $lt;property name="securityGroups" value="manager,default"/>
+ * $lt;property name="payload" value="resources/as.zip"/>
+ * $lt;/service>
+ * $lt;/services>
+ * </elasticScalerConfig>
+ */
+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/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..04dd8d8
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/main/resources/META-INF/services.xml
@@ -0,0 +1,9 @@
+<serviceGroup>
+ <service name="AutoscalerService" scope="application">
+ <parameter name="ServiceClass">org.apache.stratos.autoscaler.service.impl.AutoscalerServiceImplpl</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/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test2.iml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test2.iml b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test2.iml
new file mode 100644
index 0000000..f226621
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test2.iml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="true" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="Main1" />
+ <orderEntry type="module" module-name="Main2" />
+ </component>
+ <component name="org.twodividedbyzero.idea.findbugs">
+ <option name="_basePreferences">
+ <map>
+ <entry key="property.analysisEffortLevel" value="default" />
+ <entry key="property.analyzeAfterCompile" value="false" />
+ <entry key="property.annotationGutterIconEnabled" value="true" />
+ <entry key="property.annotationSuppressWarningsClass" value="edu.umd.cs.findbugs.annotations.SuppressWarnings" />
+ <entry key="property.annotationTextRangeMarkupEnabled" value="true" />
+ <entry key="property.exportAsHtml" value="true" />
+ <entry key="property.exportAsXml" value="true" />
+ <entry key="property.exportBaseDir" value="" />
+ <entry key="property.exportCreateArchiveDir" value="false" />
+ <entry key="property.exportOpenBrowser" value="true" />
+ <entry key="property.minPriorityToReport" value="Medium" />
+ <entry key="property.runAnalysisInBackground" value="false" />
+ <entry key="property.showHiddenDetectors" value="false" />
+ <entry key="property.toolWindowToFront" value="true" />
+ </map>
+ </option>
+ <option name="_detectors">
+ <map>
+ <entry key="AppendingToAnObjectOutputStream" value="true" />
+ <entry key="AtomicityProblem" value="true" />
+ <entry key="BadAppletConstructor" value="false" />
+ <entry key="BadResultSetAccess" value="true" />
+ <entry key="BadSyntaxForRegularExpression" value="true" />
+ <entry key="BadUseOfReturnValue" value="true" />
+ <entry key="BadlyOverriddenAdapter" value="true" />
+ <entry key="BooleanReturnNull" value="true" />
+ <entry key="BuildInterproceduralCallGraph" value="false" />
+ <entry key="BuildObligationPolicyDatabase" value="true" />
+ <entry key="CallToUnsupportedMethod" value="false" />
+ <entry key="CalledMethods" value="true" />
+ <entry key="CheckCalls" value="false" />
+ <entry key="CheckExpectedWarnings" value="false" />
+ <entry key="CheckImmutableAnnotation" value="true" />
+ <entry key="CheckTypeQualifiers" value="true" />
+ <entry key="CloneIdiom" value="true" />
+ <entry key="ComparatorIdiom" value="true" />
+ <entry key="ConfusedInheritance" value="true" />
+ <entry key="ConfusionBetweenInheritedAndOuterMethod" value="true" />
+ <entry key="CrossSiteScripting" value="true" />
+ <entry key="DefaultEncodingDetector" value="true" />
+ <entry key="DoInsideDoPrivileged" value="true" />
+ <entry key="DontCatchIllegalMonitorStateException" value="true" />
+ <entry key="DontIgnoreResultOfPutIfAbsent" value="true" />
+ <entry key="DontUseEnum" value="true" />
+ <entry key="DroppedException" value="true" />
+ <entry key="DumbMethodInvocations" value="true" />
+ <entry key="DumbMethods" value="true" />
+ <entry key="DuplicateBranches" value="true" />
+ <entry key="EmptyZipFileEntry" value="true" />
+ <entry key="EqualsOperandShouldHaveClassCompatibleWithThis" value="true" />
+ <entry key="ExplicitSerialization" value="true" />
+ <entry key="FieldItemSummary" value="true" />
+ <entry key="FinalizerNullsFields" value="true" />
+ <entry key="FindBadCast2" value="true" />
+ <entry key="FindBadForLoop" value="true" />
+ <entry key="FindBugsSummaryStats" value="true" />
+ <entry key="FindCircularDependencies" value="false" />
+ <entry key="FindDeadLocalStores" value="true" />
+ <entry key="FindDoubleCheck" value="true" />
+ <entry key="FindEmptySynchronizedBlock" value="true" />
+ <entry key="FindFieldSelfAssignment" value="true" />
+ <entry key="FindFinalizeInvocations" value="true" />
+ <entry key="FindFloatEquality" value="true" />
+ <entry key="FindFloatMath" value="false" />
+ <entry key="FindHEmismatch" value="true" />
+ <entry key="FindInconsistentSync2" value="true" />
+ <entry key="FindJSR166LockMonitorenter" value="true" />
+ <entry key="FindLocalSelfAssignment2" value="true" />
+ <entry key="FindMaskedFields" value="true" />
+ <entry key="FindMismatchedWaitOrNotify" value="true" />
+ <entry key="FindNakedNotify" value="true" />
+ <entry key="FindNonSerializableStoreIntoSession" value="false" />
+ <entry key="FindNonSerializableValuePassedToWriteObject" value="false" />
+ <entry key="FindNonShortCircuit" value="true" />
+ <entry key="FindNullDeref" value="true" />
+ <entry key="FindNullDerefsInvolvingNonShortCircuitEvaluation" value="true" />
+ <entry key="FindOpenStream" value="true" />
+ <entry key="FindPuzzlers" value="true" />
+ <entry key="FindRefComparison" value="true" />
+ <entry key="FindReturnRef" value="true" />
+ <entry key="FindRunInvocations" value="true" />
+ <entry key="FindSelfComparison" value="true" />
+ <entry key="FindSelfComparison2" value="true" />
+ <entry key="FindSleepWithLockHeld" value="true" />
+ <entry key="FindSpinLoop" value="true" />
+ <entry key="FindSqlInjection" value="true" />
+ <entry key="FindTwoLockWait" value="true" />
+ <entry key="FindUncalledPrivateMethods" value="true" />
+ <entry key="FindUnconditionalWait" value="true" />
+ <entry key="FindUninitializedGet" value="true" />
+ <entry key="FindUnrelatedTypesInGenericContainer" value="true" />
+ <entry key="FindUnreleasedLock" value="true" />
+ <entry key="FindUnsatisfiedObligation" value="true" />
+ <entry key="FindUnsyncGet" value="true" />
+ <entry key="FindUseOfNonSerializableValue" value="true" />
+ <entry key="FindUselessControlFlow" value="true" />
+ <entry key="FormatStringChecker" value="true" />
+ <entry key="FunctionsThatMightBeMistakenForProcedures" value="true" />
+ <entry key="HugeSharedStringConstants" value="true" />
+ <entry key="IDivResultCastToDouble" value="true" />
+ <entry key="IncompatMask" value="true" />
+ <entry key="InconsistentAnnotations" value="true" />
+ <entry key="InefficientMemberAccess" value="false" />
+ <entry key="InefficientToArray" value="true" />
+ <entry key="InfiniteLoop" value="true" />
+ <entry key="InfiniteRecursiveLoop" value="true" />
+ <entry key="InheritanceUnsafeGetResource" value="true" />
+ <entry key="InitializationChain" value="true" />
+ <entry key="InitializeNonnullFieldsInConstructor" value="true" />
+ <entry key="InstantiateStaticClass" value="true" />
+ <entry key="IntCast2LongAsInstant" value="true" />
+ <entry key="InvalidJUnitTest" value="true" />
+ <entry key="IteratorIdioms" value="true" />
+ <entry key="LazyInit" value="true" />
+ <entry key="LoadOfKnownNullValue" value="true" />
+ <entry key="LostLoggerDueToWeakReference" value="true" />
+ <entry key="MethodReturnCheck" value="true" />
+ <entry key="Methods" value="true" />
+ <entry key="MultithreadedInstanceAccess" value="true" />
+ <entry key="MutableLock" value="true" />
+ <entry key="MutableStaticFields" value="true" />
+ <entry key="Naming" value="true" />
+ <entry key="Noise" value="false" />
+ <entry key="NoiseNullDeref" value="false" />
+ <entry key="NoteAnnotationRetention" value="true" />
+ <entry key="NoteCheckReturnValueAnnotations" value="true" />
+ <entry key="NoteDirectlyRelevantTypeQualifiers" value="true" />
+ <entry key="NoteJCIPAnnotation" value="true" />
+ <entry key="NoteNonNullAnnotations" value="true" />
+ <entry key="NoteNonnullReturnValues" value="true" />
+ <entry key="NoteSuppressedWarnings" value="true" />
+ <entry key="NoteUnconditionalParamDerefs" value="true" />
+ <entry key="NumberConstructor" value="true" />
+ <entry key="OverridingEqualsNotSymmetrical" value="true" />
+ <entry key="PreferZeroLengthArrays" value="true" />
+ <entry key="PublicSemaphores" value="false" />
+ <entry key="QuestionableBooleanAssignment" value="true" />
+ <entry key="ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass" value="true" />
+ <entry key="ReadReturnShouldBeChecked" value="true" />
+ <entry key="RedundantInterfaces" value="true" />
+ <entry key="ReflectiveClasses" value="true" />
+ <entry key="RepeatedConditionals" value="true" />
+ <entry key="ResolveAllReferences" value="false" />
+ <entry key="RuntimeExceptionCapture" value="true" />
+ <entry key="SerializableIdiom" value="true" />
+ <entry key="StartInConstructor" value="true" />
+ <entry key="StaticCalendarDetector" value="true" />
+ <entry key="StringConcatenation" value="true" />
+ <entry key="SuperfluousInstanceOf" value="true" />
+ <entry key="SuspiciousThreadInterrupted" value="true" />
+ <entry key="SwitchFallthrough" value="true" />
+ <entry key="SynchronizationOnSharedBuiltinConstant" value="true" />
+ <entry key="SynchronizeAndNullCheckField" value="true" />
+ <entry key="SynchronizeOnClassLiteralNotGetClass" value="true" />
+ <entry key="SynchronizingOnContentsOfFieldToProtectField" value="true" />
+ <entry key="TestASM" value="false" />
+ <entry key="TestDataflowAnalysis" value="false" />
+ <entry key="TestingGround" value="false" />
+ <entry key="TestingGround2" value="false" />
+ <entry key="TrainFieldStoreTypes" value="true" />
+ <entry key="TrainLongInstantfParams" value="true" />
+ <entry key="TrainNonNullAnnotations" value="true" />
+ <entry key="TrainUnconditionalDerefParams" value="true" />
+ <entry key="URLProblems" value="true" />
+ <entry key="UncallableMethodOfAnonymousClass" value="true" />
+ <entry key="UnnecessaryMath" value="true" />
+ <entry key="UnreadFields" value="true" />
+ <entry key="UselessSubclassMethod" value="false" />
+ <entry key="VarArgsProblems" value="true" />
+ <entry key="VolatileUsage" value="true" />
+ <entry key="WaitInLoop" value="true" />
+ <entry key="WrongMapIterator" value="true" />
+ <entry key="XMLFactoryBypass" value="true" />
+ </map>
+ </option>
+ <option name="_reportCategories">
+ <map>
+ <entry key="BAD_PRACTICE" value="true" />
+ <entry key="CORRECTNESS" value="true" />
+ <entry key="EXPERIMENTAL" value="true" />
+ <entry key="I18N" value="true" />
+ <entry key="MALICIOUS_CODE" value="true" />
+ <entry key="MT_CORRECTNESS" value="true" />
+ <entry key="PERFORMANCE" value="true" />
+ <entry key="SECURITY" value="true" />
+ <entry key="STYLE" value="true" />
+ </map>
+ </option>
+ </component>
+</module>
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test4.iml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test4.iml b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test4.iml
new file mode 100644
index 0000000..8336db6
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/Test4.iml
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="true" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="Main6" />
+ </component>
+ <component name="org.twodividedbyzero.idea.findbugs">
+ <option name="_basePreferences">
+ <map>
+ <entry key="property.analysisEffortLevel" value="default" />
+ <entry key="property.analyzeAfterCompile" value="false" />
+ <entry key="property.annotationGutterIconEnabled" value="true" />
+ <entry key="property.annotationSuppressWarningsClass" value="edu.umd.cs.findbugs.annotations.SuppressWarnings" />
+ <entry key="property.annotationTextRangeMarkupEnabled" value="true" />
+ <entry key="property.exportAsHtml" value="true" />
+ <entry key="property.exportAsXml" value="true" />
+ <entry key="property.exportBaseDir" value="" />
+ <entry key="property.exportCreateArchiveDir" value="false" />
+ <entry key="property.exportOpenBrowser" value="true" />
+ <entry key="property.minPriorityToReport" value="Medium" />
+ <entry key="property.runAnalysisInBackground" value="false" />
+ <entry key="property.showHiddenDetectors" value="false" />
+ <entry key="property.toolWindowToFront" value="true" />
+ </map>
+ </option>
+ <option name="_detectors">
+ <map>
+ <entry key="AppendingToAnObjectOutputStream" value="true" />
+ <entry key="AtomicityProblem" value="true" />
+ <entry key="BadAppletConstructor" value="false" />
+ <entry key="BadResultSetAccess" value="true" />
+ <entry key="BadSyntaxForRegularExpression" value="true" />
+ <entry key="BadUseOfReturnValue" value="true" />
+ <entry key="BadlyOverriddenAdapter" value="true" />
+ <entry key="BooleanReturnNull" value="true" />
+ <entry key="BuildInterproceduralCallGraph" value="false" />
+ <entry key="BuildObligationPolicyDatabase" value="true" />
+ <entry key="CallToUnsupportedMethod" value="false" />
+ <entry key="CalledMethods" value="true" />
+ <entry key="CheckCalls" value="false" />
+ <entry key="CheckExpectedWarnings" value="false" />
+ <entry key="CheckImmutableAnnotation" value="true" />
+ <entry key="CheckTypeQualifiers" value="true" />
+ <entry key="CloneIdiom" value="true" />
+ <entry key="ComparatorIdiom" value="true" />
+ <entry key="ConfusedInheritance" value="true" />
+ <entry key="ConfusionBetweenInheritedAndOuterMethod" value="true" />
+ <entry key="CrossSiteScripting" value="true" />
+ <entry key="DefaultEncodingDetector" value="true" />
+ <entry key="DoInsideDoPrivileged" value="true" />
+ <entry key="DontCatchIllegalMonitorStateException" value="true" />
+ <entry key="DontIgnoreResultOfPutIfAbsent" value="true" />
+ <entry key="DontUseEnum" value="true" />
+ <entry key="DroppedException" value="true" />
+ <entry key="DumbMethodInvocations" value="true" />
+ <entry key="DumbMethods" value="true" />
+ <entry key="DuplicateBranches" value="true" />
+ <entry key="EmptyZipFileEntry" value="true" />
+ <entry key="EqualsOperandShouldHaveClassCompatibleWithThis" value="true" />
+ <entry key="ExplicitSerialization" value="true" />
+ <entry key="FieldItemSummary" value="true" />
+ <entry key="FinalizerNullsFields" value="true" />
+ <entry key="FindBadCast2" value="true" />
+ <entry key="FindBadForLoop" value="true" />
+ <entry key="FindBugsSummaryStats" value="true" />
+ <entry key="FindCircularDependencies" value="false" />
+ <entry key="FindDeadLocalStores" value="true" />
+ <entry key="FindDoubleCheck" value="true" />
+ <entry key="FindEmptySynchronizedBlock" value="true" />
+ <entry key="FindFieldSelfAssignment" value="true" />
+ <entry key="FindFinalizeInvocations" value="true" />
+ <entry key="FindFloatEquality" value="true" />
+ <entry key="FindFloatMath" value="false" />
+ <entry key="FindHEmismatch" value="true" />
+ <entry key="FindInconsistentSync2" value="true" />
+ <entry key="FindJSR166LockMonitorenter" value="true" />
+ <entry key="FindLocalSelfAssignment2" value="true" />
+ <entry key="FindMaskedFields" value="true" />
+ <entry key="FindMismatchedWaitOrNotify" value="true" />
+ <entry key="FindNakedNotify" value="true" />
+ <entry key="FindNonSerializableStoreIntoSession" value="false" />
+ <entry key="FindNonSerializableValuePassedToWriteObject" value="false" />
+ <entry key="FindNonShortCircuit" value="true" />
+ <entry key="FindNullDeref" value="true" />
+ <entry key="FindNullDerefsInvolvingNonShortCircuitEvaluation" value="true" />
+ <entry key="FindOpenStream" value="true" />
+ <entry key="FindPuzzlers" value="true" />
+ <entry key="FindRefComparison" value="true" />
+ <entry key="FindReturnRef" value="true" />
+ <entry key="FindRunInvocations" value="true" />
+ <entry key="FindSelfComparison" value="true" />
+ <entry key="FindSelfComparison2" value="true" />
+ <entry key="FindSleepWithLockHeld" value="true" />
+ <entry key="FindSpinLoop" value="true" />
+ <entry key="FindSqlInjection" value="true" />
+ <entry key="FindTwoLockWait" value="true" />
+ <entry key="FindUncalledPrivateMethods" value="true" />
+ <entry key="FindUnconditionalWait" value="true" />
+ <entry key="FindUninitializedGet" value="true" />
+ <entry key="FindUnrelatedTypesInGenericContainer" value="true" />
+ <entry key="FindUnreleasedLock" value="true" />
+ <entry key="FindUnsatisfiedObligation" value="true" />
+ <entry key="FindUnsyncGet" value="true" />
+ <entry key="FindUseOfNonSerializableValue" value="true" />
+ <entry key="FindUselessControlFlow" value="true" />
+ <entry key="FormatStringChecker" value="true" />
+ <entry key="FunctionsThatMightBeMistakenForProcedures" value="true" />
+ <entry key="HugeSharedStringConstants" value="true" />
+ <entry key="IDivResultCastToDouble" value="true" />
+ <entry key="IncompatMask" value="true" />
+ <entry key="InconsistentAnnotations" value="true" />
+ <entry key="InefficientMemberAccess" value="false" />
+ <entry key="InefficientToArray" value="true" />
+ <entry key="InfiniteLoop" value="true" />
+ <entry key="InfiniteRecursiveLoop" value="true" />
+ <entry key="InheritanceUnsafeGetResource" value="true" />
+ <entry key="InitializationChain" value="true" />
+ <entry key="InitializeNonnullFieldsInConstructor" value="true" />
+ <entry key="InstantiateStaticClass" value="true" />
+ <entry key="IntCast2LongAsInstant" value="true" />
+ <entry key="InvalidJUnitTest" value="true" />
+ <entry key="IteratorIdioms" value="true" />
+ <entry key="LazyInit" value="true" />
+ <entry key="LoadOfKnownNullValue" value="true" />
+ <entry key="LostLoggerDueToWeakReference" value="true" />
+ <entry key="MethodReturnCheck" value="true" />
+ <entry key="Methods" value="true" />
+ <entry key="MultithreadedInstanceAccess" value="true" />
+ <entry key="MutableLock" value="true" />
+ <entry key="MutableStaticFields" value="true" />
+ <entry key="Naming" value="true" />
+ <entry key="Noise" value="false" />
+ <entry key="NoiseNullDeref" value="false" />
+ <entry key="NoteAnnotationRetention" value="true" />
+ <entry key="NoteCheckReturnValueAnnotations" value="true" />
+ <entry key="NoteDirectlyRelevantTypeQualifiers" value="true" />
+ <entry key="NoteJCIPAnnotation" value="true" />
+ <entry key="NoteNonNullAnnotations" value="true" />
+ <entry key="NoteNonnullReturnValues" value="true" />
+ <entry key="NoteSuppressedWarnings" value="true" />
+ <entry key="NoteUnconditionalParamDerefs" value="true" />
+ <entry key="NumberConstructor" value="true" />
+ <entry key="OverridingEqualsNotSymmetrical" value="true" />
+ <entry key="PreferZeroLengthArrays" value="true" />
+ <entry key="PublicSemaphores" value="false" />
+ <entry key="QuestionableBooleanAssignment" value="true" />
+ <entry key="ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass" value="true" />
+ <entry key="ReadReturnShouldBeChecked" value="true" />
+ <entry key="RedundantInterfaces" value="true" />
+ <entry key="ReflectiveClasses" value="true" />
+ <entry key="RepeatedConditionals" value="true" />
+ <entry key="ResolveAllReferences" value="false" />
+ <entry key="RuntimeExceptionCapture" value="true" />
+ <entry key="SerializableIdiom" value="true" />
+ <entry key="StartInConstructor" value="true" />
+ <entry key="StaticCalendarDetector" value="true" />
+ <entry key="StringConcatenation" value="true" />
+ <entry key="SuperfluousInstanceOf" value="true" />
+ <entry key="SuspiciousThreadInterrupted" value="true" />
+ <entry key="SwitchFallthrough" value="true" />
+ <entry key="SynchronizationOnSharedBuiltinConstant" value="true" />
+ <entry key="SynchronizeAndNullCheckField" value="true" />
+ <entry key="SynchronizeOnClassLiteralNotGetClass" value="true" />
+ <entry key="SynchronizingOnContentsOfFieldToProtectField" value="true" />
+ <entry key="TestASM" value="false" />
+ <entry key="TestDataflowAnalysis" value="false" />
+ <entry key="TestingGround" value="false" />
+ <entry key="TestingGround2" value="false" />
+ <entry key="TrainFieldStoreTypes" value="true" />
+ <entry key="TrainLongInstantfParams" value="true" />
+ <entry key="TrainNonNullAnnotations" value="true" />
+ <entry key="TrainUnconditionalDerefParams" value="true" />
+ <entry key="URLProblems" value="true" />
+ <entry key="UncallableMethodOfAnonymousClass" value="true" />
+ <entry key="UnnecessaryMath" value="true" />
+ <entry key="UnreadFields" value="true" />
+ <entry key="UselessSubclassMethod" value="false" />
+ <entry key="VarArgsProblems" value="true" />
+ <entry key="VolatileUsage" value="true" />
+ <entry key="WaitInLoop" value="true" />
+ <entry key="WrongMapIterator" value="true" />
+ <entry key="XMLFactoryBypass" value="true" />
+ </map>
+ </option>
+ <option name="_reportCategories">
+ <map>
+ <entry key="BAD_PRACTICE" value="true" />
+ <entry key="CORRECTNESS" value="true" />
+ <entry key="EXPERIMENTAL" value="true" />
+ <entry key="I18N" value="true" />
+ <entry key="MALICIOUS_CODE" value="true" />
+ <entry key="MT_CORRECTNESS" value="true" />
+ <entry key="PERFORMANCE" value="true" />
+ <entry key="SECURITY" value="true" />
+ <entry key="STYLE" value="true" />
+ </map>
+ </option>
+ </component>
+</module>
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextComparatorTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextComparatorTest.java b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextComparatorTest.java
new file mode 100644
index 0000000..e566472
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextComparatorTest.java
@@ -0,0 +1,97 @@
+/*
+* 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.autoscaler.service.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.stratos.autoscaler.service.impl.AutoscalerServiceImpl.IaasContextComparator;
+import org.apache.stratos.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/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextTest.java b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextTest.java
new file mode 100644
index 0000000..8b0cba6
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/util/IaasContextTest.java
@@ -0,0 +1,112 @@
+/*
+* 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.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.apache.stratos.autoscaler.service.impl.AutoscalerServiceImpl.Iaases;
+import org.apache.stratos.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/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java
new file mode 100644
index 0000000..7e7a878
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/java/org/apache/stratos/autoscaler/service/xml/ElasticScalerConfigFileReaderTest.java
@@ -0,0 +1,59 @@
+/*
+* 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.autoscaler.service.xml;
+
+import java.util.List;
+import org.apache.stratos.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.apache.stratos.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/519d4c5d/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml
new file mode 100644
index 0000000..3ef215e
--- /dev/null
+++ b/components/load-balancer/autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0/src/test/resources/elastic-scaler-config.xml
@@ -0,0 +1,66 @@
+<?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>