Preparing development version 2.4.4-SNAPSHOT
[hbase.git] / bin / local-regionservers.sh
blob97e5eed9bb702f15b942d41ec2a75c69e2d79c55
1 #!/usr/bin/env bash
2 #/**
3 # * Licensed to the Apache Software Foundation (ASF) under one
4 # * or more contributor license agreements. See the NOTICE file
5 # * distributed with this work for additional information
6 # * regarding copyright ownership. The ASF licenses this file
7 # * to you under the Apache License, Version 2.0 (the
8 # * "License"); you may not use this file except in compliance
9 # * with the License. You may obtain a copy of the License at
10 # *
11 # * http://www.apache.org/licenses/LICENSE-2.0
12 # *
13 # * Unless required by applicable law or agreed to in writing, software
14 # * distributed under the License is distributed on an "AS IS" BASIS,
15 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # * See the License for the specific language governing permissions and
17 # * limitations under the License.
18 # */
19 # This is used for starting multiple regionservers on the same machine.
20 # run it from hbase-dir/ just like 'bin/hbase'
21 # Supports up to 10 regionservers (limitation = overlapping ports)
22 # For supporting more instances select different values (e.g. 16200, 16300)
23 # for HBASE_RS_BASE_PORT and HBASE_RS_INFO_BASE_PORT below
24 if [ -z "$HBASE_RS_BASE_PORT" ]; then
25 HBASE_RS_BASE_PORT=16020
27 if [ -z "$HBASE_RS_INFO_BASE_PORT" ]; then
28 HBASE_RS_INFO_BASE_PORT=16030
31 bin=`dirname "${BASH_SOURCE-$0}"`
32 bin=`cd "$bin" >/dev/null && pwd`
34 if [ $# -lt 2 ]; then
35 S=`basename "${BASH_SOURCE-$0}"`
36 echo "Usage: $S [--config <conf-dir>] [--autostart-window-size <window size in hours>]"
37 echo " [--autostart-window-retry-limit <retry count limit for autostart>] [autostart|start|stop] offset(s)"
38 echo " e.g. $S start 1 2"
39 exit
42 # default autostart args value indicating infinite window size and no retry limit
43 AUTOSTART_WINDOW_SIZE=0
44 AUTOSTART_WINDOW_RETRY_LIMIT=0
46 . "$bin"/hbase-config.sh
48 # sanity check: make sure your regionserver opts don't use ports [i.e. JMX/DBG]
49 export HBASE_REGIONSERVER_OPTS=" "
51 run_regionserver () {
52 DN=$2
53 export HBASE_IDENT_STRING="$USER-$DN"
54 HBASE_REGIONSERVER_ARGS="\
55 -Dhbase.regionserver.port=`expr "$HBASE_RS_BASE_PORT" + "$DN"` \
56 -Dhbase.regionserver.info.port=`expr "$HBASE_RS_INFO_BASE_PORT" + "$DN"`"
58 "$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" \
59 --autostart-window-size "${AUTOSTART_WINDOW_SIZE}" \
60 --autostart-window-retry-limit "${AUTOSTART_WINDOW_RETRY_LIMIT}" \
61 "$1" regionserver "$HBASE_REGIONSERVER_ARGS"
64 cmd=$1
65 shift;
67 for i in "$@"
69 if [[ "$i" =~ ^[0-9]+$ ]]; then
70 run_regionserver "$cmd" "$i"
71 else
72 echo "Invalid argument"
74 done