anoopsjohn commented on a change in pull request #939: HBASE-23349 : Force 
archive compacted storefiles after current scanne…
URL: https://github.com/apache/hbase/pull/939#discussion_r357731432
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
 ##########
 @@ -934,6 +935,47 @@ public void updateReaders(List<HStoreFile> sfs, 
List<KeyValueScanner> memStoreSc
     // Let the next() call handle re-creating and seeking
   }
 
+  // Implementation of ChangedReadersObserver
+  // reset current scanners
+  @Override
+  public void updateReaders(List<HStoreFile> storeFiles) throws IOException {
+    if (CollectionUtils.isEmpty(storeFiles)) {
+      return;
+    }
+    try {
+      if (this.closing) {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("StoreScanner already closing. There is no need to 
re-create scanners");
+        }
+        return;
+      }
+      List<KeyValueScanner> fileScanners = currentScanners.stream()
+        .filter(KeyValueScanner::isFileScanner)
+        .collect(Collectors.toList());
+      fileScanners.forEach(KeyValueScanner::close);
+      if (fileScanners.size() == currentScanners.size()) {
+        currentScanners.clear();
+      } else {
+        List<KeyValueScanner> memScanners = currentScanners.stream()
+          .filter(e -> !e.isFileScanner())
+          .collect(Collectors.toList());
+        currentScanners.clear();
+        currentScanners.addAll(memScanners);
+      }
+      final boolean usePRead = get || scanUsePread;
+      final boolean isCompaction = false;
+      final boolean includeMemstoreScanner = false;
+      List<KeyValueScanner> scanners = store.getScanners(storeFiles, 
cacheBlocks, get, usePRead,
+        isCompaction, matcher, scan.getStartRow(), scan.getStopRow(), 
this.readPt,
+        includeMemstoreScanner);
+      addCurrentScanners(scanners);
 
 Review comment:
   Here we change the scanners heap. How abt synchronizing this change with 
concurrent scanner next calls?  In case of flush u can see there is a volatile 
boolean and every next check for that boolean. with out such a way how u can 
handle?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to