Search in sources :

Example 21 with ServiceException

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

the class MasterRpcServices method getTableNames.

/**
 * Get list of userspace table names
 * @param controller Unused (set to null).
 * @param req GetTableNamesRequest
 * @return GetTableNamesResponse
 * @throws ServiceException
 */
@Override
public GetTableNamesResponse getTableNames(RpcController controller, GetTableNamesRequest req) throws ServiceException {
    try {
        server.checkServiceStarted();
        final String regex = req.hasRegex() ? req.getRegex() : null;
        final String namespace = req.hasNamespace() ? req.getNamespace() : null;
        List<TableName> tableNames = server.listTableNames(namespace, regex, req.getIncludeSysTables());
        GetTableNamesResponse.Builder builder = GetTableNamesResponse.newBuilder();
        if (tableNames != null && tableNames.size() > 0) {
            // Add the table names to the response
            for (TableName table : tableNames) {
                builder.addTableNames(ProtobufUtil.toProtoTableName(table));
            }
        }
        return builder.build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) GetTableNamesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableNamesResponse) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 22 with ServiceException

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

the class MasterRpcServices method addRSGroup.

@Override
public AddRSGroupResponse addRSGroup(RpcController controller, AddRSGroupRequest request) throws ServiceException {
    AddRSGroupResponse.Builder builder = AddRSGroupResponse.newBuilder();
    LOG.info(server.getClientIdAuditPrefix() + " add rsgroup " + request.getRSGroupName());
    try {
        if (server.getMasterCoprocessorHost() != null) {
            server.getMasterCoprocessorHost().preAddRSGroup(request.getRSGroupName());
        }
        server.getRSGroupInfoManager().addRSGroup(new RSGroupInfo(request.getRSGroupName()));
        if (server.getMasterCoprocessorHost() != null) {
            server.getMasterCoprocessorHost().postAddRSGroup(request.getRSGroupName());
        }
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    return builder.build();
}
Also used : AddRSGroupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.AddRSGroupResponse) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) RSGroupInfo(org.apache.hadoop.hbase.rsgroup.RSGroupInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 23 with ServiceException

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

the class MasterRpcServices method isProcedureDone.

/**
 * Checks if the specified procedure is done.
 * @return true if the procedure is done, false if the procedure is in the process of completing
 * @throws ServiceException if invalid procedure or failed procedure with progress failure reason.
 */
@Override
public IsProcedureDoneResponse isProcedureDone(RpcController controller, IsProcedureDoneRequest request) throws ServiceException {
    try {
        server.checkInitialized();
        ProcedureDescription desc = request.getProcedure();
        MasterProcedureManager mpm = server.getMasterProcedureManagerHost().getProcedureManager(desc.getSignature());
        if (mpm == null) {
            throw new ServiceException("The procedure is not registered: " + desc.getSignature());
        }
        LOG.debug("Checking to see if procedure from request:" + desc.getSignature() + " is done");
        IsProcedureDoneResponse.Builder builder = IsProcedureDoneResponse.newBuilder();
        boolean done = mpm.isProcedureDone(desc);
        builder.setDone(done);
        return builder.build();
    } catch (ForeignException e) {
        throw new ServiceException(e.getCause());
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) ProcedureDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription) IsProcedureDoneResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsProcedureDoneResponse) MasterProcedureManager(org.apache.hadoop.hbase.procedure.MasterProcedureManager) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 24 with ServiceException

use of org.apache.hbase.thirdparty.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 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);
    }
}
Also used : GetProcedureResultResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultResponse) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 25 with ServiceException

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

the class MasterRpcServices method requestLock.

@Override
public LockResponse requestLock(RpcController controller, final LockRequest request) throws ServiceException {
    try {
        if (request.getDescription().isEmpty()) {
            throw new IllegalArgumentException("Empty description");
        }
        NonceProcedureRunnable npr;
        LockType type = LockType.valueOf(request.getLockType().name());
        if (request.getRegionInfoCount() > 0) {
            final RegionInfo[] regionInfos = new RegionInfo[request.getRegionInfoCount()];
            for (int i = 0; i < request.getRegionInfoCount(); ++i) {
                regionInfos[i] = ProtobufUtil.toRegionInfo(request.getRegionInfo(i));
            }
            npr = new NonceProcedureRunnable(server, request.getNonceGroup(), request.getNonce()) {

                @Override
                protected void run() throws IOException {
                    setProcId(server.getLockManager().remoteLocks().requestRegionsLock(regionInfos, request.getDescription(), getNonceKey()));
                }

                @Override
                protected String getDescription() {
                    return "RequestLock";
                }
            };
        } else if (request.hasTableName()) {
            final TableName tableName = ProtobufUtil.toTableName(request.getTableName());
            npr = new NonceProcedureRunnable(server, request.getNonceGroup(), request.getNonce()) {

                @Override
                protected void run() throws IOException {
                    setProcId(server.getLockManager().remoteLocks().requestTableLock(tableName, type, request.getDescription(), getNonceKey()));
                }

                @Override
                protected String getDescription() {
                    return "RequestLock";
                }
            };
        } else if (request.hasNamespace()) {
            npr = new NonceProcedureRunnable(server, request.getNonceGroup(), request.getNonce()) {

                @Override
                protected void run() throws IOException {
                    setProcId(server.getLockManager().remoteLocks().requestNamespaceLock(request.getNamespace(), type, request.getDescription(), getNonceKey()));
                }

                @Override
                protected String getDescription() {
                    return "RequestLock";
                }
            };
        } else {
            throw new IllegalArgumentException("one of table/namespace/region should be specified");
        }
        long procId = MasterProcedureUtil.submitProcedure(npr);
        return LockResponse.newBuilder().setProcId(procId).build();
    } catch (IllegalArgumentException e) {
        LOG.warn("Exception when queuing lock", e);
        throw new ServiceException(new DoNotRetryIOException(e));
    } catch (IOException e) {
        LOG.warn("Exception when queuing lock", e);
        throw new ServiceException(e);
    }
}
Also used : DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) LockType(org.apache.hadoop.hbase.procedure2.LockType) TableName(org.apache.hadoop.hbase.TableName) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) NonceProcedureRunnable(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil.NonceProcedureRunnable)

Aggregations

ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)130 IOException (java.io.IOException)112 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)100 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)39 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)28 UncheckedIOException (java.io.UncheckedIOException)27 TableName (org.apache.hadoop.hbase.TableName)22 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)22 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)19 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)16 UnknownProtocolException (org.apache.hadoop.hbase.exceptions.UnknownProtocolException)16 Test (org.junit.Test)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ArrayList (java.util.ArrayList)15 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)15 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)15 ServerNotRunningYetException (org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)15 KeeperException (org.apache.zookeeper.KeeperException)14 Table (org.apache.hadoop.hbase.client.Table)13 User (org.apache.hadoop.hbase.security.User)13