Search in sources :

Example 6 with ScanResponse

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

the class ScannerCallable method next.

private ScanResponse next() throws IOException {
    // Reset the heartbeat flag prior to each RPC in case an exception is thrown by the server
    setHeartbeatMessage(false);
    incRPCcallsMetrics();
    ScanRequest request = RequestConverter.buildScanRequest(scannerId, caching, false, nextCallSeq, this.scanMetrics != null, renew, scan.getLimit());
    try {
        ScanResponse response = getStub().scan(getRpcController(), request);
        nextCallSeq++;
        return response;
    } catch (Exception e) {
        IOException ioe = ProtobufUtil.handleRemoteException(e);
        if (logScannerActivity) {
            LOG.info("Got exception making request " + ProtobufUtil.toText(request) + " to " + getLocation(), e);
        }
        if (logScannerActivity) {
            if (ioe instanceof UnknownScannerException) {
                try {
                    HRegionLocation location = getConnection().relocateRegion(getTableName(), scan.getStartRow());
                    LOG.info("Scanner=" + scannerId + " expired, current region location is " + location.toString());
                } catch (Throwable t) {
                    LOG.info("Failed to relocate region", t);
                }
            } else if (ioe instanceof ScannerResetException) {
                LOG.info("Scanner=" + scannerId + " has received an exception, and the server " + "asked us to reset the scanner state.", ioe);
            }
        }
        // yeah and hard to follow and in need of a refactor).
        if (ioe instanceof NotServingRegionException) {
            // Attach NSRE to signal client that it needs to re-setup scanner.
            if (this.scanMetrics != null) {
                this.scanMetrics.countOfNSRE.incrementAndGet();
            }
            throw new DoNotRetryIOException("Resetting the scanner -- see exception cause", ioe);
        } else if (ioe instanceof RegionServerStoppedException) {
            // open scanner against new location.
            throw new DoNotRetryIOException("Resetting the scanner -- see exception cause", ioe);
        } else {
            // The outer layers will retry
            throw ioe;
        }
    }
}
Also used : ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest) RegionServerStoppedException(org.apache.hadoop.hbase.regionserver.RegionServerStoppedException) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ScannerResetException(org.apache.hadoop.hbase.exceptions.ScannerResetException) ScanResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse) InterruptedIOException(java.io.InterruptedIOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) 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) UnknownScannerException(org.apache.hadoop.hbase.UnknownScannerException)

Example 7 with ScanResponse

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

the class MockRegionServer method scan.

@Override
public ScanResponse scan(RpcController controller, ScanRequest request) throws ServiceException {
    ScanResponse.Builder builder = ScanResponse.newBuilder();
    try {
        if (request.hasScan()) {
            byte[] regionName = request.getRegion().getValue().toByteArray();
            builder.setScannerId(openScanner(regionName, null));
            builder.setMoreResults(true);
        } else {
            long scannerId = request.getScannerId();
            Result result = next(scannerId);
            if (result != null) {
                builder.addCellsPerResult(result.size());
                List<CellScannable> results = new ArrayList<>(1);
                results.add(result);
                ((HBaseRpcController) controller).setCellScanner(CellUtil.createCellScanner(results));
                builder.setMoreResults(true);
            } else {
                builder.setMoreResults(false);
                close(scannerId);
            }
        }
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
    return builder.build();
}
Also used : CellScannable(org.apache.hadoop.hbase.CellScannable) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ScanResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Result(org.apache.hadoop.hbase.client.Result)

Aggregations

ScanResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse)7 IOException (java.io.IOException)4 InterruptedIOException (java.io.InterruptedIOException)4 UnknownHostException (java.net.UnknownHostException)3 ArrayList (java.util.ArrayList)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)3 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)3 UnknownScannerException (org.apache.hadoop.hbase.UnknownScannerException)3 Result (org.apache.hadoop.hbase.client.Result)3 ScannerResetException (org.apache.hadoop.hbase.exceptions.ScannerResetException)3 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)3 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)3 ScanRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest)3 RegionServerStoppedException (org.apache.hadoop.hbase.regionserver.RegionServerStoppedException)2 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)2 RegionActionResult (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult)2 FileNotFoundException (java.io.FileNotFoundException)1 BindException (java.net.BindException)1 HashMap (java.util.HashMap)1