diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateShardPathAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateShardPathAction.java index 9593b0c73ff0a..44a2de19e5a65 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateShardPathAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateShardPathAction.java @@ -103,7 +103,7 @@ protected NodePrevalidateShardPathResponse nodeOperation(NodePrevalidateShardPat // For each shard we only check whether the shard path exists, regardless of whether the content is a valid index or not. for (ShardId shardId : request.getShardIds()) { try { - var indexMetadata = clusterService.state().metadata().getProject().index(shardId.getIndex()); + var indexMetadata = clusterService.state().metadata().findIndex(shardId.getIndex()).orElse(null); String customDataPath = null; if (indexMetadata != null) { customDataPath = new IndexSettings(indexMetadata, settings).customDataPath(); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java index 1ea299e13291b..21b13dca7f512 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java @@ -238,7 +238,7 @@ private class IndexRequestContext { Iterator getShardRequestContexts() { try (var shardListeners = new RefCountingListener(1, outerListener.acquire(ignored -> putResults()))) { final var customDataPath = IndexMetadata.INDEX_DATA_PATH_SETTING.get( - metadata.getProject().index(indexRoutingTable.getIndex()).getSettings() + metadata.indexMetadata(indexRoutingTable.getIndex()).getSettings() ); final var shardRequestContexts = new ArrayList(indexRoutingTable.size()); for (int shardNum = 0; shardNum < indexRoutingTable.size(); shardNum++) { diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeService.java index d4eacae434043..086126408fb84 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeService.java @@ -240,7 +240,7 @@ private List updateIndices(ClusterState currentState, List Metadata metadata = currentState.metadata(); final List updatedMetadata = new ArrayList<>(); for (Index index : indices) { - IndexMetadata indexMetadata = metadata.getProject().index(index); + IndexMetadata indexMetadata = metadata.indexMetadata(index); final boolean shouldBeSystem = shouldBeSystem(indexMetadata); IndexMetadata updatedIndexMetadata = updateIndexIfNecessary(indexMetadata, shouldBeSystem); if (updatedIndexMetadata != null) { diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java b/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java index 39b65b2bc90c4..4fd8cc113fcf8 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimator.java @@ -53,7 +53,7 @@ public static boolean shouldReserveSpaceForInitializingShard(ShardRouting shard, // Snapshot restore (unless it is partial) require downloading all segments locally from the blobstore to start the shard. // See org.elasticsearch.xpack.searchablesnapshots.action.TransportMountSearchableSnapshotAction.buildIndexSettings // and DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS - case SNAPSHOT -> metadata.getProject().getIndexSafe(shard.index()).isPartialSearchableSnapshot() == false; + case SNAPSHOT -> metadata.indexMetadata(shard.index()).isPartialSearchableSnapshot() == false; // shrink/split/clone operation is going to clone existing locally placed shards using file system hard links // so no additional space is going to be used until future merges diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java index 69786cf83a56e..2a31873a07388 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java @@ -416,7 +416,7 @@ public static long findNextDelayedAllocation(long currentNanoTime, ClusterState for (ShardRouting shard : state.getRoutingNodes().unassigned()) { UnassignedInfo unassignedInfo = shard.unassignedInfo(); if (unassignedInfo.delayed()) { - Settings indexSettings = metadata.getProject().index(shard.index()).getSettings(); + Settings indexSettings = metadata.indexMetadata(shard.index()).getSettings(); // calculate next time to schedule final long newComputedLeftDelayNanos = unassignedInfo.remainingDelay( currentNanoTime, diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java index 92c8e31db2fa0..263c2362c9ed6 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java @@ -484,7 +484,7 @@ default void removeDelayMarkers(RoutingAllocation allocation) { if (unassignedInfo.delayed()) { final long newComputedLeftDelayNanos = unassignedInfo.remainingDelay( allocation.getCurrentNanoTime(), - metadata.getProject().getIndexSafe(shardRouting.index()).getSettings(), + metadata.indexMetadata(shardRouting.index()).getSettings(), metadata.nodeShutdowns() ); if (newComputedLeftDelayNanos == 0) { @@ -714,7 +714,7 @@ private static void disassociateDeadNodes(RoutingAllocation allocation) { // now, go over all the shards routing on the node, and fail them for (ShardRouting shardRouting : node.copyShards()) { - final IndexMetadata indexMetadata = allocation.metadata().getProject().getIndexSafe(shardRouting.index()); + final IndexMetadata indexMetadata = allocation.metadata().indexMetadata(shardRouting.index()); boolean delayed = delayedDueToKnownRestart || INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(indexMetadata.getSettings()).nanos() > 0; diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java index 10e51b4241034..3e9f934572585 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java @@ -177,7 +177,7 @@ private static Map unaccountedSearchableSnapshotSizes(ClusterState long totalSize = 0; for (ShardRouting shard : node.started()) { if (shard.getExpectedShardSize() > 0 - && clusterState.metadata().getProject().getIndexSafe(shard.index()).isSearchableSnapshot() + && clusterState.metadata().indexMetadata(shard.index()).isSearchableSnapshot() && reservedSpace.containsShardId(shard.shardId()) == false && clusterInfo.getShardSize(shard) == null) { totalSize += shard.getExpectedShardSize(); diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStats.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStats.java index 5d78cf5f95116..81efbb9f15093 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStats.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStats.java @@ -231,9 +231,8 @@ private static NodeBalanceStats createFrom( long actualShardSize = 0L; for (ShardRouting shardRouting : routingNode) { - var indexMetadata = metadata.getProject().index(shardRouting.index()); + var indexMetadata = metadata.indexMetadata(shardRouting.index()); var shardSize = clusterInfo.getShardSize(shardRouting, 0L); - assert indexMetadata != null; forecastWriteLoad += writeLoadForecaster.getForecastedWriteLoad(indexMetadata).orElse(0.0); forecastShardSize += indexMetadata.getForecastedShardSizeInBytes().orElse(shardSize); actualShardSize += shardSize; diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index 08422f1a16735..b4264aa55ad4c 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java @@ -334,7 +334,7 @@ public Decision canForceAllocateDuringReplace(ShardRouting shardRouting, Routing return decision; } - if (allocation.metadata().getProject().index(shardRouting.index()).ignoreDiskWatermarks()) { + if (allocation.metadata().indexMetadata(shardRouting.index()).ignoreDiskWatermarks()) { return YES_DISK_WATERMARKS_IGNORED; } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java index 4e61720260ecf..637744c4480aa 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java @@ -79,7 +79,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing // if its already a NO decision looking at the node, or we aren't configured to look at the host, return the decision return decision; } - if (allocation.metadata().getProject().getIndexSafe(shardRouting.index()).getAutoExpandReplicas().expandToAllNodes()) { + if (allocation.metadata().indexMetadata(shardRouting.index()).getAutoExpandReplicas().expandToAllNodes()) { return YES_AUTO_EXPAND_ALL; } if (node.node() != null) { diff --git a/server/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java b/server/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java index 0e13e8b603dc4..1696dd052de05 100644 --- a/server/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java +++ b/server/src/main/java/org/elasticsearch/gateway/ReplicaShardAllocator.java @@ -261,7 +261,7 @@ public static AllocateUnassignedDecision delayedDecision( if (explain) { UnassignedInfo unassignedInfo = unassignedShard.unassignedInfo(); Metadata metadata = allocation.metadata(); - IndexMetadata indexMetadata = metadata.getProject().index(unassignedShard.index()); + IndexMetadata indexMetadata = metadata.indexMetadata(unassignedShard.index()); totalDelayMillis = INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(indexMetadata.getSettings()).getMillis(); long remainingDelayNanos = unassignedInfo.remainingDelay( System.nanoTime(), diff --git a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java index 304e0ee2cb12e..d5d652ec05088 100644 --- a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java +++ b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java @@ -133,7 +133,7 @@ protected NodeGatewayStartedShards nodeOperation(NodeRequest request, Task task) customDataPath = request.getCustomDataPath(); } else { // TODO: Fallback for BWC with older ES versions. Remove once request.getCustomDataPath() always returns non-null - final IndexMetadata metadata = clusterService.state().metadata().getProject().index(shardId.getIndex()); + final IndexMetadata metadata = clusterService.state().metadata().findIndex(shardId.getIndex()).orElse(null); if (metadata != null) { customDataPath = new IndexSettings(metadata, settings).customDataPath(); } else { diff --git a/server/src/main/java/org/elasticsearch/index/translog/TruncateTranslogAction.java b/server/src/main/java/org/elasticsearch/index/translog/TruncateTranslogAction.java index b8f50e0b7c421..d99d42cd2f10b 100644 --- a/server/src/main/java/org/elasticsearch/index/translog/TruncateTranslogAction.java +++ b/server/src/main/java/org/elasticsearch/index/translog/TruncateTranslogAction.java @@ -155,7 +155,7 @@ private static boolean isTranslogClean(ShardPath shardPath, ClusterState cluster try { final Path translogPath = shardPath.resolveTranslog(); final long translogGlobalCheckpoint = Translog.readGlobalCheckpoint(translogPath, translogUUID); - final IndexMetadata indexMetadata = clusterState.metadata().getProject().getIndexSafe(shardPath.getShardId().getIndex()); + final IndexMetadata indexMetadata = clusterState.metadata().indexMetadata(shardPath.getShardId().getIndex()); final IndexSettings indexSettings = new IndexSettings(indexMetadata, Settings.EMPTY); final TranslogConfig translogConfig = new TranslogConfig( shardPath.getShardId(), diff --git a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java index 8ba17aec26ce7..7ad237181a662 100644 --- a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java +++ b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java @@ -159,7 +159,7 @@ private StoreFilesMetadata listStoreMetadata(NodeRequest request) throws IOExcep if (indexService != null) { customDataPath = indexService.getIndexSettings().customDataPath(); } else { - IndexMetadata metadata = clusterService.state().metadata().getProject().index(shardId.getIndex()); + IndexMetadata metadata = clusterService.state().metadata().findIndex(shardId.getIndex()).orElse(null); if (metadata != null) { customDataPath = new IndexSettings(metadata, settings).customDataPath(); } else { diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index 6ee1067d8149d..629ba32432ec8 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -744,7 +744,7 @@ private static ShardGenerations buildGenerations(SnapshotsInProgress.Entry snaps } else { snapshot.shardSnapshotStatusByRepoShardId().forEach((key, value) -> { final Index index = snapshot.indexByName(key.indexName()); - if (metadata.getProject().index(index) == null) { + if (metadata.findIndex(index).isEmpty()) { assert snapshot.partial() : "Index [" + index + "] was deleted during a snapshot but snapshot was not partial."; return; }