private WAL getRemoteWAL(RegionInfo region, String peerId, String remoteWALDir)
    throws IOException {
    Optional<WAL> opt = peerId2WAL.get(peerId);
    if (opt != null) {
      return opt.orElse(null);
    }
    Lock lock = createLock.acquireLock(peerId);
    try {
      opt = peerId2WAL.get(peerId);
      if (opt != null) {
        return opt.orElse(null);
      }
      WAL wal = createRemoteWAL(region, ReplicationUtils.getRemoteWALFileSystem(conf, remoteWALDir),
        ReplicationUtils.getPeerRemoteWALDir(remoteWALDir, peerId), getRemoteWALPrefix(peerId),
        ReplicationUtils.SYNC_WAL_SUFFIX);
      numRemoteWALUnderCreationLock.lock();
      try {
        numRemoteWALUnderCreation++;
      } finally {
        numRemoteWALUnderCreationLock.unlock();
      }
      initWAL(wal);
      peerId2WAL.put(peerId, Optional.of(wal));
      return wal;
    } finally {
      lock.unlock();
      numRemoteWALUnderCreationLock.lock();
      try {
        numRemoteWALUnderCreation--;
        if (numRemoteWALUnderCreation == 0) {
          noRemoteWALUnderCreationCond.signalAll();
        }
      } finally {
        numRemoteWALUnderCreationLock.unlock();
      }
    }
  }
Base class for a WAL Provider.
<p>
We will put some common logic here, especially for sync replication implementation, as it must do
some hacks before the normal wal creation operation.
<p>
All {@link WALProvider} implementations should extends this class instead of implement
{@link WALProvider} directly, except {@link DisabledWALProvider}.
hbase-server/src/main/java/org/apache/hadoop/hbase/wal/AbstractWALProvider.java