Updated Branches: refs/heads/master 9e95f8f04 -> 85c511639
Added load balancer cartridge scripts Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/95175020 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/95175020 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/95175020 Branch: refs/heads/master Commit: 95175020d1fb0637b9a96bf721a97a41971bd852 Parents: 57cccfb Author: Imesh Gunaratne <[email protected]> Authored: Mon Dec 9 16:39:58 2013 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Mon Dec 9 16:39:58 2013 +0530 ---------------------------------------------------------------------- .../ec2/load-balancer/start-load-balancer.sh | 70 +++++++++++ .../templates/loadbalancer.conf.template | 126 +++++++++++++++++++ 2 files changed, 196 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/95175020/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/start-load-balancer.sh ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/start-load-balancer.sh b/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/start-load-balancer.sh new file mode 100755 index 0000000..38815d6 --- /dev/null +++ b/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/start-load-balancer.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# -------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# -------------------------------------------------------------- + +# -------------------------------------------------------------- +# Load Balancer Start Script +# -------------------------------------------------------------- +# +# This script will update the load balancer configuration with +# parameter values received via the payload and start the server. +# + +set -e # Terminate on any error +export LOG="/var/log/apache-stratos/start-load-balancer.log" +export JAVA_HOME=/opt/jdk1.6.0_45 + +script_home=/opt/apache-stratos-cartridge-agent/load-balancer +lb_home=/opt/apache-stratos-load-balancer +lb_conf_path=$lb_home/repository/conf + +echo "Generating loadbalancer.conf file..." | tee -a $LOG +mb_ip=$1 +mb_port=$2 +cep_ip=$3 +cep_port=$4 +echo "mb-ip: $mb_ip" | tee -a $LOG +echo "mb-port: $mb_port" | tee -a $LOG +echo "cep-ip: $cep_ip" | tee -a $LOG +echo "cep-port: $cep_port" | tee -a $LOG + +cp -f $script_home/templates/loadbalancer.conf.template $script_home/loadbalancer.conf.orig +cat $script_home/loadbalancer.conf.orig | sed -e "s@MB_IP@$mb_ip@g" > $script_home/loadbalancer.conf + +cp -f $script_home/loadbalancer.conf $script_home/loadbalancer.conf.orig +cat $script_home/loadbalancer.conf.orig | sed -e "s@MB_PORT@$mb_port@g" > $script_home/loadbalancer.conf + +cp -f $script_home/loadbalancer.conf $script_home/loadbalancer.conf.orig +cat $script_home/loadbalancer.conf.orig | sed -e "s@CEP_IP@$cep_ip@g" > $script_home/loadbalancer.conf + +cp -f $script_home/loadbalancer.conf $script_home/loadbalancer.conf.orig +cat $script_home/loadbalancer.conf.orig | sed -e "s@CEP_PORT@$cep_port@g" > $script_home/loadbalancer.conf +rm $script_home/loadbalancer.conf.orig + +echo "Moving generated loadbalancer.conf to $lb_conf_path" | tee -a $LOG +mv -f $script_home/loadbalancer.conf $lb_conf_path + +echo "Starting load balancer..." | tee -a $LOG +sh $lb_home/bin/stratos.sh start & + +echo "Load balancer started" | tee -a $LOG + + http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/95175020/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/templates/loadbalancer.conf.template ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/templates/loadbalancer.conf.template b/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/templates/loadbalancer.conf.template new file mode 100755 index 0000000..ff7103d --- /dev/null +++ b/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/templates/loadbalancer.conf.template @@ -0,0 +1,126 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +loadbalancer { + + # Default load balancing algorithm + # Refer algorithm name from algorithms section. + algorithm: round-robin; + + # Enable/disable failover handling + # If failover handling is enabled load balancer will retry requests on all members in a + # given cluster if the selected member fails to respond. + failover: true; + + # Enable/disable session affinity + # If session affinity is enabled load balancer will track all outgoing sessions and delegate + # incoming requests to members with same sessions. + session-affinity: true; + + # Session timeout in milli-seconds + session-timeout: 90000; + + # Enable/disable topology event listener + # If this property is set to true, load balancer will listen to topology events and build + # the topology configuration accordingly. If not static configuration given in the services + # section will be used. + topology-event-listener: true; + + # Message broker endpoint + # Provide message broker ip address and port if topology-event-listener or multi-tenancy is set to true. + mb-ip: MB_IP; + mb-port: MB_PORT; + + # Topology service filter + # Provide service names in a comma separated list to filter incoming topology events if + # topology_event_listener_enabled is set to true. This functionality could be used for hosting + # dedicated load balancers for services. + # topology-service-filter: service-name1, service-name2; + + # Topology cluster filter + # Provide cluster ids in a comma separated list to filter incoming topology events if + # topology_event_listener_enabled is set to true. This functionality could be used for hosting + # dedicated load balancers for subscriptions. + # topology-cluster-filter: cluster-id1, cluster-id2; + + # Enable/disable cep statistics publisher + cep-stats-publisher: true; + + # Complex event processor endpoint + # Provide CEP ip address and port if cep-stats-publisher is set to true. + cep-ip: CEP_IP; + cep-port: CEP_PORT; + + # Multi-tenancy + # If this property is set to true, all incoming request URLs will be scanned using the given tenant-identifier-regex + # and matching tenant identifier value will be used to delegate the requests to the relevant cluster. + multi-tenancy: true; + tenant-identifier: tenant-domain; # Tenant identifier could either be tenant-id or tenant-domain. + tenant-identifier-regex: t/([^/]*)/; # Regular expression for extracting the tenant identifier value from the URL. + + # Load balancing algorithm class names + algorithms { + round-robin { # algorithm name + class-name: org.apache.stratos.load.balancer.algorithm.RoundRobin; + } + } + + # Static topology configuration + # Define a static topology configuration if topology-event-listener is set to false. + # A sample configuration has been given below: + # + # services { + # app-server { # service name, a unique identifier to identify a service + # multi-tenant: true; # Set to true if the service is multi-tenant + # clusters { + # app-server-cluster1 { # cluster id, a unique identifier to identify a cluster + # hosts: cluster1.appserver.foo.org, cluster1.org; # comma separated hostname list + # tenant-range: 1-100; # Tenant range of the cluster + # algorithm: round-robin; # algorithm name + # members { + # m1 { # member id, a unique identifier to identify a member + # ip: 10.0.0.10; # member ip address + # ports { + # http { + # value: 8080; # application port + # proxy: 80; # proxy port exposed by load balancer transport, set this value in axis2.xml + # } + # https { + # value: 8090; + # proxy: 443; + # } + # } + # } + # m2 { + # ip: 10.0.0.11; + # ports { + # http { + # value: 8080; + # proxy: 80; + # } + # https { + # value: 8090; + # proxy: 443; + # } + # } + # } + # } + # } + # } + # } + # } +}
