private void updateCurrentlyServingReplica(
     ScannerCallable scanner, Result[] result, AtomicBoolean done, ExecutorService pool) {
   if (done.compareAndSet(false, true)) {
     if (currentScannerCallable != scanner) replicaSwitched.set(true);
     currentScannerCallable = scanner;
     // store where to start the replica scanner from if we need to.
     if (result != null && result.length != 0) this.lastResult = result[result.length - 1];
     if (LOG.isTraceEnabled()) {
       LOG.trace(
           "Setting current scanner as "
               + currentScannerCallable.scannerId
               + " associated with "
               + currentScannerCallable.getHRegionInfo().getReplicaId());
     }
     // close all outstanding replica scanners but the one we heard back from
     outstandingCallables.remove(scanner);
     for (ScannerCallable s : outstandingCallables) {
       if (LOG.isDebugEnabled()) {
         LOG.debug(
             "Closing scanner "
                 + s.scannerId
                 + " because this was slow and another replica succeeded");
       }
       // Submit the "close" to the pool since this might take time, and we don't
       // want to wait for the "close" to happen yet. The "wait" will happen when
       // the table is closed (when the awaitTermination of the underlying pool is called)
       s.setClose();
       RetryingRPC r = new RetryingRPC(s);
       pool.submit(r);
     }
     // now clear outstandingCallables since we scheduled a close for all the contained scanners
     outstandingCallables.clear();
   }
 }
 public void setClose() {
   currentScannerCallable.setClose();
 }