Skip to content

Commit

Permalink
Merge branch '8.x' into backport/8.x/pr-117839
Browse files Browse the repository at this point in the history
  • Loading branch information
kderusso authored Dec 12, 2024
2 parents 6730291 + e04fe26 commit b2e03bf
Show file tree
Hide file tree
Showing 85 changed files with 690 additions and 753 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/118194.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 118194
summary: Retry on `ClusterBlockException` on transform destination index
area: Machine Learning
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.elasticsearch.xpack.core.ilm.Step.StepKey;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -73,17 +71,17 @@ public AllocateAction(
Map<String, String> require
) {
if (include == null) {
this.include = Collections.emptyMap();
this.include = Map.of();
} else {
this.include = include;
}
if (exclude == null) {
this.exclude = Collections.emptyMap();
this.exclude = Map.of();
} else {
this.exclude = exclude;
}
if (require == null) {
this.require = Collections.emptyMap();
this.require = Map.of();
} else {
this.require = require;
}
Expand Down Expand Up @@ -201,7 +199,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
}
UpdateSettingsStep allocateStep = new UpdateSettingsStep(allocateKey, allocationRoutedKey, client, newSettings.build());
AllocationRoutedStep routedCheckStep = new AllocationRoutedStep(allocationRoutedKey, nextStepKey);
return Arrays.asList(allocateStep, routedCheckStep);
return List.of(allocateStep, routedCheckStep);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;

import java.util.Collections;
import java.util.List;

import static org.elasticsearch.xpack.core.ilm.step.info.AllocationInfo.allShardsActiveAllocationInfo;
import static org.elasticsearch.xpack.core.ilm.step.info.AllocationInfo.waitingForActiveShardsAllocationInfo;
Expand Down Expand Up @@ -62,7 +62,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) {
}

AllocationDeciders allocationDeciders = new AllocationDeciders(
Collections.singletonList(
List.of(
new FilterAllocationDecider(
clusterState.getMetadata().settings(),
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -99,7 +98,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
);
CleanupSnapshotStep cleanupSnapshotStep = new CleanupSnapshotStep(cleanSnapshotKey, deleteStepKey, client);
DeleteStep deleteStep = new DeleteStep(deleteStepKey, nextStepKey, client);
return Arrays.asList(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, cleanupSnapshotStep, deleteStep);
return List.of(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, cleanupSnapshotStep, deleteStep);
} else {
WaitForNoFollowersStep waitForNoFollowersStep = new WaitForNoFollowersStep(
waitForNoFollowerStepKey,
Expand All @@ -113,7 +112,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
client
);
DeleteStep deleteStep = new DeleteStep(deleteStepKey, nextStepKey, client);
return Arrays.asList(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, deleteStep);
return List.of(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, deleteStep);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* Invokes a force merge on a single index.
Expand Down Expand Up @@ -67,10 +66,7 @@ public void performAction(
policyName,
failures == null
? "n/a"
: Strings.collectionToDelimitedString(
Arrays.stream(failures).map(Strings::toString).collect(Collectors.toList()),
","
),
: Strings.collectionToDelimitedString(Arrays.stream(failures).map(Strings::toString).toList(), ","),
NAME
);
logger.warn(errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.elasticsearch.xpack.core.ilm.Step.StepKey;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -98,7 +97,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
);
CheckNotDataStreamWriteIndexStep checkNoWriteIndexStep = new CheckNotDataStreamWriteIndexStep(checkNotWriteIndex, freezeStepKey);
FreezeStep freezeStep = new FreezeStep(freezeStepKey, nextStepKey, client);
return Arrays.asList(conditionalSkipFreezeStep, checkNoWriteIndexStep, freezeStep);
return List.of(conditionalSkipFreezeStep, checkNoWriteIndexStep, freezeStep);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* A utility class used for index lifecycle policies
Expand Down Expand Up @@ -121,7 +120,7 @@ public static ItemUsage calculateUsage(
.stream()
.filter(indexMetadata -> policyName.equals(indexMetadata.getLifecyclePolicyName()))
.map(indexMetadata -> indexMetadata.getIndex().getName())
.collect(Collectors.toList());
.toList();

final List<String> allDataStreams = indexNameExpressionResolver.dataStreamNames(
state,
Expand All @@ -136,12 +135,12 @@ public static ItemUsage calculateUsage(
} else {
return false;
}
}).collect(Collectors.toList());
}).toList();

final List<String> composableTemplates = state.metadata().templatesV2().keySet().stream().filter(templateName -> {
Settings settings = MetadataIndexTemplateService.resolveSettings(state.metadata(), templateName);
return policyName.equals(LifecycleSettings.LIFECYCLE_NAME_SETTING.get(settings));
}).collect(Collectors.toList());
}).toList();

