Search in sources :

Example 21 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException 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 procId=" + request.getProcId());
    try {
        master.checkInitialized();
        GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder();
        Pair<ProcedureInfo, Procedure> v = master.getMasterProcedureExecutor().getResultOrProcedure(request.getProcId());
        if (v.getFirst() != null) {
            ProcedureInfo result = v.getFirst();
            builder.setState(GetProcedureResultResponse.State.FINISHED);
            builder.setStartTime(result.getStartTime());
            builder.setLastUpdate(result.getLastUpdate());
            if (result.isFailed()) {
                builder.setException(ForeignExceptionUtil.toProtoForeignException(result.getException()));
            }
            if (result.hasResultData()) {
                builder.setResult(UnsafeByteOperations.unsafeWrap(result.getResult()));
            }
            master.getMasterProcedureExecutor().removeResult(request.getProcId());
        } else {
            Procedure proc = v.getSecond();
            if (proc == null) {
                builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
            } else {
                builder.setState(GetProcedureResultResponse.State.RUNNING);
                builder.setStartTime(proc.getStartTime());
                builder.setLastUpdate(proc.getLastUpdate());
            }
        }
        return builder.build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : GetProcedureResultResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultResponse) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 22 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException 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 23 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class MasterRpcServices method getCompletedSnapshots.

/**
   * List the currently available/stored snapshots. Any in-progress snapshots are ignored
   */
@Override
public GetCompletedSnapshotsResponse getCompletedSnapshots(RpcController controller, GetCompletedSnapshotsRequest request) throws ServiceException {
    try {
        master.checkInitialized();
        GetCompletedSnapshotsResponse.Builder builder = GetCompletedSnapshotsResponse.newBuilder();
        List<SnapshotDescription> snapshots = master.snapshotManager.getCompletedSnapshots();
        // convert to protobuf
        for (SnapshotDescription snapshot : snapshots) {
            builder.addSnapshots(snapshot);
        }
        return builder.build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : GetCompletedSnapshotsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetCompletedSnapshotsResponse) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) SnapshotDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.SnapshotDescription) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 24 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class ProtobufUtil method warmupRegion.

/**
   * A helper to warmup a region given a region name
   * using admin protocol
   *
   * @param admin
   * @param regionInfo
   *
   */
public static void warmupRegion(final RpcController controller, final AdminService.BlockingInterface admin, final HRegionInfo regionInfo) throws IOException {
    try {
        WarmupRegionRequest warmupRegionRequest = RequestConverter.buildWarmupRegionRequest(regionInfo);
        admin.warmupRegion(controller, warmupRegionRequest);
    } catch (ServiceException e) {
        throw getRemoteException(e);
    }
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) WarmupRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WarmupRegionRequest)

Example 25 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class ProtobufUtil method getOnlineRegions.

/**
   * A helper to get the all the online regions on a region
   * server using admin protocol.
   * @return a list of online region info
   */
public static List<HRegionInfo> getOnlineRegions(final RpcController controller, final AdminService.BlockingInterface admin) throws IOException {
    GetOnlineRegionRequest request = RequestConverter.buildGetOnlineRegionRequest();
    GetOnlineRegionResponse response = null;
    try {
        response = admin.getOnlineRegion(controller, request);
    } catch (ServiceException se) {
        throw getRemoteException(se);
    }
    return getRegionInfos(response);
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) GetOnlineRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionRequest) GetOnlineRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionResponse)

Aggregations

ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)95 IOException (java.io.IOException)76 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)65 InterruptedIOException (java.io.InterruptedIOException)28 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)24 ServerName (org.apache.hadoop.hbase.ServerName)16 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)15 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)14 ArrayList (java.util.ArrayList)12 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)12 TableName (org.apache.hadoop.hbase.TableName)10 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)10 Test (org.junit.Test)9 CellScanner (org.apache.hadoop.hbase.CellScanner)5 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)4 ClusterConnection (org.apache.hadoop.hbase.client.ClusterConnection)4 Result (org.apache.hadoop.hbase.client.Result)4 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)4 RpcCallContext (org.apache.hadoop.hbase.ipc.RpcCallContext)4 OperationQuota (org.apache.hadoop.hbase.quotas.OperationQuota)4