use of org.opensearch.env.NodeMetadata in project OpenSearch by opensearch-project.
the class RemoveCorruptedShardDataCommand method printRerouteCommand.
private void printRerouteCommand(ShardPath shardPath, Terminal terminal, boolean allocateStale) throws IOException {
final Path nodePath = getNodePath(shardPath);
final NodeMetadata nodeMetadata = PersistedClusterStateService.nodeMetadata(nodePath);
if (nodeMetadata == null) {
throw new OpenSearchException("No node meta data at " + nodePath);
}
final String nodeId = nodeMetadata.nodeId();
final String index = shardPath.getShardId().getIndexName();
final int id = shardPath.getShardId().id();
final AllocationCommands commands = new AllocationCommands(allocateStale ? new AllocateStalePrimaryAllocationCommand(index, id, nodeId, false) : new AllocateEmptyPrimaryAllocationCommand(index, id, nodeId, false));
terminal.println("");
terminal.println("POST /_cluster/reroute\n" + Strings.toString(commands, true, true));
terminal.println("");
terminal.println("You must accept the possibility of data loss by changing the `accept_data_loss` parameter to `true`.");
terminal.println("");
}
Aggregations