ClusterState clusterState = initialClusterState;
while (clusterState.readOnlyRoutingNodes().hasUnassignedShards()) {
logger.info("[{}] remaining unassigned {}", i, clusterState.readOnlyRoutingNodes().unassigned().size());
RoutingAllocation.Result result = strategy.applyStartedShards(clusterState, clusterState.readOnlyRoutingNodes().shardsWithState(INITIALIZING));
clusterState = ClusterState.builder(clusterState).routingResult(result).build();
result = strategy.reroute(clusterState);
clusterState = ClusterState.builder(clusterState).routingResult(result).build();
}
logger.info("[{}] took {}", i, TimeValue.timeValueMillis(System.currentTimeMillis() - runStart));
}
long took = System.currentTimeMillis() - start;