HBASE-18914 Remove AsyncAdmin's methods which were already deprecated in Admin interface
This commit is contained in:
parent
aeaf222e35
commit
58b0585d66
|
@ -142,17 +142,6 @@ public interface AsyncAdmin {
|
|||
*/
|
||||
CompletableFuture<Void> deleteTable(TableName tableName);
|
||||
|
||||
/**
|
||||
* Delete tables matching the passed in pattern and wait on completion. Warning: Use this method
|
||||
* carefully, there is no prompting and the effect is immediate. Consider using
|
||||
* {@link #listTableNames(Optional, boolean) } and
|
||||
* {@link #deleteTable(org.apache.hadoop.hbase.TableName)}
|
||||
* @param pattern The pattern to match table names against
|
||||
* @return Table descriptors for tables that couldn't be deleted. The return value will be wrapped
|
||||
* by a {@link CompletableFuture}. The return HTDs are read-only.
|
||||
*/
|
||||
CompletableFuture<List<TableDescriptor>> deleteTables(Pattern pattern);
|
||||
|
||||
/**
|
||||
* Truncate a table.
|
||||
* @param tableName name of table to truncate
|
||||
|
@ -166,32 +155,12 @@ public interface AsyncAdmin {
|
|||
*/
|
||||
CompletableFuture<Void> enableTable(TableName tableName);
|
||||
|
||||
/**
|
||||
* Enable tables matching the passed in pattern. Warning: Use this method carefully, there is no
|
||||
* prompting and the effect is immediate. Consider using {@link #listTables(Optional, boolean)} and
|
||||
* {@link #enableTable(TableName)}
|
||||
* @param pattern The pattern to match table names against
|
||||
* @return Table descriptors for tables that couldn't be enabled. The return value will be wrapped
|
||||
* by a {@link CompletableFuture}. The return HTDs are read-only.
|
||||
*/
|
||||
CompletableFuture<List<TableDescriptor>> enableTables(Pattern pattern);
|
||||
|
||||
/**
|
||||
* Disable a table. The table has to be in enabled state for it to be disabled.
|
||||
* @param tableName
|
||||
*/
|
||||
CompletableFuture<Void> disableTable(TableName tableName);
|
||||
|
||||
/**
|
||||
* Disable tables matching the passed in pattern. Warning: Use this method carefully, there is no
|
||||
* prompting and the effect is immediate. Consider using {@link #listTables(Optional, boolean)} and
|
||||
* {@link #disableTable(TableName)}
|
||||
* @param pattern The pattern to match table names against
|
||||
* @return Table descriptors for tables that couldn't be disabled. The return value will be wrapped by a
|
||||
* {@link CompletableFuture}. The return HTDs are read-only.
|
||||
*/
|
||||
CompletableFuture<List<TableDescriptor>> disableTables(Pattern pattern);
|
||||
|
||||
/**
|
||||
* @param tableName name of table to check
|
||||
* @return true if table is on-line. The return value will be wrapped by a
|
||||
|
@ -225,16 +194,6 @@ public interface AsyncAdmin {
|
|||
*/
|
||||
CompletableFuture<Boolean> isTableAvailable(TableName tableName, byte[][] splitKeys);
|
||||
|
||||
/**
|
||||
* Get the status of alter command - indicates how many regions have received the updated schema
|
||||
* Asynchronous operation.
|
||||
* @param tableName TableName instance
|
||||
* @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
|
||||
* yet to be updated Pair.getSecond() is the total number of regions of the table. The
|
||||
* return value will be wrapped by a {@link CompletableFuture}.
|
||||
*/
|
||||
CompletableFuture<Pair<Integer, Integer>> getAlterStatus(TableName tableName);
|
||||
|
||||
/**
|
||||
* Add a column family to an existing table.
|
||||
* @param tableName name of the table to add column family to
|
||||
|
@ -289,19 +248,6 @@ public interface AsyncAdmin {
|
|||
*/
|
||||
CompletableFuture<List<NamespaceDescriptor>> listNamespaceDescriptors();
|
||||
|
||||
/**
|
||||
* 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 Deprecated. Not used anymore after deprecation.
|
||||
* @return Deprecated. Always returns true now.
|
||||
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
|
||||
* (<a href="https://issues.apache.org/jira/browse/HBASE-18231">HBASE-18231</a>).
|
||||
* Use {@link #unassign(byte[], boolean)}.
|
||||
*/
|
||||
@Deprecated
|
||||
CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> serverName);
|
||||
|
||||
/**
|
||||
* Get all the online regions on a region server.
|
||||
*/
|
||||
|
|
|
@ -116,11 +116,6 @@ public class AsyncHBaseAdmin implements AsyncAdmin {
|
|||
return wrap(rawAdmin.deleteTable(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<TableDescriptor>> deleteTables(Pattern pattern) {
|
||||
return wrap(rawAdmin.deleteTables(pattern));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> truncateTable(TableName tableName, boolean preserveSplits) {
|
||||
return wrap(rawAdmin.truncateTable(tableName, preserveSplits));
|
||||
|
@ -131,21 +126,11 @@ public class AsyncHBaseAdmin implements AsyncAdmin {
|
|||
return wrap(rawAdmin.enableTable(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<TableDescriptor>> enableTables(Pattern pattern) {
|
||||
return wrap(rawAdmin.enableTables(pattern));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> disableTable(TableName tableName) {
|
||||
return wrap(rawAdmin.disableTable(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<TableDescriptor>> disableTables(Pattern pattern) {
|
||||
return wrap(rawAdmin.disableTables(pattern));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> isTableEnabled(TableName tableName) {
|
||||
return wrap(rawAdmin.isTableEnabled(tableName));
|
||||
|
@ -161,11 +146,6 @@ public class AsyncHBaseAdmin implements AsyncAdmin {
|
|||
return wrap(rawAdmin.isTableAvailable(tableName, splitKeys));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Pair<Integer, Integer>> getAlterStatus(TableName tableName) {
|
||||
return wrap(rawAdmin.getAlterStatus(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> addColumnFamily(TableName tableName,
|
||||
ColumnFamilyDescriptor columnFamily) {
|
||||
|
@ -208,11 +188,6 @@ public class AsyncHBaseAdmin implements AsyncAdmin {
|
|||
return wrap(rawAdmin.listNamespaceDescriptors());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> unused) {
|
||||
return wrap(rawAdmin.closeRegion(regionName, unused));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<RegionInfo>> getOnlineRegions(ServerName serverName) {
|
||||
return wrap(rawAdmin.getOnlineRegions(serverName));
|
||||
|
|
|
@ -383,31 +383,6 @@ public class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
CompletableFuture<Void> operate(TableName table);
|
||||
}
|
||||
|
||||
private CompletableFuture<List<TableDescriptor>> batchTableOperations(Pattern pattern,
|
||||
TableOperator operator, String operationType) {
|
||||
CompletableFuture<List<TableDescriptor>> future = new CompletableFuture<>();
|
||||
List<TableDescriptor> failed = new LinkedList<>();
|
||||
listTables(Optional.ofNullable(pattern), false).whenComplete(
|
||||
(tables, error) -> {
|
||||
if (error != null) {
|
||||
future.completeExceptionally(error);
|
||||
return;
|
||||
}
|
||||
CompletableFuture[] futures =
|
||||
tables.stream()
|
||||
.map((table) -> operator.operate(table.getTableName()).whenComplete((v, ex) -> {
|
||||
if (ex != null) {
|
||||
LOG.info("Failed to " + operationType + " table " + table.getTableName(), ex);
|
||||
failed.add(table);
|
||||
}
|
||||
})).<CompletableFuture> toArray(size -> new CompletableFuture[size]);
|
||||
CompletableFuture.allOf(futures).thenAccept((v) -> {
|
||||
future.complete(failed);
|
||||
});
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> tableExists(TableName tableName) {
|
||||
return AsyncMetaTableAccessor.tableExists(metaTable, tableName);
|
||||
|
@ -495,11 +470,6 @@ public class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
new DeleteTableProcedureBiConsumer(this, tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<TableDescriptor>> deleteTables(Pattern pattern) {
|
||||
return batchTableOperations(pattern, (table) -> deleteTable(table), "DELETE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> truncateTable(TableName tableName, boolean preserveSplits) {
|
||||
return this.<TruncateTableRequest, TruncateTableResponse> procedureCall(
|
||||
|
@ -516,11 +486,6 @@ public class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
new EnableTableProcedureBiConsumer(this, tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<TableDescriptor>> enableTables(Pattern pattern) {
|
||||
return batchTableOperations(pattern, (table) -> enableTable(table), "ENABLE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> disableTable(TableName tableName) {
|
||||
return this.<DisableTableRequest, DisableTableResponse> procedureCall(RequestConverter
|
||||
|
@ -529,11 +494,6 @@ public class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
new DisableTableProcedureBiConsumer(this, tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<TableDescriptor>> disableTables(Pattern pattern) {
|
||||
return batchTableOperations(pattern, (table) -> disableTable(table), "DISABLE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> isTableEnabled(TableName tableName) {
|
||||
CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
|
@ -640,18 +600,6 @@ public class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Pair<Integer, Integer>> getAlterStatus(TableName tableName) {
|
||||
return this
|
||||
.<Pair<Integer, Integer>>newMasterCaller()
|
||||
.action(
|
||||
(controller, stub) -> this
|
||||
.<GetSchemaAlterStatusRequest, GetSchemaAlterStatusResponse, Pair<Integer, Integer>> call(
|
||||
controller, stub, RequestConverter.buildGetSchemaAlterStatusRequest(tableName), (s,
|
||||
c, req, done) -> s.getSchemaAlterStatus(c, req, done), (resp) -> new Pair<>(
|
||||
resp.getYetToUpdateRegions(), resp.getTotalRegions()))).call();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> addColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily) {
|
||||
return this.<AddColumnRequest, AddColumnResponse> procedureCall(
|
||||
|
@ -725,19 +673,6 @@ public class RawAsyncHBaseAdmin implements AsyncAdmin {
|
|||
.toNamespaceDescriptorList(resp))).call();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> closeRegion(byte[] regionName, Optional<ServerName> unused) {
|
||||
CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
unassign(regionName, true).whenComplete((result, err) -> {
|
||||
if (err != null) {
|
||||
future.completeExceptionally(err);
|
||||
} else {
|
||||
future.complete(true);
|
||||
}
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<RegionInfo>> getOnlineRegions(ServerName serverName) {
|
||||
return this.<List<RegionInfo>> newAdminCaller()
|
||||
|
|
|
@ -56,8 +56,6 @@ import org.junit.experimental.categories.Category;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
|
||||
|
||||
/**
|
||||
* Class to test asynchronous region admin operations.
|
||||
*/
|
||||
|
@ -65,74 +63,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
|
|||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestAsyncRegionAdminApi extends TestAsyncAdminBase {
|
||||
|
||||
@Test
|
||||
public void testCloseRegion() throws Exception {
|
||||
createTableWithDefaultConf(tableName);
|
||||
|
||||
RegionInfo info = null;
|
||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(tableName);
|
||||
List<RegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
|
||||
for (RegionInfo regionInfo : onlineRegions) {
|
||||
if (!regionInfo.getTable().isSystemTable()) {
|
||||
info = regionInfo;
|
||||
boolean closed = admin.closeRegion(regionInfo.getRegionName(),
|
||||
Optional.of(rs.getServerName())).get();
|
||||
assertTrue(closed);
|
||||
}
|
||||
}
|
||||
boolean isInList = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()).contains(info);
|
||||
long timeout = System.currentTimeMillis() + 10000;
|
||||
while ((System.currentTimeMillis() < timeout) && (isInList)) {
|
||||
Thread.sleep(100);
|
||||
isInList = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices()).contains(info);
|
||||
}
|
||||
|
||||
assertFalse("The region should not be present in online regions list.", isInList);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
|
||||
createTableWithDefaultConf(tableName);
|
||||
|
||||
RegionInfo info = null;
|
||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(tableName);
|
||||
List<RegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
|
||||
for (RegionInfo regionInfo : onlineRegions) {
|
||||
if (!regionInfo.isMetaRegion()) {
|
||||
if (regionInfo.getRegionNameAsString().contains(tableName.getNameAsString())) {
|
||||
info = regionInfo;
|
||||
boolean catchNotServingException = false;
|
||||
try {
|
||||
admin.closeRegion(Bytes.toBytes("sample"), Optional.of(rs.getServerName()))
|
||||
.get();
|
||||
} catch (Exception e) {
|
||||
catchNotServingException = true;
|
||||
// expected, ignore it
|
||||
}
|
||||
assertTrue(catchNotServingException);
|
||||
}
|
||||
}
|
||||
}
|
||||
onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
|
||||
assertTrue("The region should be present in online regions list.",
|
||||
onlineRegions.contains(info));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloseRegionWhenServerNameIsEmpty() throws Exception {
|
||||
createTableWithDefaultConf(tableName);
|
||||
|
||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(tableName);
|
||||
List<RegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
|
||||
for (RegionInfo regionInfo : onlineRegions) {
|
||||
if (!regionInfo.isMetaRegion()) {
|
||||
if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegionWhenServerNameIsEmpty")) {
|
||||
admin.closeRegion(regionInfo.getRegionName(), Optional.empty()).get();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRegionLocation() throws Exception {
|
||||
RawAsyncHBaseAdmin rawAdmin = (RawAsyncHBaseAdmin) ASYNC_CONN.getAdmin();
|
||||
|
|
|
@ -24,11 +24,8 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
|
|||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
|
@ -42,15 +39,17 @@ import java.util.regex.Pattern;
|
|||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase {
|
||||
|
||||
private static final Pattern MATCH_ALL = Pattern.compile(".*");
|
||||
|
||||
String snapshotName1 = "snapshotName1";
|
||||
String snapshotName2 = "snapshotName2";
|
||||
String snapshotName3 = "snapshotName3";
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
admin.deleteSnapshots(Pattern.compile(".*")).get();
|
||||
admin.disableTables(Pattern.compile(".*")).get();
|
||||
admin.deleteTables(Pattern.compile(".*")).get();
|
||||
admin.deleteSnapshots(MATCH_ALL).get();
|
||||
admin.listTableNames().get().forEach(t -> admin.disableTable(t).join());
|
||||
admin.listTableNames().get().forEach(t -> admin.deleteTable(t).join());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -406,25 +406,6 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
|
|||
assertFalse(admin.tableExists(tableName).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteTables() throws Exception {
|
||||
TableName[] tables =
|
||||
{ TableName.valueOf(tableName.getNameAsString() + "1"),
|
||||
TableName.valueOf(tableName.getNameAsString() + "2"),
|
||||
TableName.valueOf(tableName.getNameAsString() + "3") };
|
||||
Arrays.stream(tables).forEach((table) -> {
|
||||
createTableWithDefaultConf(table);
|
||||
admin.tableExists(table).thenAccept((exist) -> assertTrue(exist)).join();
|
||||
admin.disableTable(table).join();
|
||||
});
|
||||
List<TableDescriptor> failed =
|
||||
admin.deleteTables(Pattern.compile(tableName.getNameAsString() + ".*")).get();
|
||||
assertEquals(0, failed.size());
|
||||
Arrays.stream(tables).forEach((table) -> {
|
||||
admin.tableExists(table).thenAccept((exist) -> assertFalse(exist)).join();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTruncateTable() throws Exception {
|
||||
testTruncateTable(tableName, false);
|
||||
|
@ -536,7 +517,8 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
|
|||
table1.get(get).get();
|
||||
table2.get(get).get();
|
||||
|
||||
this.admin.disableTables(Pattern.compile(tableName.getNameAsString() + ".*")).join();
|
||||
admin.listTableNames(Optional.of(Pattern.compile(tableName.getNameAsString() + ".*")), false)
|
||||
.get().forEach(t -> admin.disableTable(t).join());
|
||||
|
||||
// Test that tables are disabled
|
||||
get = new Get(row);
|
||||
|
@ -559,7 +541,8 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase {
|
|||
assertEquals(TableState.State.DISABLED, getStateFromMeta(tableName1));
|
||||
assertEquals(TableState.State.DISABLED, getStateFromMeta(tableName2));
|
||||
|
||||
this.admin.enableTables(Pattern.compile("testDisableAndEnableTables.*")).join();
|
||||
admin.listTableNames(Optional.of(Pattern.compile(tableName.getNameAsString() + ".*")), false)
|
||||
.get().forEach(t -> admin.enableTable(t).join());
|
||||
|
||||
// Test that tables are enabled
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue