Renames AliasStep to ShrinkSetAliasStep
This commit is contained in:
parent
77be66b8b9
commit
644d82e165
|
@ -79,11 +79,11 @@ public class ShrinkAction implements LifecycleAction {
|
|||
public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey) {
|
||||
StepKey shrinkKey = new StepKey(phase, NAME, ShrinkStep.NAME);
|
||||
StepKey enoughShardsKey = new StepKey(phase, NAME, ShrunkShardsAllocatedStep.NAME);
|
||||
StepKey aliasKey = new StepKey(phase, NAME, AliasStep.NAME);
|
||||
StepKey aliasKey = new StepKey(phase, NAME, ShrinkSetAliasStep.NAME);
|
||||
StepKey isShrunkIndexKey = new StepKey(phase, NAME, ShrunkenIndexCheckStep.NAME);
|
||||
ShrinkStep shrink = new ShrinkStep(shrinkKey, enoughShardsKey, client, numberOfShards, SHRUNKEN_INDEX_PREFIX);
|
||||
ShrunkShardsAllocatedStep allocated = new ShrunkShardsAllocatedStep(enoughShardsKey, aliasKey, numberOfShards, SHRUNKEN_INDEX_PREFIX);
|
||||
AliasStep aliasSwapAndDelete = new AliasStep(aliasKey, isShrunkIndexKey, client, SHRUNKEN_INDEX_PREFIX);
|
||||
ShrinkSetAliasStep aliasSwapAndDelete = new ShrinkSetAliasStep(aliasKey, isShrunkIndexKey, client, SHRUNKEN_INDEX_PREFIX);
|
||||
ShrunkenIndexCheckStep waitOnShrinkTakeover = new ShrunkenIndexCheckStep(isShrunkIndexKey, nextStepKey, SHRUNKEN_INDEX_PREFIX);
|
||||
return Arrays.asList(shrink, allocated, aliasSwapAndDelete, waitOnShrinkTakeover);
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AliasStep extends AsyncActionStep {
|
||||
public class ShrinkSetAliasStep extends AsyncActionStep {
|
||||
public static final String NAME = "aliases";
|
||||
private String shrunkIndexPrefix;
|
||||
|
||||
public AliasStep(StepKey key, StepKey nextStepKey, Client client, String shrunkIndexPrefix) {
|
||||
public ShrinkSetAliasStep(StepKey key, StepKey nextStepKey, Client client, String shrunkIndexPrefix) {
|
||||
super(key, nextStepKey, client);
|
||||
this.shrunkIndexPrefix = shrunkIndexPrefix;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class AliasStep extends AsyncActionStep {
|
|||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
AliasStep other = (AliasStep) obj;
|
||||
ShrinkSetAliasStep other = (ShrinkSetAliasStep) obj;
|
||||
return super.equals(obj) &&
|
||||
Objects.equals(shrunkIndexPrefix, other.shrunkIndexPrefix);
|
||||
}
|
|
@ -51,7 +51,7 @@ public class ShrinkActionTests extends AbstractSerializingTestCase<ShrinkAction>
|
|||
assertThat(steps.size(), equalTo(4));
|
||||
StepKey expectedFirstKey = new StepKey(phase, ShrinkAction.NAME, ShrinkStep.NAME);
|
||||
StepKey expectedSecondKey = new StepKey(phase, ShrinkAction.NAME, ShrunkShardsAllocatedStep.NAME);
|
||||
StepKey expectedThirdKey = new StepKey(phase, ShrinkAction.NAME, AliasStep.NAME);
|
||||
StepKey expectedThirdKey = new StepKey(phase, ShrinkAction.NAME, ShrinkSetAliasStep.NAME);
|
||||
StepKey expectedFourthKey = new StepKey(phase, ShrinkAction.NAME, ShrunkenIndexCheckStep.NAME);
|
||||
assertTrue(steps.get(0) instanceof ShrinkStep);
|
||||
assertThat(steps.get(0).getKey(), equalTo(expectedFirstKey));
|
||||
|
@ -61,9 +61,9 @@ public class ShrinkActionTests extends AbstractSerializingTestCase<ShrinkAction>
|
|||
assertThat(steps.get(1).getKey(), equalTo(expectedSecondKey));
|
||||
assertThat(((ShrunkShardsAllocatedStep) steps.get(1)).getNumberOfShards(), equalTo(action.getNumberOfShards()));
|
||||
assertThat(((ShrunkShardsAllocatedStep) steps.get(1)).getShrunkIndexPrefix(), equalTo(ShrinkAction.SHRUNKEN_INDEX_PREFIX));
|
||||
assertTrue(steps.get(2) instanceof AliasStep);
|
||||
assertTrue(steps.get(2) instanceof ShrinkSetAliasStep);
|
||||
assertThat(steps.get(2).getKey(), equalTo(expectedThirdKey));
|
||||
assertThat(((AliasStep) steps.get(2)).getShrunkIndexPrefix(), equalTo(ShrinkAction.SHRUNKEN_INDEX_PREFIX));
|
||||
assertThat(((ShrinkSetAliasStep) steps.get(2)).getShrunkIndexPrefix(), equalTo(ShrinkAction.SHRUNKEN_INDEX_PREFIX));
|
||||
assertTrue(steps.get(3) instanceof ShrunkenIndexCheckStep);
|
||||
assertThat(steps.get(3).getKey(), equalTo(expectedFourthKey));
|
||||
assertThat(((ShrunkenIndexCheckStep) steps.get(3)).getShrunkIndexPrefix(), equalTo(ShrinkAction.SHRUNKEN_INDEX_PREFIX));
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class AliasStepTests extends AbstractStepTestCase<AliasStep> {
|
||||
public class ShrinkSetAliasStepTests extends AbstractStepTestCase<ShrinkSetAliasStep> {
|
||||
|
||||
private Client client;
|
||||
|
||||
|
@ -39,15 +39,15 @@ public class AliasStepTests extends AbstractStepTestCase<AliasStep> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AliasStep createRandomInstance() {
|
||||
public ShrinkSetAliasStep createRandomInstance() {
|
||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||
String shrunkIndexPrefix = randomAlphaOfLength(10);
|
||||
return new AliasStep(stepKey, nextStepKey, client, shrunkIndexPrefix);
|
||||
return new ShrinkSetAliasStep(stepKey, nextStepKey, client, shrunkIndexPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AliasStep mutateInstance(AliasStep instance) {
|
||||
public ShrinkSetAliasStep mutateInstance(ShrinkSetAliasStep instance) {
|
||||
StepKey key = instance.getKey();
|
||||
StepKey nextKey = instance.getNextStepKey();
|
||||
String shrunkIndexPrefix = instance.getShrunkIndexPrefix();
|
||||
|
@ -64,18 +64,18 @@ public class AliasStepTests extends AbstractStepTestCase<AliasStep> {
|
|||
default:
|
||||
throw new AssertionError("Illegal randomisation branch");
|
||||
}
|
||||
return new AliasStep(key, nextKey, instance.getClient(), shrunkIndexPrefix);
|
||||
return new ShrinkSetAliasStep(key, nextKey, instance.getClient(), shrunkIndexPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AliasStep copyInstance(AliasStep instance) {
|
||||
return new AliasStep(instance.getKey(), instance.getNextStepKey(), instance.getClient(), instance.getShrunkIndexPrefix());
|
||||
public ShrinkSetAliasStep copyInstance(ShrinkSetAliasStep instance) {
|
||||
return new ShrinkSetAliasStep(instance.getKey(), instance.getNextStepKey(), instance.getClient(), instance.getShrunkIndexPrefix());
|
||||
}
|
||||
|
||||
public void testPerformAction() {
|
||||
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
|
||||
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
||||
AliasStep step = createRandomInstance();
|
||||
ShrinkSetAliasStep step = createRandomInstance();
|
||||
|
||||
String sourceIndex = indexMetaData.getIndex().getName();
|
||||
String shrunkenIndex = step.getShrunkIndexPrefix() + sourceIndex;
|
||||
|
@ -128,7 +128,7 @@ public class AliasStepTests extends AbstractStepTestCase<AliasStep> {
|
|||
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
|
||||
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
||||
Exception exception = new RuntimeException();
|
||||
AliasStep step = createRandomInstance();
|
||||
ShrinkSetAliasStep step = createRandomInstance();
|
||||
|
||||
AdminClient adminClient = Mockito.mock(AdminClient.class);
|
||||
IndicesAdminClient indicesClient = Mockito.mock(IndicesAdminClient.class);
|
Loading…
Reference in New Issue