private void checkAssignReplicationQueuesFinished(MasterProcedureEnv env)
    throws ProcedureSuspendedException {
    if (ongoingAssignReplicationQueuesProcIds.isEmpty()) {
      LOG.info("No ongoing assign replication queues procedures when removing peer {}, move on",
        peerId);
    }
    ProcedureExecutor<MasterProcedureEnv> procExec =
      env.getMasterServices().getMasterProcedureExecutor();
    long[] unfinishedProcIds =
      ongoingAssignReplicationQueuesProcIds.stream().map(procExec::getProcedure)
        .filter(p -> p != null && !p.isFinished()).mapToLong(Procedure::getProcId).toArray();
    if (unfinishedProcIds.length == 0) {
      LOG.info(
        "All assign replication queues procedures are finished when removing peer {}, move on",
        peerId);
    } else {
      throw suspend(env.getMasterConfiguration(), backoff -> LOG.info(
        "There are still {} pending assign replication queues procedures {} when removing peer {}, sleep {} secs",
        unfinishedProcIds.length, Arrays.toString(unfinishedProcIds), peerId, backoff / 1000));
    }
  }
The procedure for removing a replication peer.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/RemovePeerProcedure.java