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:54 UTC
[04/10] committing org.apache.stratos.mediator.autoscale
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscaleUtil.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscaleUtil.java b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscaleUtil.java
deleted file mode 100644
index c3131af..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscaleUtil.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * 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.
- */
-package org.wso2.carbon.mediator.autoscale.lbautoscale.util;
-
-import org.apache.axis2.clustering.ClusteringAgent;
-import org.apache.axis2.clustering.management.GroupManagementAgent;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.protocol.HTTP;
-import org.apache.synapse.MessageContext;
-import org.apache.synapse.SynapseException;
-import org.apache.synapse.core.axis2.Axis2MessageContext;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
-import org.wso2.carbon.mediator.autoscale.lbautoscale.clients.CloudControllerClient;
-import org.wso2.carbon.mediator.autoscale.lbautoscale.context.AppDomainContext;
-import org.wso2.carbon.mediator.autoscale.lbautoscale.context.LoadBalancerContext;
-import org.wso2.carbon.mediator.autoscale.lbautoscale.state.check.PendingInstancesStateChecker;
-import org.apache.axiom.om.util.Base64;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Utility methods for Autoscale mediator
- */
-public final class AutoscaleUtil {
-
- private static final Log log = LogFactory.getLog(AutoscaleUtil.class);
-
- private AutoscaleUtil() {
- }
-
- /**
- * handles the exception
- *
- * @param msg exception message
- */
- public static void handleException(String msg) {
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- /**
- * handles the exception
- *
- * @param msg exception message
- * @param e exception
- */
- public static void handleException(String msg, Exception e) {
- log.error(msg, e);
- throw new SynapseException(msg, e);
- }
-
- /**
- * Returns the contents of the file in a byte array
- *
- * @param file - Input File
- * @return Bytes from the file
- * @throws java.io.IOException, if retrieving the file contents failed.
- */
- public static byte[] getBytesFromFile(File file) throws IOException {
- if (!file.exists()) {
- log.error("Payload file " + file.getAbsolutePath() + " does not exist");
- return null;
- }
- InputStream is = new FileInputStream(file);
- byte[] bytes;
-
- try {
- // Get the size of the file
- long length = file.length();
-
- // You cannot create an array using a long type.
- // It needs to be an int type.
- // Before converting to an int type, check
- // to ensure that file is not larger than Integer.MAX_VALUE.
- if (length > Integer.MAX_VALUE) {
- if (log.isDebugEnabled()) {
- log.debug("File is too large");
- }
- }
-
- // Create the byte array to hold the data
- bytes = new byte[(int) length];
-
- // Read in the bytes
- int offset = 0;
- int numRead;
- while (offset < bytes.length
- && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
- offset += numRead;
- }
-
- // Ensure all the bytes have been read in
- if (offset < bytes.length) {
- throw new IOException("Could not completely read file " + file.getName());
- }
- } finally {
- // Close the input stream and return bytes
- is.close();
- }
-
- return bytes;
- }
-
- /**
- * Replaces the variables
- *
- * @param text input string
- * @return output String
- */
- public static String replaceVariables(String text) {
- int indexOfStartingChars;
- int indexOfClosingBrace;
-
- // The following condition deals with properties.
- // Properties are specified as ${system.property},
- // and are assumed to be System properties
- if ((indexOfStartingChars = text.indexOf("${")) != -1 &&
- (indexOfClosingBrace = text.indexOf("}")) != -1) { // Is a property used?
- String var = text.substring(indexOfStartingChars + 2,
- indexOfClosingBrace);
-
- String propValue = System.getProperty(var);
- if (propValue == null) {
- propValue = System.getenv(var);
- }
- if (propValue != null) {
- text = text.substring(0, indexOfStartingChars) + propValue +
- text.substring(indexOfClosingBrace + 1);
- }
- }
- return text;
- }
-
-/* public static InstanceManager createEC2InstanceManager(String accessKey,
- String secretKey,
- String instanceMgtEPR) {
- AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
- AmazonEC2Client ec2Client = new AmazonEC2Client(awsCredentials);
- ec2Client.setEndpoint(instanceMgtEPR);
- return new InstanceManager(ec2Client);
- }*/
-
- public static String getUserData(String payloadFileName) {
- String userData = null;
- try {
- File file = new File(payloadFileName);
- if (!file.exists()) {
- handleException("Payload file " + payloadFileName + " does not exist");
- }
- if (!file.canRead()) {
- handleException("Payload file " + payloadFileName + " does cannot be read");
- }
- byte[] bytes = AutoscaleUtil.getBytesFromFile(file);
- if (bytes != null) {
-// /BASE64.e encoder = new BASE64Encoder();
- userData = Base64.encode(bytes);
- }
- } catch (IOException e) {
- AutoscaleUtil.handleException("Cannot read data from payload file " + payloadFileName,
- e);
- }
- return userData;
- }
-
- /*public static boolean areEqual(List<GroupIdentifier> securityGroups1, String[] sourceGroups2) {
- for (String sourceGroup : sourceGroups2) {
- boolean isSourceGroupFound = false;
- for (GroupIdentifier securityGroup : securityGroups1) {
- if (securityGroup.getGroupName().equals(sourceGroup)) {
- isSourceGroupFound = true;
- }
- }
- if (!isSourceGroupFound) {
- return false;
- }
- }
- return true;
- } */
-
- /**
- * TODO These methods should use to common place since these are using endpoints and mediators
- */
- public static int getTenantId(String url) {
- String address = url;
- String servicesPrefix = "/t/";
- if (address != null && address.contains(servicesPrefix)) {
- int domainNameStartIndex =
- address.indexOf(servicesPrefix) + servicesPrefix.length();
- int domainNameEndIndex = address.indexOf('/', domainNameStartIndex);
- String domainName = address.substring(domainNameStartIndex,
- domainNameEndIndex == -1 ? address.length() : domainNameEndIndex);
- // return tenant id if domain name is not null
- if (domainName != null) {
- try {
- return AutoscalerTaskDSHolder.getInstance().getRealmService().getTenantManager().getTenantId(domainName);
- } catch (org.wso2.carbon.user.api.UserStoreException e) {
- log.error("An error occurred while obtaining the tenant id.", e);
- }
- }
- }
- // return 0 if the domain name is null
- return 0;
- }
-
- /**
- * TODO These methods should use to common place since these are using endpoints and mediators
- */
- @SuppressWarnings("unchecked")
- public static String getTargetHost(MessageContext synCtx) {
- org.apache.axis2.context.MessageContext axis2MessageContext =
- ((Axis2MessageContext) synCtx).getAxis2MessageContext();
- Map<String, String> headers =
- (Map<String, String>) axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
- String address = headers.get(HTTP.TARGET_HOST);
- if (address.contains(":")) {
- address = address.substring(0, address.indexOf(":"));
- }
- return address;
- }
-
- @SuppressWarnings("unchecked")
- public static Map<String, Map<String, ?>> getAppDomainContexts(ConfigurationContext configCtx,
- LoadBalancerConfiguration lbConfig) {
- Map<String, Map<String, ?>> oldAppDomainContexts =
- (Map<String, Map<String, ?>>) configCtx.getPropertyNonReplicable(AutoscaleConstants.APP_DOMAIN_CONTEXTS);
- Map<String, Map<String, ?>> newAppDomainContexts = new HashMap<String, Map<String, ?>>();
-
- ClusteringAgent clusteringAgent = configCtx.getAxisConfiguration().getClusteringAgent();
-
- for (String domain : lbConfig.getServiceDomains()) {
-
- for (String subDomain : lbConfig.getServiceSubDomains(domain)) {
- if (clusteringAgent.getGroupManagementAgent(domain, subDomain) == null) {
- throw new SynapseException("Axis2 clustering GroupManagementAgent for domain: " + domain +
- ", sub-domain: " + subDomain +
- " has not been defined");
- }
-
- if(oldAppDomainContexts == null || oldAppDomainContexts.get(domain) == null ||
- (oldAppDomainContexts.get(domain) != null && oldAppDomainContexts.get(domain).get(subDomain) == null)){
-
- AppDomainContext appCtxt = new AppDomainContext(lbConfig.getServiceConfig(domain,
- subDomain));
-
- addAppDomainContext(newAppDomainContexts, domain, subDomain, appCtxt);
-
- } else {
- addAppDomainContext(newAppDomainContexts, domain, subDomain, (AppDomainContext) oldAppDomainContexts.get(domain).get(subDomain));
- }
-
- }
-
- }
-// }
- configCtx.setNonReplicableProperty(AutoscaleConstants.APP_DOMAIN_CONTEXTS,
- newAppDomainContexts);
-
- return newAppDomainContexts;
- }
-
-
- private static void addAppDomainContext(Map<String, Map<String, ?>> appDomainContexts,
- String domain, String subDomain, AppDomainContext appCtxt) {
-
- Map<String, AppDomainContext> map ;
-
- if(appDomainContexts.containsKey(domain)){
- map = (Map<String, AppDomainContext>) appDomainContexts.get(domain);
- }
- else{
- map = new HashMap<String, AppDomainContext>();
- }
- // put this appDomainContext
- map.put(subDomain, appCtxt);
-
- // update the parent map
- appDomainContexts.put(domain, map);
-
- }
-
- public static String domainSubDomainString(String domain, String subDomain){
- return "Domain: "+domain+" - Sub Domain: "+subDomain;
- }
-
- public static int runInstances(final CloudControllerClient client, final LoadBalancerContext context, final String domain,
- final String subDomain, int diff) {
-
- int successfullyStartedInstanceCount = diff;
-
- if(context == null){
- // can't help
- return 0;
- }
-
- while (diff > 0) {
- // call autoscaler service and ask to spawn an instance
- // and increment pending instance count only if autoscaler service returns
- // true.
- try {
- String ip = client.startInstance(domain, subDomain);
-
- if (ip == null || ip.isEmpty()) {
- log.debug("Instance start up failed for " + domainSubDomainString(domain, subDomain));
- successfullyStartedInstanceCount--;
-
- } else {
- log.debug("An instance of " + domainSubDomainString(domain, subDomain) +
- " is started up.");
- if (context != null) {
- context.incrementPendingInstances(1);
- }
- }
- } catch (Exception e) {
- log.error("Failed to start an instance of " + domainSubDomainString(domain, subDomain) + ".\n", e);
- successfullyStartedInstanceCount--;
- }
-
- diff--;
- }
-
- if (successfullyStartedInstanceCount > 0) {
-
- Thread stateChecker =
- new Thread(new PendingInstancesStateChecker(
- context,
- domain,
- subDomain,
- successfullyStartedInstanceCount,
- context.getRunningInstanceCount(),
- client));
- stateChecker.start();
- }
-
- return successfullyStartedInstanceCount;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscalerTaskDSHolder.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscalerTaskDSHolder.java b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscalerTaskDSHolder.java
deleted file mode 100644
index f097e2e..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/java/org/wso2/carbon/mediator/autoscale/lbautoscale/util/AutoscalerTaskDSHolder.java
+++ /dev/null
@@ -1,129 +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.mediator.autoscale.lbautoscale.util;
-
-import org.apache.axis2.clustering.ClusteringAgent;
-import org.apache.axis2.context.ConfigurationContext;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration.LBConfiguration;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration.ServiceConfiguration;
-import org.wso2.carbon.lb.common.service.LoadBalancerConfigurationService;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.stratos.cloud.controller.interfaces.CloudControllerService;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-
-/**
- * Singleton class to hold Agent Management Service
- */
-public class AutoscalerTaskDSHolder {
-
- private ConfigurationContextService configurationContextService;
- private LoadBalancerConfiguration wholeLbConfig;
- private CloudControllerService cloudControllerService;
-
- private RealmService realmService;
- private ClusteringAgent agent;
- private ConfigurationContext configCtxt;
- private UserRegistry configRegistry;
- private UserRegistry governanceRegistry;
-
- private static AutoscalerTaskDSHolder instance = new AutoscalerTaskDSHolder();
-
- private AutoscalerTaskDSHolder(){
-
- }
-
- public static AutoscalerTaskDSHolder getInstance(){
- return instance;
- }
-
- public ConfigurationContextService getConfigurationContextServiceService(){
- return this.configurationContextService;
- }
-
- public void setConfigurationContextService(ConfigurationContextService cCtxService){
- this.configurationContextService = cCtxService;
- }
-
- public LoadBalancerConfiguration getWholeLoadBalancerConfig() {
- return wholeLbConfig;
- }
-
- public LBConfiguration getLoadBalancerConfig() {
- return wholeLbConfig.getLoadBalancerConfig();
- }
-
- public ClusteringAgent getAgent() {
- return agent;
- }
-
- public void setAgent(ClusteringAgent agent) {
- this.agent = agent;
- }
-
-
- public void setRealmService(RealmService realmService) {
- this.realmService = realmService;
- }
-
- public RealmService getRealmService() {
- return realmService;
- }
-
- public void setLbConfigService(LoadBalancerConfigurationService lbConfigSer) {
- if (lbConfigSer != null) {
- this.wholeLbConfig = (LoadBalancerConfiguration) lbConfigSer.getLoadBalancerConfig();
- } else {
- this.wholeLbConfig = null;
- }
- }
-
- public void setConfigCtxt(ConfigurationContext configCtxt) {
- this.configCtxt = configCtxt;
- }
-
- public ConfigurationContext getConfigCtxt() {
- return configCtxt;
- }
-
- public void setCloudControllerService(CloudControllerService cc) {
- this.cloudControllerService = cc;
- }
-
- public CloudControllerService getCloudControllerService() {
- return cloudControllerService;
- }
-
- public UserRegistry getConfigRegistry() {
- return configRegistry;
- }
-
- public void setConfigRegistry(UserRegistry configRegistry) {
- this.configRegistry = configRegistry;
- }
-
- public UserRegistry getGovernanceRegistry() {
- return governanceRegistry;
- }
-
- public void setGovernanceRegistry(UserRegistry governanceRegistry) {
- this.governanceRegistry = governanceRegistry;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory
deleted file mode 100644
index 399d502..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory
+++ /dev/null
@@ -1,2 +0,0 @@
-org.wso2.carbon.mediator.autoscale.ec2autoscale.mediators.AutoscaleInMediatorFactory
-org.wso2.carbon.mediator.autoscale.ec2autoscale.mediators.AutoscaleOutMediatorFactory
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorSerializer
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorSerializer b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorSerializer
deleted file mode 100644
index 05fce78..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorSerializer
+++ /dev/null
@@ -1,2 +0,0 @@
-org.wso2.carbon.mediator.autoscale.ec2autoscale.mediators.AutoscaleInMediatorSerializer
-org.wso2.carbon.mediator.autoscale.ec2autoscale.mediators.AutoscaleOutMediatorSerializer
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-load-average.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-load-average.xml b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-load-average.xml
deleted file mode 100644
index f8ecf6f..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-load-average.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://wso2.com) All Rights Reserved.
- ~
- ~ WSO2 Inc. licenses this file to you under the Apache License,
- ~ Version 2.0 (the "License"); you may not use this file except
- ~ in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!-- The default synapse configuration shipped with the WSO2 Load Balancer
- This handles the load balancing and the autoscaling of the stratos services
- -->
-
-<definitions xmlns="http://ws.apache.org/ns/synapse">
-
- <!-- You can add any flat sequences, endpoints, etc.. to this synapse-messages-in-flight.xml file if you do
- *not* want to have the defaults given below, specific to WSO2 LB and auto-scaler
- -->
-
-
- <!-- Given below is the auto-scale mediator specific task. Uncomment it, if you want to
- auto-scale your applications.
- -->
-
- <task class="org.wso2.carbon.mediator.autoscale2.LoadAverageBasedEC2LoadAnalyzerTask"
- name="LoadAnalyzer">
-
-
- <!--
- The private key for the ec2
- -->
- <property name="ec2PrivateKey" value="/mnt/payload/pk.pem"/>
-
- <!--
- The certificate for the ec2
- -->
- <property name="ec2Cert" value="/mnt/payload/cert.pem"/>
-
- <!--
- The amazon instance type for the load balanced service instances.
- Recommended and the default is m1.large.
- -->
- <property name="instanceType" value="m1.large"/>
-
- <!--
- The amazon instance type for the instances of the load balancer itself.
- Default is m1.large. Can be changed to m1.small too.
- -->
- <property name="loadBalancerInstanceType" value="m1.large"/>
-
- <!--
- The group of the service being load balanced.
- -->
- <property name="applicationGroup" value="as-2011-02-23,cloud-mysql,default"/>
-
- <!--
- The group of the load balancer.
- -->
- <property name="loadBalancerGroup" value="stratos-appserver-lb,cloud-mysql,default"/>
-
- <!--
- The Amazon availability zone for the instances. 1-c is given as the default
- -->
- <property name="availabilityZone" value="us-east-1c"/>
-
- <!--
- Additional information for the amazon instances
- -->
- <property name="instanceAdditionalInfo" value="EC2 autoscale instance"/>
-
- <!--
- The key pair
- -->
- <property name="key" value="stratos-1.0.0-keypair"/>
-
- <!--
- The service payload file which should be loaded to the bucket
- -->
- <property name="applicationPayload" value="resources/cluster_node.zip"/>
-
- <!--
- The load balancer payload file which should be loaded to the bucket
- -->
- <property name="loadBalancerPayload" value="/mnt/payload.zip"/>
-
- <!--
- The elasticIP property can be overriden by the ELASTIC_IP environment var,
- which is set in the payload
- -->
- <property name="elasticIP" value="${ELASTIC_IP}"/>
-
- <!--
- The minimum and maximum limits of the load balanced service instances
- -->
- <property name="minAppInstances" value="1"/>
- <property name="maxAppInstances" value="5"/>
-
- <!--
- The minimum and maximum limits of the load balancer instances
- -->
- <property name="minLoadBalancerInstances" value="1"/>
-
- <property name="roundsToAverage" value="10"/>
-
- <!--
- The instances spawned at once, per scaling up decision.
- Default and the recommended value is 1
- -->
- <property name="instancesPerScaleUp" value="1"/>
-
- <!--
- The low and high limits of the load average
- -->
- <property name="loadAverageLowerLimit" value="2"/>
- <property name="loadAverageHigherLimit" value="5"/>
-
- <!--
- The Load Balanced Service Ports
- -->
- <property name="serviceHttpPort" value="9763"/>
- <property name="serviceHttpsPort" value="9443"/>
-
- <!--
- The interval to trigger the task in seconds
- -->
- <trigger interval="5"/>
- </task>
-</definitions>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-messages-in-flight.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-messages-in-flight.xml b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-messages-in-flight.xml
deleted file mode 100644
index 3e66066..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-messages-in-flight.xml
+++ /dev/null
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://wso2.com) All Rights Reserved.
- ~
- ~ WSO2 Inc. licenses this file to you under the Apache License,
- ~ Version 2.0 (the "License"); you may not use this file except
- ~ in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!-- The default synapse configuration shipped with the WSO2 Load Balancer
- This handles the load balancing and the autoscaling of the stratos services
- -->
-
-<definitions xmlns="http://ws.apache.org/ns/synapse">
-
- <!-- You can add any flat sequences, endpoints, etc.. to this synapse-messages-in-flight.xml file if you do
- *not* want to have the defaults given below, specific to WSO2 LB and auto-scaler
- -->
-
-
- <!-- Given below is the auto-scale mediator specific task. Uncomment it, if you want to
- auto-scale your applications.
- -->
-
- <task class="org.wso2.carbon.mediator.autoscale2.MessagesInFlightBasedEC2LoadAnalyzerTask"
- name="LoadAnalyzer">
-
-
- <!--
- The private key for the ec2
- -->
- <property name="ec2PrivateKey" value="/mnt/payload/pk.pem"/>
-
- <!--
- The certificate for the ec2
- -->
- <property name="ec2Cert" value="/mnt/payload/cert.pem"/>
-
- <!--
- The amazon instance type for the load balanced service instances.
- Recommended and the default is m1.large.
- -->
- <property name="instanceType" value="m1.large"/>
-
- <!--
- The amazon instance type for the instances of the load balancer itself.
- Default is m1.large. Can be changed to m1.small too.
- -->
- <property name="loadBalancerInstanceType" value="m1.large"/>
-
- <!--
- The group of the service being load balanced.
- -->
- <property name="applicationGroup" value="as-2011-02-23,cloud-mysql,default"/>
-
- <!--
- The group of the load balancer.
- -->
- <property name="loadBalancerGroup" value="stratos-appserver-lb,cloud-mysql,default"/>
-
- <!--
- The Amazon availability zone for the instances. 1-c is given as the default
- -->
- <property name="availabilityZone" value="us-east-1c"/>
-
- <!--
- Additional information for the amazon instances
- -->
- <property name="instanceAdditionalInfo" value="EC2 autoscale instance"/>
-
- <!--
- The key pair
- -->
- <property name="key" value="stratos-1.0.0-keypair"/>
-
- <!--
- The service payload file which should be loaded to the bucket
- -->
- <property name="applicationPayload" value="resources/cluster_node.zip"/>
-
- <!--
- The load balancer payload file which should be loaded to the bucket
- -->
- <property name="loadBalancerPayload" value="/mnt/payload.zip"/>
-
- <!--
- The elasticIP property can be overriden by the ELASTIC_IP environment var,
- which is set in the payload
- -->
- <property name="elasticIP" value="${ELASTIC_IP}"/>
-
- <!--
- The time in milliseconds which the message takes to expire
- -->
- <property name="messageExpiryTime" value="60000"/>
-
- <!--
- The minimum and maximum limits of the load balanced service instances
- -->
- <property name="minAppInstances" value="1"/>
- <property name="maxAppInstances" value="5"/>
-
- <!--
- The number of load balancer instances
- -->
- <property name="loadBalancerInstances" value="1"/>
-
- <!--
- The given queue length per node, for the calculation in scaling up
- -->
- <property name="queueLengthPerNode" value="400"/>
- <property name="roundsToAverage" value="10"/>
-
- <!--
- The instances spawned at once, per scaling up decision.
- Default and the recommended value is 1
- -->
- <property name="instancesPerScaleUp" value="1"/>
-
- <!--
- The interval to trigger the task in seconds
- -->
- <trigger interval="5"/>
- </task>
-</definitions>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-service-messages-in-flight.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-service-messages-in-flight.xml b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-service-messages-in-flight.xml
deleted file mode 100644
index 7332d38..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/main/resources/synapse-service-messages-in-flight.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://wso2.com) All Rights Reserved.
- ~
- ~ WSO2 Inc. licenses this file to you under the Apache License,
- ~ Version 2.0 (the "License"); you may not use this file except
- ~ in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!-- The default synapse configuration shipped with the WSO2 Load Balancer
- This handles the load balancing and the autoscaling of the stratos services
- -->
-
-<definitions xmlns="http://ws.apache.org/ns/synapse">
-
- <!-- You can add any flat sequences, endpoints, etc.. to this synapse-messages-in-flight.xml file if you do
- *not* want to have the defaults given below, specific to WSO2 LB and auto-scaler
- -->
-
-
- <!-- Given below is the auto-scale mediator specific task. Uncomment it, if you want to
- auto-scale your applications.
- -->
- <task class="org.wso2.carbon.mediator.autoscale.lbautoscale.ServiceRequestsInFlightAutoscaler"
- name="LoadAnalyzer">
-
- <!--
- The private key for ec2
- -->
- <property name="ec2PrivateKey" value="/mnt/payload/pk.pem"/>
-
- <!--
- The certificate for ec2
- -->
- <property name="ec2Cert" value="/mnt/payload/cert.pem"/>
- <!--
- The key pair
- -->
- <property name="sshKey" value="stratos-1.0.0-keypair"/>
-
- <property name="loadBalancer">
- <loadBalancer>
- <property name="securityGroup" value="stratos-appserver-lb"/>
- <property name="instanceType" value="m1.large"/>
- <property name="instances" value="1"/>
- <property name="elasticIP" value="${ELASTIC_IP}"/>
- <property name="availabilityZone" value="us-east-1c"/>
- <property name="payload" value="/mnt/payload.zip"/>
- </loadBalancer>
- </property>
-
- <property name="services">
- <services>
- <defaults>
- <property name="payload" value="resources/cluster_node.zip"/>
- <property name="availabilityZone" value="us-east-1c"/>
- <property name="securityGroup" value="as-2011-02-23"/>
- <property name="instanceType" value="m1.large"/>
- <property name="minAppInstances" value="1"/>
- <property name="maxAppInstances" value="5"/>
- <property name="queueLengthPerNode" value="400"/>
- <property name="roundsToAverage" value="10"/>
- <property name="instancesPerScaleUp" value="1"/>
- <property name="messageExpiryTime" value="60000"/>
- </defaults>
- <service domain="wso2.as.domain">
- <property name="payload" value="resources/cluster_node.zip"/>
- <property name="availabilityZone" value="us-east-1c"/>
- </service>
- <service domain="wso2.ds.domain">
- <property name="payload" value="resources/cluster_node.zip"/>
- <property name="minAppInstances" value="1"/>
- <property name="maxAppInstances" value="5"/>
- <property name="queueLengthPerNode" value="400"/>
- <property name="roundsToAverage" value="10"/>
- <property name="instancesPerScaleUp" value="1"/>
- <property name="availabilityZone" value="us-east-1c"/>
- <property name="securityGroup" value="ds-2011-02-23"/>
- </service>
- <service domain="wso2.bps.domain">
- <property name="payload" value="resources/cluster_node.zip"/>
- <property name="minAppInstances" value="1"/>
- <property name="maxAppInstances" value="5"/>
- <property name="queueLengthPerNode" value="400"/>
- <property name="roundsToAverage" value="10"/>
- <property name="instancesPerScaleUp" value="1"/>
- <property name="availabilityZone" value="us-east-1c"/>
- <property name="securityGroup" value="bps-2011-02-23"/>
- </service>
- </services>
- </property>
-
- <!--
- The interval to trigger the task in seconds
- -->
- <trigger interval="5"/>
- </task>
-</definitions>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/AppDomainContextsTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/AppDomainContextsTest.java b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/AppDomainContextsTest.java
deleted file mode 100644
index 1d017a3..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/AppDomainContextsTest.java
+++ /dev/null
@@ -1,105 +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.mediator.autoscale.lbautoscale;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.axis2.clustering.ClusteringAgent;
-import org.apache.axis2.clustering.tribes.TribesClusteringAgent;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration.ServiceConfiguration;
-import org.wso2.carbon.lb.common.group.mgt.SubDomainAwareGroupManagementAgent;
-import org.wso2.carbon.mediator.autoscale.lbautoscale.context.AppDomainContext;
-import org.wso2.carbon.mediator.autoscale.lbautoscale.util.AutoscaleUtil;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-public class AppDomainContextsTest extends TestCase {
-
- private static Map<String, Map<String, ?>> map;
- private LoadBalancerConfiguration lbConfig;
- ConfigurationContext configCtx;
- ClusteringAgent clusteringAgent;
-
- protected void setUp() throws Exception {
- super.setUp();
- configCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
- clusteringAgent = new TribesClusteringAgent();
- clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
- "worker"),
- "wso2.as1.domain", "worker", -1);
- clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
- "mgt"),
- "wso2.as1.domain", "mgt", -1);
- clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
- "mgt"),
- "wso2.as2.domain", "mgt", -1);
- configCtx.getAxisConfiguration().setClusteringAgent(clusteringAgent);
-
- File f = new File("src/test/resources/loadbalancer.conf");
- System.setProperty("loadbalancer.conf", f.getAbsolutePath());
- lbConfig = LoadBalancerConfiguration.getInstance();
-
- map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
-
- }
-
-
- public void testRemoval(){
- // removing a cluster domain with only 1 sub domain
- lbConfig.removeServiceConfiguration("wso2.as2.domain", "mgt");
- map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
-
- Assert.assertEquals(true, !map.containsKey("wso2.as2.domain"));
-
- // removing a cluster domain with more than 1 sub domain
- lbConfig.removeServiceConfiguration("wso2.as1.domain", "mgt");
- map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
-
- Assert.assertEquals(true, map.containsKey("wso2.as1.domain"));
- Assert.assertEquals(true, map.get("wso2.as1.domain").get("mgt") == null);
- Assert.assertEquals(true, map.get("wso2.as1.domain").get("worker") != null);
- }
-
- public void testAddition(){
- ServiceConfiguration config1 = lbConfig.new ServiceConfiguration();
- config1.setDomain("wso2.as3.domain");
- config1.setSub_domain("mgt");
- lbConfig.addServiceConfiguration(config1);
- clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
- "mgt"),
- "wso2.as3.domain", "mgt", -1);
- map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
-
- Assert.assertEquals(true, map.containsKey("wso2.as3.domain"));
- Assert.assertEquals(true, map.get("wso2.as3.domain").get("mgt") != null);
- }
-
- @Deprecated // use only for writing test cases
- void printKeys(Map<?,?> map){
- for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
- Object type = iterator.next();
- System.out.println(type);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/ServiceRequestsInFlightAutoscalerTest.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/ServiceRequestsInFlightAutoscalerTest.java b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/ServiceRequestsInFlightAutoscalerTest.java
deleted file mode 100644
index 1f1a084..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/java/org/wso2/carbon/mediator/autoscale/lbautoscale/ServiceRequestsInFlightAutoscalerTest.java
+++ /dev/null
@@ -1,29 +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.mediator.autoscale.lbautoscale;
-
-/**
- * Test for ServiceRequestsInFlightAutoscaler
- */
-//public class ServiceRequestsInFlightAutoscalerTest extends TestCase {
-//
-// public void testInit() {
-//
-// //new ServiceRequestsInFlightAutoscaler().init(new Axis2SynapseEnvironment());
-// }
-//}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/resources/loadbalancer.conf
----------------------------------------------------------------------
diff --git a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/resources/loadbalancer.conf b/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/resources/loadbalancer.conf
deleted file mode 100644
index 7b2a80a..0000000
--- a/components/load-balancer/autoscaler/org.wso2.carbon.mediator.autoscale/4.1.3/src/test/resources/loadbalancer.conf
+++ /dev/null
@@ -1,50 +0,0 @@
-loadbalancer {
- instances 1;
- enable_autoscaler true;
- # interval between two task executions in milliseconds
- autoscaler_task_interval 5000;
- # after an instance booted up, task will wait till this much of time and let the server started up
- server_startup_delay 15000; #default will be 60000ms
-}
-
-services {
- defaults {
- min_app_instances 1;
- max_app_instances 5;
- max_requests_per_second 400;
- alarming_upper_rate 0.65;
- alarming_lower_rate 0.2;
- scale_down_factor 0.25;
- rounds_to_average 10;
- instances_per_scale_up 1;
- message_expiry_time 60000;
- }
-
- appserver {
- hosts appserver.cloud-test.wso2.com, as.cloud-test.wso2.com;
- sub_domain worker1;
- domains {
- wso2.as1.domain {
- hosts as1.cloud-test.wso2.com;
- min_app_instances 0;
- sub_domain worker;
- tenant_range 1-5;
- }
- wso2.as1.domain {
- hosts mgt.as1.cloud-test.wso2.com;
- min_app_instances 0;
- sub_domain mgt;
- tenant_range 1-5;
- }
- wso2.as2.domain {
- hosts mgt.as2.cloud-test.wso2.com;
- min_app_instances 0;
- sub_domain mgt;
- tenant_range 1-5;
- }
-
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/pom.xml b/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/pom.xml
index 4f52100..c77ab0b 100644
--- a/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/pom.xml
+++ b/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/pom.xml
@@ -18,7 +18,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <groupId>org.wso2.carbon</groupId>
+ <groupId>org.apache.stratos</groupId>
<artifactId>loadbalancer-components</artifactId>
<version>4.1.0</version>
<relativePath>../../../pom.xml</relativePath>
@@ -36,25 +36,22 @@
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.mediation.initializer</artifactId>
- <version>4.1.0</version>
- <!--version>${wso2carbon.version}</version-->
+ <version>${wso2carbon.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.mediation.dependency.mgt</artifactId>
- <version>4.1.0</version>
- <!--version>${wso2carbon.version}</version-->
+ <version>${wso2carbon.version}</version>
</dependency>
<dependency>
<groupId>org.apache.synapse</groupId>
<artifactId>synapse-core</artifactId>
- <version>2.1.1-wso2v4</version>
+ <version>${synapse.core.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
- <version>4.1.0</version>
- <!--version>${wso2carbon.version}</version-->
+ <version>${wso2carbon.version}</version>
</dependency>
<dependency>
<groupId>org.apache.stratos</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/Main.iml
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/Main.iml b/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/Main.iml
index 54e5e3d..8bf5197 100644
--- a/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/Main.iml
+++ b/components/load-balancer/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/Main.iml
@@ -3,7 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/../../../../org.wso2.carbon.lb.endpoint/4.1.3/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/pom.xml b/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/pom.xml
deleted file mode 100644
index 49f4624..0000000
--- a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>loadbalancer-components</artifactId>
- <version>4.1.0</version>
- <relativePath>../../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.lb.endpoint</artifactId>
- <packaging>bundle</packaging>
- <version>4.1.3</version>
- <name>WSO2 Carbon - Tenant Aware LoadBalance Endpoint</name>
- <url>http://wso2.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.mediation.initializer</artifactId>
- <version>${wso2carbon.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.mediation.dependency.mgt</artifactId>
- <version>${wso2carbon.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.synapse</groupId>
- <artifactId>synapse-core</artifactId>
- <version>2.1.1-wso2v4</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.logging</artifactId>
- <version>${wso2carbon.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.lb.common</artifactId>
- <version>4.1.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-kernel</artifactId>
- <version>1.6.1-wso2v9</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.cartridge.messages</artifactId>
- <version>2.1.1</version>
- </dependency>
- </dependencies>
-
- <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>
-
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Bundle-Name>${project.artifactId}</Bundle-Name>
- <Export-Package>
- org.wso2.carbon.lb.endpoint.endpoint,
- org.wso2.carbon.lb.endpoint,
- org.wso2.carbon.lb.endpoint.util,
- </Export-Package>
- <Import-Package>
- !org.wso2.carbon.lb.endpoint.endpoint,
- !org.wso2.carbon.lb.endpoint,
- org.wso2.carbon.lb.common.*; version=${wso2carbon.version},
- org.wso2.carbon.registry.core.service; version=1.0.1,
- *;resolution:=optional
- </Import-Package>
- <DynamicImport-Package>*</DynamicImport-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointConstants.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointConstants.java b/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointConstants.java
deleted file mode 100644
index cf31ef0..0000000
--- a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointConstants.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2009, 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.
- */
-
-package org.wso2.carbon.lb.endpoint;
-
-/**
- * The <code>EndpointConstants</code> class defined the endpoint constants.
- */
-public class EndpointConstants {
-
- public static final String ADDRESS_ENDPOINT = "Address Endpoint";
- public static final String WSDL_ENDPOINT = "WSDL Endpoint";
- public static final String FAILOVER_ENDPOINT = "Failover Group";
- public static final String LOADBALANCE_ENDPOINT = "Loadbalance Endpoint";
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointDeployer.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointDeployer.java b/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointDeployer.java
deleted file mode 100644
index d9366b8..0000000
--- a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/EndpointDeployer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright (c) 2009, 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.
- */
-
-package org.wso2.carbon.lb.endpoint;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.context.ConfigurationContext;
-import org.wso2.carbon.mediation.initializer.ServiceBusConstants;
-import org.wso2.carbon.mediation.initializer.ServiceBusUtils;
-import org.wso2.carbon.mediation.initializer.persistence.MediationPersistenceManager;
-
-import java.util.Properties;
-
-/**
- * Responsible for deploying Synapse artifacts.
- */
-public class EndpointDeployer extends org.apache.synapse.deployers.EndpointDeployer {
-
- MediationPersistenceManager mpm;
-
- @Override
- public void init(ConfigurationContext configCtx) {
- super.init(configCtx);
- this.mpm = ServiceBusUtils.getMediationPersistenceManager(configCtx.getAxisConfiguration());
- }
-
- @Override
- public String deploySynapseArtifact(OMElement artifactConfig, String fileName,
- Properties properties) {
- String epName = super.deploySynapseArtifact(artifactConfig, fileName, properties);
- mpm.saveItemToRegistry(epName, ServiceBusConstants.ITEM_TYPE_ENDPOINT);
- return epName;
- }
-
- @Override
- public String updateSynapseArtifact(OMElement artifactConfig, String fileName,
- String existingArtifactName, Properties properties) {
- String epName = super.updateSynapseArtifact(
- artifactConfig, fileName, existingArtifactName, properties);
- mpm.saveItemToRegistry(epName, ServiceBusConstants.ITEM_TYPE_ENDPOINT);
- return epName;
- }
-
- @Override
- public void undeploySynapseArtifact(String artifactName) {
- super.undeploySynapseArtifact(artifactName);
- mpm.deleteItemFromRegistry(artifactName, ServiceBusConstants.ITEM_TYPE_ENDPOINT);
- }
-
- @Override
- public void restoreSynapseArtifact(String artifactName) {
- super.restoreSynapseArtifact(artifactName);
- mpm.saveItemToRegistry(artifactName, ServiceBusConstants.ITEM_TYPE_ENDPOINT);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantAwareLoadBalanceEndpointException.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantAwareLoadBalanceEndpointException.java b/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantAwareLoadBalanceEndpointException.java
deleted file mode 100644
index d49758a..0000000
--- a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantAwareLoadBalanceEndpointException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) 2009, 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.
- */
-package org.wso2.carbon.lb.endpoint;
-
-/**
- * Exception to be thrown from this component.
- */
-public class TenantAwareLoadBalanceEndpointException extends RuntimeException {
-
- private static final long serialVersionUID = -663839410798538370L;
-
- public TenantAwareLoadBalanceEndpointException(String msg) {
- super(msg);
- }
-
- public TenantAwareLoadBalanceEndpointException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public TenantAwareLoadBalanceEndpointException(Throwable cause) {
- super(cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantLoadBalanceMembershipHandler.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantLoadBalanceMembershipHandler.java b/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantLoadBalanceMembershipHandler.java
deleted file mode 100644
index dec45b4..0000000
--- a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/TenantLoadBalanceMembershipHandler.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package org.wso2.carbon.lb.endpoint;
-
-
-import org.apache.axis2.clustering.ClusteringAgent;
-import org.apache.axis2.clustering.Member;
-import org.apache.axis2.clustering.management.GroupManagementAgent;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.SynapseException;
-import org.apache.synapse.core.LoadBalanceMembershipHandler;
-import org.apache.synapse.endpoints.algorithms.AlgorithmContext;
-import org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm;
-import org.wso2.carbon.lb.common.conf.util.HostContext;
-import org.wso2.carbon.lb.endpoint.util.ConfigHolder;
-import org.wso2.carbon.user.api.UserStoreException;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Bridge between Axis2 membership notification and Synapse load balancing
- */
-public class TenantLoadBalanceMembershipHandler implements LoadBalanceMembershipHandler {
- private static final Log log = LogFactory.getLog(TenantLoadBalanceMembershipHandler.class);
-
- private ConfigurationContext configCtx;
-
- private LoadbalanceAlgorithm lbAlgo;
-
- /**
- * Key - Host, Value - HostContext
- */
- private static Map<String, HostContext> hostContextsMap =
- new HashMap<String, HostContext>();
-
- private ClusteringAgent clusteringAgent;
-
- private boolean isClusteringEnabled;
- private String endpointName;
-
- public TenantLoadBalanceMembershipHandler(Map<String, HostContext> hostContexts,
- LoadbalanceAlgorithm algorithm,
- ConfigurationContext configCtx,
- boolean isClusteringEnabled,
- String endpointName) {
-
- lbAlgo = algorithm;
- this.isClusteringEnabled = isClusteringEnabled;
- this.endpointName = endpointName;
- this.configCtx = configCtx;
-
- for (HostContext host : hostContexts.values()) {
-
- addHostContext(host);
-
- }
- }
-
- /**
- * This will be used to add new {@link HostContext}s.
- * @param host {@link HostContext}
- */
- public void addHostContext(HostContext host){
-
- String hostName = host.getHostName();
-
- AlgorithmContext algorithmContext =
- new AlgorithmContext(isClusteringEnabled,
- configCtx, endpointName + "." +
- hostName);
-
- host.setAlgorithm(lbAlgo.clone());
- host.setAlgorithmContext(algorithmContext);
-
- hostContextsMap.put(hostName, host);
-
- }
-
- /**
- * This will be used to remove an existing {@link HostContext}s.
- * @param host {@link HostContext}
- */
- public void removeHostContext(String host){
-
- hostContextsMap.remove(host);
-
- }
-
- public void init(Properties props, LoadbalanceAlgorithm algorithm) {
- // Nothing to do
- }
-
- public void setConfigurationContext(ConfigurationContext configCtx) {
- this.configCtx = configCtx;
-
- // The following code does the bridging between Axis2 and Synapse load balancing
- clusteringAgent = configCtx.getAxisConfiguration().getClusteringAgent();
- if (clusteringAgent == null) {
- String msg = "In order to enable load balancing across an Axis2 cluster, " +
- "the cluster entry should be enabled in the axis2.xml file";
- log.error(msg);
- throw new SynapseException(msg);
- }
- }
-
- public ConfigurationContext getConfigurationContext() {
- return configCtx;
- }
-
- /**
- * Getting the next member to which the request has to be sent in a round-robin fashion
- *
- * @param context The AlgorithmContext
- * @return The current member
- * @deprecated Use {@link #getNextApplicationMember(String, int)}
- */
- public Member getNextApplicationMember(AlgorithmContext context) {
- throw new UnsupportedOperationException("This operation is invalid. " +
- "Call getNextApplicationMember(String host)");
- }
-
- public boolean isAValidHostName(String host){
- if(getHostContext(host) != null){
- return true;
- }
- return false;
- }
-
- public Member getNextApplicationMember(String host, int tenantId) {
- HostContext hostContext = getHostContext(host);
-
- if(hostContext == null){
- String msg = "Invalid host name : " + host;
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- // here we have to pass tenant id to get domain from hostContext
- String domain = hostContext.getDomainFromTenantId(tenantId);
- String subDomain = hostContext.getSubDomainFromTenantId(tenantId);
-
- LoadbalanceAlgorithm algorithm = hostContext.getAlgorithm();
- GroupManagementAgent groupMgtAgent = clusteringAgent.getGroupManagementAgent(domain, subDomain);
-
- if (groupMgtAgent == null) {
- String tenantDomain;
- try {
- tenantDomain = ConfigHolder.getInstance().getRealmService().getTenantManager().getDomain(tenantId);
- } catch (UserStoreException ignore) {
- tenantDomain = ""+tenantId;
- }
-
- String msg =
- "No Group Management Agent found for the domain: " + domain + ", subDomain: "
- + subDomain + ", host: " + host+ " and for tenant: "
- + tenantDomain;
- log.error(msg);
- throw new SynapseException(msg);
- }
- algorithm.setApplicationMembers(groupMgtAgent.getMembers());
- AlgorithmContext context = hostContext.getAlgorithmContext();
- return algorithm.getNextApplicationMember(context);
- }
-
- public HostContext getHostContext(String host) {
- HostContext hostContext = hostContextsMap.get(host);
- if (hostContext == null) {
- int indexOfDot;
- if ((indexOfDot = host.indexOf(".")) != -1) {
- hostContext = getHostContext(host.substring(indexOfDot + 1));
- }
- }
- return hostContext;
- }
-
- public LoadbalanceAlgorithm getLoadbalanceAlgorithm() {
- return lbAlgo;
- }
-
- public Properties getProperties() {
- return null;
- }
-
- public ClusteringAgent getClusteringAgent() {
- return clusteringAgent;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/builder/TopologySyncher.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/builder/TopologySyncher.java b/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/builder/TopologySyncher.java
deleted file mode 100644
index 31e9f67..0000000
--- a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/builder/TopologySyncher.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.wso2.carbon.lb.endpoint.builder;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.SynapseException;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration.ServiceConfiguration;
-import org.wso2.carbon.lb.common.conf.structure.Node;
-import org.wso2.carbon.lb.common.conf.structure.NodeBuilder;
-import org.wso2.carbon.lb.common.conf.util.HostContext;
-import org.wso2.carbon.lb.common.conf.util.TenantDomainContext;
-import org.wso2.carbon.lb.endpoint.TenantLoadBalanceMembershipHandler;
-import org.wso2.carbon.lb.endpoint.group.mgt.GroupMgtAgentBuilder;
-import org.wso2.carbon.lb.endpoint.util.ConfigHolder;
-
-/**
- * A Thread, which is responsible for making a sense out of a message received for
- * ELB via topology synchronization.
- */
-public class TopologySyncher implements Runnable {
-
- private static final Log log = LogFactory.getLog(TopologySyncher.class);
-
- /*
- * This is a reference to sharedTopologyQueue ConfigHolder.
- */
- private BlockingQueue<String> sharedQueue;
-
- public TopologySyncher(BlockingQueue<String> queue) {
-
- sharedQueue = queue;
-
- }
-
- @Override
- public void run() {
- // grab the lb configuration instance
- LoadBalancerConfiguration lbconfig = LoadBalancerConfiguration.getInstance();
-
- // FIXME Currently there has to be at least one dummy cluster defined in the loadbalancer
- // conf
- // in order to proper initialization of TribesClusteringAgent.
- generateGroupMgtAgents(lbconfig);
-
- // this thread should run for ever, untill terminated.
- while (true) {
- try {
-
- // grabs a message or waits till the queue is non-empty
- String message = sharedQueue.take();
-// ConfigHolder data = ConfigHolder.getInstance();
-
- // this message needs attention only if it's not same as the previous message and
- // not null of course.
-// if (data.getPreviousMsg() == null || !data.getPreviousMsg().equals(message)) {
-
- // reset the previous message
-// data.setPreviousMsg(message);
-
- // build the nginx format of this message, and get the Node object
- Node topologyNode = NodeBuilder.buildNode(message);
-
- // reset service configurations
-// lbconfig.resetData();
- // create new service configurations
- List<ServiceConfiguration> currentServiceConfigs = lbconfig.createServicesConfig(topologyNode);
-
- generateGroupMgtAgents(lbconfig);
-
- removeGroupMgtAgents(lbconfig, currentServiceConfigs);
-
-// }
-
- } catch (InterruptedException ignore) {
- }
- }
-
- }
-
- private void removeGroupMgtAgents(LoadBalancerConfiguration lbConfig, List<ServiceConfiguration> currentServiceConfigs) {
-
- for (Iterator iterator = lbConfig.getServiceConfigurations().values().iterator(); iterator.hasNext();) {
- Map<String, ServiceConfiguration> valuesMap = (Map<String, ServiceConfiguration>) iterator.next();
-
- for (Iterator iterator2 = valuesMap.values().iterator(); iterator2.hasNext();) {
- ServiceConfiguration oldServiceConfig = (ServiceConfiguration) iterator2.next();
-
- if(!currentServiceConfigs.contains(oldServiceConfig)){
- // if the ServiceConfiguration is not there any more in the latest topology
- lbConfig.removeServiceConfiguration(oldServiceConfig.getDomain(), oldServiceConfig.getSubDomain());
- GroupMgtAgentBuilder.resetGroupMgtAgent(oldServiceConfig.getDomain(), oldServiceConfig.getSubDomain());
- }
- }
- }
- }
-
- /**
- * @param lbconfig
- */
- private void generateGroupMgtAgents(LoadBalancerConfiguration lbconfig) {
- TenantLoadBalanceMembershipHandler handler =
- ConfigHolder.getInstance()
- .getTenantLoadBalanceMembershipHandler();
-
- if (handler == null) {
- String msg =
- "TenantLoadBalanceMembershipHandler is null. Thus, We cannot proceed.";
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- Map<String, HostContext> hostContexts = lbconfig.getHostContextMap();
-
- // Add the Axis2 GroupManagement agents
- if (hostContexts != null) {
- // iterate through each host context
- for (HostContext hostCtxt : hostContexts.values()) {
- // each host can has multiple Tenant Contexts, iterate through them
- for (TenantDomainContext tenantCtxt : hostCtxt
- .getTenantDomainContexts()) {
-
- String domain = tenantCtxt.getDomain();
- String subDomain = tenantCtxt.getSubDomain();
-
- // creates the group management agent
- GroupMgtAgentBuilder.createGroupMgtAgent(domain,
- subDomain);
- }
-
- // add to the handler
- handler.addHostContext(hostCtxt);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/290c6307/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/cluster/manager/ClusterDomainManagerImpl.java
----------------------------------------------------------------------
diff --git a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/cluster/manager/ClusterDomainManagerImpl.java b/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/cluster/manager/ClusterDomainManagerImpl.java
deleted file mode 100644
index 1032fc9..0000000
--- a/components/load-balancer/lb-endpoint/org.wso2.carbon.lb.endpoint/4.1.3/src/main/java/org/wso2/carbon/lb/endpoint/cluster/manager/ClusterDomainManagerImpl.java
+++ /dev/null
@@ -1,227 +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.lb.endpoint.cluster.manager;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.axis2.clustering.ClusteringAgent;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.SynapseException;
-import org.wso2.carbon.cartridge.messages.ClusterDomainManager;
-import org.wso2.carbon.cartridge.messages.ClusterDomain;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration;
-import org.wso2.carbon.lb.common.conf.LoadBalancerConfiguration.ServiceConfiguration;
-import org.wso2.carbon.lb.common.conf.util.Constants;
-import org.wso2.carbon.lb.common.conf.util.HostContext;
-import org.wso2.carbon.lb.common.conf.util.TenantDomainContext;
-import org.wso2.carbon.lb.common.group.mgt.SubDomainAwareGroupManagementAgent;
-import org.wso2.carbon.lb.endpoint.TenantLoadBalanceMembershipHandler;
-import org.wso2.carbon.lb.endpoint.util.ConfigHolder;
-
-/**
- * Bridge between the ELB and the Stratos2 Agent.
- */
-public class ClusterDomainManagerImpl implements ClusterDomainManager {
-
- private static final Log log = LogFactory.getLog(ClusterDomainManagerImpl.class);
-
- @Override
- public void addClusterDomain(ClusterDomain cluster) {
-
- // create group management agent, if one doesn't exist already.
- HostContext hostCtxt = createGroupMgtAgentIfNotExists(cluster);
-
- // we should only update if the above step is successful.
- if (hostCtxt != null) {
- // create / update Service Configuration
- createOrUpdateServiceConfig(cluster, hostCtxt);
- }
-
- }
-
- @Override
- public void removeClusterDomain(String domain, String subDomain, String hostName) {
-
- TenantLoadBalanceMembershipHandler handler =
- ConfigHolder.getInstance()
- .getTenantLoadBalanceMembershipHandler();
-
- if (handler == null) {
- String msg = "TenantLoadBalanceMembershipHandler is null. Thus, We cannot proceed.";
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- handler.removeHostContext(hostName);
-
- LoadBalancerConfiguration lbConfig = ConfigHolder.getInstance().getLbConfig();
-
- lbConfig.removeServiceConfiguration(domain, subDomain);
-
- }
-
- private void createOrUpdateServiceConfig(ClusterDomain cluster, HostContext ctxt) {
- LoadBalancerConfiguration lbConfig = ConfigHolder.getInstance().getLbConfig();
-
- String domain = cluster.getDomain();
- String subDomain = cluster.getSubDomain();
-
- if (subDomain == null || subDomain.isEmpty()) {
- // uses default sub domain
- subDomain = Constants.DEFAULT_SUB_DOMAIN;
- }
-
- String hostName = cluster.getHostName();
- String tenantRange = cluster.getTenantRange();
- int minInstances = cluster.getMinInstances();
- int maxInstances = cluster.getMaxInstances();
- String service = cluster.getServiceName();
- int maxRequestsPerSecond = cluster.getMaxRequestsPerSecond();
- int roundsToAverage = cluster.getRoundsToAverage();
- double alarmingUpperRate = cluster.getAlarmingUpperRate();
- double alarmingLowerRate = cluster.getAlarmingLowerRate();
- double scaleDownFactor = cluster.getScaleDownFactor();
-
- ServiceConfiguration serviceConfig ;
-
- if((serviceConfig = lbConfig.getServiceConfig(domain, subDomain)) == null){
- serviceConfig = lbConfig.new ServiceConfiguration();
- }
-
- // we simply override the attributes with new values
- serviceConfig.setDomain(domain);
- serviceConfig.setSub_domain(subDomain);
- serviceConfig.setTenant_range(tenantRange);
- serviceConfig.setHosts(hostName);
- serviceConfig.setMin_app_instances(minInstances);
- serviceConfig.setMax_app_instances(maxInstances);
- serviceConfig.setMax_requests_per_second(maxRequestsPerSecond);
- serviceConfig.setRounds_to_average(roundsToAverage);
- serviceConfig.setAlarming_upper_rate(alarmingUpperRate);
- serviceConfig.setAlarming_lower_rate(alarmingLowerRate);
- serviceConfig.setScale_down_factor(scaleDownFactor);
-
- // add to host name tracker
- lbConfig.addToHostNameTrackerMap(service, serviceConfig.getHosts());
-
- // add to host contexts
- lbConfig.addToHostContextMap(hostName, ctxt);
-
- // finally add this service config
- lbConfig.addServiceConfiguration(serviceConfig);
- }
-
- protected HostContext createGroupMgtAgentIfNotExists(ClusterDomain cluster) {
-
- String domain = cluster.getDomain();
- String subDomain = cluster.getSubDomain();
- String hostName = cluster.getHostName();
- String tenantRange = cluster.getTenantRange();
-
- // sub domain can be null, but others can't
- if (domain == null || hostName == null || tenantRange == null) {
- String msg =
- "Invalid value/s detected - domain: " + domain + "\n host name: " +
- hostName + "\n tenant range: " + tenantRange;
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- if (subDomain == null || subDomain.isEmpty()) {
- // uses default sub domain
- subDomain = Constants.DEFAULT_SUB_DOMAIN;
- }
-
- ClusteringAgent clusteringAgent = null;
-
- try {
- clusteringAgent =
- ConfigHolder.getInstance().getAxisConfiguration()
- .getClusteringAgent();
-
- } catch (Exception e) {
- String msg = "Failed to retrieve Clustering Agent.";
- log.error(msg, e);
- throw new SynapseException(msg, e);
-
- }
-
- if (clusteringAgent == null) {
- String msg = "Clustering Agent is null.";
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- /*
- * Add Group Management Agent if one is not already present for this domain and sub
- * domain
- */
-
- if (clusteringAgent.getGroupManagementAgent(domain, subDomain) == null) {
- clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(subDomain),
- domain, subDomain,-1);
-
- if (log.isDebugEnabled()) {
- log.debug("Group management agent added to cluster domain: " + domain +
- " and sub domain: " + subDomain);
- }
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Group management agent is already available for cluster domain: " +
- domain + " and sub domain: " + subDomain);
- }
- }
-
- TenantLoadBalanceMembershipHandler handler =
- ConfigHolder.getInstance()
- .getTenantLoadBalanceMembershipHandler();
-
- if (handler == null) {
- String msg = "TenantLoadBalanceMembershipHandler is null. Thus, We cannot proceed.";
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- HostContext hostCtxt;
-
- // if there's an already registered HostContext use it
- if((hostCtxt = handler.getHostContext(hostName)) == null){
- hostCtxt = new HostContext(hostName);
- }
-
- List<TenantDomainContext> ctxts;
- ctxts = new ArrayList<TenantDomainContext>(hostCtxt.getTenantDomainContexts());
-
- // default value is super tenant mode - which is defined by tenant id 0, in this context
- int tenantId = 0;
- if(!"*".equals(tenantRange)){
- tenantId = Integer.parseInt(tenantRange);
- }
-
- ctxts.add(new TenantDomainContext(tenantId, domain, subDomain));
-
- hostCtxt.addTenantDomainContexts(ctxts);
-
- handler.addHostContext(hostCtxt);
-
- return hostCtxt;
- }
-
-}