Search in sources :

Example 1 with ScanRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest in project hbase by apache.

the class AnnotationReadingPriorityFunction method getBasePriority.

/**
   * Get the priority for a given request from the header and the param
   * This doesn't consider which user is sending the request at all.
   * This doesn't consider annotations
   */
protected int getBasePriority(RequestHeader header, Message param) {
    if (param == null) {
        return HConstants.NORMAL_QOS;
    }
    // Trust the client-set priorities if set
    if (header.hasPriority()) {
        return header.getPriority();
    }
    String cls = param.getClass().getName();
    Class<? extends Message> rpcArgClass = argumentToClassMap.get(cls);
    RegionSpecifier regionSpecifier = null;
    //check whether the request has reference to meta region or now.
    try {
        // Check if the param has a region specifier; the pb methods are hasRegion and getRegion if
        // hasRegion returns true.  Not all listed methods have region specifier each time.  For
        // example, the ScanRequest has it on setup but thereafter relies on the scannerid rather than
        // send the region over every time.
        Method hasRegion = methodMap.get("hasRegion").get(rpcArgClass);
        if (hasRegion != null && (Boolean) hasRegion.invoke(param, (Object[]) null)) {
            Method getRegion = methodMap.get("getRegion").get(rpcArgClass);
            regionSpecifier = (RegionSpecifier) getRegion.invoke(param, (Object[]) null);
            Region region = rpcServices.getRegion(regionSpecifier);
            if (region.getRegionInfo().isSystemTable()) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("High priority because region=" + region.getRegionInfo().getRegionNameAsString());
                }
                return HConstants.SYSTEMTABLE_QOS;
            }
        }
    } catch (Exception ex) {
        // server and have it throw the exception if still an issue.  Just mark it normal priority.
        if (LOG.isTraceEnabled())
            LOG.trace("Marking normal priority after getting exception=" + ex);
        return HConstants.NORMAL_QOS;
    }
    if (param instanceof ScanRequest) {
        // scanner methods...
        ScanRequest request = (ScanRequest) param;
        if (!request.hasScannerId()) {
            return HConstants.NORMAL_QOS;
        }
        RegionScanner scanner = rpcServices.getScanner(request.getScannerId());
        if (scanner != null && scanner.getRegionInfo().isSystemTable()) {
            if (LOG.isTraceEnabled()) {
                // Scanner requests are small in size so TextFormat version should not overwhelm log.
                LOG.trace("High priority scanner request " + TextFormat.shortDebugString(request));
            }
            return HConstants.SYSTEMTABLE_QOS;
        }
    }
    return HConstants.NORMAL_QOS;
}
Also used : ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest) Method(java.lang.reflect.Method) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)

Example 2 with ScanRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest in project hbase by apache.

the class ScannerCallable method openScanner.

private ScanResponse openScanner() throws IOException {
    incRPCcallsMetrics();
    ScanRequest request = RequestConverter.buildScanRequest(getLocation().getRegionInfo().getRegionName(), this.scan, this.caching, false);
    try {
        ScanResponse response = getStub().scan(getRpcController(), request);
        long id = response.getScannerId();
        if (logScannerActivity) {
            LOG.info("Open scanner=" + id + " for scan=" + scan.toString() + " on region " + getLocation().toString());
        }
        if (response.hasMvccReadPoint()) {
            this.scan.setMvccReadPoint(response.getMvccReadPoint());
        }
        this.scannerId = id;
        return response;
    } catch (Exception e) {
        throw ProtobufUtil.handleRemoteException(e);
    }
}
Also used : ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest) ScanResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse) InterruptedIOException(java.io.InterruptedIOException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) RegionServerStoppedException(org.apache.hadoop.hbase.regionserver.RegionServerStoppedException) UnknownScannerException(org.apache.hadoop.hbase.UnknownScannerException) ScannerResetException(org.apache.hadoop.hbase.exceptions.ScannerResetException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Example 3 with ScanRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest in project hbase by apache.

the class AsyncScanSingleRegionRpcRetryingCaller method closeScanner.

private void closeScanner() {
    incRPCCallsMetrics(scanMetrics, regionServerRemote);
    resetController(controller, rpcTimeoutNs, priority);
    ScanRequest req = RequestConverter.buildScanRequest(this.scannerId, 0, true, false);
    stub.scan(controller, req, resp -> {
        if (controller.failed()) {
            LOG.warn("Call to " + loc.getServerName() + " for closing scanner id = " + scannerId + " for " + loc.getRegion().getEncodedName() + " of " + loc.getRegion().getTable() + " failed, ignore, probably already closed", controller.getFailed());
        }
    });
}
Also used : ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest)