return new ItemUsage(indices, dataStreams, composableTemplates);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -72,7 +71,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
client
);
ReadOnlyStep readOnlyStep = new ReadOnlyStep(readOnlyKey, nextStepKey, client);
return Arrays.asList(checkNotWriteIndexStep, waitUntilTimeSeriesEndTimeStep, readOnlyStep);
return List.of(checkNotWriteIndexStep, waitUntilTimeSeriesEndTimeStep, readOnlyStep);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.elasticsearch.xpack.core.ilm.Step.StepKey;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -172,7 +171,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
client,
INDEXING_COMPLETE
);
return Arrays.asList(waitForRolloverReadyStep, rolloverStep, waitForActiveShardsStep, updateDateStep, setIndexingCompleteStep);
return List.of(waitForRolloverReadyStep, rolloverStep, waitForActiveShardsStep, updateDateStep, setIndexingCompleteStep);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener,
response.getFailedShards(),
failures == null
? "n/a"
: Strings.collectionToDelimitedString(
Arrays.stream(failures).map(Strings::toString).collect(Collectors.toList()),
","
)
: Strings.collectionToDelimitedString(Arrays.stream(failures).map(Strings::toString).toList(), ",")
);
listener.onResponse(true, new Info(-1));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.elasticsearch.xpack.core.ilm.Step.StepKey;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -101,7 +100,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
Settings indexPriority = recoveryPriority == null
? NULL_PRIORITY_SETTINGS
: Settings.builder().put(IndexMetadata.INDEX_PRIORITY_SETTING.getKey(), recoveryPriority).build();
return Collections.singletonList(new UpdateSettingsStep(key, nextStepKey, client, indexPriority));
return List.of(new UpdateSettingsStep(key, nextStepKey, client, indexPriority));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.time.Instant;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.elasticsearch.xpack.core.ilm.ShrinkIndexNameSupplier.SHRUNKEN_INDEX_PREFIX;
Expand Down Expand Up @@ -329,7 +328,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
allowWriteAfterShrinkStep
);

return steps.filter(Objects::nonNull).collect(Collectors.toList());
return steps.filter(Objects::nonNull).toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -30,8 +29,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

