@Override
  public void peerSyncReplicationStateChange(String peerId, SyncReplicationState from,
    SyncReplicationState to, int stage) {
    if (from == SyncReplicationState.ACTIVE) {
      if (stage == 0) {
        Lock lock = createLock.acquireLock(peerId);
        try {
          Optional<WAL> opt = peerId2WAL.get(peerId);
          if (opt != null) {
            opt.ifPresent(w -> w.skipRemoteWAL(to == SyncReplicationState.STANDBY));
          } else {
            // add a place holder to tell the getWAL caller do not use the remote WAL any more.
            peerId2WAL.put(peerId, Optional.empty());
          }
        } finally {
          lock.unlock();
        }
      } else if (stage == 1) {
        peerId2WAL.remove(peerId).ifPresent(AbstractWALProvider::safeClose);
      }
    }
  }
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