code: private void waitForJournalFlush() throws UnavailableException {
      if (mFlushCounter == INVALID_FLUSH_COUNTER) {
        // Check this before the precondition.
        return;
      }
  
      RetryPolicy retry = new TimeoutRetry(FLUSH_RETRY_TIMEOUT_MS, FLUSH_RETRY_INTERVAL_MS);
      while (retry.attempt()) {
        try {
          mAsyncJournalWriter.flush(mFlushCounter);
          return;
        } catch (IOException e) {
          LOG.warn("Journal flush failed. retrying...", e);
        } catch (JournalClosedException e) {
          throw new UnavailableException(String.format("Failed to complete request: %s",
              e.getMessage()), e);
        } catch (Throwable e) {
          ProcessUtils.fatalError(LOG, e, "Journal flush failed");
        }
      }
      ProcessUtils.fatalError(LOG, "Journal flush failed after %d attempts", retry.getAttemptCount());
    }
docs: Waits for the flush counter to be flushed to the journal. If the counter is
  {@link #INVALID_FLUSH_COUNTER}, this is a noop.