Repository: hbase Updated Branches: refs/heads/branch-2 6440509d7 -> 41da64a14
HBASE-18231 Deprecate Admin#closeRegion*() commands in favor of Admin#unassign(). Other changes: - Update corresponding tests in TestAdmin2. Removed tests centered around serverName part of old functions. - Remove dead functions from ProtobufUtil and ServerManager - Rename closeRegion* functions in HBTU to unassignRegion* Change-Id: Ib9bdeb185e10750daf652be0bb328306accb73ab Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/41da64a1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/41da64a1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/41da64a1 Branch: refs/heads/branch-2 Commit: 41da64a144e286c3d42a58d61227a9edc852af8f Parents: 6440509 Author: Apekshit Sharma <a...@apache.org> Authored: Mon Jul 31 19:21:40 2017 -0700 Committer: Apekshit Sharma <a...@apache.org> Committed: Wed Aug 2 15:22:17 2017 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/client/Admin.java | 36 +++----- .../apache/hadoop/hbase/client/AsyncAdmin.java | 8 +- .../hadoop/hbase/client/AsyncHBaseAdmin.java | 4 +- .../apache/hadoop/hbase/client/HBaseAdmin.java | 69 +++------------ .../hadoop/hbase/client/RawAsyncHBaseAdmin.java | 28 +----- .../hbase/shaded/protobuf/ProtobufUtil.java | 44 ---------- .../hadoop/hbase/master/ServerManager.java | 29 ------- .../hadoop/hbase/HBaseTestingUtility.java | 27 +++--- .../apache/hadoop/hbase/client/TestAdmin2.java | 89 ++------------------ .../hadoop/hbase/client/TestReplicasClient.java | 2 +- .../hadoop/hbase/master/TestMasterFailover.java | 4 +- .../hbase/master/TestMasterNoCluster.java | 4 - .../TestQuotaObserverChoreRegionReports.java | 2 +- .../regionserver/TestRegionServerNoMaster.java | 2 +- .../hadoop/hbase/util/TestHBaseFsckTwoRS.java | 2 +- 15 files changed, 59 insertions(+), 291 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java index 6e9b0df..4f5c128 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java @@ -826,56 +826,46 @@ public interface Admin extends Abortable, Closeable { Future<Void> modifyColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException; - /** - * Close a region. For expert-admins. Runs close on the regionserver. The master will not be - * informed of the close. + * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * * @param regionname region name to close - * @param serverName If supplied, we'll use this location rather than the one currently in - * <code>hbase:meta</code> + * @param serverName Deprecated. Not used. * @throws IOException if a remote or network exception occurs + * @deprecated Since 2.0. Will be removed in 3.0. Use {@link #unassign(byte[], boolean)} instead. */ void closeRegion(final String regionname, final String serverName) throws IOException; /** - * Close a region. For expert-admins Runs close on the regionserver. The master will not be - * informed of the close. + * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * * @param regionname region name to close - * @param serverName The servername of the regionserver. If passed null we will use servername - * found in the hbase:meta table. A server name is made of host, port and startcode. Here is an - * example: <code> host187.example.com,60020,1289493121758</code> + * @param serverName Deprecated. Not used. * @throws IOException if a remote or network exception occurs + * @deprecated Since 2.0. Will be removed in 3.0. Use {@link #unassign(byte[], boolean)} instead. */ void closeRegion(final byte[] regionname, final String serverName) throws IOException; /** - * For expert-admins. Runs close on the regionserver. Closes a region based on the encoded region - * name. The region server name is mandatory. If the servername is provided then based on the - * online regions in the specified regionserver the specified region will be closed. The master - * will not be informed of the close. Note that the regionname is the encoded regionname. + * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name * suffix: e.g. if regionname is * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>, * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>. - * @param serverName The servername of the regionserver. A server name is made of host, port and - * startcode. This is mandatory. Here is an example: - * <code> host187.example.com,60020,1289493121758</code> - * @return true if the region was closed, false if not. + * @param serverName Deprecated. Not used. + * @return Deprecated. Returns true always. * @throws IOException if a remote or network exception occurs + * @deprecated Since 2.0. Will be removed in 3.0. Use {@link #unassign(byte[], boolean)} instead. */ boolean closeRegionWithEncodedRegionName(final String encodedRegionName, final String serverName) throws IOException; /** - * Close a region. For expert-admins Runs close on the regionserver. The master will not be - * informed of the close. + * Used {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. * - * @param sn - * @param hri - * @throws IOException + * @param sn Deprecated. Not used. + * @deprecated Since 2.0. Will be removed in 3.0. Use {@link #unassign(byte[], boolean)} instead. */ void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException; http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java index 1adf353..7e4412d 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java @@ -293,11 +293,9 @@ public interface AsyncAdmin { * Close a region. For expert-admins Runs close on the regionserver. The master will not be * informed of the close. * @param regionName region name to close - * @param serverName The servername of the regionserver. If not present, we will use servername - * found in the hbase:meta table. A server name is made of host, port and startcode. Here - * is an example: <code> host187.example.com,60020,1289493121758</code> - * @return true if the region was closed, false if not. The return value will be wrapped by a - * {@link CompletableFuture}. + * @param serverName Deprecated. Not used anymore after deprecation. + * @return Deprecated. Always returns true now. + * @deprecated Since 2.0. Will be removed in 3.0. Use {@link #unassign(byte[], boolean)} instead. */ CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> serverName); http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java index 6126b8a..9ba3b73 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java @@ -215,8 +215,8 @@ public class AsyncHBaseAdmin implements AsyncAdmin { } @Override - public CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> serverName) { - return wrap(rawAdmin.closeRegion(regionName, serverName)); + public CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> unused) { + return wrap(rawAdmin.closeRegion(regionName, unused)); } @Override http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java ---------------------------------------------------------------------- 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 447b396..66dbac5 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 @@ -92,8 +92,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearCompactionQueuesRequest; -import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest; -import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactRegionRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest; @@ -129,7 +127,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteTabl import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteTableResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DisableTableRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DisableTableResponse; -import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DrainRegionServersRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableTableRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableTableResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest; @@ -168,7 +165,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyName import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MoveRegionRequest; -import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RemoveDrainFromRegionServersRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesRequest; @@ -1144,66 +1140,30 @@ public class HBaseAdmin implements Admin { } } + @Deprecated @Override - public void closeRegion(final String regionname, final String serverName) throws IOException { - closeRegion(Bytes.toBytes(regionname), serverName); + public void closeRegion(final String regionName, final String unused) throws IOException { + unassign(Bytes.toBytes(regionName), true); } + @Deprecated @Override - public void closeRegion(final byte [] regionname, final String serverName) throws IOException { - if (serverName != null) { - Pair<HRegionInfo, ServerName> pair = MetaTableAccessor.getRegion(connection, regionname); - if (pair == null || pair.getFirst() == null) { - throw new UnknownRegionException(Bytes.toStringBinary(regionname)); - } else { - closeRegion(ServerName.valueOf(serverName), pair.getFirst()); - } - } else { - Pair<HRegionInfo, ServerName> pair = MetaTableAccessor.getRegion(connection, regionname); - if (pair == null) { - throw new UnknownRegionException(Bytes.toStringBinary(regionname)); - } else if (pair.getSecond() == null) { - throw new NoServerForRegionException(Bytes.toStringBinary(regionname)); - } else { - closeRegion(pair.getSecond(), pair.getFirst()); - } - } + public void closeRegion(final byte [] regionName, final String unused) throws IOException { + unassign(regionName, true); } + @Deprecated @Override public boolean closeRegionWithEncodedRegionName(final String encodedRegionName, - final String serverName) - throws IOException { - if (null == serverName || ("").equals(serverName.trim())) { - throw new IllegalArgumentException("The servername cannot be null or empty."); - } - ServerName sn = ServerName.valueOf(serverName); - AdminService.BlockingInterface admin = this.connection.getAdmin(sn); - // Close the region without updating zk state. - CloseRegionRequest request = - ProtobufUtil.buildCloseRegionRequest(sn, encodedRegionName); - // TODO: There is no timeout on this controller. Set one! - HBaseRpcController controller = this.rpcControllerFactory.newController(); - try { - CloseRegionResponse response = admin.closeRegion(controller, request); - boolean closed = response.getClosed(); - if (false == closed) { - LOG.error("Not able to close the region " + encodedRegionName + "."); - } - return closed; - } catch (Exception e) { - throw ProtobufUtil.handleRemoteException(e); - } + final String unused) throws IOException { + unassign(Bytes.toBytes(encodedRegionName), true); + return true; } + @Deprecated @Override - public void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException { - AdminService.BlockingInterface admin = this.connection.getAdmin(sn); - // TODO: There is no timeout on this controller. Set one! - HBaseRpcController controller = rpcControllerFactory.newController(); - - // Close the region without updating zk state. - ProtobufUtil.closeRegion(controller, admin, sn, hri.getRegionName()); + public void closeRegion(final ServerName unused, final HRegionInfo hri) throws IOException { + unassign(hri.getRegionName(), true); } @Override @@ -1444,8 +1404,7 @@ public class HBaseAdmin implements Admin { } @Override - public void unassign(final byte [] regionName, final boolean force) - throws MasterNotRunningException, ZooKeeperConnectionException, IOException { + public void unassign(final byte [] regionName, final boolean force) throws IOException { final byte[] toBeUnassigned = getRegionName(regionName); executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) { @Override http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java index ca4a80e..285286a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java @@ -726,40 +726,18 @@ public class RawAsyncHBaseAdmin implements AsyncAdmin { } @Override - public CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> serverName) { + public CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> unused) { CompletableFuture<Boolean> future = new CompletableFuture<>(); - getRegionLocation(regionName).whenComplete((location, err) -> { + unassign(regionName, true).whenComplete((result, err) -> { if (err != null) { future.completeExceptionally(err); - return; - } - ServerName server = serverName.isPresent() ? serverName.get() : location.getServerName(); - if (server == null) { - future.completeExceptionally(new NotServingRegionException(regionName)); } else { - closeRegion(location.getRegionInfo(), server).whenComplete((result, err2) -> { - if (err2 != null) { - future.completeExceptionally(err2); - } else { - future.complete(result); - } - }); + future.complete(true); } }); return future; } - private CompletableFuture<Boolean> closeRegion(HRegionInfo hri, ServerName serverName) { - return this - .<Boolean> newAdminCaller() - .action( - (controller, stub) -> this.<CloseRegionRequest, CloseRegionResponse, Boolean> adminCall( - controller, stub, - ProtobufUtil.buildCloseRegionRequest(serverName, hri.getRegionName()), - (s, c, req, done) -> s.closeRegion(controller, req, done), resp -> resp.getClosed())) - .serverName(serverName).call(); - } - @Override public CompletableFuture<List<HRegionInfo>> getOnlineRegions(ServerName serverName) { return this.<List<HRegionInfo>> newAdminCaller() http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java index 2311e23..542ade9 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java @@ -116,7 +116,6 @@ import org.apache.hadoop.hbase.shaded.com.google.protobuf.TextFormat; import org.apache.hadoop.hbase.shaded.com.google.protobuf.UnsafeByteOperations; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest; -import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest; @@ -1847,30 +1846,6 @@ public final class ProtobufUtil { } /** - * A helper to close a region given a region name - * using admin protocol. - * - * @param admin - * @param regionName - * @return true if the region is closed - * @throws IOException - */ - public static boolean closeRegion(final RpcController controller, - final AdminService.BlockingInterface admin, - final ServerName server, final byte[] regionName, - final ServerName destinationServer) throws IOException { - CloseRegionRequest closeRegionRequest = - ProtobufUtil.buildCloseRegionRequest(server, - regionName, destinationServer); - try { - CloseRegionResponse response = admin.closeRegion(controller, closeRegionRequest); - return ResponseConverter.isClosed(response); - } catch (ServiceException se) { - throw getRemoteException(se); - } - } - - /** * A helper to warmup a region given a region name * using admin protocol * @@ -3272,25 +3247,6 @@ public final class ProtobufUtil { return builder.build(); } - /** - * Create a CloseRegionRequest for a given encoded region name - * - * @param encodedRegionName the name of the region to close - * @return a CloseRegionRequest - */ - public static CloseRegionRequest - buildCloseRegionRequest(ServerName server, final String encodedRegionName) { - CloseRegionRequest.Builder builder = CloseRegionRequest.newBuilder(); - RegionSpecifier region = RequestConverter.buildRegionSpecifier( - RegionSpecifierType.ENCODED_REGION_NAME, - Bytes.toBytes(encodedRegionName)); - builder.setRegion(region); - if (server != null) { - builder.setServerStartCode(server.getStartcode()); - } - return builder.build(); - } - public static ProcedureDescription buildProcedureDescription(String signature, String instance, Map<String, String> props) { ProcedureDescription.Builder builder = http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java index b0add68..c636a67 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -838,35 +838,6 @@ public class ServerManager { } /** - * Sends an CLOSE RPC to the specified server to close the specified region. - * <p> - * A region server could reject the close request because it either does not - * have the specified region or the region is being split. - * @param server server to open a region - * @param region region to open - * @param dest - if the region is moved to another server, the destination server. null otherwise. - * @throws IOException - */ - public boolean sendRegionClose(ServerName server, HRegionInfo region, - ServerName dest) throws IOException { - if (server == null) throw new NullPointerException("Passed server is null"); - AdminService.BlockingInterface admin = getRsAdmin(server); - if (admin == null) { - throw new IOException("Attempting to send CLOSE RPC to server " + - server.toString() + " for region " + - region.getRegionNameAsString() + - " failed because no RPC connection found to this server"); - } - HBaseRpcController controller = newRpcController(); - return ProtobufUtil.closeRegion(controller, admin, server, region.getRegionName(), dest); - } - - public boolean sendRegionClose(ServerName server, - HRegionInfo region) throws IOException { - return sendRegionClose(server, region, null); - } - - /** * Sends a WARMUP RPC to the specified server to warmup the specified region. * <p> * A region server could reject the close request because it either does not http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 3fb9459..8761ef6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -3030,23 +3030,21 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { /** - * Closes the named region. + * Unassign the named region. * - * @param regionName The region to close. - * @throws IOException + * @param regionName The region to unassign. */ - public void closeRegion(String regionName) throws IOException { - closeRegion(Bytes.toBytes(regionName)); + public void unassignRegion(String regionName) throws IOException { + unassignRegion(Bytes.toBytes(regionName)); } /** - * Closes the named region. + * Unassign the named region. * - * @param regionName The region to close. - * @throws IOException + * @param regionName The region to unassign. */ - public void closeRegion(byte[] regionName) throws IOException { - getAdmin().closeRegion(regionName, null); + public void unassignRegion(byte[] regionName) throws IOException { + getAdmin().unassign(regionName, true); } /** @@ -3054,10 +3052,9 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { * * @param row The row to find the containing region. * @param table The table to find the region. - * @throws IOException */ - public void closeRegionByRow(String row, RegionLocator table) throws IOException { - closeRegionByRow(Bytes.toBytes(row), table); + public void unassignRegionByRow(String row, RegionLocator table) throws IOException { + unassignRegionByRow(Bytes.toBytes(row), table); } /** @@ -3067,9 +3064,9 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { * @param table The table to find the region. * @throws IOException */ - public void closeRegionByRow(byte[] row, RegionLocator table) throws IOException { + public void unassignRegionByRow(byte[] row, RegionLocator table) throws IOException { HRegionLocation hrl = table.getRegionLocation(row); - closeRegion(hrl.getRegionInfo().getRegionName()); + unassignRegion(hrl.getRegionInfo().getRegionName()); } /* http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java index b3c3e70..7bdda80 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java @@ -52,6 +52,7 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotDisabledException; import org.apache.hadoop.hbase.TableNotEnabledException; import org.apache.hadoop.hbase.TableNotFoundException; +import org.apache.hadoop.hbase.UnknownRegionException; import org.apache.hadoop.hbase.ZooKeeperConnectionException; import org.apache.hadoop.hbase.constraint.ConstraintException; import org.apache.hadoop.hbase.master.assignment.AssignmentManager; @@ -311,8 +312,7 @@ public class TestAdmin2 { } @Test (timeout=300000) - public void testShouldCloseTheRegionBasedOnTheEncodedRegionName() - throws Exception { + public void testShouldUnassignTheRegion() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); createTableWithDefaultConf(tableName); @@ -322,8 +322,7 @@ public class TestAdmin2 { for (HRegionInfo regionInfo : onlineRegions) { if (!regionInfo.getTable().isSystemTable()) { info = regionInfo; - admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), rs - .getServerName().getServerName()); + admin.unassign(regionInfo.getRegionName(), true); } } boolean isInList = ProtobufUtil.getOnlineRegions( @@ -353,9 +352,8 @@ public class TestAdmin2 { if (regionInfo.getRegionNameAsString().contains(name)) { info = regionInfo; try { - admin.closeRegionWithEncodedRegionName("sample", rs.getServerName() - .getServerName()); - } catch (NotServingRegionException nsre) { + admin.unassign(Bytes.toBytes("sample"), true); + } catch (UnknownRegionException nsre) { // expected, ignore it } } @@ -376,11 +374,9 @@ public class TestAdmin2 { List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()); for (HRegionInfo regionInfo : onlineRegions) { if (!regionInfo.isMetaTable()) { - if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion2")) { info = regionInfo; - admin.closeRegion(regionInfo.getRegionNameAsString(), rs - .getServerName().getServerName()); + admin.unassign(regionInfo.getRegionName(), true); } } } @@ -398,79 +394,6 @@ public class TestAdmin2 { isInList); } - @Test (timeout=300000) - public void testCloseRegionWhenServerNameIsNull() throws Exception { - final byte[] tableName = Bytes.toBytes(name.getMethodName()); - createTableWithDefaultConf(tableName); - - HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(tableName)); - - try { - List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()); - for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaTable()) { - if (regionInfo.getRegionNameAsString() - .contains(name.getMethodName())) { - admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), - null); - } - } - } - fail("The test should throw exception if the servername passed is null."); - } catch (IllegalArgumentException e) { - } - } - - @Test (timeout=300000) - public void testCloseRegionWhenServerNameIsEmpty() throws Exception { - final byte[] tableName = Bytes.toBytes(name.getMethodName()); - createTableWithDefaultConf(tableName); - - HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(tableName)); - - try { - List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()); - for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaTable()) { - if (regionInfo.getRegionNameAsString() - .contains(name.getMethodName())) { - admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), - " "); - } - } - } - fail("The test should throw exception if the servername passed is empty."); - } catch (IllegalArgumentException e) { - } - } - - @Test (timeout=300000) - public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception { - final byte[] tableName = Bytes.toBytes(name.getMethodName()); - createTableWithDefaultConf(tableName); - - HRegionInfo info = null; - HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(tableName)); - - List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()); - for (HRegionInfo regionInfo : onlineRegions) { - if (!regionInfo.isMetaTable()) { - if (regionInfo.getRegionNameAsString().contains(name.getMethodName())) { - info = regionInfo; - try { - admin.closeRegionWithEncodedRegionName(regionInfo - .getRegionNameAsString(), rs.getServerName().getServerName()); - } catch (NotServingRegionException nsre) { - // expected, ignore it. - } - } - } - } - onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()); - assertTrue("The region should be present in online regions list.", - onlineRegions.contains(info)); - } - private HBaseAdmin createTable(TableName tableName) throws IOException { HBaseAdmin admin = TEST_UTIL.getHBaseAdmin(); http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java index 7b4442b..46c3f0d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java @@ -248,7 +248,7 @@ public class TestReplicasClient { private void closeRegion(HRegionInfo hri) throws Exception { AdminProtos.CloseRegionRequest crr = ProtobufUtil.buildCloseRegionRequest( - getRS().getServerName(), hri.getEncodedName()); + getRS().getServerName(), hri.getRegionName()); AdminProtos.CloseRegionResponse responseClose = getRS() .getRSRpcServices().closeRegion(null, crr); Assert.assertTrue(responseClose.getClosed()); http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java index 29c0576..418dda4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java @@ -62,7 +62,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; @Category({FlakeyTests.class, LargeTests.class}) -@Ignore // Needs to be rewritten for AMv2. Uses tricks not ordained when up on AMv2. +//@Ignore // Needs to be rewritten for AMv2. Uses tricks not ordained when up on AMv2. public class TestMasterFailover { private static final Log LOG = LogFactory.getLog(TestMasterFailover.class); @@ -426,7 +426,7 @@ public class TestMasterFailover { log("Master has aborted"); rs.getRSRpcServices().closeRegion(null, ProtobufUtil.buildCloseRegionRequest( - rs.getServerName(), HRegionInfo.FIRST_META_REGIONINFO.getEncodedName())); + rs.getServerName(), HRegionInfo.FIRST_META_REGIONINFO.getRegionName())); // Start up a new master log("Starting up a new master"); http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java index 4c06f07..04ab29c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java @@ -213,10 +213,6 @@ public class TestMasterNoCluster { ServerManager sm = super.createServerManager(master); // Spy on the created servermanager ServerManager spy = Mockito.spy(sm); - // Fake a successful close. - Mockito.doReturn(true).when(spy). - sendRegionClose((ServerName)Mockito.any(), (HRegionInfo)Mockito.any(), - (ServerName)Mockito.any()); return spy; } http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java index ae315a8..1707168 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java @@ -181,7 +181,7 @@ public class TestQuotaObserverChoreRegionReports { List<HRegionInfo> regions = admin.getTableRegions(tn); assertEquals(1, regions.size()); HRegionInfo hri = regions.get(0); - admin.closeRegion(TEST_UTIL.getMiniHBaseCluster().getRegionServer(0).getServerName(), hri); + admin.unassign(hri.getRegionName(), true); // We should see this table move out of violation after the report expires. Waiter.waitFor(TEST_UTIL.getConfiguration(), 30000, 1000, new Waiter.Predicate<Exception>() { http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java index 5cf351f..89598ad 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java @@ -176,7 +176,7 @@ public class TestRegionServerNoMaster { public static void closeRegion(HBaseTestingUtility HTU, HRegionServer rs, HRegionInfo hri) throws Exception { AdminProtos.CloseRegionRequest crr = ProtobufUtil.buildCloseRegionRequest( - rs.getServerName(), hri.getEncodedName()); + rs.getServerName(), hri.getRegionName()); AdminProtos.CloseRegionResponse responseClose = rs.rpcServices.closeRegion(null, crr); Assert.assertTrue(responseClose.getClosed()); checkRegionIsClosed(HTU, rs, hri); http://git-wip-us.apache.org/repos/asf/hbase/blob/41da64a1/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java index 58a3a75..50a5b06 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java @@ -111,7 +111,7 @@ public class TestHBaseFsckTwoRS extends BaseTestHBaseFsck { @Test(timeout=180000) public void testFixAssignmentsWhenMETAinTransition() throws Exception { MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); - admin.closeRegion(cluster.getServerHoldingMeta(), HRegionInfo.FIRST_META_REGIONINFO); + admin.unassign(HRegionInfo.FIRST_META_REGIONINFO.getRegionName(), true); assignmentManager.offlineRegion(HRegionInfo.FIRST_META_REGIONINFO); new MetaTableLocator().deleteMetaLocation(cluster.getMaster().getZooKeeper()); assertFalse(regionStates.isRegionOnline(HRegionInfo.FIRST_META_REGIONINFO));