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
This commit is contained in:
parent
7a6de1bd42
commit
de696cf6b6
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
@ -1846,30 +1845,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 =
|
||||
|
|
|
@ -837,35 +837,6 @@ public class ServerManager {
|
|||
return rpcControllerFactory == null ? null : rpcControllerFactory.newController();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
|
|
@ -3030,23 +3030,31 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the region containing the given row.
|
||||
*
|
||||
* @param row The row to find the containing region.
|
||||
* @param table The table to find the region.
|
||||
*/
|
||||
public void unassignRegionByRow(String row, RegionLocator table) throws IOException {
|
||||
unassignRegionByRow(Bytes.toBytes(row), table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3056,20 +3064,9 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
|||
* @param table The table to find the region.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void closeRegionByRow(String row, RegionLocator table) throws IOException {
|
||||
closeRegionByRow(Bytes.toBytes(row), table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the region containing the given row.
|
||||
*
|
||||
* @param row The row to find the containing region.
|
||||
* @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());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,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>() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue