Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private class IndexRequestContext {
Iterator<ShardRequestContext> 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<ShardRequestContext>(indexRoutingTable.size());
for (int shardNum = 0; shardNum < indexRoutingTable.size(); shardNum++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private List<IndexMetadata> updateIndices(ClusterState currentState, List<Index>
Metadata metadata = currentState.metadata();
final List<IndexMetadata> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private static Map<String, Long> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down