diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 617842f56b0..1ae01280f11 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -1664,10 +1664,12 @@ public class HBaseAdmin implements Abortable, Closeable { */ public void assign(final byte[] regionName) throws MasterNotRunningException, ZooKeeperConnectionException, IOException { + final byte[] toBeAssigned = getRegionName(regionName); executeCallable(new MasterAdminCallable(getConnection()) { @Override public Void call() throws ServiceException { - AssignRegionRequest request = RequestConverter.buildAssignRegionRequest(regionName); + AssignRegionRequest request = + RequestConverter.buildAssignRegionRequest(toBeAssigned); masterAdmin.assignRegion(null,request); return null; } @@ -1688,13 +1690,14 @@ public class HBaseAdmin implements Abortable, Closeable { * @throws ZooKeeperConnectionException * @throws IOException */ - public void unassign(final byte [] regionName, final boolean force) + public void unassign(final byte [] getRegionName, final boolean force) throws MasterNotRunningException, ZooKeeperConnectionException, IOException { + final byte[] toBeUnassigned = getRegionName(getRegionName); executeCallable(new MasterAdminCallable(getConnection()) { @Override public Void call() throws ServiceException { UnassignRegionRequest request = - RequestConverter.buildUnassignRegionRequest(regionName, force); + RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force); masterAdmin.unassignRegion(null,request); return null; } @@ -2003,6 +2006,26 @@ public class HBaseAdmin implements Abortable, Closeable { return pair; } + /** + * If the input is a region name, it is returned as is. If it's an + * encoded region name, the corresponding region is found from meta + * and its region name is returned. If we can't find any region in + * meta matching the input as either region name or encoded region + * name, the input is returned as is. We don't throw unknown + * region exception. + */ + private byte[] getRegionName( + final byte[] regionNameOrEncodedRegionName) throws IOException { + CatalogTracker ct = getCatalogTracker(); + Pair regionServerPair + = getRegion(regionNameOrEncodedRegionName, ct); + byte[] tmp = regionNameOrEncodedRegionName; + if (regionServerPair != null && regionServerPair.getFirst() != null) { + tmp = regionServerPair.getFirst().getRegionName(); + } + return tmp; + } + /** * Check if table exists or not * @param tableName Name of a table. diff --git a/hbase-server/src/main/ruby/shell/commands/assign.rb b/hbase-server/src/main/ruby/shell/commands/assign.rb index 9978ff8075d..448a5460b4e 100644 --- a/hbase-server/src/main/ruby/shell/commands/assign.rb +++ b/hbase-server/src/main/ruby/shell/commands/assign.rb @@ -24,6 +24,10 @@ module Shell return <<-EOF Assign a region. Use with caution. If region already assigned, this command will do a force reassign. For experts only. +Examples: + + hbase> assign 'REGIONNAME' + hbase> assign 'ENCODED_REGIONNAME' EOF end diff --git a/hbase-server/src/main/ruby/shell/commands/close_region.rb b/hbase-server/src/main/ruby/shell/commands/close_region.rb index 1cd149725a7..b7cdf3dca24 100644 --- a/hbase-server/src/main/ruby/shell/commands/close_region.rb +++ b/hbase-server/src/main/ruby/shell/commands/close_region.rb @@ -44,6 +44,8 @@ Examples: hbase> close_region 'REGIONNAME' hbase> close_region 'REGIONNAME', 'SERVER_NAME' + hbase> close_region 'ENCODED_REGIONNAME' + hbase> close_region 'ENCODED_REGIONNAME', 'SERVER_NAME' EOF end diff --git a/hbase-server/src/main/ruby/shell/commands/flush.rb b/hbase-server/src/main/ruby/shell/commands/flush.rb index 185b4731706..2aefec52e9d 100644 --- a/hbase-server/src/main/ruby/shell/commands/flush.rb +++ b/hbase-server/src/main/ruby/shell/commands/flush.rb @@ -27,6 +27,7 @@ flush an individual region. For example: hbase> flush 'TABLENAME' hbase> flush 'REGIONNAME' + hbase> flush 'ENCODED_REGIONNAME' EOF end diff --git a/hbase-server/src/main/ruby/shell/commands/unassign.rb b/hbase-server/src/main/ruby/shell/commands/unassign.rb index 60cc6ca3fc8..5eea71f6e08 100644 --- a/hbase-server/src/main/ruby/shell/commands/unassign.rb +++ b/hbase-server/src/main/ruby/shell/commands/unassign.rb @@ -30,6 +30,8 @@ Use with caution. For expert use only. Examples: hbase> unassign 'REGIONNAME' hbase> unassign 'REGIONNAME', true + hbase> unassign 'ENCODED_REGIONNAME' + hbase> unassign 'ENCODED_REGIONNAME', true EOF end