Preparing hbase release 2.4.2RC0; tagging and updates to CHANGES.md and RELEASENOTES.md
[hbase.git] / bin / considerAsDead.sh
blobae1b8d885bf370ed2e550095069ec1ddd467b5b2
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 # */
22 usage="Usage: considerAsDead.sh --hostname serverName"
24 # if no args specified, show usage
25 if [ $# -le 1 ]; then
26 echo $usage
27 exit 1
30 bin=`dirname "${BASH_SOURCE-$0}"`
31 bin=`cd "$bin">/dev/null; pwd`
33 . $bin/hbase-config.sh
35 shift
36 deadhost=$@
38 remote_cmd="cd ${HBASE_HOME}; $bin/hbase-daemon.sh --config ${HBASE_CONF_DIR} restart"
40 zparent=`$bin/hbase org.apache.hadoop.hbase.util.HBaseConfTool zookeeper.znode.parent`
41 if [ "$zparent" == "null" ]; then zparent="/hbase"; fi
43 zkrs=`$bin/hbase org.apache.hadoop.hbase.util.HBaseConfTool zookeeper.znode.rs`
44 if [ "$zkrs" == "null" ]; then zkrs="rs"; fi
46 zkrs="$zparent/$zkrs"
47 online_regionservers=`$bin/hbase zkcli ls $zkrs 2>&1 | tail -1 | sed "s/\[//" | sed "s/\]//"`
48 for rs in $online_regionservers
50 rs_parts=(${rs//,/ })
51 hostname=${rs_parts[0]}
52 echo $deadhost
53 echo $hostname
54 if [ "$deadhost" == "$hostname" ]; then
55 znode="$zkrs/$rs"
56 echo "ZNode Deleting:" $znode
57 $bin/hbase zkcli delete $znode > /dev/null 2>&1
58 sleep 1
59 ssh $HBASE_SSH_OPTS $hostname $remote_cmd 2>&1 | sed "s/^/$hostname: /"
60 fi
61 done