private W createCombinedWriter(W localWriter, Path localPath)
    throws IOException, CommonFSUtils.StreamLacksCapabilityException {
    // retry forever if we can not create the remote writer to prevent aborting the RS due to log
    // rolling error, unless the skipRemoteWal is set to true.
    // TODO: since for now we only have one thread doing log rolling, this may block the rolling for
    // other wals
    Path remoteWAL = new Path(remoteWALDir, localPath.getName());
    for (int retry = 0;; retry++) {
      if (skipRemoteWAL) {
        return localWriter;
      }
      W remoteWriter;
      try {
        remoteWriter = createWriterInstance(remoteFs, remoteWAL);
      } catch (IOException e) {
        LOG.warn("create remote writer {} failed, retry = {}", remoteWAL, retry, e);
        try {
          Thread.sleep(ConnectionUtils.getPauseTime(100, retry));
        } catch (InterruptedException ie) {
          // restore the interrupt state
          Thread.currentThread().interrupt();
          // must close local writer here otherwise no one will close it for us
          Closeables.close(localWriter, true);
          throw (IOException) new InterruptedIOException().initCause(ie);
        }
        continue;
      }
      return createCombinedWriter(localWriter, remoteWriter);
    }
  }
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