Package org.apache.hadoop.hbase
Class ClearUserNamespacesAndTablesRule
java.lang.Object
org.junit.rules.ExternalResource
org.apache.hadoop.hbase.ClearUserNamespacesAndTablesRule
- All Implemented Interfaces:
org.junit.rules.TestRule
A
TestRule that clears all user namespaces and tables before the test executes. Can be used in either the Rule or ClassRule positions.
Lazily realizes the provided AsyncConnection so as to avoid initialization races with
other Rules. Does not close() provided
connection instance when finished.
Use in combination with MiniClusterRule and ConnectionRule, for example:
{
@code
public class TestMyClass {
@ClassRule
public static final MiniClusterRule miniClusterRule = MiniClusterRule.newBuilder().build();
private final ConnectionRule connectionRule =
new ConnectionRule(miniClusterRule::createConnection);
private final ClearUserNamespacesAndTablesRule clearUserNamespacesAndTablesRule =
new ClearUserNamespacesAndTablesRule(connectionRule::getConnection);
@Rule
public TestRule rule =
RuleChain.outerRule(connectionRule).around(clearUserNamespacesAndTablesRule);
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.hadoop.hbase.client.AsyncAdminprivate final Supplier<org.apache.hadoop.hbase.client.AsyncConnection>private static final org.slf4j.Logger -
Constructor Summary
ConstructorsConstructorDescriptionClearUserNamespacesAndTablesRule(Supplier<org.apache.hadoop.hbase.client.AsyncConnection> connectionSupplier) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbefore()private CompletableFuture<Void>private CompletableFuture<Void>deleteNamespace(String namespace) private CompletableFuture<Void>deleteTable(org.apache.hadoop.hbase.TableName tableName) private CompletableFuture<Void>private CompletableFuture<Void>private CompletableFuture<Void>disableIfEnabled(org.apache.hadoop.hbase.TableName tableName) private CompletableFuture<Void>disableTable(org.apache.hadoop.hbase.TableName tableName) private CompletableFuture<Boolean>isTableEnabled(org.apache.hadoop.hbase.TableName tableName) private CompletableFuture<List<org.apache.hadoop.hbase.TableName>>private CompletableFuture<List<String>>Methods inherited from class org.junit.rules.ExternalResource
after, apply
-
Field Details
-
logger
-
connectionSupplier
-
admin
-
-
Constructor Details
-
ClearUserNamespacesAndTablesRule
public ClearUserNamespacesAndTablesRule(Supplier<org.apache.hadoop.hbase.client.AsyncConnection> connectionSupplier)
-
-
Method Details
-
before
- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
Throwable
-
clearTablesAndNamespaces
-
deleteUserTables
-
listTableNames
-
isTableEnabled
-
disableIfEnabled
-
disableTable
-
deleteTable
-
listUserNamespaces
-
deleteNamespace
-
deleteUserNamespaces
-