Search in sources :

Example 6 with NodeMetadata

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("");
}
Also used : Path(java.nio.file.Path) NodeMetadata(org.opensearch.env.NodeMetadata) AllocateStalePrimaryAllocationCommand(org.opensearch.cluster.routing.allocation.command.AllocateStalePrimaryAllocationCommand) AllocateEmptyPrimaryAllocationCommand(org.opensearch.cluster.routing.allocation.command.AllocateEmptyPrimaryAllocationCommand) OpenSearchException(org.opensearch.OpenSearchException) AllocationCommands(org.opensearch.cluster.routing.allocation.command.AllocationCommands)

Aggregations

NodeMetadata (org.opensearch.env.NodeMetadata)6 Path (java.nio.file.Path)3 OpenSearchException (org.opensearch.OpenSearchException)3 IOException (java.io.IOException)2 ClusterState (org.opensearch.cluster.ClusterState)2 IndexTemplateMetadata (org.opensearch.cluster.metadata.IndexTemplateMetadata)2 Metadata (org.opensearch.cluster.metadata.Metadata)2 PersistedClusterStateService (org.opensearch.gateway.PersistedClusterStateService)2 UncheckedIOException (java.io.UncheckedIOException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)1 DirectoryReader (org.apache.lucene.index.DirectoryReader)1 IndexNotFoundException (org.apache.lucene.index.IndexNotFoundException)1 NIOFSDirectory (org.apache.lucene.store.NIOFSDirectory)1 OpenSearchTimeoutException (org.opensearch.OpenSearchTimeoutException)1 Version (org.opensearch.Version)1 SearchTransportService (org.opensearch.action.search.SearchTransportService)1 BootstrapContext (org.opensearch.bootstrap.BootstrapContext)1 ClusterStateObserver (org.opensearch.cluster.ClusterStateObserver)1 NodeConnectionsService (org.opensearch.cluster.NodeConnectionsService)1