public void waitForCompleteCycle(Duration timeout) {
        Instant endTime = Instant.now().plus(timeout);
        synchronized (monitor) {
            // To wait at least one complete cycle, if a cycle is already running we need to wait for the next one beyond.
            long wantedCycle = cycleCount + (processingCycle ? 2 : 1);
            waitingForCycle = true;
            try {
                while (cycleCount < wantedCycle) {
                    if (Instant.now().isAfter(endTime))
                        throw new IllegalStateException("Timed out waiting for cycle to complete. Not completed after " + timeout);
                    if ( !isRunning() )
                        throw new IllegalStateException("Fleetcontroller not running. Will never complete cycles");
                    try {
                        monitor.wait(100);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            } finally {
                waitingForCycle = false;
            }
        }
    }
Move tasks that are dependent on the most recently generated state being published into
a completion queue with a dependency on the provided version argument. Once that version
has been ACKed by all distributors in the system, those tasks will be marked as completed.
clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetController.java