use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultRequest in project hbase by apache.
the class TestProcedureFuture method testWithProcIdAndSpinning.
/**
* Verify that the spin loop for the procedure running works.
*/
@Test(timeout = 60000)
public void testWithProcIdAndSpinning() throws Exception {
final AtomicInteger spinCount = new AtomicInteger(0);
HBaseAdmin admin = Mockito.mock(HBaseAdmin.class);
TestFuture f = new TestFuture(admin, 100L) {
@Override
protected GetProcedureResultResponse getProcedureResult(final GetProcedureResultRequest request) throws IOException {
boolean done = spinCount.incrementAndGet() >= 10;
return GetProcedureResultResponse.newBuilder().setState(done ? GetProcedureResultResponse.State.FINISHED : GetProcedureResultResponse.State.RUNNING).build();
}
};
f.get(1, TimeUnit.MINUTES);
assertEquals(10, spinCount.get());
assertTrue("expected convertResult() to be called", f.wasConvertResultCalled());
assertFalse("unexpected waitOperationResult() called", f.wasWaitOperationResultCalled());
assertTrue("expected postOperationResult() to be called", f.wasPostOperationResultCalled());
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultRequest in project hbase by apache.
the class AsyncHBaseAdmin method getProcedureResult.
private void getProcedureResult(final long procId, CompletableFuture<Void> future) {
this.<GetProcedureResultResponse>newMasterCaller().action((controller, stub) -> this.<GetProcedureResultRequest, GetProcedureResultResponse, GetProcedureResultResponse>call(controller, stub, GetProcedureResultRequest.newBuilder().setProcId(procId).build(), (s, c, req, done) -> s.getProcedureResult(c, req, done), (resp) -> resp)).call().whenComplete((response, error) -> {
if (error != null) {
LOG.warn("failed to get the procedure result procId=" + procId, ConnectionUtils.translateException(error));
connection.RETRY_TIMER.newTimeout(t -> getProcedureResult(procId, future), pauseNs, TimeUnit.NANOSECONDS);
return;
}
if (response.getState() == GetProcedureResultResponse.State.RUNNING) {
connection.RETRY_TIMER.newTimeout(t -> getProcedureResult(procId, future), pauseNs, TimeUnit.NANOSECONDS);
return;
}
if (response.hasException()) {
IOException ioe = ForeignExceptionUtil.toIOException(response.getException());
future.completeExceptionally(ioe);
} else {
future.complete(null);
}
});
}
Aggregations