Updated stream names in cep execution plans and updated 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/acd6fe39 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/acd6fe39 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/acd6fe39 Branch: refs/heads/master Commit: acd6fe39ca3b2ae77630a7c4761dd0ac8faaaa2b Parents: 673a792 Author: Imesh Gunaratne <[email protected]> Authored: Thu Dec 12 14:42:51 2013 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Thu Dec 12 14:42:51 2013 +0530 ---------------------------------------------------------------------- .../AverageInFlightRequestsFinder.xml | 2 +- .../GradientOfRequestsInFlightFinder.xml | 2 +- ...SecondDerivativeOfRequestsInFlightFinder.xml | 2 +- .../ec2/load-balancer/cartridge-agent.sh | 89 ++++++++++++++++++++ .../ec2/load-balancer/start-load-balancer.sh | 7 ++ .../templates/loadbalancer.conf.template | 10 ++- 6 files changed, 107 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/acd6fe39/extensions/cep/artifacts/execution-plans/AverageInFlightRequestsFinder.xml ---------------------------------------------------------------------- diff --git a/extensions/cep/artifacts/execution-plans/AverageInFlightRequestsFinder.xml b/extensions/cep/artifacts/execution-plans/AverageInFlightRequestsFinder.xml index 7cb354d..42fa74b 100644 --- a/extensions/cep/artifacts/execution-plans/AverageInFlightRequestsFinder.xml +++ b/extensions/cep/artifacts/execution-plans/AverageInFlightRequestsFinder.xml @@ -7,7 +7,7 @@ <property name="siddhi.persistence.snapshot.time.interval.minutes">0</property> </siddhiConfiguration> <importedStreams> - <stream as="lbStats1" name="stratos.lb.stats" version="1.0.0"/> + <stream as="lbStats1" name="in_flight_requests" version="1.0.0"/> </importedStreams> <queryExpressions><![CDATA[ from lbStats1#window.timeBatch(1 min) http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/acd6fe39/extensions/cep/artifacts/execution-plans/GradientOfRequestsInFlightFinder.xml ---------------------------------------------------------------------- diff --git a/extensions/cep/artifacts/execution-plans/GradientOfRequestsInFlightFinder.xml b/extensions/cep/artifacts/execution-plans/GradientOfRequestsInFlightFinder.xml index af1020a..a7361d9 100644 --- a/extensions/cep/artifacts/execution-plans/GradientOfRequestsInFlightFinder.xml +++ b/extensions/cep/artifacts/execution-plans/GradientOfRequestsInFlightFinder.xml @@ -7,7 +7,7 @@ <property name="siddhi.persistence.snapshot.time.interval.minutes">0</property> </siddhiConfiguration> <importedStreams> - <stream as="lbStats2" name="stratos.lb.stats" version="1.0.0"/> + <stream as="lbStats2" name="in_flight_requests" version="1.0.0"/> </importedStreams> <queryExpressions><![CDATA[ from lbStats2#window.stratos:gradient(1 min, in_flight_requests) http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/acd6fe39/extensions/cep/artifacts/execution-plans/SecondDerivativeOfRequestsInFlightFinder.xml ---------------------------------------------------------------------- diff --git a/extensions/cep/artifacts/execution-plans/SecondDerivativeOfRequestsInFlightFinder.xml b/extensions/cep/artifacts/execution-plans/SecondDerivativeOfRequestsInFlightFinder.xml index 6047f27..6670613 100644 --- a/extensions/cep/artifacts/execution-plans/SecondDerivativeOfRequestsInFlightFinder.xml +++ b/extensions/cep/artifacts/execution-plans/SecondDerivativeOfRequestsInFlightFinder.xml @@ -7,7 +7,7 @@ <property name="siddhi.persistence.snapshot.time.interval.minutes">0</property> </siddhiConfiguration> <importedStreams> - <stream as="lbStats3" name="stratos.lb.stats" version="1.0.0"/> + <stream as="lbStats3" name="in_flight_requests" version="1.0.0"/> </importedStreams> <queryExpressions><![CDATA[ from lbStats3#window.stratos:secondDerivative(1 min, in_flight_requests) http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/acd6fe39/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/cartridge-agent.sh ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/cartridge-agent.sh b/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/cartridge-agent.sh new file mode 100644 index 0000000..3b5d998 --- /dev/null +++ b/products/cartridge-agent/modules/cartridge-agent/ec2/load-balancer/cartridge-agent.sh @@ -0,0 +1,89 @@ +#!/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. +# +# -------------------------------------------------------------- + +# This script will be called from /etc/rc.local when the cartridge +# instance is spawned. It will initiate all the tasks that needs to +# be run to bring the cartridge instance to operational state. + +set -e # Terminate on any error +export LOG=/var/log/apache-stratos/cartridge-agent.log +instance_path=/opt/apache-stratos-cartridge-agent # Cartridge agent home +event_publisher_path=/opt/apache-stratos-cartridge-agent/event-publisher # Event publisher home +event_subscriber_path=/opt/apache-stratos-cartridge-agent/event-subscriber # Event subscriber home +health_publisher_path=/opt/apache-stratos-cartridge-agent/health-publisher # Health publisher home + +# --------------------------------------------- +# Download payload +# --------------------------------------------- +if [ ! -d ${instance_path}/payload ]; then + echo "creating payload directory... " | tee -a $LOG + mkdir ${instance_path}/payload + echo "payload directory created" | tee -a $LOG + wget http://169.254.169.254/latest/user-data -O ${instance_path}/payload/launch-params + echo "payload copied" | tee -a $LOG + + for i in `/usr/bin/ruby ${instance_path}/get-launch-params.rb` + do + # Add double quotes on both sides of the value + value=`echo "${i}" | sed -e s@=@=\"@g` + value=${value}"\"" + if [[ ${value} == PORTS* ]]; then + # Replace port separator | with , + value=`echo ${value} | sed -e s@'|'@,@g` + fi + echo "writing to launch.params ${value}" | tee -a $LOG + echo "export" ${value} >> ${instance_path}/launch.params + done +fi + +source ${instance_path}/launch.params + +#--------------------------- +# Starting load balancer +#--------------------------- +pushd $instance_path/load-balancer/ +sh start-load-balancer.sh $MB_IP $MB_PORT $CEP_IP $CEP_PORT $LB_CLUSTER_ID & +popd + +#--------------------------- +# Starting topic subscriber +#--------------------------- +# change mb ip port in conf/jndi.properties +pushd $event_subscriber_path +cp -f templates/jndi.properties.template conf/jndi.properties.tmp +cat conf/jndi.properties.tmp | sed -e "s@MB-IP@$MB_IP@g" > conf/jndi.properties +cp -f conf/jndi.properties conf/jndi.properties.tmp +cat conf/jndi.properties.tmp | sed -e "s@MB-PORT@$MB_PORT@g" > conf/jndi.properties +rm -f conf/jndi.properties.tmp +popd + +pushd $event_subscriber_path/bin +echo "Executing: event-subscriber.sh " +sh event-subscriber.sh & +echo "Event subscribed" | tee -a $LOG +popd + +pushd $health_publisher_path/bin +echo "Executing: health-publisher.sh" +sh health-publisher.sh $MEMBER_ID $CEP_IP $CEP_PORT $PORTS $CLUSTER_ID +echo "Health stat published" | tee -a $LOG +popd http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/acd6fe39/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 index 38815d6..a370344 100755 --- 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 @@ -41,10 +41,13 @@ mb_ip=$1 mb_port=$2 cep_ip=$3 cep_port=$4 +lb_cluster_id=$5 + 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 +echo "lb-cluster-id: $lb_cluster_id" | 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 @@ -57,6 +60,10 @@ cat $script_home/loadbalancer.conf.orig | sed -e "s@CEP_IP@$cep_ip@g" > $script_ 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 + +cp -f $script_home/loadbalancer.conf $script_home/loadbalancer.conf.orig +cat $script_home/loadbalancer.conf.orig | sed -e "s@LB_CLUSTER_ID@$lb_cluster_id@g" > $script_home/loadbalancer.conf + rm $script_home/loadbalancer.conf.orig echo "Moving generated loadbalancer.conf to $lb_conf_path" | tee -a $LOG http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/acd6fe39/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 index ff7103d..354aa45 100755 --- 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 @@ -49,13 +49,19 @@ loadbalancer { # 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-service-filter: service-name=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; + # topology-cluster-filter: cluster-id=cluster-id1,cluster-id2; + + # Topology member filter + # Provide load balancer 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 allowing members + # to join a given load balancer cluster. + topology-member-filter: lb-cluster-id=LB_CLUSTER_ID; # Enable/disable cep statistics publisher cep-stats-publisher: true;
