use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest in project hbase by apache.
the class HBaseAdmin method execProcedure.
@Override
public void execProcedure(String signature, String instance, Map<String, String> props) throws IOException {
ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
builder.setSignature(signature).setInstance(instance);
for (Entry<String, String> entry : props.entrySet()) {
NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey()).setValue(entry.getValue()).build();
builder.addConfiguration(pair);
}
final ExecProcedureRequest request = ExecProcedureRequest.newBuilder().setProcedure(builder.build()).build();
// run the procedure on the master
ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(getConnection(), getRpcControllerFactory()) {
@Override
protected ExecProcedureResponse rpcCall() throws Exception {
return master.execProcedure(getRpcController(), request);
}
});
long start = EnvironmentEdgeManager.currentTime();
long max = response.getExpectedTimeout();
long maxPauseTime = max / this.numRetries;
int tries = 0;
LOG.debug("Waiting a max of " + max + " ms for procedure '" + signature + " : " + instance + "'' to complete. (max " + maxPauseTime + " ms per retry)");
boolean done = false;
while (tries == 0 || ((EnvironmentEdgeManager.currentTime() - start) < max && !done)) {
try {
// sleep a backoff <= pauseTime amount
long sleep = getPauseTime(tries++);
sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
LOG.debug("(#" + tries + ") Sleeping: " + sleep + "ms while waiting for procedure completion.");
Thread.sleep(sleep);
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException("Interrupted").initCause(e);
}
LOG.debug("Getting current status of procedure from master...");
done = isProcedureFinished(signature, instance, props);
}
if (!done) {
throw new IOException("Procedure '" + signature + " : " + instance + "' wasn't completed in expectedTime:" + max + " ms");
}
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest in project hbase by apache.
the class HBaseAdmin method execProcedureWithRet.
@Override
public byte[] execProcedureWithRet(String signature, String instance, Map<String, String> props) throws IOException {
ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
builder.setSignature(signature).setInstance(instance);
for (Entry<String, String> entry : props.entrySet()) {
NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey()).setValue(entry.getValue()).build();
builder.addConfiguration(pair);
}
final ExecProcedureRequest request = ExecProcedureRequest.newBuilder().setProcedure(builder.build()).build();
// run the procedure on the master
ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(getConnection(), getRpcControllerFactory()) {
@Override
protected ExecProcedureResponse rpcCall() throws Exception {
return master.execProcedureWithRet(getRpcController(), request);
}
});
return response.hasReturnData() ? response.getReturnData().toByteArray() : null;
}
Aggregations