protected static void waitForClusterStable() throws Exception { Long timeout = 1200L; String state = systemClient.upgrade().getClusterState(); Long startTime = System.currentTimeMillis(); Long timeoutInMilliSeconds = timeout * 1000; while (true) { if (systemClient.upgrade().getClusterState().contains("STABLE")) { // Wait an extra 10 seconds before returning... // Thread.sleep(10000); logger.info("Cluster is STABLE"); return; } // retry after 10 seconds... logger.info("Cluster is " + state + ", retry after 10 seconds"); Thread.sleep(10000); // No need to try further... if ((System.currentTimeMillis() - startTime) > timeoutInMilliSeconds) { logger.info("Cluster is still not stable after waiting for " + timeout + " seconds"); break; } } }