Example 4 with ScanRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest in project hbase by apache.

the class AsyncClientScanner method callOpenScanner.

private CompletableFuture<OpenScannerResponse> callOpenScanner(HBaseRpcController controller, HRegionLocation loc, ClientService.Interface stub) {
    boolean isRegionServerRemote = isRemote(loc.getHostname());
    incRPCCallsMetrics(scanMetrics, isRegionServerRemote);
    if (openScannerTries.getAndIncrement() > 1) {
        incRPCRetriesMetrics(scanMetrics, isRegionServerRemote);
    }
    CompletableFuture<OpenScannerResponse> future = new CompletableFuture<>();
    try {
        ScanRequest request = RequestConverter.buildScanRequest(loc.getRegion().getRegionName(), scan, scan.getCaching(), false);
        stub.scan(controller, request, resp -> {
            if (controller.failed()) {
                future.completeExceptionally(controller.getFailed());
                return;
            }
            future.complete(new OpenScannerResponse(loc, isRegionServerRemote, stub, controller, resp));
        });
    } catch (IOException e) {
        future.completeExceptionally(e);
    }
    return future;
}
Also used : ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest) CompletableFuture(java.util.concurrent.CompletableFuture) IOException(java.io.IOException)

Example 5 with ScanRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest in project hbase by apache.

the class ProtobufUtil method getSlowLogParams.

/**
 * Return SlowLogParams to maintain recent online slowlog responses
 *
 * @param message Message object {@link Message}
 * @return SlowLogParams with regionName(for filter queries) and params
 */
public static SlowLogParams getSlowLogParams(Message message) {
    if (message == null) {
        return null;
    }
    if (message instanceof ScanRequest) {
        ScanRequest scanRequest = (ScanRequest) message;
        String regionName = getStringForByteString(scanRequest.getRegion().getValue());
        String params = TextFormat.shortDebugString(message);
        return new SlowLogParams(regionName, params);
    } else if (message instanceof MutationProto) {
        MutationProto mutationProto = (MutationProto) message;
        String params = "type= " + mutationProto.getMutateType().toString();
        return new SlowLogParams(params);
    } else if (message instanceof GetRequest) {
        GetRequest getRequest = (GetRequest) message;
        String regionName = getStringForByteString(getRequest.getRegion().getValue());
        String params = "region= " + regionName + ", row= " + getStringForByteString(getRequest.getGet().getRow());
        return new SlowLogParams(regionName, params);
    } else if (message instanceof MultiRequest) {
        MultiRequest multiRequest = (MultiRequest) message;
        int actionsCount = multiRequest.getRegionActionList().stream().mapToInt(ClientProtos.RegionAction::getActionCount).sum();
        RegionAction actions = multiRequest.getRegionActionList().get(0);
        String regionName = getStringForByteString(actions.getRegion().getValue());
        String params = "region= " + regionName + ", for " + actionsCount + " action(s)";
        return new SlowLogParams(regionName, params);
    } else if (message instanceof MutateRequest) {
        MutateRequest mutateRequest = (MutateRequest) message;
        String regionName = getStringForByteString(mutateRequest.getRegion().getValue());
        String params = "region= " + regionName;
        return new SlowLogParams(regionName, params);
    } else if (message instanceof CoprocessorServiceRequest) {
        CoprocessorServiceRequest coprocessorServiceRequest = (CoprocessorServiceRequest) message;
        String params = "coprocessorService= " + coprocessorServiceRequest.getCall().getServiceName() + ":" + coprocessorServiceRequest.getCall().getMethodName();
        return new SlowLogParams(params);
    }
    String params = message.getClass().toString();
    return new SlowLogParams(params);
}
Also used : ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest) CoprocessorServiceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest) MultiRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest) SlowLogParams(org.apache.hadoop.hbase.client.SlowLogParams) GetRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest) MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest) RegionAction(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)

Aggregations

ScanRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest)19 IOException (java.io.IOException)6 ScanResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse)5 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)4 Test (org.junit.Test)4 InterruptedIOException (java.io.InterruptedIOException)3 UnknownHostException (java.net.UnknownHostException)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)3 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)3 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)3 TableName (org.apache.hadoop.hbase.TableName)3 UnknownScannerException (org.apache.hadoop.hbase.UnknownScannerException)3 ScannerResetException (org.apache.hadoop.hbase.exceptions.ScannerResetException)3 RegionServerStoppedException (org.apache.hadoop.hbase.regionserver.RegionServerStoppedException)3 GetRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest)3 MutateRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest)3 MutationProto (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)3 RegionSpecifier (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)3