HBASE-18102 Purge close_region command that allows by-pass of Master

Change-Id: I67e3f74e16706043056bac73bc1ff3a713d0e977
This commit is contained in:
Apekshit Sharma 2017-07-31 19:22:33 -07:00
parent de696cf6b6
commit 71151eb0e9
3 changed files with 7 additions and 51 deletions

View File

@ -428,18 +428,6 @@ module Hbase
end
end
#----------------------------------------------------------------------------------------------
# Closes a region.
# If server name is nil, we presume region_name is full region name (HRegionInfo.getRegionName).
# If server name is not nil, we presume it is the region's encoded name (HRegionInfo.getEncodedName)
def close_region(region_name, server)
if region_name.end_with? '.'
@admin.closeRegion(region_name, server)
else
closeEncodedRegion?(region_name, server)
end
end
#----------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------
# Assign a region
@ -836,12 +824,6 @@ module Hbase
@admin.isTableEnabled(TableName.valueOf(table_name))
end
#----------------------------------------------------------------------------------------------
# Is supplied region name is encoded region name
def closeEncodedRegion?(region_name, server)
@admin.closeRegionWithEncodedRegionName(region_name, server)
end
#----------------------------------------------------------------------------------------------
# Return a new HColumnDescriptor made of passed args
def hcd(arg, htd)

View File

@ -22,36 +22,14 @@ module Shell
class CloseRegion < Command
def help
<<-EOF
Close a single region. Ask the master to close a region out on the cluster
or if 'SERVER_NAME' is supplied, ask the designated hosting regionserver to
close the region directly. Closing a region, the master expects 'REGIONNAME'
to be a fully qualified region name. When asking the hosting regionserver to
directly close a region, you pass the regions' encoded name only. A region
name looks like this:
TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.
or
Namespace:TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.
The trailing period is part of the regionserver name. A region's encoded name
is the hash at the end of a region name; e.g. 527db22f95c8a9e0116f0cc13c680396
(without the period). A 'SERVER_NAME' is its host, port plus startcode. For
example: host187.example.com,60020,1289493121758 (find servername in master ui
or when you do detailed status in shell). This command will end up running
close on the region hosting regionserver. The close is done without the
master's involvement (It will not know of the close). Once closed, region will
stay closed. Use assign to reopen/reassign. Use unassign or move to assign
the region elsewhere on cluster. Use with caution. For experts only.
Examples:
hbase> close_region 'REGIONNAME'
hbase> close_region 'REGIONNAME', 'SERVER_NAME'
hbase> close_region 'ENCODED_REGIONNAME', 'SERVER_NAME'
---------------------------------------------
DEPRECATED!!! Use 'unassign' command instead.
---------------------------------------------
EOF
end
def command(region_name, server = nil)
admin.close_region(region_name, server)
puts "DEPRECATED!!! Use 'unassign' command instead."
end
end
end

View File

@ -334,17 +334,13 @@ module Hbase
shutdown
end
define_test "close_region should allow encoded & non-encoded region names" do
define_test "unassign should allow encoded & non-encoded region names" do
region = command(:locate_region, @test_name, '')
serverName = region.getServerName().getServerName()
regionName = region.getRegionInfo().getRegionNameAsString()
encodedRegionName = region.getRegionInfo().getEncodedName()
# Close region with just region name.
command(:close_region, regionName, nil)
# Close region with region name and server.
command(:close_region, regionName, serverName)
command(:close_region, encodedRegionName, serverName)
command(:unassign, regionName, true)
command(:unassign, encodedRegionName, true)
end
end