@Override
  protected Flow executeFromState(MasterProcedureEnv env, SyncReplicationReplayWALState state)
    throws ProcedureSuspendedException {
    SyncReplicationReplayWALManager syncReplicationReplayWALManager =
      env.getMasterServices().getSyncReplicationReplayWALManager();
    switch (state) {
      case ASSIGN_WORKER:
        worker = syncReplicationReplayWALManager.acquirePeerWorker(peerId, this);
        setNextState(SyncReplicationReplayWALState.DISPATCH_WALS_TO_WORKER);
        return Flow.HAS_MORE_STATE;
      case DISPATCH_WALS_TO_WORKER:
        addChildProcedure(new SyncReplicationReplayWALRemoteProcedure(peerId, wals, worker));
        setNextState(SyncReplicationReplayWALState.RELEASE_WORKER);
        return Flow.HAS_MORE_STATE;
      case RELEASE_WORKER:
        boolean finished = false;
        try {
          finished = syncReplicationReplayWALManager.isReplayWALFinished(wals.get(0));
        } catch (IOException e) {
          throw suspend(env.getMasterConfiguration(),
            backoff -> LOG.warn("Failed to check whether replay wals {} finished for peer id={}"
              + ", sleep {} secs and retry", wals, peerId, backoff / 1000, e));
        }
        syncReplicationReplayWALManager.releasePeerWorker(peerId, worker,
          env.getProcedureScheduler());
        if (!finished) {
          LOG.warn("Failed to replay wals {} for peer id={}, retry", wals, peerId);
          setNextState(SyncReplicationReplayWALState.ASSIGN_WORKER);
          return Flow.HAS_MORE_STATE;
        }
        return Flow.NO_MORE_STATE;
      default:
        throw new UnsupportedOperationException("unhandled state=" + state);
    }
  }
The procedure for replaying a set of remote wals. It will get an available region server and
schedule a {@link SyncReplicationReplayWALRemoteProcedure} to actually send the request to region
server.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/SyncReplicationReplayWALProcedure.java