public void waitForNodesInSlobrok(int distNodeCount, int storNodeCount, Duration timeout) throws InterruptedException {
        Instant endTime = Instant.now().plus(timeout);
        synchronized (monitor) {
            while (true) {
                int distCount = 0, storCount = 0;
                for (NodeInfo info : cluster.getNodeInfos()) {
                    if (info.isInSlobrok()) {
                        if (info.isDistributor()) ++distCount;
                        else ++storCount;
                    }
                }
                if (distCount == distNodeCount && storCount == storNodeCount) return;

                if (Instant.now().isAfter(endTime)) {
                    throw new IllegalStateException("Did not get all " + distNodeCount + " distributors and " + storNodeCount
                            + " storage nodes registered in slobrok within timeout of " + timeout + ". (Got "
                            + distCount + " distributors and " + storCount + " storage nodes)");
                }
                monitor.wait(10);
            }
        }
    }
This function might not be 100% threadsafe, as in theory cluster can be changing while accessed.
But it is only used in unit tests that should not trigger any thread issues. Don't want to add locks that reduce
live performance to remove a non-problem.
clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/FleetController.java