Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILM: Rollup action uses GenerateUniqueIndexNameStep #70626

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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