private boolean completeFlush(final List<HStoreFile> sfs, long snapshotId) throws IOException {
    // NOTE:we should keep clearSnapshot method inside the write lock because clearSnapshot may
    // close {@link DefaultMemStore#snapshot}, which may be used by
    // {@link DefaultMemStore#getScanners}.
    storeEngine.addStoreFiles(sfs,
      // NOTE: here we must increase the refCount for storeFiles because we would open the
      // storeFiles and get the StoreFileScanners for them in HStore.notifyChangedReadersObservers.
      // If we don't increase the refCount here, HStore.closeAndArchiveCompactedFiles called by
      // CompactedHFilesDischarger may archive the storeFiles after a concurrent compaction.Because
      // HStore.requestCompaction is under storeEngine lock, so here we increase the refCount under
      // storeEngine lock. see HBASE-27519 for more details.
      snapshotId > 0 ? () -> {
        this.memstore.clearSnapshot(snapshotId);
        HStoreFile.increaseStoreFilesRefeCount(sfs);
      } : () -> {
        HStoreFile.increaseStoreFilesRefeCount(sfs);
      });
    // notify to be called here - only in case of flushes
    try {
      notifyChangedReadersObservers(sfs);
    } finally {
      HStoreFile.decreaseStoreFilesRefeCount(sfs);
    }
    if (LOG.isTraceEnabled()) {
      long totalSize = getTotalSize(sfs);
      String traceMessage = "FLUSH time,count,size,store size,store files ["
        + EnvironmentEdgeManager.currentTime() + "," + sfs.size() + "," + totalSize + ","
        + storeSize + "," + storeEngine.getStoreFileManager().getStorefileCount() + "]";
      LOG.trace(traceMessage);
    }
    return needsCompaction();
  }
Write out current snapshot. Presumes {@code StoreFlusherImpl.prepare()} has been called
previously.
@param logCacheFlushId flush sequence number
@return The path name of the tmp file to which the store was flushed
@throws IOException if exception occurs during process
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java