I have just concerns about variables, if they can contain any white
space chars. If so, they should be in "quotes". If we are 100% sure they
cannot contain any white space chars I'm ok with this patch.
RR
On 07/29/2011 05:41 PM, Adam Stokes wrote:
- Provided array variable for defining DNS SRV records or
a fqdn:port
- Based on FEDERATED_BROKERS array if DNS SRV record exist
format dns query answer into<fqdn>:<port>, otherwise
process as is.
- Attempt to setup bidirectional communication with all defined
brokers.
- Setup a qpid-route TIMEOUT variable so we aren't waiting longer
than 5 seconds for a broker to respond.
Signed-off-by: Adam Stokes<astokes(a)fedoraproject.org>
---
matahari-broker.init.in | 44 ++++++++++++++++++++++++++++++++++++++++++++
matahari-broker.sysconf.in | 8 ++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/matahari-broker.init.in b/matahari-broker.init.in
index 13a535d..ebb35ee 100755
--- a/matahari-broker.init.in
+++ b/matahari-broker.init.in
@@ -42,6 +42,8 @@ pidfile=@localstatedir(a)/run/matahari-broker.pid
# Turn off automatic systemd redirects
SYSTEMCTL_SKIP_REDIRECT=1
+# Timeout for qpid-route in seconds
+TIMEOUT=5
# Source function library.
. @sysconfdir(a)/rc.d/init.d/functions
@@ -50,6 +52,44 @@ if [ -f @sysconfdir@/sysconfig/matahari-broker ] ; then
fi
RETVAL=0
+# Enable broker federation
+federate() {
+ unset array
+ declare -a array
+ for name in $@
I'm not sure if FEDERATED_BROKERS can contain any white
space character.
If so, the $@ should be in "quotes". The same is for every other variables.
+ do
+ case $name in
+ *_matahari-broker._tcp*)
+ RESP=`dig SRV $name +short| awk '{print $4":"$3}'|sed
's/\.:/:/'`
+ array+=$RESP
+ ;;
+ *)
+ array+=$name
+ ;;
+ esac
+ done
+
+ for $name in ${array[@]}
+ do
+ /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add $name \
+ localhost:$MATAHARI_PORT amq.direct&> /dev/null
+
+ /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add localhost:$MATAHARI_PORT \
+ $name amq.direct&> /dev/null
+
+ /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add $name \
+ localhost:$MATAHARI_PORT qmf.default.direct&> /dev/null
+
+ /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add localhost:$MATAHARI_PORT \
+ $name qmf.default.direct&> /dev/null
+
+ /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add $name \
+ localhost:$MATAHARI_PORT qmf.default.topic&> /dev/null
+
+ /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add localhost:$MATAHARI_PORT \
+ $name qmf.default.topic&> /dev/null
+ done
+}
start() {
echo -n $"Starting Matahari broker daemon: "
@@ -64,6 +104,10 @@ start() {
[ -x /sbin/restorecon ]&& /sbin/restorecon $pidfile
runuser -s /bin/sh qpidd -c "/usr/sbin/$prog --check --pid-dir
@localstatedir@/run/matahari $QPIDD_OPTIONS> $pidfile"
fi
+ if [ ${#FEDERATED_BROKERS[@]} -gt 0 ]; then
This test is not necessary, but
for readability we can keep it here.
+ federate ${FEDERATED_BROKERS[@]}
+ RETVAL=0
+ fi
return $RETVAL
}
diff --git a/matahari-broker.sysconf.in b/matahari-broker.sysconf.in
index 9b1c2b5..4473610 100644
--- a/matahari-broker.sysconf.in
+++ b/matahari-broker.sysconf.in
@@ -11,3 +11,11 @@ fi
QPIDD_OPTIONS="--config @sysconfdir(a)/matahari-broker.conf --port
$MATAHARI_PORT"
+# Federated Broker configuration
+# Takes the following formats:
+#<fqdn>:<port>
+# DNS SRV record format "_matahari-broker._tcp" is REQUIRED
+# _matahari-broker._tcp.<fqdn>
+#
+# A mixture of the above is acceptable.
+# FEDERATED_BROKERS=("broker1.example.com:49000"
"_matahari-broker._tcp.example.com")