HBASE-19210 TestNamespacesInstanceResource fails
[hbase.git] / bin / regionservers.sh
blob6db11bb13236ff6d9c1c4ddc2068e08d62cdcc66
1 #!/usr/bin/env bash
3 #/**
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
11 # *
12 # * http://www.apache.org/licenses/LICENSE-2.0
13 # *
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.
19 # */
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
37 if [ $# -le 0 ]; then
38 echo $usage
39 exit 1
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"
55 else
56 export HOSTLIST="${HBASE_REGIONSERVERS}"
60 regionservers=`cat "$HOSTLIST"`
61 if [ "$regionservers" = "localhost" ]; then
62 HBASE_REGIONSERVER_ARGS="\
63 -Dhbase.regionserver.port=16201 \
64 -Dhbase.regionserver.info.port=16301"
66 $"${@// /\\ }" ${HBASE_REGIONSERVER_ARGS} \
67 2>&1 | sed "s/^/$regionserver: /" &
68 else
69 for regionserver in `cat "$HOSTLIST"`; do
70 if ${HBASE_SLAVE_PARALLEL:-true}; then
71 ssh $HBASE_SSH_OPTS $regionserver $"${@// /\\ }" \
72 2>&1 | sed "s/^/$regionserver: /" &
73 else # run each command serially
74 ssh $HBASE_SSH_OPTS $regionserver $"${@// /\\ }" \
75 2>&1 | sed "s/^/$regionserver: /"
77 if [ "$HBASE_SLAVE_SLEEP" != "" ]; then
78 sleep $HBASE_SLAVE_SLEEP
80 done
83 wait