Search in sources :

Example 6 with QosPriority

use of org.apache.hadoop.hbase.ipc.QosPriority in project hbase by apache.

the class RSRpcServices method closeRegion.

/**
   * Close a region on the region server.
   *
   * @param controller the RPC controller
   * @param request the request
   * @throws ServiceException
   */
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public CloseRegionResponse closeRegion(final RpcController controller, final CloseRegionRequest request) throws ServiceException {
    final ServerName sn = (request.hasDestinationServer() ? ProtobufUtil.toServerName(request.getDestinationServer()) : null);
    try {
        checkOpen();
        if (request.hasServerStartCode()) {
            // check that we are the same server that this RPC is intended for.
            long serverStartCode = request.getServerStartCode();
            if (regionServer.serverName.getStartcode() != serverStartCode) {
                throw new ServiceException(new DoNotRetryIOException("This RPC was intended for a " + "different server with startCode: " + serverStartCode + ", this server is: " + regionServer.serverName));
            }
        }
        final String encodedRegionName = ProtobufUtil.getRegionEncodedName(request.getRegion());
        requestCount.increment();
        if (sn == null) {
            LOG.info("Close " + encodedRegionName + " without moving");
        } else {
            LOG.info("Close " + encodedRegionName + ", moving to " + sn);
        }
        boolean closed = regionServer.closeRegion(encodedRegionName, false, sn);
        CloseRegionResponse.Builder builder = CloseRegionResponse.newBuilder().setClosed(closed);
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ServerName(org.apache.hadoop.hbase.ServerName) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) CloseRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 7 with QosPriority

use of org.apache.hadoop.hbase.ipc.QosPriority in project hbase by apache.

the class RSRpcServices method getStoreFile.

@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public GetStoreFileResponse getStoreFile(final RpcController controller, final GetStoreFileRequest request) throws ServiceException {
    try {
        checkOpen();
        Region region = getRegion(request.getRegion());
        requestCount.increment();
        Set<byte[]> columnFamilies;
        if (request.getFamilyCount() == 0) {
            columnFamilies = region.getTableDesc().getFamiliesKeys();
        } else {
            columnFamilies = new TreeSet<>(Bytes.BYTES_RAWCOMPARATOR);
            for (ByteString cf : request.getFamilyList()) {
                columnFamilies.add(cf.toByteArray());
            }
        }
        int nCF = columnFamilies.size();
        List<String> fileList = region.getStoreFileList(columnFamilies.toArray(new byte[nCF][]));
        GetStoreFileResponse.Builder builder = GetStoreFileResponse.newBuilder();
        builder.addAllStoreFile(fileList);
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) GetStoreFileResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetStoreFileResponse) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 8 with QosPriority

use of org.apache.hadoop.hbase.ipc.QosPriority in project hbase by apache.

the class RSRpcServices method compactRegion.

/**
   * Compact a region on the region server.
   *
   * @param controller the RPC controller
   * @param request the request
   * @throws ServiceException
   */
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public CompactRegionResponse compactRegion(final RpcController controller, final CompactRegionRequest request) throws ServiceException {
    try {
        checkOpen();
        requestCount.increment();
        Region region = getRegion(request.getRegion());
        region.startRegionOperation(Operation.COMPACT_REGION);
        LOG.info("Compacting " + region.getRegionInfo().getRegionNameAsString());
        boolean major = false;
        byte[] family = null;
        Store store = null;
        if (request.hasFamily()) {
            family = request.getFamily().toByteArray();
            store = region.getStore(family);
            if (store == null) {
                throw new ServiceException(new DoNotRetryIOException("column family " + Bytes.toString(family) + " does not exist in region " + region.getRegionInfo().getRegionNameAsString()));
            }
        }
        if (request.hasMajor()) {
            major = request.getMajor();
        }
        if (major) {
            if (family != null) {
                store.triggerMajorCompaction();
            } else {
                region.triggerMajorCompaction();
            }
        }
        String familyLogMsg = (family != null) ? " for column family: " + Bytes.toString(family) : "";
        if (LOG.isTraceEnabled()) {
            LOG.trace("User-triggered compaction requested for region " + region.getRegionInfo().getRegionNameAsString() + familyLogMsg);
        }
        String log = "User-triggered " + (major ? "major " : "") + "compaction" + familyLogMsg;
        if (family != null) {
            regionServer.compactSplitThread.requestCompaction(region, store, log, Store.PRIORITY_USER, null, RpcServer.getRequestUser());
        } else {
            regionServer.compactSplitThread.requestCompaction(region, log, Store.PRIORITY_USER, null, RpcServer.getRequestUser());
        }
        return CompactRegionResponse.newBuilder().build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 9 with QosPriority

use of org.apache.hadoop.hbase.ipc.QosPriority in project hbase by apache.

the class RSRpcServices method getRegionLoad.

@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public GetRegionLoadResponse getRegionLoad(RpcController controller, GetRegionLoadRequest request) throws ServiceException {
    List<Region> regions;
    if (request.hasTableName()) {
        TableName tableName = ProtobufUtil.toTableName(request.getTableName());
        regions = regionServer.getOnlineRegions(tableName);
    } else {
        regions = regionServer.getOnlineRegions();
    }
    List<RegionLoad> rLoads = new ArrayList<>(regions.size());
    RegionLoad.Builder regionLoadBuilder = ClusterStatusProtos.RegionLoad.newBuilder();
    RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
    try {
        for (Region region : regions) {
            rLoads.add(regionServer.createRegionLoad(region, regionLoadBuilder, regionSpecifier));
        }
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    GetRegionLoadResponse.Builder builder = GetRegionLoadResponse.newBuilder();
    builder.addAllRegionLoads(rLoads);
    return builder.build();
}
Also used : ArrayList(java.util.ArrayList) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier) TableName(org.apache.hadoop.hbase.TableName) RegionLoad(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) GetRegionLoadResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionLoadResponse) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 10 with QosPriority

use of org.apache.hadoop.hbase.ipc.QosPriority in project hbase by apache.

the class MasterRpcServices method getRegionInfo.

@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller, final GetRegionInfoRequest request) throws ServiceException {
    byte[] regionName = request.getRegion().getValue().toByteArray();
    TableName tableName = HRegionInfo.getTable(regionName);
    if (MobUtils.isMobRegionName(tableName, regionName)) {
        // a dummy region info contains the compaction state.
        HRegionInfo mobRegionInfo = MobUtils.getMobRegionInfo(tableName);
        GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
        builder.setRegionInfo(HRegionInfo.convert(mobRegionInfo));
        if (request.hasCompactionState() && request.getCompactionState()) {
            builder.setCompactionState(master.getMobCompactionState(tableName));
        }
        return builder.build();
    } else {
        return super.getRegionInfo(controller, request);
    }
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) GetRegionInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Aggregations

QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)17 IOException (java.io.IOException)15 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)15 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)15 InterruptedIOException (java.io.InterruptedIOException)13 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)13 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)8 ArrayList (java.util.ArrayList)5 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)4 TableName (org.apache.hadoop.hbase.TableName)4 CellScanner (org.apache.hadoop.hbase.CellScanner)2 DroppedSnapshotException (org.apache.hadoop.hbase.DroppedSnapshotException)2 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)2 GetRegionInfoResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse)2 WALEntry (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)1 ServerName (org.apache.hadoop.hbase.ServerName)1