Remove toStepKeys from LifecycleAction (#41775)

The `toStepKeys()` method was only called in its own test case. The real
list of StepKeys that's used in action execution is generated from the
list of actual step objects returned by `toSteps()`.

This commit removes that method.
This commit is contained in:
Gordon Brown 2019-05-10 16:06:42 -06:00 committed by GitHub
parent c19ea0a6f1
commit a85189a558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1 additions and 112 deletions

View File

@ -149,13 +149,6 @@ public class AllocateAction implements LifecycleAction {
return Arrays.asList(allocateStep, routedCheckStep);
}
@Override
public List<StepKey> toStepKeys(String phase) {
StepKey allocateKey = new StepKey(phase, NAME, NAME);
StepKey allocationRoutedKey = new StepKey(phase, NAME, AllocationRoutedStep.NAME);
return Arrays.asList(allocateKey, allocationRoutedKey);
}
@Override
public int hashCode() {
return Objects.hash(numberOfReplicas, include, exclude, require);

View File

@ -12,7 +12,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
import java.io.IOException;
import java.util.Arrays;
@ -67,14 +66,6 @@ public class DeleteAction implements LifecycleAction {
return Arrays.asList(waitForNoFollowersStep, deleteStep);
}
@Override
public List<StepKey> toStepKeys(String phase) {
Step.StepKey waitForNoFollowerStepKey = new Step.StepKey(phase, NAME, WaitForNoFollowersStep.NAME);
Step.StepKey deleteStepKey = new Step.StepKey(phase, NAME, DeleteStep.NAME);
return Arrays.asList(waitForNoFollowerStepKey, deleteStepKey);
}
@Override
public int hashCode() {
return 1;

View File

@ -98,14 +98,6 @@ public class ForceMergeAction implements LifecycleAction {
return Arrays.asList(readOnlyStep, forceMergeStep, segmentCountStep);
}
@Override
public List<StepKey> toStepKeys(String phase) {
StepKey readOnlyKey = new StepKey(phase, NAME, ReadOnlyAction.NAME);
StepKey forceMergeKey = new StepKey(phase, NAME, ForceMergeStep.NAME);
StepKey countKey = new StepKey(phase, NAME, SegmentCountStep.NAME);
return Arrays.asList(readOnlyKey, forceMergeKey, countKey);
}
@Override
public int hashCode() {
return Objects.hash(maxNumSegments);

View File

@ -64,12 +64,6 @@ public class FreezeAction implements LifecycleAction {
return Arrays.asList(freezeStep);
}
@Override
public List<StepKey> toStepKeys(String phase) {
StepKey freezeStepKey = new StepKey(phase, NAME, FreezeStep.NAME);
return Arrays.asList(freezeStepKey);
}
@Override
public int hashCode() {
return 1;

View File

@ -9,7 +9,6 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
import java.util.List;
@ -30,15 +29,6 @@ public interface LifecycleAction extends ToXContentObject, NamedWriteable {
*/
List<Step> toSteps(Client client, String phase, @Nullable Step.StepKey nextStepKey);
/**
*
* @param phase
* the name of the phase this action is being executed within
* @return the {@link StepKey}s for the steps which will be executed in this
* action
*/
List<StepKey> toStepKeys(String phase);
/**
* @return true if this action is considered safe. An action is not safe if
* it will produce unwanted side effects or will get stuck when the

View File

@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
import java.io.IOException;
import java.util.Collections;
@ -66,11 +65,6 @@ public class ReadOnlyAction implements LifecycleAction {
return Collections.singletonList(new UpdateSettingsStep(key, nextStepKey, client, readOnlySettings));
}
@Override
public List<StepKey> toStepKeys(String phase) {
return Collections.singletonList(new Step.StepKey(phase, NAME, NAME));
}
@Override
public int hashCode() {
return ReadOnlyAction.class.hashCode();

View File

@ -151,15 +151,6 @@ public class RolloverAction implements LifecycleAction {
return Arrays.asList(waitForRolloverReadyStep, rolloverStep, updateDateStep, setIndexingCompleteStep);
}
@Override
public List<StepKey> toStepKeys(String phase) {
StepKey rolloverReadyStepKey = new StepKey(phase, NAME, WaitForRolloverReadyStep.NAME);
StepKey rolloverStepKey = new StepKey(phase, NAME, RolloverStep.NAME);
StepKey updateDateStepKey = new StepKey(phase, NAME, UpdateRolloverLifecycleDateStep.NAME);
StepKey setIndexingCompleteStepKey = new StepKey(phase, NAME, INDEXING_COMPLETE_STEP_NAME);
return Arrays.asList(rolloverReadyStepKey, rolloverStepKey, updateDateStepKey, setIndexingCompleteStepKey);
}
@Override
public int hashCode() {
return Objects.hash(maxSize, maxAge, maxDocs);

View File

@ -90,11 +90,6 @@ public class SetPriorityAction implements LifecycleAction {
return Collections.singletonList(new UpdateSettingsStep(key, nextStepKey, client, indexPriority));
}
@Override
public List<StepKey> toStepKeys(String phase) {
return Collections.singletonList(new StepKey(phase, NAME, NAME));
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@ -111,22 +111,6 @@ public class ShrinkAction implements LifecycleAction {
shrink, allocated, copyMetadata, aliasSwapAndDelete, waitOnShrinkTakeover);
}
@Override
public List<StepKey> toStepKeys(String phase) {
StepKey conditionalSkipKey = new StepKey(phase, NAME, BranchingStep.NAME);
StepKey waitForNoFollowerStepKey = new StepKey(phase, NAME, WaitForNoFollowersStep.NAME);
StepKey readOnlyKey = new StepKey(phase, NAME, ReadOnlyAction.NAME);
StepKey setSingleNodeKey = new StepKey(phase, NAME, SetSingleNodeAllocateStep.NAME);
StepKey checkShrinkReadyKey = new StepKey(phase, NAME, CheckShrinkReadyStep.NAME);
StepKey shrinkKey = new StepKey(phase, NAME, ShrinkStep.NAME);
StepKey enoughShardsKey = new StepKey(phase, NAME, ShrunkShardsAllocatedStep.NAME);
StepKey copyMetadataKey = new StepKey(phase, NAME, CopyExecutionStateStep.NAME);
StepKey aliasKey = new StepKey(phase, NAME, ShrinkSetAliasStep.NAME);
StepKey isShrunkIndexKey = new StepKey(phase, NAME, ShrunkenIndexCheckStep.NAME);
return Arrays.asList(conditionalSkipKey, waitForNoFollowerStepKey, readOnlyKey, setSingleNodeKey, checkShrinkReadyKey, shrinkKey,
enoughShardsKey, copyMetadataKey, aliasKey, isShrunkIndexKey);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@ -54,19 +54,6 @@ public final class UnfollowAction implements LifecycleAction {
return Arrays.asList(step1, step2, step3, step4, step5, step6, step7);
}
@Override
public List<StepKey> toStepKeys(String phase) {
StepKey indexingCompleteStep = new StepKey(phase, NAME, WaitForIndexingCompleteStep.NAME);
StepKey waitForFollowShardTasksStep = new StepKey(phase, NAME, WaitForFollowShardTasksStep.NAME);
StepKey pauseFollowerIndexStep = new StepKey(phase, NAME, PauseFollowerIndexStep.NAME);
StepKey closeFollowerIndexStep = new StepKey(phase, NAME, CloseFollowerIndexStep.NAME);
StepKey unfollowIndexStep = new StepKey(phase, NAME, UnfollowFollowIndexStep.NAME);
StepKey openFollowerIndexStep = new StepKey(phase, NAME, OpenFollowerIndexStep.NAME);
StepKey waitForYellowStep = new StepKey(phase, NAME, WaitForYellowStep.NAME);
return Arrays.asList(indexingCompleteStep, waitForFollowShardTasksStep, pauseFollowerIndexStep,
closeFollowerIndexStep, unfollowIndexStep, openFollowerIndexStep, waitForYellowStep);
}
@Override
public boolean isSafeAction() {
// There are no settings to change, so therefor this action should be safe:

View File

@ -7,10 +7,6 @@
package org.elasticsearch.xpack.core.indexlifecycle;
import org.elasticsearch.test.AbstractSerializingTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
import java.util.List;
import java.util.stream.Collectors;
public abstract class AbstractActionTestCase<T extends LifecycleAction> extends AbstractSerializingTestCase<T> {
@ -25,16 +21,4 @@ public abstract class AbstractActionTestCase<T extends LifecycleAction> extends
assertEquals(isSafeAction(), action.isSafeAction());
}
public void testToStepKeys() {
T action = createTestInstance();
String phase = randomAlphaOfLengthBetween(1, 10);
StepKey nextStepKey = new StepKey(randomAlphaOfLengthBetween(1, 10), randomAlphaOfLengthBetween(1, 10),
randomAlphaOfLengthBetween(1, 10));
List<Step> steps = action.toSteps(null, phase, nextStepKey);
assertNotNull(steps);
List<StepKey> stepKeys = action.toStepKeys(phase);
assertNotNull(stepKeys);
List<StepKey> expectedStepKeys = steps.stream().map(Step::getKey).collect(Collectors.toList());
assertEquals(expectedStepKeys, stepKeys);
}
}

View File

@ -11,7 +11,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
import java.io.IOException;
import java.util.ArrayList;
@ -75,11 +74,6 @@ public class MockAction implements LifecycleAction {
return new ArrayList<>(steps);
}
@Override
public List<StepKey> toStepKeys(String phase) {
return steps.stream().map(Step::getKey).collect(Collectors.toList());
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeList(steps.stream().map(MockStep::new).collect(Collectors.toList()));