Search in sources :

Example 26 with ServiceException

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

the class MasterRpcServices method rpcPreCheck.

/**
 * Checks for the following pre-checks in order:
 * <ol>
 *   <li>Master is initialized</li>
 *   <li>Rpc caller has admin permissions</li>
 * </ol>
 * @param requestName name of rpc request. Used in reporting failures to provide context.
 * @throws ServiceException If any of the above listed pre-check fails.
 */
private void rpcPreCheck(String requestName) throws ServiceException {
    try {
        server.checkInitialized();
        requirePermission(requestName, Permission.Action.ADMIN);
    } catch (IOException ioe) {
        throw new ServiceException(ioe);
    }
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 27 with ServiceException

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

the class MasterRpcServices method moveServers.

@Override
public MoveServersResponse moveServers(RpcController controller, MoveServersRequest request) throws ServiceException {
    Set<Address> hostPorts = Sets.newHashSet();
    MoveServersResponse.Builder builder = MoveServersResponse.newBuilder();
    for (HBaseProtos.ServerName el : request.getServersList()) {
        hostPorts.add(Address.fromParts(el.getHostName(), el.getPort()));
    }
    LOG.info(server.getClientIdAuditPrefix() + " move servers " + hostPorts + " to rsgroup " + request.getTargetGroup());
    try {
        if (server.getMasterCoprocessorHost() != null) {
            server.getMasterCoprocessorHost().preMoveServers(hostPorts, request.getTargetGroup());
        }
        server.getRSGroupInfoManager().moveServers(hostPorts, request.getTargetGroup());
        if (server.getMasterCoprocessorHost() != null) {
            server.getMasterCoprocessorHost().postMoveServers(hostPorts, request.getTargetGroup());
        }
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    return builder.build();
}
Also used : Address(org.apache.hadoop.hbase.net.Address) InetAddress(java.net.InetAddress) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) MoveServersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.MoveServersResponse) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)

Example 28 with ServiceException

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

the class MasterRpcServices method getRSGroupInfoOfTable.

@Override
public GetRSGroupInfoOfTableResponse getRSGroupInfoOfTable(RpcController controller, GetRSGroupInfoOfTableRequest request) throws ServiceException {
    TableName tableName = ProtobufUtil.toTableName(request.getTableName());
    LOG.info(server.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table=" + tableName);
    try {
        if (server.getMasterCoprocessorHost() != null) {
            server.getMasterCoprocessorHost().preGetRSGroupInfoOfTable(tableName);
        }
        GetRSGroupInfoOfTableResponse resp;
        TableDescriptor td = server.getTableDescriptors().get(tableName);
        if (td == null) {
            resp = GetRSGroupInfoOfTableResponse.getDefaultInstance();
        } else {
            RSGroupInfo rsGroupInfo = RSGroupUtil.getRSGroupInfo(server, server.getRSGroupInfoManager(), tableName).orElse(server.getRSGroupInfoManager().getRSGroup(RSGroupInfo.DEFAULT_GROUP));
            resp = GetRSGroupInfoOfTableResponse.newBuilder().setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo)).build();
        }
        if (server.getMasterCoprocessorHost() != null) {
            server.getMasterCoprocessorHost().postGetRSGroupInfoOfTable(tableName);
        }
        return resp;
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) GetRSGroupInfoOfTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfTableResponse) 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) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 29 with ServiceException

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

the class MasterRpcServices method setSplitOrMergeEnabled.

@Override
public SetSplitOrMergeEnabledResponse setSplitOrMergeEnabled(RpcController controller, SetSplitOrMergeEnabledRequest request) throws ServiceException {
    SetSplitOrMergeEnabledResponse.Builder response = SetSplitOrMergeEnabledResponse.newBuilder();
    try {
        server.checkInitialized();
        boolean newValue = request.getEnabled();
        for (MasterProtos.MasterSwitchType masterSwitchType : request.getSwitchTypesList()) {
            MasterSwitchType switchType = convert(masterSwitchType);
            boolean oldValue = server.isSplitOrMergeEnabled(switchType);
            response.addPrevValue(oldValue);
            if (server.cpHost != null) {
                server.cpHost.preSetSplitOrMergeEnabled(newValue, switchType);
            }
            server.getSplitOrMergeTracker().setSplitOrMergeEnabled(newValue, switchType);
            if (server.cpHost != null) {
                server.cpHost.postSetSplitOrMergeEnabled(newValue, switchType);
            }
        }
    } catch (IOException | KeeperException e) {
        throw new ServiceException(e);
    }
    return response.build();
}
Also used : MasterSwitchType(org.apache.hadoop.hbase.client.MasterSwitchType) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) SetSplitOrMergeEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledResponse) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) KeeperException(org.apache.zookeeper.KeeperException) MasterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos)

Example 30 with ServiceException

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

the class MasterRpcServices method getSchemaAlterStatus.

/**
 * Get the number of regions of the table that have been updated by the alter.
 *
 * @return Pair indicating the number of regions updated Pair.getFirst is the
 *         regions that are yet to be updated Pair.getSecond is the total number
 *         of regions of the table
 * @throws ServiceException
 */
@Override
public GetSchemaAlterStatusResponse getSchemaAlterStatus(RpcController controller, GetSchemaAlterStatusRequest req) throws ServiceException {
    // TODO: currently, we query using the table name on the client side. this
    // may overlap with other table operations or the table operation may
    // have completed before querying this API. We need to refactor to a
    // transaction system in the future to avoid these ambiguities.
    TableName tableName = ProtobufUtil.toTableName(req.getTableName());
    try {
        server.checkInitialized();
        Pair<Integer, Integer> pair = server.getAssignmentManager().getReopenStatus(tableName);
        GetSchemaAlterStatusResponse.Builder ret = GetSchemaAlterStatusResponse.newBuilder();
        ret.setYetToUpdateRegions(pair.getFirst());
        ret.setTotalRegions(pair.getSecond());
        return ret.build();
    } catch (IOException ioe) {
        throw new ServiceException(ioe);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) GetSchemaAlterStatusResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse)

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