use of org.apache.hadoop.hbase.client.AsyncAdmin in project hbase by apache.
the class TestProcedurePriority method setUp.
@BeforeClass
public static void setUp() throws Exception {
UTIL.getConfiguration().setLong(ProcedureExecutor.WORKER_KEEP_ALIVE_TIME_CONF_KEY, 5000);
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 4);
UTIL.getConfiguration().set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, MyCP.class.getName());
UTIL.startMiniCluster(3);
CORE_POOL_SIZE = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getCorePoolSize();
TABLE_COUNT = 50 * CORE_POOL_SIZE;
List<Future<?>> futures = new ArrayList<>();
AsyncAdmin admin = UTIL.getAsyncConnection().getAdmin();
Semaphore concurrency = new Semaphore(10);
for (int i = 0; i < TABLE_COUNT; i++) {
concurrency.acquire();
futures.add(admin.createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE_NAME_PREFIX + i)).setColumnFamily(ColumnFamilyDescriptorBuilder.of(CF)).build()).whenComplete((r, e) -> concurrency.release()));
}
for (Future<?> future : futures) {
future.get(3, TimeUnit.MINUTES);
}
UTIL.getAdmin().balance(BalanceRequest.newBuilder().setIgnoreRegionsInTransition(true).build());
UTIL.waitUntilNoRegionsInTransition();
}
use of org.apache.hadoop.hbase.client.AsyncAdmin in project hbase by apache.
the class TestShellExecEndpointCoprocessor method testShellExecBackground.
@Test
public void testShellExecBackground() throws IOException {
final AsyncConnection conn = connectionRule.getConnection();
final AsyncAdmin admin = conn.getAdmin();
final File testDataDir = ensureTestDataDirExists(miniClusterRule.getTestingUtility());
final File testFile = new File(testDataDir, "shell_exec_background.txt");
assertTrue(testFile.createNewFile());
assertEquals(0, testFile.length());
final String command = "echo \"hello world\" >> " + testFile.getAbsolutePath();
final ShellExecRequest req = ShellExecRequest.newBuilder().setCommand(command).setAwaitResponse(false).build();
final ShellExecResponse resp = admin.<ShellExecService.Stub, ShellExecResponse>coprocessorService(ShellExecService::newStub, (stub, controller, callback) -> stub.shellExec(controller, req, callback)).join();
assertFalse("the response from a background task should have no exit code", resp.hasExitCode());
assertFalse("the response from a background task should have no stdout", resp.hasStdout());
assertFalse("the response from a background task should have no stderr", resp.hasStderr());
Waiter.waitFor(conn.getConfiguration(), 5_000, () -> testFile.length() > 0);
final String content = new String(Files.readAllBytes(testFile.toPath())).trim();
assertEquals("hello world", content);
}
use of org.apache.hadoop.hbase.client.AsyncAdmin in project hbase by apache.
the class TestOpenRegionProcedureBackoff method testBackoff.
@Test
public void testBackoff() throws IOException, InterruptedException, ExecutionException {
FAIL = true;
AsyncAdmin admin = UTIL.getAsyncConnection().getAdminBuilder().setRpcTimeout(5, TimeUnit.MINUTES).setOperationTimeout(10, TimeUnit.MINUTES).build();
CompletableFuture<?> future = admin.createTable(TableDescriptorBuilder.newBuilder(NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.of(CF)).build());
assertBackoffIncrease();
FAIL = false;
future.get();
UTIL.waitTableAvailable(NAME);
}
use of org.apache.hadoop.hbase.client.AsyncAdmin in project hbase by apache.
the class TestServerCrashProcedureCarryingMetaStuck method test.
@Test
public void test() throws Exception {
RegionServerThread rsThread = null;
for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
if (!t.getRegionServer().getRegions(TableName.META_TABLE_NAME).isEmpty()) {
rsThread = t;
break;
}
}
HRegionServer rs = rsThread.getRegionServer();
RegionInfo hri = rs.getRegions(TableName.META_TABLE_NAME).get(0).getRegionInfo();
HMaster master = UTIL.getMiniHBaseCluster().getMaster();
ProcedureExecutor<MasterProcedureEnv> executor = master.getMasterProcedureExecutor();
DummyRegionProcedure proc = new DummyRegionProcedure(executor.getEnvironment(), hri);
long procId = master.getMasterProcedureExecutor().submitProcedure(proc);
proc.waitUntilArrive();
try (AsyncConnection conn = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get()) {
AsyncAdmin admin = conn.getAdmin();
CompletableFuture<Void> future = admin.move(hri.getRegionName());
rs.abort("For testing!");
UTIL.waitFor(30000, () -> executor.getProcedures().stream().filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).anyMatch(p -> Bytes.equals(hri.getRegionName(), p.getRegion().getRegionName())));
proc.resume();
UTIL.waitFor(30000, () -> executor.isFinished(procId));
// see whether the move region procedure can finish properly
future.get(30, TimeUnit.SECONDS);
}
}
Aggregations