From df06294915ee70b66e9dd0592b99083ca50fb56d Mon Sep 17 00:00:00 2001 From: Chinmay Kulkarni Date: Thu, 8 Jun 2017 16:25:00 -0700 Subject: [PATCH] HBASE-17988 get-active-master.rb and draining_servers.rb no longer work Modified jruby scripts to pick up drainingZNode and masterAddressZNode correctly, from within znodePaths in ZooKeeperWatcher. Modified get-active-master.rb to retrieve server name using MasterAddressTracker instead of ZKUtil. Tested on a standalone HBase deployment to check that the scripts work as expected. Signed-off-by: Sean Busbey Signed-off-by: Mike Drob --- bin/draining_servers.rb | 6 +++--- bin/get-active-master.rb | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/bin/draining_servers.rb b/bin/draining_servers.rb index 8a615a8c8f2..8e1b2506f31 100644 --- a/bin/draining_servers.rb +++ b/bin/draining_servers.rb @@ -89,7 +89,7 @@ def addServers(options, hostOrServers) servers = getServerNames(hostOrServers, config) zkw = org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.new(config, "draining_servers", nil) - parentZnode = zkw.drainingZNode + parentZnode = zkw.znodePaths.drainingZNode begin for server in servers @@ -106,7 +106,7 @@ def removeServers(options, hostOrServers) servers = getServerNames(hostOrServers, config) zkw = org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.new(config, "draining_servers", nil) - parentZnode = zkw.drainingZNode + parentZnode = zkw.znodePaths.drainingZNode begin for server in servers @@ -123,7 +123,7 @@ def listServers(options) config = HBaseConfiguration.create() zkw = org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.new(config, "draining_servers", nil) - parentZnode = zkw.drainingZNode + parentZnode = zkw.znodePaths.drainingZNode servers = ZKUtil.listChildrenNoWatch(zkw, parentZnode) servers.each {|server| puts server} diff --git a/bin/get-active-master.rb b/bin/get-active-master.rb index bd303b3e417..44794252c4c 100644 --- a/bin/get-active-master.rb +++ b/bin/get-active-master.rb @@ -20,8 +20,8 @@ include Java java_import org.apache.hadoop.hbase.HBaseConfiguration java_import org.apache.hadoop.hbase.ServerName -java_import org.apache.hadoop.hbase.zookeeper.ZKUtil java_import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher +java_import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker # disable debug/info logging on this script for clarity log_level = org.apache.log4j.Level::ERROR @@ -32,13 +32,7 @@ config = HBaseConfiguration.create zk = ZooKeeperWatcher.new(config, 'get-active-master', nil) begin - master_address = ZKUtil.getData(zk, zk.masterAddressZNode) - if master_address - puts ServerName.parseFrom(master_address).getHostname() - else - puts 'Master not running' - end + puts MasterAddressTracker.getMasterAddress(zk).getHostname() ensure zk.close() end -