String toNode = node1.equals(fromNode) ? node2 : node1;
logger.trace("--> START relocate the shard from {} to {}", fromNode, toNode);
cluster().client(node1).admin().cluster().prepareReroute()
.add(new MoveAllocationCommand(new ShardId(BlobIndices.fullIndexName("test"), 0), fromNode, toNode))
.execute().actionGet();
ClusterHealthResponse clusterHealthResponse = cluster().client(node1).admin().cluster()
.prepareHealth()
.setWaitForEvents(Priority.LANGUID)
.setWaitForRelocatingShards(0)
.setTimeout(ACCEPTABLE_RELOCATION_TIME).execute().actionGet();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
clusterHealthResponse = cluster().client(node2).admin().cluster()
.prepareHealth()
.setWaitForEvents(Priority.LANGUID)
.setWaitForRelocatingShards(0)
.setTimeout(ACCEPTABLE_RELOCATION_TIME).execute().actionGet();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
logger.trace("--> DONE relocate the shard from {} to {}", fromNode, toNode);
}
logger.trace("--> done relocations");
logger.trace("--> marking and waiting for upload threads to stop ...");