From 4bce48b258973c5304cf57356800c66a75caac26 Mon Sep 17 00:00:00 2001 From: Joe Gallo Date: Tue, 10 Dec 2024 09:52:19 -0500 Subject: [PATCH] Some ILM tidying cleanups, mostly around String formatting (#118338) --- .../xpack/core/ilm/AsyncWaitStep.java | 2 +- .../xpack/core/ilm/BranchingStep.java | 2 +- .../ilm/CheckNotDataStreamWriteIndexStep.java | 9 ++--- .../xpack/core/ilm/CheckShrinkReadyStep.java | 4 +-- .../core/ilm/CheckTargetShardsCountStep.java | 6 ++-- .../core/ilm/CleanupShrinkIndexStep.java | 33 +++++++++---------- .../xpack/core/ilm/ClusterStateWaitStep.java | 12 +++---- .../ClusterStateWaitUntilThresholdStep.java | 11 +++---- .../core/ilm/CopyExecutionStateStep.java | 2 +- .../xpack/core/ilm/CopySettingsStep.java | 7 ++-- .../core/ilm/DataTierMigrationRoutedStep.java | 10 +++--- .../xpack/core/ilm/DeleteStep.java | 6 ++-- .../xpack/core/ilm/DownsampleAction.java | 2 +- .../DownsamplePrepareLifeCycleStateStep.java | 2 +- .../core/ilm/ExplainLifecycleRequest.java | 2 +- .../core/ilm/ExplainLifecycleResponse.java | 2 +- .../xpack/core/ilm/ForceMergeStep.java | 4 +-- .../core/ilm/InitializePolicyException.java | 5 ++- .../ilm/LifecycleExecutionStateUtils.java | 4 +-- .../core/ilm/LifecycleOperationMetadata.java | 1 - .../xpack/core/ilm/LifecyclePolicy.java | 6 ++-- .../ilm/LifecyclePolicySecurityClient.java | 8 ++--- .../xpack/core/ilm/LifecyclePolicyUtils.java | 2 +- .../core/ilm/OperationModeUpdateTask.java | 2 +- .../xpack/core/ilm/PhaseCacheManagement.java | 6 +--- .../ReplaceDataStreamBackingIndexStep.java | 13 +++----- .../xpack/core/ilm/RolloverStep.java | 9 ++--- .../core/ilm/SearchableSnapshotAction.java | 2 +- .../xpack/core/ilm/SegmentCountStep.java | 2 +- .../xpack/core/ilm/SetPriorityAction.java | 8 ++--- .../core/ilm/SetSingleNodeAllocateStep.java | 2 +- .../xpack/core/ilm/ShrinkAction.java | 8 +++-- .../xpack/core/ilm/ShrinkStep.java | 4 +-- .../SwapAliasesAndDeleteSourceIndexStep.java | 7 ++-- .../core/ilm/TimeseriesLifecycleType.java | 4 +-- .../xpack/core/ilm/UnfollowAction.java | 2 +- .../core/ilm/UnfollowFollowerIndexStep.java | 2 +- .../ilm/UpdateRolloverLifecycleDateStep.java | 2 +- .../core/ilm/WaitForActiveShardsStep.java | 10 ++---- .../xpack/core/ilm/WaitForIndexColorStep.java | 7 ++-- .../core/ilm/WaitForRolloverReadyStep.java | 14 +++----- .../xpack/core/ilm/WaitForSnapshotStep.java | 8 ++--- .../WaitUntilTimeSeriesEndTimePassesStep.java | 11 +++---- .../core/ilm/AllocationRoutedStepTests.java | 6 ++-- .../CheckNoDataStreamWriteIndexStepTests.java | 6 ++-- .../core/ilm/CheckShrinkReadyStepTests.java | 6 ++-- .../ilm/CheckTargetShardsCountStepTests.java | 2 +- ...usterStateWaitUntilThresholdStepTests.java | 14 ++++---- .../ilm/DataTierMigrationRoutedStepTests.java | 16 ++++----- .../xpack/core/ilm/ForceMergeStepTests.java | 2 +- .../ilm/ShrunkShardsAllocatedStepTests.java | 6 ++-- .../core/ilm/ShrunkenIndexCheckStepTests.java | 6 ++-- .../core/ilm/WaitForActiveShardsTests.java | 6 ++-- .../core/ilm/WaitForDataTierStepTests.java | 4 +-- .../core/ilm/WaitForIndexColorStepTests.java | 18 +++++----- .../ilm/WaitForIndexingCompleteStepTests.java | 10 +++--- .../core/ilm/WaitForNoFollowersStepTests.java | 20 +++++------ .../ilm/WaitForRolloverReadyStepTests.java | 20 +++++------ ...UntilTimeSeriesEndTimePassesStepTests.java | 8 ++--- .../xpack/ilm/ExecuteStepsUpdateTask.java | 2 +- .../xpack/ilm/MoveToErrorStepUpdateTask.java | 2 +- 61 files changed, 187 insertions(+), 232 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AsyncWaitStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AsyncWaitStep.java index fb7a564674534..6a72af5bce5e9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AsyncWaitStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AsyncWaitStep.java @@ -20,7 +20,7 @@ */ public abstract class AsyncWaitStep extends Step { - private Client client; + private final Client client; public AsyncWaitStep(StepKey key, StepKey nextStepKey, Client client) { super(key, nextStepKey); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/BranchingStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/BranchingStep.java index db9e9a881b2f9..5dd5ab8e54f6a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/BranchingStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/BranchingStep.java @@ -71,7 +71,7 @@ public ClusterState performAction(Index index, ClusterState clusterState) { * This method returns the next step to execute based on the predicate. If * the predicate returned true, then nextStepKeyOnTrue is the key of the * next step to run, otherwise nextStepKeyOnFalse is. - * + *

* throws {@link UnsupportedOperationException} if performAction was not called yet * * @return next step to execute diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckNotDataStreamWriteIndexStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckNotDataStreamWriteIndexStep.java index 28b04bc9614bb..fcb9c78ebefd7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckNotDataStreamWriteIndexStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckNotDataStreamWriteIndexStep.java @@ -13,11 +13,10 @@ import org.elasticsearch.cluster.metadata.IndexAbstraction; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; +import org.elasticsearch.common.Strings; import org.elasticsearch.index.Index; import org.elasticsearch.xpack.core.ilm.step.info.SingleMessageFieldInfo; -import java.util.Locale; - /** * Some actions cannot be executed on a data stream's write index (eg. `searchable-snapshot`). This step checks if the managed index is * part of a data stream, in which case it will check it's not the write index. If the managed index is the write index of a data stream @@ -46,8 +45,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { String indexName = index.getName(); if (indexMetadata == null) { - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "[%s] lifecycle action for index [%s] executed but index no longer exists", getKey().action(), indexName @@ -64,8 +62,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { if (dataStream != null) { boolean isFailureStoreWriteIndex = index.equals(dataStream.getFailureStoreWriteIndex()); if (isFailureStoreWriteIndex || dataStream.getWriteIndex().equals(index)) { - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "index [%s] is the%s write index for data stream [%s], pausing " + "ILM execution of lifecycle [%s] until this index is no longer the write index for the data stream via manual or " + "automated rollover", diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStep.java index b731dc0b6c2c8..3760684467dfb 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStep.java @@ -23,7 +23,6 @@ import org.elasticsearch.xpack.core.ilm.step.info.SingleMessageFieldInfo; import java.io.IOException; -import java.util.Locale; import java.util.Objects; /** @@ -158,8 +157,7 @@ public Info(String nodeId, long expectedShards, long numberShardsLeftToAllocate) if (numberShardsLeftToAllocate < 0) { this.message = "Waiting for all shards to become active"; } else { - this.message = String.format( - Locale.ROOT, + this.message = Strings.format( "Waiting for node [%s] to contain [%d] shards, found [%d], remaining [%d]", nodeId, expectedShards, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStep.java index 61e4446c5c522..af4b6fd4291ce 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStep.java @@ -10,11 +10,10 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; +import org.elasticsearch.common.Strings; import org.elasticsearch.index.Index; import org.elasticsearch.xpack.core.ilm.step.info.SingleMessageFieldInfo; -import java.util.Locale; - /** * This step checks whether the new shrunken index's shards count is a factor of the source index's shards count. */ @@ -53,8 +52,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { int sourceNumberOfShards = indexMetadata.getNumberOfShards(); if (sourceNumberOfShards % numberOfShards != 0) { String policyName = indexMetadata.getLifecyclePolicyName(); - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "lifecycle action of policy [%s] for index [%s] cannot make progress " + "because the target shards count [%d] must be a factor of the source index's shards count [%d]", policyName, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStep.java index 5bb226eec936a..509f96bf1bc35 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CleanupShrinkIndexStep.java @@ -66,27 +66,24 @@ void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState currentCl } getClient().admin() .indices() - .delete( - new DeleteIndexRequest(shrinkIndexName).masterNodeTimeout(TimeValue.MAX_VALUE), - new ActionListener() { - @Override - public void onResponse(AcknowledgedResponse acknowledgedResponse) { - // even if not all nodes acked the delete request yet we can consider this operation as successful as - // we'll generate a new index name and attempt to shrink into the newly generated name - listener.onResponse(null); - } + .delete(new DeleteIndexRequest(shrinkIndexName).masterNodeTimeout(TimeValue.MAX_VALUE), new ActionListener<>() { + @Override + public void onResponse(AcknowledgedResponse acknowledgedResponse) { + // even if not all nodes acked the delete request yet we can consider this operation as successful as + // we'll generate a new index name and attempt to shrink into the newly generated name + listener.onResponse(null); + } - @Override - public void onFailure(Exception e) { - if (e instanceof IndexNotFoundException) { - // we can move on if the index was deleted in the meantime - listener.onResponse(null); - } else { - listener.onFailure(e); - } + @Override + public void onFailure(Exception e) { + if (e instanceof IndexNotFoundException) { + // we can move on if the index was deleted in the meantime + listener.onResponse(null); + } else { + listener.onFailure(e); } } - ); + }); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitStep.java index bc76d53226ee0..d1dbfede63c60 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitStep.java @@ -12,7 +12,7 @@ /** * Checks whether a condition has been met based on the cluster state. - * + *

* If checking a condition not based on the cluster state, or which may take time to evaluate, use {@link AsyncWaitStep}. */ public abstract class ClusterStateWaitStep extends Step { @@ -35,19 +35,19 @@ public boolean isCompletable() { public static class Result { private final boolean complete; - private final ToXContentObject infomationContext; + private final ToXContentObject informationContext; - public Result(boolean complete, ToXContentObject infomationContext) { + public Result(boolean complete, ToXContentObject informationContext) { this.complete = complete; - this.infomationContext = infomationContext; + this.informationContext = informationContext; } public boolean isComplete() { return complete; } - public ToXContentObject getInfomationContext() { - return infomationContext; + public ToXContentObject getInformationContext() { + return informationContext; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStep.java index fc30ae07e8889..5e30baa6b9669 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStep.java @@ -19,7 +19,6 @@ import org.elasticsearch.xpack.core.ilm.step.info.SingleMessageFieldInfo; import java.time.Clock; -import java.util.Locale; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; @@ -30,7 +29,7 @@ * If the action response is complete, the {@link ClusterStateWaitUntilThresholdStep}'s nextStepKey will be the nextStepKey of the * wrapped action. When the threshold level is surpassed, if the underlying step's condition was not met, the nextStepKey will be changed to * the provided {@link #nextKeyOnThresholdBreach} and this step will stop waiting. - * + *

* Failures encountered whilst executing the wrapped action will be propagated directly. */ public class ClusterStateWaitUntilThresholdStep extends ClusterStateWaitStep { @@ -72,14 +71,13 @@ public Result isConditionMet(Index index, ClusterState clusterState) { // we may not have passed the time threshold, but the step is not completable due to a different reason thresholdPassed.set(true); - String message = String.format( - Locale.ROOT, + String message = Strings.format( "[%s] lifecycle step, as part of [%s] action, for index [%s] Is not " + "completable, reason: [%s]. Abandoning execution and moving to the next fallback step [%s]", getKey().name(), getKey().action(), idxMeta.getIndex().getName(), - Strings.toString(stepResult.getInfomationContext()), + Strings.toString(stepResult.getInformationContext()), nextKeyOnThresholdBreach ); logger.debug(message); @@ -90,8 +88,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { // we retried this step enough, next step will be the configured to {@code nextKeyOnThresholdBreach} thresholdPassed.set(true); - String message = String.format( - Locale.ROOT, + String message = Strings.format( "[%s] lifecycle step, as part of [%s] action, for index [%s] executed for" + " more than [%s]. Abandoning execution and moving to the next fallback step [%s]", getKey().name(), diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopyExecutionStateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopyExecutionStateStep.java index 6b39258bcc77f..35818943017b5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopyExecutionStateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopyExecutionStateStep.java @@ -23,7 +23,7 @@ * Copies the execution state data from one index to another, typically after a * new index has been created. As part of the execution state copy it will set the target index * "current step" to the provided target next step {@link org.elasticsearch.xpack.core.ilm.Step.StepKey}. - * + *

* Useful for actions such as shrink. */ public class CopyExecutionStateStep extends ClusterStateActionStep { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopySettingsStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopySettingsStep.java index eddeb1a4cb1b2..00180f95fb269 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopySettingsStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/CopySettingsStep.java @@ -12,11 +12,11 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; import org.elasticsearch.cluster.metadata.Metadata; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import java.util.Arrays; -import java.util.Locale; import java.util.Objects; import java.util.function.BiFunction; @@ -78,9 +78,8 @@ public ClusterState performAction(Index index, ClusterState clusterState) { String targetIndexName = targetIndexNameSupplier.apply(sourceIndexName, sourceIndexMetadata.getLifecycleExecutionState()); IndexMetadata targetIndexMetadata = clusterState.metadata().index(targetIndexName); if (targetIndexMetadata == null) { - String errorMessage = String.format( - Locale.ROOT, - "index [%s] is being referenced by ILM action [%s] on step [%s] but " + "it doesn't exist", + String errorMessage = Strings.format( + "index [%s] is being referenced by ILM action [%s] on step [%s] but it doesn't exist", targetIndexName, getKey().action(), getKey().name() diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStep.java index 855b579e8843b..b15fece92d4e2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStep.java @@ -13,12 +13,12 @@ import org.elasticsearch.cluster.metadata.DesiredNodes; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; +import org.elasticsearch.common.Strings; import org.elasticsearch.index.Index; import org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider; import org.elasticsearch.xpack.core.ilm.step.info.AllocationInfo; import java.util.List; -import java.util.Locale; import java.util.Optional; import static org.elasticsearch.xpack.core.ilm.AllocationRoutedStep.getPendingAllocations; @@ -103,8 +103,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { if (allocationPendingAllShards > 0) { String statusMessage = availableDestinationTier.map( - s -> String.format( - Locale.ROOT, + s -> Strings.format( "[%s] lifecycle action [%s] waiting for [%s] shards to be moved to the [%s] tier (tier " + "migration preference configuration is %s)", index.getName(), @@ -115,9 +114,8 @@ public Result isConditionMet(Index index, ClusterState clusterState) { ) ) .orElseGet( - () -> String.format( - Locale.ROOT, - "index [%s] has a preference for tiers %s, but no nodes for any of those tiers are " + "available in the cluster", + () -> Strings.format( + "index [%s] has a preference for tiers %s, but no nodes for any of those tiers are available in the cluster", index.getName(), preferredTierConfiguration ) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DeleteStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DeleteStep.java index 663978088f22a..1b45dc15cdd3b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DeleteStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DeleteStep.java @@ -17,11 +17,10 @@ import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexAbstraction; import org.elasticsearch.cluster.metadata.IndexMetadata; +import org.elasticsearch.common.Strings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; -import java.util.Locale; - /** * Deletes a single index. */ @@ -64,8 +63,7 @@ public void performDuringNoSnapshot(IndexMetadata indexMetadata, ClusterState cu ); return; } else if (isFailureStoreWriteIndex || dataStream.getWriteIndex().getName().equals(indexName)) { - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "index [%s] is the%s write index for data stream [%s]. " + "stopping execution of lifecycle [%s] as a data stream's write index cannot be deleted. manually rolling over the" + " index will resume the execution of the policy as the index will not be the data stream's write index anymore", diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java index 59ff38b317327..697f948e47832 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsampleAction.java @@ -213,7 +213,7 @@ public List toSteps(Client client, String phase, StepKey nextStepKey) { // upgrade was performed resume the ILM execution and complete the downsample action after upgrade.) NoopStep cleanupDownsampleIndexStep = new NoopStep(cleanupDownsampleIndexKey, downsampleKey); - // Prepare the lifecycleState by generating the name of the target index, that subsequest steps will use. + // Prepare the lifecycleState by generating the name of the target index, that subsequent steps will use. DownsamplePrepareLifeCycleStateStep generateDownsampleIndexNameStep = new DownsamplePrepareLifeCycleStateStep( generateDownsampleIndexNameKey, downsampleKey, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsamplePrepareLifeCycleStateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsamplePrepareLifeCycleStateStep.java index a5d8ef175d27d..c9f568683e3dc 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsamplePrepareLifeCycleStateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/DownsamplePrepareLifeCycleStateStep.java @@ -20,7 +20,7 @@ /** * An ILM step that sets the target index to use in the {@link DownsampleStep}. - * The reason why this is done in a seperate step and stored in {@link LifecycleExecutionState}, + * The reason why this is done in a separate step and stored in {@link LifecycleExecutionState}, * is because other steps after downsampling also depend on the target index generated here. */ public class DownsamplePrepareLifeCycleStateStep extends ClusterStateActionStep { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleRequest.java index 00bb4e6f70702..5c607335bff39 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleRequest.java @@ -18,7 +18,7 @@ /** * The request object used by the Explain Lifecycle API. - * + *

* Multiple indices may be queried in the same request using the * {@link #indices(String...)} method */ diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleResponse.java index 755851b2ec88c..914a025e35c21 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ExplainLifecycleResponse.java @@ -22,7 +22,7 @@ /** * The response object returned by the Explain Lifecycle API. - * + *

* Since the API can be run over multiple indices the response provides a map of * index to the explanation of the lifecycle status for that index. */ diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ForceMergeStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ForceMergeStep.java index 693631a7ffcd3..f3afe9e4d52cc 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ForceMergeStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ForceMergeStep.java @@ -19,7 +19,6 @@ import org.elasticsearch.common.Strings; import java.util.Arrays; -import java.util.Locale; import java.util.Objects; import java.util.stream.Collectors; @@ -62,8 +61,7 @@ public void performAction( } else { DefaultShardOperationFailedException[] failures = response.getShardFailures(); String policyName = indexMetadata.getLifecyclePolicyName(); - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "index [%s] in policy [%s] encountered failures [%s] on step [%s]", indexName, policyName, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/InitializePolicyException.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/InitializePolicyException.java index f42b20aa501e4..c8b80bc79c9e8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/InitializePolicyException.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/InitializePolicyException.java @@ -7,8 +7,7 @@ package org.elasticsearch.xpack.core.ilm; import org.elasticsearch.ElasticsearchException; - -import java.util.Locale; +import org.elasticsearch.common.Strings; /** * Exception thrown when a problem is encountered while initialising an ILM policy for an index. @@ -16,6 +15,6 @@ public class InitializePolicyException extends ElasticsearchException { public InitializePolicyException(String policy, String index, Throwable cause) { - super(String.format(Locale.ROOT, "unable to initialize policy [%s] for index [%s]", policy, index), cause); + super(Strings.format("unable to initialize policy [%s] for index [%s]", policy, index), cause); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleExecutionStateUtils.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleExecutionStateUtils.java index 4456350f3f92a..ab445ed279ea8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleExecutionStateUtils.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleExecutionStateUtils.java @@ -24,10 +24,10 @@ private LifecycleExecutionStateUtils() {} /** * Given a cluster state, index, and lifecycle state, returns a cluster state where * the lifecycle state will be associated with the given index. - * + *

* The passed-in index must already be present in the cluster state, this method cannot * be used to add an index. - * + *

* See also {@link Metadata#withLifecycleState}. */ public static ClusterState newClusterStateWithLifecycleState( diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadata.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadata.java index 529eb16b668c3..8517635da977c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadata.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadata.java @@ -38,7 +38,6 @@ public class LifecycleOperationMetadata implements Metadata.Custom { public static final ParseField SLM_OPERATION_MODE_FIELD = new ParseField("slm_operation_mode"); public static final LifecycleOperationMetadata EMPTY = new LifecycleOperationMetadata(OperationMode.RUNNING, OperationMode.RUNNING); - @SuppressWarnings("unchecked") public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( TYPE, a -> new LifecycleOperationMetadata(OperationMode.valueOf((String) a[0]), OperationMode.valueOf((String) a[1])) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicy.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicy.java index ee42eb8b3fce3..e7021d22de47e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicy.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicy.java @@ -220,16 +220,16 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws * This method is used to compile this policy into its execution plan built out * of {@link Step} instances. The order of the {@link Phase}s and {@link LifecycleAction}s is * determined by the {@link LifecycleType} associated with this policy. - * + *

* The order of the policy will have this structure: - * + *

* - initialize policy context step * - phase-1 phase-after-step * - ... phase-1 action steps * - phase-2 phase-after-step * - ... * - terminal policy step - * + *

* We first initialize the policy's context and ensure that the index has proper settings set. * Then we begin each phase's after-step along with all its actions as steps. Finally, we have * a terminal step to inform us that this policy's steps are all complete. Each phase's `after` diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicySecurityClient.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicySecurityClient.java index e8f76b655b70e..8a64dee53792f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicySecurityClient.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicySecurityClient.java @@ -21,16 +21,16 @@ * This class wraps a client and calls the client using the headers provided in * constructor. The intent is to abstract away the fact that there are headers * so {@link Step}s etc. can call this client as if it was a normal client. - * + *

* Note: This client will not close the wrapped {@link Client} instance since * the intent is that the wrapped client is shared between multiple instances of * this class. */ public class LifecyclePolicySecurityClient extends AbstractClient { - private Client client; - private Map headers; - private String origin; + private final Client client; + private final Map headers; + private final String origin; public LifecyclePolicySecurityClient(Client client, String origin, Map headers) { super(client.settings(), client.threadPool()); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyUtils.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyUtils.java index 8fe8c8835b98d..1a64e589d20b5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyUtils.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecyclePolicyUtils.java @@ -33,7 +33,7 @@ */ public class LifecyclePolicyUtils { - private LifecyclePolicyUtils() {}; + private LifecyclePolicyUtils() {} /** * Loads a built-in index lifecycle policy and returns its source. diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/OperationModeUpdateTask.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/OperationModeUpdateTask.java index 53247d6428bfb..e3719d57ca25c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/OperationModeUpdateTask.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/OperationModeUpdateTask.java @@ -23,7 +23,7 @@ /** * This task updates the operation mode state for ILM. - * + *

* As stopping ILM proved to be an action we want to sometimes take in order to allow clusters to stabilise when under heavy load this * task might run at {@link Priority#IMMEDIATE} priority so please make sure to keep this task as lightweight as possible. */ diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/PhaseCacheManagement.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/PhaseCacheManagement.java index 26966195989bb..c3e8cbb6af3bd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/PhaseCacheManagement.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/PhaseCacheManagement.java @@ -230,11 +230,7 @@ public static boolean isIndexPhaseDefinitionUpdatable( final Set newPhaseStepKeys = readStepKeys(xContentRegistry, client, peiJson, currentPhase, licenseState); if (newPhaseStepKeys == null) { logger.debug( - () -> format( - "[%s] unable to parse phase definition for policy [%s] " + "to determine if it could be refreshed", - index, - policyId - ) + () -> format("[%s] unable to parse phase definition for policy [%s] to determine if it could be refreshed", index, policyId) ); return false; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ReplaceDataStreamBackingIndexStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ReplaceDataStreamBackingIndexStep.java index 3962768e94212..8bbe68513f425 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ReplaceDataStreamBackingIndexStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ReplaceDataStreamBackingIndexStep.java @@ -14,9 +14,9 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; import org.elasticsearch.cluster.metadata.Metadata; +import org.elasticsearch.common.Strings; import org.elasticsearch.index.Index; -import java.util.Locale; import java.util.Objects; import java.util.function.BiFunction; @@ -75,8 +75,7 @@ public ClusterState performAction(Index index, ClusterState clusterState) { assert indexAbstraction != null : "invalid cluster metadata. index [" + index.getName() + "] was not found"; DataStream dataStream = indexAbstraction.getParentDataStream(); if (dataStream == null) { - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "index [%s] is not part of a data stream. stopping execution of lifecycle " + "[%s] until the index is added to a data stream", originalIndex, @@ -88,8 +87,7 @@ public ClusterState performAction(Index index, ClusterState clusterState) { boolean isFailureStoreWriteIndex = index.equals(dataStream.getFailureStoreWriteIndex()); if (isFailureStoreWriteIndex || dataStream.getWriteIndex().equals(index)) { - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "index [%s] is the%s write index for data stream [%s], pausing " + "ILM execution of lifecycle [%s] until this index is no longer the write index for the data stream via manual or " + "automated rollover", @@ -104,9 +102,8 @@ public ClusterState performAction(Index index, ClusterState clusterState) { IndexMetadata targetIndexMetadata = clusterState.metadata().index(targetIndexName); if (targetIndexMetadata == null) { - String errorMessage = String.format( - Locale.ROOT, - "target index [%s] doesn't exist. stopping execution of lifecycle [%s] for" + " index [%s]", + String errorMessage = Strings.format( + "target index [%s] doesn't exist. stopping execution of lifecycle [%s] for index [%s]", targetIndexName, policyName, originalIndex diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RolloverStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RolloverStep.java index 3d140f5a9d764..b2ca71936ca33 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RolloverStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/RolloverStep.java @@ -21,7 +21,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.core.TimeValue; -import java.util.Locale; import java.util.Objects; /** @@ -51,7 +50,7 @@ public void performAction( String indexName = indexMetadata.getIndex().getName(); boolean indexingComplete = LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE_SETTING.get(indexMetadata.getSettings()); if (indexingComplete) { - logger.trace(indexMetadata.getIndex() + " has lifecycle complete set, skipping " + RolloverStep.NAME); + logger.trace("{} has lifecycle complete set, skipping {}", indexMetadata.getIndex(), RolloverStep.NAME); listener.onResponse(null); return; } @@ -81,8 +80,7 @@ public void performAction( if (Strings.isNullOrEmpty(rolloverAlias)) { listener.onFailure( new IllegalArgumentException( - String.format( - Locale.ROOT, + Strings.format( "setting [%s] for index [%s] is empty or not defined, it must be set to the name of the alias " + "pointing to the group of indices being rolled over", RolloverAction.LIFECYCLE_ROLLOVER_ALIAS, @@ -106,8 +104,7 @@ public void performAction( if (indexMetadata.getAliases().containsKey(rolloverAlias) == false) { listener.onFailure( new IllegalArgumentException( - String.format( - Locale.ROOT, + Strings.format( "%s [%s] does not point to index [%s]", RolloverAction.LIFECYCLE_ROLLOVER_ALIAS, rolloverAlias, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SearchableSnapshotAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SearchableSnapshotAction.java index da64df2672bdb..f585575534b76 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SearchableSnapshotAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SearchableSnapshotAction.java @@ -470,5 +470,5 @@ static SearchableSnapshotMetadata extractSearchableSnapshotFromSettings(IndexMet return new SearchableSnapshotMetadata(indexName, repo, snapshotName, partial); } - record SearchableSnapshotMetadata(String sourceIndex, String repositoryName, String snapshotName, boolean partial) {}; + record SearchableSnapshotMetadata(String sourceIndex, String repositoryName, String snapshotName, boolean partial) {} } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SegmentCountStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SegmentCountStep.java index 82f502c96e8b5..800ea603ede8c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SegmentCountStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SegmentCountStep.java @@ -62,7 +62,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, if (idxSegments == null || (response.getShardFailures() != null && response.getShardFailures().length > 0)) { final DefaultShardOperationFailedException[] failures = response.getShardFailures(); logger.info( - "[{}] retrieval of segment counts after force merge did not succeed, " + "there were {} shard failures. failures: {}", + "[{}] retrieval of segment counts after force merge did not succeed, there were {} shard failures. failures: {}", index.getName(), response.getFailedShards(), failures == null diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetPriorityAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetPriorityAction.java index c94e881ad407e..376567bc2004c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetPriorityAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetPriorityAction.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Objects; /** * A {@link LifecycleAction} which sets the index's priority. The higher the priority, the faster the recovery. @@ -31,7 +32,6 @@ public class SetPriorityAction implements LifecycleAction { public static final String NAME = "set_priority"; public static final ParseField RECOVERY_PRIORITY_FIELD = new ParseField("priority"); - @SuppressWarnings("unchecked") private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( NAME, a -> new SetPriorityAction((Integer) a[0]) @@ -108,15 +108,13 @@ public List toSteps(Client client, String phase, StepKey nextStepKey) { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - SetPriorityAction that = (SetPriorityAction) o; - - return recoveryPriority != null ? recoveryPriority.equals(that.recoveryPriority) : that.recoveryPriority == null; + return Objects.equals(recoveryPriority, that.recoveryPriority); } @Override public int hashCode() { - return recoveryPriority != null ? recoveryPriority.hashCode() : 0; + return Objects.hash(recoveryPriority); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java index 1744d0e0384fd..379888493c894 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java @@ -120,7 +120,7 @@ public void performAction( // No nodes currently match the allocation rules, so report this as an error and we'll retry logger.debug("could not find any nodes to allocate index [{}] onto prior to shrink", indexName); listener.onFailure( - new NoNodeAvailableException("could not find any nodes to allocate index [" + indexName + "] onto" + " prior to shrink") + new NoNodeAvailableException("could not find any nodes to allocate index [" + indexName + "] onto prior to shrink") ); } } else { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkAction.java index 9cbcd6c62dc3b..401d87f853360 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkAction.java @@ -69,9 +69,9 @@ public class ShrinkAction implements LifecycleAction { .put(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey(), (String) null) .build(); - private Integer numberOfShards; - private ByteSizeValue maxPrimaryShardSize; - private boolean allowWriteAfterShrink; + private final Integer numberOfShards; + private final ByteSizeValue maxPrimaryShardSize; + private final boolean allowWriteAfterShrink; public static ShrinkAction parse(XContentParser parser) throws IOException { return PARSER.parse(parser, null); @@ -89,11 +89,13 @@ public ShrinkAction(@Nullable Integer numberOfShards, @Nullable ByteSizeValue ma throw new IllegalArgumentException("[max_primary_shard_size] must be greater than 0"); } this.maxPrimaryShardSize = maxPrimaryShardSize; + this.numberOfShards = null; } else { if (numberOfShards <= 0) { throw new IllegalArgumentException("[" + NUMBER_OF_SHARDS_FIELD.getPreferredName() + "] must be greater than 0"); } this.numberOfShards = numberOfShards; + this.maxPrimaryShardSize = null; } this.allowWriteAfterShrink = allowWriteAfterShrink; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkStep.java index 0628e60a7f39f..2ada24eef7cf6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkStep.java @@ -30,8 +30,8 @@ public class ShrinkStep extends AsyncActionStep { public static final String NAME = "shrink"; private static final Logger logger = LogManager.getLogger(ShrinkStep.class); - private Integer numberOfShards; - private ByteSizeValue maxPrimaryShardSize; + private final Integer numberOfShards; + private final ByteSizeValue maxPrimaryShardSize; public ShrinkStep(StepKey key, StepKey nextStepKey, Client client, Integer numberOfShards, ByteSizeValue maxPrimaryShardSize) { super(key, nextStepKey, client); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStep.java index 82e4280dcc4cc..a44b717b0a457 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStep.java @@ -15,9 +15,9 @@ import org.elasticsearch.cluster.ClusterStateObserver; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; +import org.elasticsearch.common.Strings; import org.elasticsearch.core.TimeValue; -import java.util.Locale; import java.util.Objects; import java.util.function.BiFunction; @@ -83,9 +83,8 @@ public void performAction( if (targetIndexMetadata == null) { String policyName = indexMetadata.getLifecyclePolicyName(); - String errorMessage = String.format( - Locale.ROOT, - "target index [%s] doesn't exist. stopping execution of lifecycle [%s] for" + " index [%s]", + String errorMessage = Strings.format( + "target index [%s] doesn't exist. stopping execution of lifecycle [%s] for index [%s]", targetIndexName, policyName, originalIndex diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java index 3203f85b2a7eb..48a0e65bddf22 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java @@ -197,9 +197,7 @@ public void validate(Collection phases) { } phase.getActions().forEach((actionName, action) -> { if (ALLOWED_ACTIONS.get(phase.getName()).contains(actionName) == false) { - throw new IllegalArgumentException( - "invalid action [" + actionName + "] " + "defined in phase [" + phase.getName() + "]" - ); + throw new IllegalArgumentException("invalid action [" + actionName + "] defined in phase [" + phase.getName() + "]"); } }); }); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowAction.java index ef2e807f2c247..31aaba551a3f3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowAction.java @@ -23,7 +23,7 @@ /** * Converts a CCR following index into a normal, standalone index, once the index is ready to be safely separated. - * + *

* "Readiness" is composed of two conditions: * 1) The index must have {@link LifecycleSettings#LIFECYCLE_INDEXING_COMPLETE} set to {@code true}, which is * done automatically by {@link RolloverAction} (or manually). diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowerIndexStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowerIndexStep.java index 6e07d4e6ac823..b896196185b37 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowerIndexStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowerIndexStep.java @@ -43,7 +43,7 @@ void innerPerformAction(String followerIndex, ClusterState currentClusterState, if (exception instanceof ElasticsearchException e && e.getMetadata("es.failed_to_remove_retention_leases") != null) { List leasesNotRemoved = e.getMetadata("es.failed_to_remove_retention_leases"); logger.debug( - "failed to remove leader retention lease(s) {} while unfollowing index [{}], " + "continuing with lifecycle execution", + "failed to remove leader retention lease(s) {} while unfollowing index [{}], continuing with lifecycle execution", leasesNotRemoved, followerIndex ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UpdateRolloverLifecycleDateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UpdateRolloverLifecycleDateStep.java index fe9101ea6edef..c0209ba7f6cc6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UpdateRolloverLifecycleDateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/UpdateRolloverLifecycleDateStep.java @@ -46,7 +46,7 @@ public ClusterState performAction(Index index, ClusterState currentState) { boolean indexingComplete = LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE_SETTING.get(indexMetadata.getSettings()); if (indexingComplete) { - logger.trace(indexMetadata.getIndex() + " has lifecycle complete set, skipping " + UpdateRolloverLifecycleDateStep.NAME); + logger.trace("{} has lifecycle complete set, skipping {}", indexMetadata.getIndex(), UpdateRolloverLifecycleDateStep.NAME); // The index won't have RolloverInfo if this is a Following index and indexing_complete was set by CCR, // so just use the current time. diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsStep.java index 71c99d7f21848..989223ef48da7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsStep.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.util.List; -import java.util.Locale; import java.util.Objects; import static org.elasticsearch.cluster.metadata.IndexMetadata.parseIndexNameCounter; @@ -54,8 +53,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { IndexMetadata originalIndexMeta = metadata.index(index); if (originalIndexMeta == null) { - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "[%s] lifecycle action for index [%s] executed but index no longer exists", getKey().action(), index.getName() @@ -67,8 +65,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { boolean indexingComplete = LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE_SETTING.get(originalIndexMeta.getSettings()); if (indexingComplete) { - String message = String.format( - Locale.ROOT, + String message = Strings.format( "index [%s] has lifecycle complete set, skipping [%s]", originalIndexMeta.getIndex().getName(), WaitForActiveShardsStep.NAME @@ -148,8 +145,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { } private static Result getErrorResultOnNullMetadata(StepKey key, Index originalIndex) { - String errorMessage = String.format( - Locale.ROOT, + String errorMessage = Strings.format( "unable to find the index that was rolled over from [%s] as part of lifecycle action [%s]", originalIndex.getName(), key.action() diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStep.java index 9140ff5549e15..b4c66c2f5ac22 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStep.java @@ -15,11 +15,11 @@ import org.elasticsearch.cluster.metadata.LifecycleExecutionState; import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.common.Strings; import org.elasticsearch.core.Nullable; import org.elasticsearch.index.Index; import org.elasticsearch.xpack.core.ilm.step.info.SingleMessageFieldInfo; -import java.util.Locale; import java.util.Objects; import java.util.function.BiFunction; @@ -89,9 +89,8 @@ public Result isConditionMet(Index index, ClusterState clusterState) { IndexMetadata indexMetadata = clusterState.metadata().index(indexName); // check if the (potentially) derived index exists if (indexMetadata == null) { - String errorMessage = String.format( - Locale.ROOT, - "[%s] lifecycle action for index [%s] executed but the target index [%s] " + "does not exist", + String errorMessage = Strings.format( + "[%s] lifecycle action for index [%s] executed but the target index [%s] does not exist", getKey().action(), index.getName(), indexName diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStep.java index aa20e33a3fbf2..7e074e8caea5b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStep.java @@ -24,7 +24,6 @@ import org.elasticsearch.index.Index; import org.elasticsearch.xpack.core.ilm.step.info.EmptyInfo; -import java.util.Locale; import java.util.Objects; /** @@ -108,8 +107,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, if (Strings.isNullOrEmpty(rolloverAlias)) { listener.onFailure( new IllegalArgumentException( - String.format( - Locale.ROOT, + Strings.format( "setting [%s] for index [%s] is empty or not defined", RolloverAction.LIFECYCLE_ROLLOVER_ALIAS, index.getName() @@ -147,7 +145,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, boolean indexingComplete = LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE_SETTING.get(indexMetadata.getSettings()); if (indexingComplete) { - logger.trace(index + " has lifecycle complete set, skipping " + WaitForRolloverReadyStep.NAME); + logger.trace("{} has lifecycle complete set, skipping {}", index, WaitForRolloverReadyStep.NAME); // If this index is still the write index for this alias, skipping rollover and continuing with the policy almost certainly // isn't what we want, as something likely still expects to be writing to this index. // If the alias doesn't point to this index, that's okay as that will be the result if this index is using a @@ -155,8 +153,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, if (aliasPointsToThisIndex && Boolean.TRUE.equals(isWriteIndex)) { listener.onFailure( new IllegalStateException( - String.format( - Locale.ROOT, + Strings.format( "index [%s] has [%s] set to [true], but is still the write index for alias [%s]", index.getName(), LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE, @@ -175,8 +172,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, if (aliasPointsToThisIndex == false) { listener.onFailure( new IllegalArgumentException( - String.format( - Locale.ROOT, + Strings.format( "%s [%s] does not point to index [%s]", RolloverAction.LIFECYCLE_ROLLOVER_ALIAS, rolloverAlias, @@ -191,7 +187,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, if (Boolean.FALSE.equals(isWriteIndex)) { listener.onFailure( new IllegalArgumentException( - String.format(Locale.ROOT, "index [%s] is not the write index for alias [%s]", index.getName(), rolloverAlias) + Strings.format("index [%s] is not the write index for alias [%s]", index.getName(), rolloverAlias) ) ); return; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForSnapshotStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForSnapshotStep.java index 7ce81fa90a557..74ab24445f74f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForSnapshotStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitForSnapshotStep.java @@ -13,6 +13,7 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; +import org.elasticsearch.common.Strings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; import org.elasticsearch.xcontent.ToXContentObject; @@ -21,7 +22,6 @@ import org.elasticsearch.xpack.core.slm.SnapshotLifecyclePolicyMetadata; import java.util.Date; -import java.util.Locale; import java.util.Objects; /*** @@ -87,7 +87,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, logger.debug("skipping ILM policy execution because no last snapshot start date, action time: {}", actionTime); } else { logger.debug( - "skipping ILM policy execution because snapshot start time {} is before action time {}, snapshot timestamp " + "is {}", + "skipping ILM policy execution because snapshot start time {} is before action time {}, snapshot timestamp is {}", snapPolicyMeta.getLastSuccess().getSnapshotStartTimestamp(), actionTime, snapPolicyMeta.getLastSuccess().getSnapshotFinishTimestamp() @@ -134,14 +134,14 @@ public boolean isRetryable() { private ToXContentObject notExecutedMessage(long time) { return (builder, params) -> { builder.startObject(); - builder.field(MESSAGE_FIELD, String.format(Locale.ROOT, POLICY_NOT_EXECUTED_MESSAGE, policy, new Date(time))); + builder.field(MESSAGE_FIELD, Strings.format(POLICY_NOT_EXECUTED_MESSAGE, policy, new Date(time))); builder.endObject(); return builder; }; } private static IllegalStateException error(String message, Object... args) { - return new IllegalStateException(String.format(Locale.ROOT, message, args)); + return new IllegalStateException(Strings.format(message, args)); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStep.java index 38cc39c3bfd55..50a7d48672c8e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStep.java @@ -9,6 +9,7 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; +import org.elasticsearch.common.Strings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexMode; @@ -17,14 +18,13 @@ import org.elasticsearch.xpack.core.ilm.step.info.SingleMessageFieldInfo; import java.time.Instant; -import java.util.Locale; import java.util.function.Supplier; /** * This {@link Step} waits until the {@link org.elasticsearch.index.IndexSettings#TIME_SERIES_END_TIME} passes for time series indices. * For regular indices this step doesn't wait at all and the condition is evaluated to true immediately. - * - * Note that this step doens't execute an async/transport action and is able to evaluate its condition based on the local information + *

+ * Note that this step doesn't execute an async/transport action and is able to evaluate its condition based on the local information * available however, we want this step to be executed periodically using the `AsyncWaitStep` infrastructure. * The condition will be evaluated every {@link LifecycleSettings#LIFECYCLE_POLL_INTERVAL}. */ @@ -47,7 +47,7 @@ public boolean isRetryable() { public void evaluateCondition(Metadata metadata, Index index, Listener listener, TimeValue masterTimeout) { IndexMetadata indexMetadata = metadata.index(index); assert indexMetadata != null - : "the index metadata for index [" + index.getName() + "] must exist in the cluster state for step " + "[" + NAME + "]"; + : "the index metadata for index [" + index.getName() + "] must exist in the cluster state for step [" + NAME + "]"; if (IndexSettings.MODE.get(indexMetadata.getSettings()) != IndexMode.TIME_SERIES) { // this index is not a time series index so no need to wait @@ -60,8 +60,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener, listener.onResponse( false, new SingleMessageFieldInfo( - String.format( - Locale.ROOT, + Strings.format( "The [%s] setting for index [%s] is [%s]. Waiting until the index's time series end time lapses before" + " proceeding with action [%s] as the index can still accept writes.", IndexSettings.TIME_SERIES_END_TIME.getKey(), diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java index 06a3c0da856aa..415014623f340 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java @@ -182,7 +182,7 @@ public void testClusterExcludeFiltersConditionMetOnlyOneCopyAllocated() { Result expectedResult = new ClusterStateWaitStep.Result(false, allShardsActiveAllocationInfo(1, 1)); assertEquals(expectedResult.isComplete(), actualResult.isComplete()); - assertEquals(expectedResult.getInfomationContext(), actualResult.getInfomationContext()); + assertEquals(expectedResult.getInformationContext(), actualResult.getInformationContext()); } public void testExcludeConditionMetOnlyOneCopyAllocated() { @@ -496,7 +496,7 @@ public void testExecuteIndexMissing() throws Exception { Result actualResult = step.isConditionMet(index, clusterState); assertFalse(actualResult.isComplete()); - assertNull(actualResult.getInfomationContext()); + assertNull(actualResult.getInformationContext()); } private void assertAllocateStatus( @@ -538,6 +538,6 @@ private void assertAllocateStatus( .build(); Result actualResult = step.isConditionMet(index, clusterState); assertEquals(expectedResult.isComplete(), actualResult.isComplete()); - assertEquals(expectedResult.getInfomationContext(), actualResult.getInfomationContext()); + assertEquals(expectedResult.getInformationContext(), actualResult.getInformationContext()); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckNoDataStreamWriteIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckNoDataStreamWriteIndexStepTests.java index e0957239e33a8..af9aa0982d61d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckNoDataStreamWriteIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckNoDataStreamWriteIndexStepTests.java @@ -60,7 +60,7 @@ public void testStepCompleteIfIndexIsNotPartOfDataStream() { ClusterStateWaitStep.Result result = createRandomInstance().isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), is(nullValue())); + assertThat(result.getInformationContext(), is(nullValue())); } public void testStepIncompleteIfIndexIsTheDataStreamWriteIndex() { @@ -95,7 +95,7 @@ public void testStepIncompleteIfIndexIsTheDataStreamWriteIndex() { String expectedIndexName = indexToOperateOn.getIndex().getName(); ClusterStateWaitStep.Result result = createRandomInstance().isConditionMet(indexToOperateOn.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat( info.getMessage(), is( @@ -162,6 +162,6 @@ public void testStepCompleteIfPartOfDataStreamButNotWriteIndex() { IndexMetadata indexToOperateOn = useFailureStore ? failureIndexMetadata : indexMetadata; ClusterStateWaitStep.Result result = createRandomInstance().isConditionMet(indexToOperateOn.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), is(nullValue())); + assertThat(result.getInformationContext(), is(nullValue())); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java index e46c40ca96ff7..371f7def67c52 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java @@ -418,7 +418,7 @@ public void testExecuteIndexMissing() throws Exception { ClusterStateWaitStep.Result actualResult = step.isConditionMet(index, clusterState); assertFalse(actualResult.isComplete()); - assertNull(actualResult.getInfomationContext()); + assertNull(actualResult.getInformationContext()); } public void testStepCompletableIfAllShardsActive() { @@ -576,7 +576,7 @@ public void testStepBecomesUncompletable() { ClusterStateWaitStep.Result actualResult = step.isConditionMet(index, clusterState); assertFalse(actualResult.isComplete()); assertThat( - Strings.toString(actualResult.getInfomationContext()), + Strings.toString(actualResult.getInformationContext()), containsString("node with id [node1] is currently marked as shutting down") ); assertFalse(step.isCompletable()); @@ -626,7 +626,7 @@ private void assertAllocateStatus( .build(); ClusterStateWaitStep.Result actualResult = step.isConditionMet(index, clusterState); assertEquals(expectedResult.isComplete(), actualResult.isComplete()); - assertEquals(expectedResult.getInfomationContext(), actualResult.getInfomationContext()); + assertEquals(expectedResult.getInformationContext(), actualResult.getInformationContext()); } public static UnassignedInfo randomUnassignedInfo(String message) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStepTests.java index 2b5ad6fac6921..8eb8d0f395aba 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckTargetShardsCountStepTests.java @@ -76,7 +76,7 @@ public void testStepIncompleteIfTargetShardsCountNotValid() { ClusterStateWaitStep.Result result = checkTargetShardsCountStep.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat( info.getMessage(), is( diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStepTests.java index eec2acf6da824..ea583b51c4c28 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ClusterStateWaitUntilThresholdStepTests.java @@ -71,7 +71,7 @@ public void testIndexIsMissingReturnsIncompleteResult() { ClusterState.EMPTY_STATE ); assertThat(result.isComplete(), is(false)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } public void testIsConditionMetForUnderlyingStep() { @@ -96,7 +96,7 @@ public void testIsConditionMetForUnderlyingStep() { ClusterStateWaitStep.Result result = underTest.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } { @@ -121,9 +121,9 @@ public void testIsConditionMetForUnderlyingStep() { ClusterStateWaitStep.Result result = underTest.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - assertThat(result.getInfomationContext(), notNullValue()); + assertThat(result.getInformationContext(), notNullValue()); WaitForIndexingCompleteStep.IndexingNotCompleteInfo info = (WaitForIndexingCompleteStep.IndexingNotCompleteInfo) result - .getInfomationContext(); + .getInformationContext(); assertThat( info.getMessage(), equalTo( @@ -155,7 +155,7 @@ public void testIsConditionMetForUnderlyingStep() { ClusterStateWaitStep.Result result = underTest.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); assertThat(underTest.getNextStepKey(), is(not(nextKeyOnThresholdBreach))); assertThat(underTest.getNextStepKey(), is(stepToExecute.getNextStepKey())); } @@ -185,8 +185,8 @@ public void testIsConditionMetForUnderlyingStep() { ClusterStateWaitStep.Result result = underTest.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), notNullValue()); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + assertThat(result.getInformationContext(), notNullValue()); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat( info.getMessage(), equalTo( diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStepTests.java index 8b05a3156ed04..95c1f5c4aa96b 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/DataTierMigrationRoutedStepTests.java @@ -90,7 +90,7 @@ public void testExecuteWithUnassignedShard() { Result actualResult = step.isConditionMet(index, clusterState); assertThat(actualResult.isComplete(), is(false)); - assertThat(actualResult.getInfomationContext(), is(expectedResult.getInfomationContext())); + assertThat(actualResult.getInformationContext(), is(expectedResult.getInformationContext())); } public void testExecuteWithPendingShards() { @@ -130,7 +130,7 @@ public void testExecuteWithPendingShards() { Result actualResult = step.isConditionMet(index, clusterState); assertThat(actualResult.isComplete(), is(false)); - assertThat(actualResult.getInfomationContext(), is(expectedResult.getInfomationContext())); + assertThat(actualResult.getInformationContext(), is(expectedResult.getInformationContext())); } public void testExecuteWithPendingShardsAndTargetRoleNotPresentInCluster() { @@ -164,7 +164,7 @@ public void testExecuteWithPendingShardsAndTargetRoleNotPresentInCluster() { Result actualResult = step.isConditionMet(index, clusterState); assertThat(actualResult.isComplete(), is(false)); - assertThat(actualResult.getInfomationContext(), is(expectedResult.getInfomationContext())); + assertThat(actualResult.getInformationContext(), is(expectedResult.getInformationContext())); } public void testExecuteIndexMissing() { @@ -175,7 +175,7 @@ public void testExecuteIndexMissing() { Result actualResult = step.isConditionMet(index, clusterState); assertThat(actualResult.isComplete(), is(false)); - assertThat(actualResult.getInfomationContext(), is(nullValue())); + assertThat(actualResult.getInformationContext(), is(nullValue())); } public void testExecuteIsComplete() { @@ -200,7 +200,7 @@ public void testExecuteIsComplete() { DataTierMigrationRoutedStep step = createRandomInstance(); Result result = step.isConditionMet(index, clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), is(nullValue())); + assertThat(result.getInformationContext(), is(nullValue())); } public void testExecuteWithGenericDataNodes() { @@ -221,7 +221,7 @@ public void testExecuteWithGenericDataNodes() { DataTierMigrationRoutedStep step = createRandomInstance(); Result result = step.isConditionMet(index, clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), is(nullValue())); + assertThat(result.getInformationContext(), is(nullValue())); } public void testExecuteForIndexWithoutTierRoutingInformationWaitsForReplicasToBeActive() { @@ -246,7 +246,7 @@ public void testExecuteForIndexWithoutTierRoutingInformationWaitsForReplicasToBe Result result = step.isConditionMet(index, clusterState); assertThat(result.isComplete(), is(false)); - assertThat(result.getInfomationContext(), is(expectedResult.getInfomationContext())); + assertThat(result.getInformationContext(), is(expectedResult.getInformationContext())); } { @@ -267,7 +267,7 @@ public void testExecuteForIndexWithoutTierRoutingInformationWaitsForReplicasToBe Result result = step.isConditionMet(index, clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), is(nullValue())); + assertThat(result.getInformationContext(), is(nullValue())); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ForceMergeStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ForceMergeStepTests.java index c4857a31b7a7a..dd82a648f0436 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ForceMergeStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ForceMergeStepTests.java @@ -16,7 +16,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; -import org.elasticsearch.core.Strings; +import org.elasticsearch.common.Strings; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexVersion; import org.elasticsearch.rest.RestStatus; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkShardsAllocatedStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkShardsAllocatedStepTests.java index 3f4b1adf8253b..59eff971c1643 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkShardsAllocatedStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkShardsAllocatedStepTests.java @@ -95,7 +95,7 @@ public void testConditionMet() { Result result = step.isConditionMet(originalIndexMetadata.getIndex(), clusterState); assertTrue(result.isComplete()); - assertNull(result.getInfomationContext()); + assertNull(result.getInformationContext()); } public void testConditionNotMetBecauseOfActive() { @@ -138,7 +138,7 @@ public void testConditionNotMetBecauseOfActive() { Result result = step.isConditionMet(originalIndexMetadata.getIndex(), clusterState); assertFalse(result.isComplete()); - assertEquals(new ShrunkShardsAllocatedStep.Info(true, shrinkNumberOfShards, false), result.getInfomationContext()); + assertEquals(new ShrunkShardsAllocatedStep.Info(true, shrinkNumberOfShards, false), result.getInformationContext()); } public void testConditionNotMetBecauseOfShrunkIndexDoesntExistYet() { @@ -167,6 +167,6 @@ public void testConditionNotMetBecauseOfShrunkIndexDoesntExistYet() { Result result = step.isConditionMet(originalIndexMetadata.getIndex(), clusterState); assertFalse(result.isComplete()); - assertEquals(new ShrunkShardsAllocatedStep.Info(false, -1, false), result.getInfomationContext()); + assertEquals(new ShrunkShardsAllocatedStep.Info(false, -1, false), result.getInformationContext()); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkenIndexCheckStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkenIndexCheckStepTests.java index 3c5be3c0d337b..523404a00a0c5 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkenIndexCheckStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ShrunkenIndexCheckStepTests.java @@ -60,7 +60,7 @@ public void testConditionMet() { ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).build(); Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertTrue(result.isComplete()); - assertNull(result.getInfomationContext()); + assertNull(result.getInformationContext()); } public void testConditionNotMetBecauseNotSameShrunkenIndex() { @@ -78,7 +78,7 @@ public void testConditionNotMetBecauseNotSameShrunkenIndex() { ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).build(); Result result = step.isConditionMet(shrinkIndexMetadata.getIndex(), clusterState); assertFalse(result.isComplete()); - assertEquals(new ShrunkenIndexCheckStep.Info(sourceIndex), result.getInfomationContext()); + assertEquals(new ShrunkenIndexCheckStep.Info(sourceIndex), result.getInformationContext()); } public void testConditionNotMetBecauseSourceIndexExists() { @@ -102,7 +102,7 @@ public void testConditionNotMetBecauseSourceIndexExists() { ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).build(); Result result = step.isConditionMet(shrinkIndexMetadata.getIndex(), clusterState); assertFalse(result.isComplete()); - assertEquals(new ShrunkenIndexCheckStep.Info(sourceIndex), result.getInfomationContext()); + assertEquals(new ShrunkenIndexCheckStep.Info(sourceIndex), result.getInformationContext()); } public void testIllegalState() { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsTests.java index f5f36781e011b..e12bae3b92f80 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForActiveShardsTests.java @@ -250,7 +250,7 @@ public void testResultEvaluatedOnDataStream() throws IOException { JsonXContent.contentBuilder(), ToXContent.EMPTY_PARAMS ); - String actualResultAsString = Strings.toString(result.getInfomationContext()); + String actualResultAsString = Strings.toString(result.getInformationContext()); assertThat(actualResultAsString, is(Strings.toString(expected))); assertThat(actualResultAsString, containsString("waiting for [3] shards to become active, but only [2] are active")); } @@ -294,7 +294,7 @@ public void testResultReportsMeaningfulMessage() throws IOException { JsonXContent.contentBuilder(), ToXContent.EMPTY_PARAMS ); - String actualResultAsString = Strings.toString(result.getInfomationContext()); + String actualResultAsString = Strings.toString(result.getInformationContext()); assertThat(actualResultAsString, is(Strings.toString(expected))); assertThat(actualResultAsString, containsString("waiting for [3] shards to become active, but only [2] are active")); } @@ -318,7 +318,7 @@ public void testResultReportsErrorMessage() { ClusterStateWaitStep.Result result = step.isConditionMet(new Index("index-000000", UUID.randomUUID().toString()), clusterState); assertThat(result.isComplete(), is(false)); - String actualResultAsString = Strings.toString(result.getInfomationContext()); + String actualResultAsString = Strings.toString(result.getInformationContext()); assertThat( actualResultAsString, containsString( diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForDataTierStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForDataTierStepTests.java index 3c68e929df980..3247c02cd9bac 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForDataTierStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForDataTierStepTests.java @@ -81,9 +81,9 @@ private void verify(WaitForDataTierStep step, ClusterState state, boolean comple ClusterStateWaitStep.Result result = step.isConditionMet(null, state); assertThat(result.isComplete(), is(complete)); if (message != null) { - assertThat(Strings.toString(result.getInfomationContext()), containsString(message)); + assertThat(Strings.toString(result.getInformationContext()), containsString(message)); } else { - assertThat(result.getInfomationContext(), is(nullValue())); + assertThat(result.getInformationContext(), is(nullValue())); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStepTests.java index 3e3952fa11619..0ae7b02c7400a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexColorStepTests.java @@ -94,7 +94,7 @@ public void testConditionMetForGreen() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.GREEN); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } public void testConditionNotMetForGreen() { @@ -120,7 +120,7 @@ public void testConditionNotMetForGreen() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.GREEN); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat(info, notNullValue()); assertThat(info.getMessage(), equalTo("index is not green; not all shards are active")); } @@ -140,7 +140,7 @@ public void testConditionNotMetNoIndexRoutingTable() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.YELLOW); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat(info, notNullValue()); assertThat(info.getMessage(), equalTo("index is red; no indexRoutingTable")); } @@ -168,7 +168,7 @@ public void testConditionMetForYellow() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.YELLOW); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } public void testConditionNotMetForYellow() { @@ -194,7 +194,7 @@ public void testConditionNotMetForYellow() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.YELLOW); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat(info, notNullValue()); assertThat(info.getMessage(), equalTo("index is red; not all primary shards are active")); } @@ -214,7 +214,7 @@ public void testConditionNotMetNoIndexRoutingTableForYellow() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.YELLOW); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat(info, notNullValue()); assertThat(info.getMessage(), equalTo("index is red; no indexRoutingTable")); } @@ -244,7 +244,7 @@ public void testStepReturnsFalseIfTargetIndexIsMissing() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.GREEN, indexPrefix); ClusterStateWaitStep.Result result = step.isConditionMet(originalIndex.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); String targetIndex = indexPrefix + originalIndex.getIndex().getName(); assertThat( info.getMessage(), @@ -304,7 +304,7 @@ public void testStepWaitsForTargetIndexHealthWhenPrefixConfigured() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.GREEN); ClusterStateWaitStep.Result result = step.isConditionMet(originalIndex.getIndex(), clusterTargetInitializing); assertThat(result.isComplete(), is(false)); - SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInfomationContext(); + SingleMessageFieldInfo info = (SingleMessageFieldInfo) result.getInformationContext(); assertThat(info.getMessage(), is("index is not green; not all shards are active")); } @@ -327,7 +327,7 @@ public void testStepWaitsForTargetIndexHealthWhenPrefixConfigured() { WaitForIndexColorStep step = new WaitForIndexColorStep(randomStepKey(), randomStepKey(), ClusterHealthStatus.GREEN); ClusterStateWaitStep.Result result = step.isConditionMet(originalIndex.getIndex(), clusterTargetInitializing); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexingCompleteStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexingCompleteStepTests.java index 098c609cbbd33..ad5e4c9533c99 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexingCompleteStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForIndexingCompleteStepTests.java @@ -66,7 +66,7 @@ public void testConditionMet() { WaitForIndexingCompleteStep step = createRandomInstance(); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } public void testConditionMetNotAFollowerIndex() { @@ -83,7 +83,7 @@ public void testConditionMetNotAFollowerIndex() { WaitForIndexingCompleteStep step = createRandomInstance(); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(true)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } public void testConditionNotMet() { @@ -105,9 +105,9 @@ public void testConditionNotMet() { WaitForIndexingCompleteStep step = createRandomInstance(); ClusterStateWaitStep.Result result = step.isConditionMet(indexMetadata.getIndex(), clusterState); assertThat(result.isComplete(), is(false)); - assertThat(result.getInfomationContext(), notNullValue()); + assertThat(result.getInformationContext(), notNullValue()); WaitForIndexingCompleteStep.IndexingNotCompleteInfo info = (WaitForIndexingCompleteStep.IndexingNotCompleteInfo) result - .getInfomationContext(); + .getInformationContext(); assertThat( info.getMessage(), equalTo( @@ -123,6 +123,6 @@ public void testIndexDeleted() { WaitForIndexingCompleteStep step = createRandomInstance(); ClusterStateWaitStep.Result result = step.isConditionMet(new Index("this-index-doesnt-exist", "uuid"), clusterState); assertThat(result.isComplete(), is(false)); - assertThat(result.getInfomationContext(), nullValue()); + assertThat(result.getInformationContext(), nullValue()); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForNoFollowersStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForNoFollowersStepTests.java index 01a12fb795316..b67404956deb2 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForNoFollowersStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForNoFollowersStepTests.java @@ -86,9 +86,9 @@ public void testConditionMetWhenCCREnabled() { final SetOnce stepInfoHolder = new SetOnce<>(); step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean conditionMet, ToXContentObject infomationContext) { + public void onResponse(boolean conditionMet, ToXContentObject informationContext) { conditionMetHolder.set(conditionMet); - stepInfoHolder.set(infomationContext); + stepInfoHolder.set(informationContext); } @Override @@ -120,9 +120,9 @@ public void testConditionMetWhenCCRDisabled() { final SetOnce stepInfoHolder = new SetOnce<>(); step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean conditionMet, ToXContentObject infomationContext) { + public void onResponse(boolean conditionMet, ToXContentObject informationContext) { conditionMetHolder.set(conditionMet); - stepInfoHolder.set(infomationContext); + stepInfoHolder.set(informationContext); } @Override @@ -154,9 +154,9 @@ public void testConditionNotMet() { final SetOnce stepInfoHolder = new SetOnce<>(); step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean conditionMet, ToXContentObject infomationContext) { + public void onResponse(boolean conditionMet, ToXContentObject informationContext) { conditionMetHolder.set(conditionMet); - stepInfoHolder.set(infomationContext); + stepInfoHolder.set(informationContext); } @Override @@ -195,9 +195,9 @@ public void testNoShardStats() { final SetOnce stepInfoHolder = new SetOnce<>(); step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean conditionMet, ToXContentObject infomationContext) { + public void onResponse(boolean conditionMet, ToXContentObject informationContext) { conditionMetHolder.set(conditionMet); - stepInfoHolder.set(infomationContext); + stepInfoHolder.set(informationContext); } @Override @@ -235,12 +235,12 @@ public void testFailure() { final SetOnce exceptionHolder = new SetOnce<>(); step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean conditionMet, ToXContentObject infomationContext) { + public void onResponse(boolean conditionMet, ToXContentObject informationContext) { fail( "onResponse should not be called in this test, called with conditionMet: " + conditionMet + " and stepInfo: " - + Strings.toString(infomationContext) + + Strings.toString(informationContext) ); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStepTests.java index afb17644303bb..0264f7b09c6fd 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForRolloverReadyStepTests.java @@ -237,7 +237,7 @@ public void testEvaluateCondition() { step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { conditionsMet.set(complete); } @@ -289,7 +289,7 @@ public void testEvaluateConditionOnDataStreamTarget() { step.evaluateCondition(metadata, indexToOperateOn.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { conditionsMet.set(complete); } @@ -359,7 +359,7 @@ public void testSkipRolloverIfDataStreamIsAlreadyRolledOver() { step.evaluateCondition(metadata, indexToOperateOn.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { conditionsMet.set(complete); } @@ -471,7 +471,7 @@ public void testPerformActionWriteIndexIsFalse() { step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { fail("expecting failure as the write index must be set to true or null"); } @@ -512,7 +512,7 @@ public void testPerformActionWithIndexingComplete() { step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { conditionsMet.set(complete); } @@ -543,7 +543,7 @@ public void testPerformActionWithIndexingCompleteStillWriteIndex() { step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { throw new AssertionError("Should have failed with indexing_complete but index is not write index"); } @@ -573,7 +573,7 @@ public void testPerformActionNotComplete() { step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { actionCompleted.set(complete); } @@ -615,7 +615,7 @@ public void testPerformActionFailure() { step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { throw new AssertionError("Unexpected method call"); } @@ -645,7 +645,7 @@ public void testPerformActionInvalidNullOrEmptyAlias() { SetOnce exceptionThrown = new SetOnce<>(); step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { throw new AssertionError("Unexpected method call"); } @@ -680,7 +680,7 @@ public void testPerformActionAliasDoesNotPointToIndex() { SetOnce exceptionThrown = new SetOnce<>(); step.evaluateCondition(Metadata.builder().put(indexMetadata, true).build(), indexMetadata.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { throw new AssertionError("Unexpected method call"); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStepTests.java index 50ed7ddcc3f33..8ca6c0016a791 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitUntilTimeSeriesEndTimePassesStepTests.java @@ -78,7 +78,7 @@ public void testEvaluateCondition() { step.evaluateCondition(clusterState.metadata(), previousGeneration, new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { assertThat(complete, is(true)); } @@ -96,9 +96,9 @@ public void onFailure(Exception e) { step.evaluateCondition(clusterState.metadata(), writeIndex, new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { assertThat(complete, is(false)); - String information = Strings.toString(infomationContext); + String information = Strings.toString(informationContext); assertThat( information, containsString( @@ -130,7 +130,7 @@ public void onFailure(Exception e) { step.evaluateCondition(newMetadata, indexMeta.getIndex(), new AsyncWaitStep.Listener() { @Override - public void onResponse(boolean complete, ToXContentObject infomationContext) { + public void onResponse(boolean complete, ToXContentObject informationContext) { assertThat(complete, is(true)); } diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/ExecuteStepsUpdateTask.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/ExecuteStepsUpdateTask.java index 8129fd84d222c..77b143f93576b 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/ExecuteStepsUpdateTask.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/ExecuteStepsUpdateTask.java @@ -180,7 +180,7 @@ public ClusterState doExecute(final ClusterState currentState) throws IOExceptio ); } } else { - final ToXContentObject stepInfo = result.getInfomationContext(); + final ToXContentObject stepInfo = result.getInformationContext(); if (logger.isTraceEnabled()) { logger.trace( "[{}] condition not met ({}) [{}], returning existing state (info: {})", diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/MoveToErrorStepUpdateTask.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/MoveToErrorStepUpdateTask.java index e56495bd3be05..cec4402c151a2 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/MoveToErrorStepUpdateTask.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/MoveToErrorStepUpdateTask.java @@ -15,7 +15,7 @@ import org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; -import org.elasticsearch.core.Strings; +import org.elasticsearch.common.Strings; import org.elasticsearch.index.Index; import org.elasticsearch.xpack.core.ilm.Step;