new ScannerCallableWithReplicas(getTable(), getConnection(), createScannerCallable(), pool, primaryOperationTimeout, scan, getRetries(), scannerTimeout, caching, conf, caller); this.callable.setCaching(this.caching); incRegionCountMetrics(scanMetrics); return true;
replicaSwitched.set(false); addCallsForCurrentReplica(cs); int startIndex = 0; updateCurrentlyServingReplica(r.getSecond(), r.getFirst(), done, pool); } else { addCallsForOtherReplicas(cs, 0, regionReplication - 1); updateCurrentlyServingReplica(r.getSecond(), r.getFirst(), done, pool);
if (callable.switchedToADifferentReplica()) { this.currentRegion = callable.getHRegionInfo(); scanResultCache.addAndGet(values, callable.isHeartbeatMessage()); int numberOfCompleteRows = scanResultCache.numberOfCompleteRows() - numberOfCompleteRowsBefore; if (callable.isHeartbeatMessage()) { if (!cache.isEmpty()) { if (callable.isHeartbeatMessage() && callable.getCursor() != null) { cache.add(Result.createCursorResult(callable.getCursor())); break;
private boolean regionExhausted(Result[] values) { // 1. Not a heartbeat message and we get nothing, this means the region is exhausted. And in the // old time we always return empty result for a open scanner operation so we add a check here to // keep compatible with the old logic. Should remove the isOpenScanner in the future. // 2. Server tells us that it has no more results for this region. return (values.length == 0 && !callable.isHeartbeatMessage()) || callable.moreResultsInRegion() == MoreResults.NO; }
callable.setCaching(this.caching); if (values == null && callable.switchedToADifferentReplica()) { this.currentRegion = callable.getHRegionInfo(); continue; getResultsToAddToCache(values, callable.isHeartbeatMessage()); if (!resultsToAddToCache.isEmpty()) { for (Result rs : resultsToAddToCache) { if (callable.isHeartbeatMessage() && cache.size() > 0) { if (LOG.isTraceEnabled()) { LOG.trace("Heartbeat message received and cache contains Results." if (null != values && values.length > 0 && callable.hasMoreResultsContext()) { serverHasMoreResults = callable.getServerHasMoreResults() & partialResults.isEmpty();
this.callable.setClose(); call(callable, caller, scannerTimeout); this.callable = null; this.currentRegion = callable.getHRegionInfo(); if (this.scanMetrics != null) { this.scanMetrics.countOfRegions.incrementAndGet();
private void closeScanner() throws IOException { if (this.callable != null) { this.callable.setClose(); call(callable, caller, scannerTimeout, false); this.callable = null; } }
this.currentRegion = smallScanCallable.getHRegionInfo(); long currentTime = System.currentTimeMillis(); if (this.scanMetrics != null) { if (smallScanCallable.hasMoreResultsContext()) { currentRegionDone = !smallScanCallable.getServerHasMoreResults(); } else { currentRegionDone = countdown > 0;
private void addCallsForOtherReplicas( ResultBoundedCompletionService<Pair<Result[], ScannerCallable>> cs, int min, int max) { for (int id = min; id <= max; id++) { if (currentScannerCallable.id == id) { continue; //this was already scheduled earlier } ScannerCallable s = currentScannerCallable.getScannerCallableForReplica(id); setStartRowForReplicaCallable(s); outstandingCallables.add(s); RetryingRPC retryingOnReplica = new RetryingRPC(s); cs.submit(retryingOnReplica, scannerTimeout, id); } }
@VisibleForTesting boolean isAnyRPCcancelled() { return callable.isAnyRPCcancelled(); }
@Override public boolean renewLease() { if (callable == null) { return false; } // do not return any rows, do not advance the scanner callable.setRenew(true); try { this.caller.callWithoutRetries(callable, this.scannerTimeout); return true; } catch (Exception e) { LOG.debug("scanner failed to renew lease", e); return false; } finally { callable.setRenew(false); } }
private Result[] call(ScannerCallableWithReplicas callable, RpcRetryingCaller<Result[]> caller, int scannerTimeout, boolean updateCurrentRegion) throws IOException { if (Thread.interrupted()) { throw new InterruptedIOException(); } // callWithoutRetries is at this layer. Within the ScannerCallableWithReplicas, // we do a callWithRetries Result[] rrs = caller.callWithoutRetries(callable, scannerTimeout); if (currentRegion == null && updateCurrentRegion) { currentRegion = callable.getHRegionInfo(); } return rrs; }
public ScannerCallableWithReplicas getCallable(ClusterConnection connection, TableName table, Scan scan, ScanMetrics scanMetrics, byte[] localStartKey, int cacheNum, RpcControllerFactory controllerFactory, ExecutorService pool, int primaryOperationTimeout, int retries, int scannerTimeout, Configuration conf, RpcRetryingCaller<Result[]> caller) { scan.setStartRow(localStartKey); SmallScannerCallable s = new SmallScannerCallable( connection, table, scan, scanMetrics, controllerFactory, cacheNum, 0); ScannerCallableWithReplicas scannerCallableWithReplicas = new ScannerCallableWithReplicas(table, connection, s, pool, primaryOperationTimeout, scan, retries, scannerTimeout, cacheNum, conf, caller); return scannerCallableWithReplicas; }
private boolean regionExhausted(Result[] values) { // 1. Not a heartbeat message and we get nothing, this means the region is exhausted. And in the // old time we always return empty result for a open scanner operation so we add a check here to // keep compatible with the old logic. Should remove the isOpenScanner in the future. // 2. Server tells us that it has no more results for this region. return (values.length == 0 && !callable.isHeartbeatMessage()) || callable.moreResultsInRegion() == MoreResults.NO; }
this.callable.setClose(); this.currentRegion = callable.getHRegionInfo(); if (this.scanMetrics != null) { this.scanMetrics.countOfRegions.incrementAndGet();
@Override public void close() { if (!scanMetricsPublished) writeScanMetrics(); if (callable != null) { callable.setClose(); try { call(callable, caller, scannerTimeout, false); } catch (UnknownScannerException 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 due to lease time out. LOG.debug("scanner failed to close", e); } catch (IOException e) { /* An exception other than UnknownScanner is unexpected. */ LOG.warn("scanner failed to close.", e); } callable = null; } closed = true; }
this.currentRegion = smallScanCallable.getHRegionInfo(); long currentTime = System.currentTimeMillis(); if (this.scanMetrics != null) { if (smallScanCallable.hasMoreResultsContext()) { currentRegionDone = !smallScanCallable.getServerHasMoreResults(); } else {
private void addCallsForOtherReplicas( ResultBoundedCompletionService<Pair<Result[], ScannerCallable>> cs, int min, int max) { for (int id = min; id <= max; id++) { if (currentScannerCallable.id == id) { continue; //this was already scheduled earlier } ScannerCallable s = currentScannerCallable.getScannerCallableForReplica(id); setStartRowForReplicaCallable(s); outstandingCallables.add(s); RetryingRPC retryingOnReplica = new RetryingRPC(s); cs.submit(retryingOnReplica, scannerTimeout, id); } }
@VisibleForTesting boolean isAnyRPCcancelled() { return callable.isAnyRPCcancelled(); }
@Override public boolean renewLease() { if (callable == null) { return false; } // do not return any rows, do not advance the scanner callable.setRenew(true); try { this.caller.callWithoutRetries(callable, this.scannerTimeout); return true; } catch (Exception e) { LOG.debug("scanner failed to renew lease", e); return false; } finally { callable.setRenew(false); } }