public ScannerCallable getScannerCallableForReplica(int id) { ScannerCallable s = new ScannerCallable(this.getConnection(), getTableName(), this.getScan(), this.scanMetrics, this.rpcControllerFactory, id); s.setCaching(this.caching); return s; }
/** * @param reload force reload of server location * @throws IOException */ @Override public void prepare(boolean reload) throws IOException { if (Thread.interrupted()) { throw new InterruptedIOException(); } RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload, id, getConnection(), getTableName(), getRow()); location = id < rl.size() ? rl.getRegionLocation(id) : null; if (location == null || location.getServerName() == null) { // With this exception, there will be a retry. The location can be null for a replica // when the table is created or after a split. throw new HBaseIOException("There is no location for replica id #" + id); } ServerName dest = location.getServerName(); setStub(super.getConnection().getClient(dest)); if (!instantiated || reload) { checkIfRegionServerIsRemote(); instantiated = true; } cursor = null; // check how often we retry. if (reload) { incRPCRetriesMetrics(scanMetrics, isRegionServerRemote); } }
close(); return null; response = openScanner(); } else { response = next(); setHeartbeatMessage(isHeartBeat); if (isHeartBeat && scan.isNeedCursorResult() && response.hasCursor()) { cursor = ProtobufUtil.toCursor(response.getCursor()); Result[] rrs = ResponseConverter.getResults(getRpcControllerCellScanner(), response); if (logScannerActivity) { long now = System.currentTimeMillis(); setMoreResultsForScan(MoreResults.YES); } else { setMoreResultsForScan(MoreResults.NO); setAlreadyClosed(); setMoreResultsForScan(MoreResults.UNKNOWN); setMoreResultsInRegion(MoreResults.YES); } else { setMoreResultsInRegion(MoreResults.NO); setAlreadyClosed(); setMoreResultsInRegion(MoreResults.UNKNOWN);
if (LOG.isTraceEnabled()) { LOG.trace("Setting current scanner as id=" + currentScannerCallable.scannerId + " associated with replica=" + currentScannerCallable.getHRegionInfo().getReplicaId()); if (LOG.isTraceEnabled()) { LOG.trace("Closing scanner id=" + s.scannerId + ", replica=" + s.getHRegionInfo().getRegionId() + " because slow and replica=" + this.currentScannerCallable.getHRegionInfo().getReplicaId() + " succeeded"); s.setClose(); final RetryingRPC r = new RetryingRPC(s); pool.submit(new Callable<Void>(){
close(); this.scannerId = openScanner(); } else { Result [] rrs = null; ScanRequest request = null; setHeartbeatMessage(false); try { incRPCcallsMetrics(); request = RequestConverter.buildScanRequest(scannerId, caching, false, nextCallSeq, ScanResponse response = null; controller = controllerFactory.newController(); controller.setPriority(getTableName()); controller.setCallTimeout(callTimeout); try { response = getStub().scan(controller, request); setHeartbeatMessage(response.hasHeartbeatMessage() && response.getHeartbeatMessage()); updateServerSideMetrics(response); setHasMoreResultsContext(true); setServerHasMoreResults(response.getMoreResultsInRegion()); } else { setHasMoreResultsContext(false);
private ScanResponse next() throws IOException { setHeartbeatMessage(false); incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest(scannerId, caching, false, nextCallSeq, this.scanMetrics != null, renew, scan.getLimit()); try { ScanResponse response = getStub().scan(getRpcController(), request); nextCallSeq++; return response; if (logScannerActivity) { LOG.info( "Got exception making request " + ProtobufUtil.toText(request) + " to " + getLocation(), e); try { HRegionLocation location = getConnection().relocateRegion(getTableName(), scan.getStartRow()); LOG.info("Scanner=" + scannerId + " expired, current region location is " + location.toString());
rowUpperLimit + " rows using " + connection.toString()); callable = new ScannerCallable(connection, metaTableName, scan, null); callable.withRetries(); callable.setCaching(rows); done: do { if (processedRows >= rowUpperLimit) { Result [] rrs = callable.withRetries(); if (rrs == null || rrs.length == 0 || rrs[0].size() == 0) { break; //exit completely startRow = callable.getHRegionInfo().getEndKey(); } finally { callable.setClose(); callable.withRetries();
close(); } else if (scannerId == -1L && !closed) { this.scannerId = openScanner(); } else { Result [] rrs = null; try { incRPCcallsMetrics(); long timestamp = System.currentTimeMillis(); rrs = server.next(scannerId, caching); updateResultsMetrics(rrs); } catch (IOException e) { if (logScannerActivity) {
LOG.trace("Closing scanner id=" + currentScannerCallable.scannerId); Result[] r = currentScannerCallable.call(timeout); currentScannerCallable = null; return r; rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(true, RegionReplicaUtil.DEFAULT_REPLICA_ID, cConnection, tableName, currentScannerCallable.getRow()); } catch (RetriesExhaustedException | DoNotRetryIOException e) { .getCachedLocation(tableName, currentScannerCallable.getRow()); if (rl == null) { throw e;
protected ScannerCallable getScannerCallable(byte [] localStartKey, int nbRows) { scan.setStartRow(localStartKey); ScannerCallable s = new ScannerCallable(getConnection(), getTableName(), scan, this.scanMetrics); s.setCaching(nbRows); return s; }
this.callable.setClose(); callable.withRetries(); this.callable = null; callable.withRetries(); this.currentRegion = callable.getHRegionInfo(); if (this.scanMetrics != null) { this.scanMetrics.countOfRegions.inc();
public void setCaching(int caching) { currentScannerCallable.setCaching(caching); }
public HRegionInfo getHRegionInfo() { return currentScannerCallable.getHRegionInfo(); }
public void setClose() { currentScannerCallable.setClose(); }
public void close() { if (callable != null) { callable.setClose(); try { callable.withRetries(); } catch (IOException e) { // We used to catch this error, interpret, and rethrow. However, we // have since decided that it's not nice for a scanner's close to // throw exceptions. Chances are it was just an UnknownScanner // exception due to lease time out. } finally { // we want to output the scan metrics even if an error occurred on close try { writeScanMetrics(); } catch (IOException e) { // As above, we still don't want the scanner close() method to throw. } } callable = null; } closed = true; } }
@Override protected ScannerCallable createScannerCallable() { if (!scan.includeStartRow() && !isEmptyStartRow(scan.getStartRow())) { // we have not implemented locate to next row for sync client yet, so here we change the // inclusive of start row to true. scan.withStartRow(createClosestRowAfter(scan.getStartRow()), true); } return new ScannerCallable(getConnection(), getTable(), scan, this.scanMetrics, this.rpcControllerFactory); } }
public int getCaching() { return currentScannerCallable.getCaching(); }
callable.setCaching(this.caching); callable.setCaching(1); values = callable.withRetries(); callable.setCaching(this.caching); skipFirst = false; values = callable.withRetries(); } catch (DoNotRetryIOException e) { if (e instanceof UnknownScannerException) {
/** * @param reload force reload of server location * @throws IOException */ @Override public void connect(boolean reload) throws IOException { if (!instantiated || reload) { super.connect(reload); checkIfRegionServerIsRemote(); instantiated = true; } // check how often we retry. // HConnectionManager will call instantiateServer with reload==true // if and only if for retries. if (reload && this.scanMetrics != null) { this.scanMetrics.countOfRPCRetries.inc(); if (isRegionServerRemote) { this.scanMetrics.countOfRemoteRPCRetries.inc(); } } }
private ScanResponse next() throws IOException { setHeartbeatMessage(false); incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest(scannerId, caching, false, nextCallSeq, this.scanMetrics != null, renew, scan.getLimit()); try { ScanResponse response = getStub().scan(getRpcController(), request); nextCallSeq++; return response; if (logScannerActivity) { LOG.info( "Got exception making request " + ProtobufUtil.toText(request) + " to " + getLocation(), e); try { HRegionLocation location = getConnection().relocateRegion(getTableName(), scan.getStartRow()); LOG.info("Scanner=" + scannerId + " expired, current region location is " + location.toString());