@Override
  protected void prePeerModification(MasterProcedureEnv env)
    throws IOException, ReplicationException, ProcedureSuspendedException {
    if (!env.getMasterServices().getReplicationLogCleanerBarrier().disable()) {
      throw suspend(env.getMasterConfiguration(),
        backoff -> LOG.warn("LogCleaner is run at the same time when adding peer {}, sleep {} secs",
          peerId, backoff / 1000));
    }
    cleanerDisabled = true;
    MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
      cpHost.preAddReplicationPeer(peerId, peerConfig);
    }
    if (peerConfig.isSyncReplication()) {
      if (!env.getMasterServices().getSyncReplicationPeerLock().tryAcquire()) {
        throw suspend(env.getMasterConfiguration(),
          backoff -> LOG.warn(
            "Can not acquire sync replication peer lock for peer {}, sleep {} secs", peerId,
            backoff / 1000));
      }
    }
    env.getReplicationPeerManager().preAddPeer(peerId, peerConfig);
  }
The procedure for adding a new replication peer.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/AddPeerProcedure.java