#!/bin/bash
#
# We use the jobtracker as provisioning server
#
# Correct start order (reverse to obtain the stop order):
#
# • HBase master
# • HBase regionservers
#
HOSTNAME=$( hostname -f )
DOMAIN_N="t.hadoop.research-infrastructures.eu"
SERVICES_START_ORDER="service-hbase-master service-hbase-regionserver service-hbase-thrift"
SERVICES_STOP_ORDER="service-hbase-thrift service-hbase-regionserver service-hbase-master"

SERVICES=$SERVICES_START_ORDER
ARG=$1

function action_loop(){
    ACTION=$ARG
    if [ "$ACTION" == "stop" ] ; then
	SERVICES=$SERVICES_STOP_ORDER
    fi
    for SRV in $SERVICES ; do 
	$SRV $ACTION
    done
}

case "$ARG" in
  start|restart|reload|force-reload|status|stop)
        action_loop
        ;;
  *)
        echo "Usage: $0 start|stop|restart|status" >&2
        exit 3
        ;;
esac

exit 0
