HBASE-12428 region_mover.rb script is broken if port is not specified

If the port is not specified, there is an object nil exception.
This commit is contained in:
Jesse Yates 2014-11-06 12:39:41 -08:00
parent de21812ad5
commit 4fa23aadc0
1 changed files with 12 additions and 8 deletions

View File

@ -319,15 +319,13 @@ end
# Move regions off the passed hostname:port
def unloadRegions(options, hostname, port)
# Get configuration
config = getConfiguration()
# Clean up any old files.
filename = getFilename(options, hostname, port)
deleteFile(filename)
# Get configuration
config = getConfiguration()
# Get an admin instance
admin = HBaseAdmin.new(config)
port = config.getInt(HConstants::REGIONSERVER_PORT, HConstants::DEFAULT_REGIONSERVER_PORT) \
unless port
admin = HBaseAdmin.new(config)
servers = getServers(admin)
# Remove the server we are unloading from from list of servers.
# Side-effect is the servername that matches this hostname
@ -382,9 +380,7 @@ def loadRegions(options, hostname, port)
config = getConfiguration()
# Get an admin instance
admin = HBaseAdmin.new(config)
port = config.getInt(HConstants::REGIONSERVER_PORT, HConstants::DEFAULT_REGIONSERVER_PORT) \
unless port
filename = getFilename(options, hostname, port)
filename = getFilename(options, hostname, port)
regions = readFile(filename)
return if regions.isEmpty()
servername = nil
@ -504,6 +500,14 @@ if not hostname
opts optparse
exit 2
end
# Get configuration
config = getConfiguration()
if not port
port = config.getInt(HConstants::REGIONSERVER_PORT, HConstants::DEFAULT_REGIONSERVER_PORT)
end
port = port.to_s
# Create a logger and save it to ruby global
$LOG = configureLogging(options)
case ARGV[0]