`GatewayService` implements logic for delaying state recovery in the cluster until enough data nodes have joined and/or some timeout has occurred. The implementation is pretty old and doesn't make use of much modern infrastructure for doing this kind of thing, making it pretty hard to follow and to improve (see e.g. #86588). We should clean it up and simplify it.
test/framework/src/main/java/org/elasticsearch/common/util/concurrent/DeterministicTaskQueue.java
private static final Logger logger = LogManager.getLogger(DeterministicTaskQueue.class);
    public static final String NODE_ID_LOG_CONTEXT_KEY = "nodeId";
    private final List<Runnable> runnableTasks = new ArrayList<>();
    private final Random random;
    private List<DeferredTask> deferredTasks = new ArrayList<>();
    private long currentTimeMillis;
    private long nextDeferredTaskExecutionTimeMillis = Long.MAX_VALUE;
    private long executionDelayVariabilityMillis;
    private long latestDeferredExecutionTime;
    public DeterministicTaskQueue(Random random) {
        this.random = random;
    }
    public DeterministicTaskQueue() {
        this(ESTestCase.random());
    }
    public long getExecutionDelayVariabilityMillis() {
        return executionDelayVariabilityMillis;
    }
    public void setExecutionDelayVariabilityMillis(long executionDelayVariabilityMillis) {
        assert executionDelayVariabilityMillis >= 0 : executionDelayVariabilityMillis;
        this.executionDelayVariabilityMillis = executionDelayVariabilityMillis;
    }
    public void runAllRunnableTasks() {