Source:
<code>public void rebalance() { entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "explicitly started"); newScript("rebalance") .body.append( couchbaseCli("rebalance") + getCouchbaseHostnameAndCredentials()) .failOnNonZeroResultCode() .execute(); Repeater.create() .backoff(Duration.millis(10), 2, Duration.millis(500)) .limitTimeTo(Duration.THIRTY_SECONDS) .until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { for (HostAndPort nodeHostAndPort : getNodesHostAndPort()) { if (isNodeRebalancing(nodeHostAndPort.toString())) { return true; } } return false; } } ).run(); entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "waiting for completion"); <START> boolean completed = Repeater.create() <END> .backoff(Duration.ONE_SECOND, 1.2, Duration.TEN_SECONDS) .limitTimeTo(Duration.FIVE_MINUTES) .until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { for (HostAndPort nodeHostAndPort : getNodesHostAndPort()) { if (isNodeRebalancing(nodeHostAndPort.toString())) { return false; } } return true; } }) .run(); if (completed) { entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "completed"); ServiceStateLogic.ServiceNotUpLogic.clearNotUpIndicator(getEntity(), "rebalancing"); log.info("Rebalanced cluster via primary node {}", getEntity()); } else { entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "timed out"); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(getEntity(), "rebalancing", "rebalance did not complete within time limit"); log.warn("Timeout rebalancing cluster via primary node {}", getEntity()); } }</code><technical_language>Wrap is tasks, execute sequentially, show in activity pane. DockerHost test for SSHable reboot for example, in Clocker</technical_language>

Target:
public void rebalance() { entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "explicitly started"); newScript("rebalance") .body.append( couchbaseCli("rebalance") + getCouchbaseHostnameAndCredentials()) .failOnNonZeroResultCode() .execute(); Repeater.create() .backoff(Duration.millis(10), 2, Duration.millis(500)) .limitTimeTo(Duration.THIRTY_SECONDS) .until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { for (HostAndPort nodeHostAndPort : getNodesHostAndPort()) { if (isNodeRebalancing(nodeHostAndPort.toString())) { return true; } } return false; } } ).run(); entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "waiting for completion"); Task<Boolean> reBalance = TaskBuilder.<Boolean>builder() .name("Waiting until node is rebalancing") .body(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return Repeater.create() .backoff(Duration.ONE_SECOND, 1.2, Duration.TEN_SECONDS) .limitTimeTo(Duration.FIVE_MINUTES) .until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { for (HostAndPort nodeHostAndPort : getNodesHostAndPort()) { if (isNodeRebalancing(nodeHostAndPort.toString())) { return false; } } return true; } }) .run(); } }) .build(); Boolean completed = DynamicTasks.queueIfPossible(reBalance) .orSubmitAndBlock() .andWaitForSuccess(); if (completed) { entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "completed"); ServiceStateLogic.ServiceNotUpLogic.clearNotUpIndicator(getEntity(), "rebalancing"); log.info("Rebalanced cluster via primary node {}", getEntity()); } else { entity.setAttribute(CouchbaseNode.REBALANCE_STATUS, "timed out"); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(getEntity(), "rebalancing", "rebalance did not complete within time limit"); log.warn("Timeout rebalancing cluster via primary node {}", getEntity()); } }