use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultResponse in project hbase by apache.
the class MasterRpcServices method getProcedureResult.
@Override
public GetProcedureResultResponse getProcedureResult(RpcController controller, GetProcedureResultRequest request) throws ServiceException {
LOG.debug("Checking to see if procedure is done pid=" + request.getProcId());
try {
server.checkInitialized();
GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder();
long procId = request.getProcId();
ProcedureExecutor<?> executor = server.getMasterProcedureExecutor();
Procedure<?> result = executor.getResultOrProcedure(procId);
if (result != null) {
builder.setSubmittedTime(result.getSubmittedTime());
builder.setLastUpdate(result.getLastUpdate());
if (executor.isFinished(procId)) {
builder.setState(GetProcedureResultResponse.State.FINISHED);
if (result.isFailed()) {
IOException exception = MasterProcedureUtil.unwrapRemoteIOException(result);
builder.setException(ForeignExceptionUtil.toProtoForeignException(exception));
}
byte[] resultData = result.getResult();
if (resultData != null) {
builder.setResult(UnsafeByteOperations.unsafeWrap(resultData));
}
server.getMasterProcedureExecutor().removeResult(request.getProcId());
} else {
builder.setState(GetProcedureResultResponse.State.RUNNING);
}
} else {
builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
}
return builder.build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultResponse 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);
}
});
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultResponse in project hbase by apache.
the class RawAsyncHBaseAdmin method getProcedureResult.
private void getProcedureResult(long procId, CompletableFuture<Void> future, int retries) {
addListener(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(), (response, error) -> {
if (error != null) {
LOG.warn("failed to get the procedure result procId={}", procId, ConnectionUtils.translateException(error));
retryTimer.newTimeout(t -> getProcedureResult(procId, future, retries + 1), ConnectionUtils.getPauseTime(pauseNs, retries), TimeUnit.NANOSECONDS);
return;
}
if (response.getState() == GetProcedureResultResponse.State.RUNNING) {
retryTimer.newTimeout(t -> getProcedureResult(procId, future, retries + 1), ConnectionUtils.getPauseTime(pauseNs, retries), TimeUnit.NANOSECONDS);
return;
}
if (response.hasException()) {
IOException ioe = ForeignExceptionUtil.toIOException(response.getException());
future.completeExceptionally(ioe);
} else {
future.complete(null);
}
});
}
Aggregations