/**
* Represents the lifecycle of an index from creation to deletion. A
* {@link TimeseriesLifecycleType} is made up of a set of {@link Phase}s which it will
Expand Down Expand Up @@ -114,7 +111,7 @@ public class TimeseriesLifecycleType implements LifecycleType {
// Set of actions that cannot be defined (executed) after the managed index has been mounted as searchable snapshot.
// It's ordered to produce consistent error messages which can be unit tested.
public static final Set<String> ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT = Collections.unmodifiableSet(
new LinkedHashSet<>(Arrays.asList(ForceMergeAction.NAME, FreezeAction.NAME, ShrinkAction.NAME, DownsampleAction.NAME))
new LinkedHashSet<>(List.of(ForceMergeAction.NAME, FreezeAction.NAME, ShrinkAction.NAME, DownsampleAction.NAME))
);

private TimeseriesLifecycleType() {}
Expand Down Expand Up @@ -180,11 +177,11 @@ public static boolean shouldInjectMigrateStepForPhase(Phase phase) {
public List<LifecycleAction> getOrderedActions(Phase phase) {
Map<String, LifecycleAction> actions = phase.getActions();
return switch (phase.getName()) {
case HOT_PHASE -> ORDERED_VALID_HOT_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).collect(toList());
case WARM_PHASE -> ORDERED_VALID_WARM_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).collect(toList());
case COLD_PHASE -> ORDERED_VALID_COLD_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).collect(toList());
case FROZEN_PHASE -> ORDERED_VALID_FROZEN_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).collect(toList());
case DELETE_PHASE -> ORDERED_VALID_DELETE_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).collect(toList());
case HOT_PHASE -> ORDERED_VALID_HOT_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).toList();
case WARM_PHASE -> ORDERED_VALID_WARM_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).toList();
case COLD_PHASE -> ORDERED_VALID_COLD_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).toList();
case FROZEN_PHASE -> ORDERED_VALID_FROZEN_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).toList();
case DELETE_PHASE -> ORDERED_VALID_DELETE_ACTIONS.stream().map(actions::get).filter(Objects::nonNull).toList();
default -> throw new IllegalArgumentException("lifecycle type [" + TYPE + "] does not support phase [" + phase.getName() + "]");
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.elasticsearch.xpack.core.ilm.Step.StepKey;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -72,7 +71,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
UnfollowFollowerIndexStep step5 = new UnfollowFollowerIndexStep(unfollowFollowerIndex, openFollowerIndex, client);
OpenIndexStep step6 = new OpenIndexStep(openFollowerIndex, waitForYellowStep, client);
WaitForIndexColorStep step7 = new WaitForIndexColorStep(waitForYellowStep, nextStepKey, ClusterHealthStatus.YELLOW);
return Arrays.asList(conditionalSkipUnfollowStep, step1, step2, step3, step4, step5, step6, step7);
return List.of(conditionalSkipUnfollowStep, step1, step2, step3, step4, step5, step6, step7);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.elasticsearch.xpack.core.ilm.UnfollowAction.CCR_METADATA_KEY;

Expand Down Expand Up @@ -78,7 +77,7 @@ static void handleResponse(FollowStatsAction.StatsResponses responses, Listener
status.followerGlobalCheckpoint()
)
)
.collect(Collectors.toList());
.toList();
listener.onResponse(false, new Info(shardFollowTaskInfos));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.elasticsearch.xpack.core.ilm.Step.StepKey;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -62,7 +61,7 @@ public String getPolicy() {
@Override
public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
StepKey waitForSnapshotKey = new StepKey(phase, NAME, WaitForSnapshotStep.NAME);
return Collections.singletonList(new WaitForSnapshotStep(waitForSnapshotKey, nextStepKey, client, policy));
return List.of(new WaitForSnapshotStep(waitForSnapshotKey, nextStepKey, client, policy));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xpack.core.ilm.Step.StepKey;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -44,20 +43,20 @@ static AllocateAction randomInstance() {
includes = randomAllocationRoutingMap(1, 100);
hasAtLeastOneMap = true;
} else {
includes = randomBoolean() ? null : Collections.emptyMap();
includes = randomBoolean() ? null : Map.of();
}
Map<String, String> excludes;
if (randomBoolean()) {
hasAtLeastOneMap = true;
excludes = randomAllocationRoutingMap(1, 100);
} else {
excludes = randomBoolean() ? null : Collections.emptyMap();
excludes = randomBoolean() ? null : Map.of();
}
Map<String, String> requires;
if (hasAtLeastOneMap == false || randomBoolean()) {
requires = randomAllocationRoutingMap(1, 100);
} else {
requires = randomBoolean() ? null : Collections.emptyMap();
requires = randomBoolean() ? null : Map.of();
}
Integer numberOfReplicas = randomBoolean() ? null : randomIntBetween(0, 10);
Integer totalShardsPerNode = randomBoolean() ? null : randomIntBetween(-1, 10);
Expand Down Expand Up @@ -97,9 +96,9 @@ protected AllocateAction mutateInstance(AllocateAction instance) {
}

public void testAllMapsNullOrEmpty() {
Map<String, String> include = randomBoolean() ? null : Collections.emptyMap();
Map<String, String> exclude = randomBoolean() ? null : Collections.emptyMap();
Map<String, String> require = randomBoolean() ? null : Collections.emptyMap();
Map<String, String> include = randomBoolean() ? null : Map.of();
Map<String, String> exclude = randomBoolean() ? null : Map.of();
Map<String, String> require = randomBoolean() ? null : Map.of();
IllegalArgumentException exception = expectThrows(
IllegalArgumentException.class,
() -> new AllocateAction(null, null, include, exclude, require)
Expand All @@ -124,8 +123,8 @@ public void testAllMapsNullOrEmpty() {

public void testInvalidNumberOfReplicas() {
Map<String, String> include = randomAllocationRoutingMap(1, 5);
Map<String, String> exclude = randomBoolean() ? null : Collections.emptyMap();
Map<String, String> require = randomBoolean() ? null : Collections.emptyMap();
Map<String, String> exclude = randomBoolean() ? null : Map.of();
Map<String, String> require = randomBoolean() ? null : Map.of();
IllegalArgumentException exception = expectThrows(
IllegalArgumentException.class,
() -> new AllocateAction(randomIntBetween(-1000, -1), randomIntBetween(0, 300), include, exclude, require)
Expand All @@ -135,8 +134,8 @@ public void testInvalidNumberOfReplicas() {

public void testInvalidTotalShardsPerNode() {
Map<String, String> include = randomAllocationRoutingMap(1, 5);
Map<String, String> exclude = randomBoolean() ? null : Collections.emptyMap();
Map<String, String> require = randomBoolean() ? null : Collections.emptyMap();
Map<String, String> exclude = randomBoolean() ? null : Map.of();
Map<String, String> require = randomBoolean() ? null : Map.of();
IllegalArgumentException exception = expectThrows(
IllegalArgumentException.class,
() -> new AllocateAction(randomIntBetween(0, 300), randomIntBetween(-1000, -2), include, exclude, require)
Expand Down
Loading

0 comments on commit b2e03bf

Please sign in to comment.