public class ClearUserNamespacesAndTablesRule extends org.junit.rules.ExternalResource
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);
}
}
| Modifier and Type | Field and Description |
|---|---|
private org.apache.hadoop.hbase.client.AsyncAdmin |
admin |
private Supplier<org.apache.hadoop.hbase.client.AsyncConnection> |
connectionSupplier |
private static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
ClearUserNamespacesAndTablesRule(Supplier<org.apache.hadoop.hbase.client.AsyncConnection> connectionSupplier) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
before() |
private CompletableFuture<Void> |
clearTablesAndNamespaces() |
private CompletableFuture<Void> |
deleteNamespace(String namespace) |
private CompletableFuture<Void> |
deleteTable(org.apache.hadoop.hbase.TableName tableName) |
private CompletableFuture<Void> |
deleteUserNamespaces() |
private CompletableFuture<Void> |
deleteUserTables() |
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>> |
listTableNames() |
private CompletableFuture<List<String>> |
listUserNamespaces() |
private static final org.slf4j.Logger logger
private final Supplier<org.apache.hadoop.hbase.client.AsyncConnection> connectionSupplier
private org.apache.hadoop.hbase.client.AsyncAdmin admin
public ClearUserNamespacesAndTablesRule(Supplier<org.apache.hadoop.hbase.client.AsyncConnection> connectionSupplier)
protected void before() throws Throwable
before in class org.junit.rules.ExternalResourceThrowableprivate CompletableFuture<Void> clearTablesAndNamespaces()
private CompletableFuture<Void> deleteUserTables()
private CompletableFuture<List<org.apache.hadoop.hbase.TableName>> listTableNames()
private CompletableFuture<Boolean> isTableEnabled(org.apache.hadoop.hbase.TableName tableName)
private CompletableFuture<Void> disableIfEnabled(org.apache.hadoop.hbase.TableName tableName)
private CompletableFuture<Void> disableTable(org.apache.hadoop.hbase.TableName tableName)
private CompletableFuture<Void> deleteTable(org.apache.hadoop.hbase.TableName tableName)
private CompletableFuture<List<String>> listUserNamespaces()
private CompletableFuture<Void> deleteNamespace(String namespace)
private CompletableFuture<Void> deleteUserNamespaces()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.