Search in sources :

Example 1 with ExecProcedureResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse in project hbase by apache.

the class MasterRpcServices method execProcedureWithRet.

/**
   * Triggers a synchronous attempt to run a distributed procedure and sets
   * return data in response.
   * {@inheritDoc}
   */
@Override
public ExecProcedureResponse execProcedureWithRet(RpcController controller, ExecProcedureRequest request) throws ServiceException {
    try {
        master.checkInitialized();
        ProcedureDescription desc = request.getProcedure();
        MasterProcedureManager mpm = master.getMasterProcedureManagerHost().getProcedureManager(desc.getSignature());
        if (mpm == null) {
            throw new ServiceException("The procedure is not registered: " + desc.getSignature());
        }
        LOG.info(master.getClientIdAuditPrefix() + " procedure request for: " + desc.getSignature());
        byte[] data = mpm.execProcedureWithRet(desc);
        ExecProcedureResponse.Builder builder = ExecProcedureResponse.newBuilder();
        // set return data if available
        if (data != null) {
            builder.setReturnData(UnsafeByteOperations.unsafeWrap(data));
        }
        return builder.build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ProcedureDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription) MasterProcedureManager(org.apache.hadoop.hbase.procedure.MasterProcedureManager) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ExecProcedureResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse)

Example 2 with ExecProcedureResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse 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");
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) ExecProcedureResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) InterruptedIOException(java.io.InterruptedIOException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException) TimeoutException(java.util.concurrent.TimeoutException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) FailedLogCloseException(org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) NamespaceNotFoundException(org.apache.hadoop.hbase.NamespaceNotFoundException) TableExistsException(org.apache.hadoop.hbase.TableExistsException) KeeperException(org.apache.zookeeper.KeeperException) UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException) RemoteException(org.apache.hadoop.ipc.RemoteException) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) NameStringPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair) ProcedureDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription) ExecProcedureRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest)

Example 3 with ExecProcedureResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse 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;
}
Also used : NameStringPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair) ProcedureDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription) ExecProcedureRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest) ExecProcedureResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) InterruptedIOException(java.io.InterruptedIOException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException) TimeoutException(java.util.concurrent.TimeoutException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) FailedLogCloseException(org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) NamespaceNotFoundException(org.apache.hadoop.hbase.NamespaceNotFoundException) TableExistsException(org.apache.hadoop.hbase.TableExistsException) KeeperException(org.apache.zookeeper.KeeperException) UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException) RemoteException(org.apache.hadoop.ipc.RemoteException) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)

Aggregations

IOException (java.io.IOException)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)3 ProcedureDescription (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription)3 ExecProcedureResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse)3 InterruptedIOException (java.io.InterruptedIOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 MasterNotRunningException (org.apache.hadoop.hbase.MasterNotRunningException)2 NamespaceNotFoundException (org.apache.hadoop.hbase.NamespaceNotFoundException)2 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)2 TableExistsException (org.apache.hadoop.hbase.TableExistsException)2 TableNotDisabledException (org.apache.hadoop.hbase.TableNotDisabledException)2 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)2 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)2 ZooKeeperConnectionException (org.apache.hadoop.hbase.ZooKeeperConnectionException)2 TimeoutIOException (org.apache.hadoop.hbase.exceptions.TimeoutIOException)2 FailedLogCloseException (org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException)2 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)2 NameStringPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair)2