private Map<byte[], List<byte[]>> rollWriterInternal(boolean force) throws IOException {
    rollWriterLock.lock();
    try {
      if (this.closed) {
        throw new WALClosedException("WAL has been closed");
      }
      // Return if nothing to flush.
      if (!force && this.writer != null && this.numEntries.get() <= 0) {
        return null;
      }
      Map<byte[], List<byte[]>> regionsToFlush = null;
      try {
        Path oldPath = getOldPath();
        Path newPath = getNewPath();
        // Any exception from here on is catastrophic, non-recoverable, so we currently abort.
        W nextWriter = this.createWriterInstance(fs, newPath);
        if (remoteFs != null) {
          // create a remote wal if necessary
          nextWriter = createCombinedWriter(nextWriter, newPath);
        }
        tellListenersAboutPreLogRoll(oldPath, newPath);
        // NewPath could be equal to oldPath if replaceWriter fails.
        newPath = replaceWriter(oldPath, newPath, nextWriter);
        tellListenersAboutPostLogRoll(oldPath, newPath);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Create new " + implClassName + " writer with pipeline: "
            + FanOutOneBlockAsyncDFSOutputHelper
              .getDataNodeInfo(Arrays.stream(getPipeline()).collect(Collectors.toList())));
        }
        // We got a new writer, so reset the slow sync count
        lastTimeCheckSlowSync = EnvironmentEdgeManager.currentTime();
        slowSyncCount.set(0);
        // Can we delete any of the old log files?
        if (getNumRolledLogFiles() > 0) {
          cleanOldLogs();
          regionsToFlush = findRegionsToForceFlush();
        }
      } catch (CommonFSUtils.StreamLacksCapabilityException exception) {
        // If the underlying FileSystem can't do what we ask, treat as IO failure, so
        // we'll abort.
        throw new IOException(
          "Underlying FileSystem can't meet stream requirements. See RS log " + "for details.",
          exception);
      }
      return regionsToFlush;
    } finally {
      rollWriterLock.unlock();
    }
  }
Cleans up current writer closing it and then puts in place the passed in {@code nextWriter}.
<p/>
<ul>
<li>In the case of creating a new WAL, oldPath will be null.</li>
<li>In the case of rolling over from one file to the next, none of the parameters will be null.
</li>
<li>In the case of closing out this FSHLog with no further use newPath and nextWriter will be
null.</li>
</ul>
@param oldPath    may be null
@param newPath    may be null
@param nextWriter may be null
@return the passed in <code>newPath</code>
@throws IOException if there is a problem flushing or closing the underlying FS
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java