Skip to content

Commit 5072759

Browse files
authored
Remove ClusterState param from ILM AsyncBranchingStep (#129076)
The `ClusterState` parameter of the `asyncPredicate` is not used anywhere.
1 parent 8d0c9ce commit 5072759

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AsyncBranchingStep.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import org.elasticsearch.cluster.ClusterState;
1414
import org.elasticsearch.cluster.ClusterStateObserver;
1515
import org.elasticsearch.cluster.metadata.IndexMetadata;
16-
import org.elasticsearch.common.TriConsumer;
1716

1817
import java.util.Objects;
18+
import java.util.function.BiConsumer;
1919

2020
/**
2121
* This step changes its {@link #getNextStepKey()} depending on the
@@ -26,14 +26,14 @@ public class AsyncBranchingStep extends AsyncActionStep {
2626

2727
private final StepKey nextStepKeyOnFalse;
2828
private final StepKey nextStepKeyOnTrue;
29-
private final TriConsumer<IndexMetadata, ClusterState, ActionListener<Boolean>> asyncPredicate;
29+
private final BiConsumer<IndexMetadata, ActionListener<Boolean>> asyncPredicate;
3030
private final SetOnce<Boolean> predicateValue;
3131

3232
public AsyncBranchingStep(
3333
StepKey key,
3434
StepKey nextStepKeyOnFalse,
3535
StepKey nextStepKeyOnTrue,
36-
TriConsumer<IndexMetadata, ClusterState, ActionListener<Boolean>> asyncPredicate,
36+
BiConsumer<IndexMetadata, ActionListener<Boolean>> asyncPredicate,
3737
Client client
3838
) {
3939
// super.nextStepKey is set to null since it is not used by this step
@@ -56,7 +56,7 @@ public void performAction(
5656
ClusterStateObserver observer,
5757
ActionListener<Void> listener
5858
) {
59-
asyncPredicate.apply(indexMetadata, currentClusterState, listener.safeMap(value -> {
59+
asyncPredicate.accept(indexMetadata, listener.safeMap(value -> {
6060
predicateValue.set(value);
6161
return null;
6262
}));
@@ -87,7 +87,7 @@ final StepKey getNextStepKeyOnTrue() {
8787
/**
8888
* @return the next step if {@code predicate} is true
8989
*/
90-
final TriConsumer<IndexMetadata, ClusterState, ActionListener<Boolean>> getAsyncPredicate() {
90+
final BiConsumer<IndexMetadata, ActionListener<Boolean>> getAsyncPredicate() {
9191
return asyncPredicate;
9292
}
9393

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/ShrinkAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
187187
preShrinkBranchingKey,
188188
checkNotWriteIndex,
189189
lastOrNextStep,
190-
(indexMetadata, clusterState, listener) -> {
190+
(indexMetadata, listener) -> {
191191
if (indexMetadata.getSettings().get(LifecycleSettings.SNAPSHOT_INDEX_NAME) != null) {
192192
logger.warn(
193193
"[{}] action is configured for index [{}] in policy [{}] which is mounted as searchable snapshot. "

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AsyncBranchingStepTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import org.elasticsearch.cluster.ClusterState;
1212
import org.elasticsearch.cluster.metadata.IndexMetadata;
1313
import org.elasticsearch.cluster.metadata.Metadata;
14-
import org.elasticsearch.common.TriConsumer;
1514
import org.elasticsearch.index.IndexVersion;
1615
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
1716

1817
import java.util.concurrent.CountDownLatch;
1918
import java.util.concurrent.TimeUnit;
19+
import java.util.function.BiConsumer;
2020

2121
import static org.hamcrest.Matchers.equalTo;
2222

@@ -34,15 +34,15 @@ public void testPredicateNextStepChange() throws InterruptedException {
3434
StepKey nextStepKey = new StepKey(randomAlphaOfLength(6), randomAlphaOfLength(6), BranchingStep.NAME);
3535
StepKey nextSkipKey = new StepKey(randomAlphaOfLength(7), randomAlphaOfLength(7), BranchingStep.NAME);
3636
{
37-
AsyncBranchingStep step = new AsyncBranchingStep(stepKey, nextStepKey, nextSkipKey, (i, c, l) -> l.onResponse(true), client);
37+
AsyncBranchingStep step = new AsyncBranchingStep(stepKey, nextStepKey, nextSkipKey, (i, l) -> l.onResponse(true), client);
3838
expectThrows(IllegalStateException.class, step::getNextStepKey);
3939
CountDownLatch latch = new CountDownLatch(1);
4040
step.performAction(state.metadata().getProject().index(indexName), state, null, new Listener(latch));
4141
assertTrue(latch.await(5, TimeUnit.SECONDS));
4242
assertThat(step.getNextStepKey(), equalTo(step.getNextStepKeyOnTrue()));
4343
}
4444
{
45-
AsyncBranchingStep step = new AsyncBranchingStep(stepKey, nextStepKey, nextSkipKey, (i, c, l) -> l.onResponse(false), client);
45+
AsyncBranchingStep step = new AsyncBranchingStep(stepKey, nextStepKey, nextSkipKey, (i, l) -> l.onResponse(false), client);
4646
expectThrows(IllegalStateException.class, step::getNextStepKey);
4747
CountDownLatch latch = new CountDownLatch(1);
4848
step.performAction(state.metadata().getProject().index(indexName), state, null, new Listener(latch));
@@ -56,15 +56,15 @@ public AsyncBranchingStep createRandomInstance() {
5656
StepKey stepKey = new StepKey(randomAlphaOfLength(5), randomAlphaOfLength(5), BranchingStep.NAME);
5757
StepKey nextStepKey = new StepKey(randomAlphaOfLength(6), randomAlphaOfLength(6), BranchingStep.NAME);
5858
StepKey nextSkipKey = new StepKey(randomAlphaOfLength(7), randomAlphaOfLength(7), BranchingStep.NAME);
59-
return new AsyncBranchingStep(stepKey, nextStepKey, nextSkipKey, (i, c, l) -> l.onResponse(randomBoolean()), client);
59+
return new AsyncBranchingStep(stepKey, nextStepKey, nextSkipKey, (i, l) -> l.onResponse(randomBoolean()), client);
6060
}
6161

6262
@Override
6363
public AsyncBranchingStep mutateInstance(AsyncBranchingStep instance) {
6464
StepKey key = instance.getKey();
6565
StepKey nextStepKey = instance.getNextStepKeyOnFalse();
6666
StepKey nextSkipStepKey = instance.getNextStepKeyOnTrue();
67-
TriConsumer<IndexMetadata, ClusterState, ActionListener<Boolean>> asyncPredicate = instance.getAsyncPredicate();
67+
BiConsumer<IndexMetadata, ActionListener<Boolean>> asyncPredicate = instance.getAsyncPredicate();
6868

6969
switch (between(0, 2)) {
7070
case 0 -> key = new StepKey(key.phase(), key.action(), key.name() + randomAlphaOfLength(5));

0 commit comments

Comments
 (0)