Skip to content

Commit

Permalink
ILM: Rollup action uses GenerateUniqueIndexNameStep (#70626)
Browse files Browse the repository at this point in the history
ILM: Rollup action uses GenerateUniqueIndexNameStep
  • Loading branch information
andreidan authored Mar 23, 2021
1 parent 45f141e commit c8bb627
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 161 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class RollupILMAction implements LifecycleAction {
@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<RollupILMAction, Void> PARSER = new ConstructingObjectParser<>(NAME,
a -> new RollupILMAction((RollupActionConfig) a[0], (String) a[1]));
public static final String ROLLUP_INDEX_PREFIX = "rollup-";
public static final String GENERATE_ROLLUP_STEP_NAME = "generate-rollup-name";

private final RollupActionConfig config;
private final String rollupPolicy;
Expand Down Expand Up @@ -97,12 +99,13 @@ public boolean isSafeAction() {
public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
StepKey checkNotWriteIndex = new StepKey(phase, NAME, CheckNotDataStreamWriteIndexStep.NAME);
StepKey readOnlyKey = new StepKey(phase, NAME, ReadOnlyStep.NAME);
StepKey generateRollupIndexNameKey = new StepKey(phase, NAME, GenerateRollupIndexNameStep.NAME);
StepKey generateRollupIndexNameKey = new StepKey(phase, NAME, GENERATE_ROLLUP_STEP_NAME);
StepKey rollupKey = new StepKey(phase, NAME, NAME);
CheckNotDataStreamWriteIndexStep checkNotWriteIndexStep = new CheckNotDataStreamWriteIndexStep(checkNotWriteIndex,
readOnlyKey);
ReadOnlyStep readOnlyStep = new ReadOnlyStep(readOnlyKey, generateRollupIndexNameKey, client);
GenerateRollupIndexNameStep generateRollupIndexNameStep = new GenerateRollupIndexNameStep(generateRollupIndexNameKey, rollupKey);
GenerateUniqueIndexNameStep generateRollupIndexNameStep = new GenerateUniqueIndexNameStep(generateRollupIndexNameKey, rollupKey,
ROLLUP_INDEX_PREFIX, (rollupIndexName, lifecycleStateBuilder) -> lifecycleStateBuilder.setRollupIndexName(rollupIndexName));
if (rollupPolicy == null) {
Step rollupStep = new RollupStep(rollupKey, nextStepKey, client, config);
return List.of(checkNotWriteIndexStep, readOnlyStep, generateRollupIndexNameStep, rollupStep);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Collections;
import java.util.List;

import static org.elasticsearch.xpack.core.ilm.RollupILMAction.GENERATE_ROLLUP_STEP_NAME;
import static org.hamcrest.Matchers.equalTo;

public class RollupILMActionTests extends AbstractActionTestCase<RollupILMAction> {
Expand Down Expand Up @@ -59,8 +60,8 @@ public void testToSteps() {
assertThat(steps.get(0).getKey().getName(), equalTo(CheckNotDataStreamWriteIndexStep.NAME));
assertThat(steps.get(0).getNextStepKey().getName(), equalTo(ReadOnlyStep.NAME));
assertThat(steps.get(1).getKey().getName(), equalTo(ReadOnlyStep.NAME));
assertThat(steps.get(1).getNextStepKey().getName(), equalTo(GenerateRollupIndexNameStep.NAME));
assertThat(steps.get(2).getKey().getName(), equalTo(GenerateRollupIndexNameStep.NAME));
assertThat(steps.get(1).getNextStepKey().getName(), equalTo(GENERATE_ROLLUP_STEP_NAME));
assertThat(steps.get(2).getKey().getName(), equalTo(GENERATE_ROLLUP_STEP_NAME));
assertThat(steps.get(2).getNextStepKey().getName(), equalTo(RollupStep.NAME));
assertThat(steps.get(3).getKey().getName(), equalTo(RollupStep.NAME));
assertThat(steps.get(3).getNextStepKey(), equalTo(nextStepKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testRollupIndexAndSetNewRollupPolicy() throws Exception {
* @throws IOException if request fails
*/
private String getRollupIndexName(String index) throws IOException {
Response response = client().performRequest(new Request("GET", "/rollup-" + index + "-*"));
Response response = client().performRequest(new Request("GET", "/rollup-*-" + index));
Map<String, Object> asMap = responseAsMap(response);
if (asMap.size() == 1) {
return (String) asMap.keySet().toArray()[0];
Expand Down

0 comments on commit c8bb627

Please sign in to comment.