private void migrate(ReplicationPeerStorage src, ReplicationPeerStorage dst)
    throws ReplicationException {
    LOG.info("Start migrating from {} to {}", src.getClass().getSimpleName(),
      dst.getClass().getSimpleName());
    for (String peerId : src.listPeerIds()) {
      LOG.info("Going to migrate {}", peerId);
      ReplicationPeerConfig peerConfig = src.getPeerConfig(peerId);
      boolean enabled = src.isPeerEnabled(peerId);
      SyncReplicationState syncState = src.getPeerSyncReplicationState(peerId);
      SyncReplicationState newSyncState = src.getPeerNewSyncReplicationState(peerId);
      if (newSyncState != SyncReplicationState.NONE) {
        throw new IllegalStateException("Can not migrate peer " + peerId
          + " as it is in an intermediate state, syncReplicationState is " + syncState
          + " while newSyncReplicationState is " + newSyncState);
      }
      dst.addPeer(peerId, peerConfig, enabled, syncState);
      LOG.info("Migrated peer {}, peerConfig = '{}', enabled = {}, syncReplicationState = {}",
        peerId, peerConfig, enabled, syncState);
    }
  }
A tool for copying replication peer data across different replication peer storages.
<p/>
Notice that we will not delete the replication peer data from the source storage, as this tool
can also be used by online migration. See HBASE-27110 for the whole design.
hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/CopyReplicationPeers.java