4 # * Licensed to the Apache Software Foundation (ASF) under one
5 # * or more contributor license agreements. See the NOTICE file
6 # * distributed with this work for additional information
7 # * regarding copyright ownership. The ASF licenses this file
8 # * to you under the Apache License, Version 2.0 (the
9 # * "License"); you may not use this file except in compliance
10 # * with the License. You may obtain a copy of the License at
12 # * http://www.apache.org/licenses/LICENSE-2.0
14 # * Unless required by applicable law or agreed to in writing, software
15 # * distributed under the License is distributed on an "AS IS" BASIS,
16 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # * See the License for the specific language governing permissions and
18 # * limitations under the License.
21 # Run a shell command on all regionserver hosts.
23 # Environment Variables
25 # HBASE_REGIONSERVERS File naming remote hosts.
26 # Default is ${HADOOP_CONF_DIR}/regionservers
27 # HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_HOME}/conf.
28 # HBASE_CONF_DIR Alternate hbase conf dir. Default is ${HBASE_HOME}/conf.
29 # HBASE_SLAVE_SLEEP Seconds to sleep between spawning remote commands.
30 # HBASE_SSH_OPTS Options passed to ssh when running remote commands.
32 # Modelled after $HADOOP_HOME/bin/slaves.sh.
34 usage
="Usage: regionservers [--config <hbase-confdir>] command..."
36 # if no args specified, show usage
42 bin
=`dirname "${BASH_SOURCE-$0}"`
43 bin
=`cd "$bin">/dev/null; pwd`
45 .
"$bin"/hbase-config.sh
47 # If the regionservers file is specified in the command line,
48 # then it takes precedence over the definition in
49 # hbase-env.sh. Save it here.
50 HOSTLIST
=$HBASE_REGIONSERVERS
52 if [ "$HOSTLIST" = "" ]; then
53 if [ "$HBASE_REGIONSERVERS" = "" ]; then
54 export HOSTLIST
="${HBASE_CONF_DIR}/regionservers"
56 export HOSTLIST
="${HBASE_REGIONSERVERS}"
60 regionservers
=`cat "$HOSTLIST"`
61 if [ "$regionservers" = "localhost" ]; then
62 "$bin"/local-regionservers.sh start
1
64 for regionserver
in `cat "$HOSTLIST"`; do
65 if ${HBASE_SLAVE_PARALLEL:-true}; then
66 ssh $HBASE_SSH_OPTS $regionserver $
"${@// /\\ }" \
67 2>&1 |
sed "s/^/$regionserver: /" &
68 else # run each command serially
69 ssh $HBASE_SSH_OPTS $regionserver $
"${@// /\\ }" \
70 2>&1 |
sed "s/^/$regionserver: /"
72 if [ "$HBASE_SLAVE_SLEEP" != "" ]; then
73 sleep $HBASE_SLAVE_SLEEP