Skip to content

Commit 9683da1

Browse files
joegalloMax Hniebergall
authored andcommitted
Clean up some older collections idioms in ILM (elastic#118508) (elastic#118582)
1 parent 2882648 commit 9683da1

File tree

82 files changed

+470
-692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+470
-692
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
2121

2222
import java.io.IOException;
23-
import java.util.Arrays;
24-
import java.util.Collections;
2523
import java.util.List;
2624
import java.util.Map;
2725
import java.util.Objects;
@@ -73,17 +71,17 @@ public AllocateAction(
7371
Map<String, String> require
7472
) {
7573
if (include == null) {
76-
this.include = Collections.emptyMap();
74+
this.include = Map.of();
7775
} else {
7876
this.include = include;
7977
}
8078
if (exclude == null) {
81-
this.exclude = Collections.emptyMap();
79+
this.exclude = Map.of();
8280
} else {
8381
this.exclude = exclude;
8482
}
8583
if (require == null) {
86-
this.require = Collections.emptyMap();
84+
this.require = Map.of();
8785
} else {
8886
this.require = require;
8987
}
@@ -201,7 +199,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
201199
}
202200
UpdateSettingsStep allocateStep = new UpdateSettingsStep(allocateKey, allocationRoutedKey, client, newSettings.build());
203201
AllocationRoutedStep routedCheckStep = new AllocationRoutedStep(allocationRoutedKey, nextStepKey);
204-
return Arrays.asList(allocateStep, routedCheckStep);
202+
return List.of(allocateStep, routedCheckStep);
205203
}
206204

207205
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.elasticsearch.common.settings.Settings;
2323
import org.elasticsearch.index.Index;
2424

25-
import java.util.Collections;
25+
import java.util.List;
2626

2727
import static org.elasticsearch.xpack.core.ilm.step.info.AllocationInfo.allShardsActiveAllocationInfo;
2828
import static org.elasticsearch.xpack.core.ilm.step.info.AllocationInfo.waitingForActiveShardsAllocationInfo;
@@ -62,7 +62,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) {
6262
}
6363

6464
AllocationDeciders allocationDeciders = new AllocationDeciders(
65-
Collections.singletonList(
65+
List.of(
6666
new FilterAllocationDecider(
6767
clusterState.getMetadata().settings(),
6868
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.io.IOException;
1919
import java.time.Instant;
20-
import java.util.Arrays;
2120
import java.util.List;
2221
import java.util.Objects;
2322

@@ -99,7 +98,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
9998
);
10099
CleanupSnapshotStep cleanupSnapshotStep = new CleanupSnapshotStep(cleanSnapshotKey, deleteStepKey, client);
101100
DeleteStep deleteStep = new DeleteStep(deleteStepKey, nextStepKey, client);
102-
return Arrays.asList(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, cleanupSnapshotStep, deleteStep);
101+
return List.of(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, cleanupSnapshotStep, deleteStep);
103102
} else {
104103
WaitForNoFollowersStep waitForNoFollowersStep = new WaitForNoFollowersStep(
105104
waitForNoFollowerStepKey,
@@ -113,7 +112,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
113112
client
114113
);
115114
DeleteStep deleteStep = new DeleteStep(deleteStepKey, nextStepKey, client);
116-
return Arrays.asList(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, deleteStep);
115+
return List.of(waitForNoFollowersStep, waitUntilTimeSeriesEndTimeStep, deleteStep);
117116
}
118117
}
119118

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.util.Arrays;
2222
import java.util.Objects;
23-
import java.util.stream.Collectors;
2423

2524
/**
2625
* Invokes a force merge on a single index.
@@ -67,10 +66,7 @@ public void performAction(
6766
policyName,
6867
failures == null
6968
? "n/a"
70-
: Strings.collectionToDelimitedString(
71-
Arrays.stream(failures).map(Strings::toString).collect(Collectors.toList()),
72-
","
73-
),
69+
: Strings.collectionToDelimitedString(Arrays.stream(failures).map(Strings::toString).toList(), ","),
7470
NAME
7571
);
7672
logger.warn(errorMessage);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
1919

2020
import java.io.IOException;
21-
import java.util.Arrays;
2221
import java.util.List;
2322

2423
/**
@@ -98,7 +97,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
9897
);
9998
CheckNotDataStreamWriteIndexStep checkNoWriteIndexStep = new CheckNotDataStreamWriteIndexStep(checkNotWriteIndex, freezeStepKey);
10099
FreezeStep freezeStep = new FreezeStep(freezeStepKey, nextStepKey, client);
101-
return Arrays.asList(conditionalSkipFreezeStep, checkNoWriteIndexStep, freezeStep);
100+
return List.of(conditionalSkipFreezeStep, checkNoWriteIndexStep, freezeStep);
102101
}
103102

104103
@Override

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.io.IOException;
2727
import java.util.List;
2828
import java.util.Map;
29-
import java.util.stream.Collectors;
3029

3130
/**
3231
* A utility class used for index lifecycle policies
@@ -121,7 +120,7 @@ public static ItemUsage calculateUsage(
121120
.stream()
122121
.filter(indexMetadata -> policyName.equals(indexMetadata.getLifecyclePolicyName()))
123122
.map(indexMetadata -> indexMetadata.getIndex().getName())
124-
.collect(Collectors.toList());
123+
.toList();
125124

126125
final List<String> allDataStreams = indexNameExpressionResolver.dataStreamNames(
127126
state,
@@ -136,12 +135,12 @@ public static ItemUsage calculateUsage(
136135
} else {
137136
return false;
138137
}
139-
}).collect(Collectors.toList());
138+
}).toList();
140139

141140
final List<String> composableTemplates = state.metadata().templatesV2().keySet().stream().filter(templateName -> {
142141
Settings settings = MetadataIndexTemplateService.resolveSettings(state.metadata(), templateName);
143142
return policyName.equals(LifecycleSettings.LIFECYCLE_NAME_SETTING.get(settings));
144-
}).collect(Collectors.toList());
143+
}).toList();
145144

146145
return new ItemUsage(indices, dataStreams, composableTemplates);
147146
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.io.IOException;
1919
import java.time.Instant;
20-
import java.util.Arrays;
2120
import java.util.List;
2221

2322
/**
@@ -72,7 +71,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
7271
client
7372
);
7473
ReadOnlyStep readOnlyStep = new ReadOnlyStep(readOnlyKey, nextStepKey, client);
75-
return Arrays.asList(checkNotWriteIndexStep, waitUntilTimeSeriesEndTimeStep, readOnlyStep);
74+
return List.of(checkNotWriteIndexStep, waitUntilTimeSeriesEndTimeStep, readOnlyStep);
7675
}
7776

7877
@Override

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
2323

2424
import java.io.IOException;
25-
import java.util.Arrays;
2625
import java.util.List;
2726
import java.util.Objects;
2827

@@ -172,7 +171,7 @@ public List<Step> toSteps(Client client, String phase, Step.StepKey nextStepKey)
172171
client,
173172
INDEXING_COMPLETE
174173
);
175-
return Arrays.asList(waitForRolloverReadyStep, rolloverStep, waitForActiveShardsStep, updateDateStep, setIndexingCompleteStep);
174+
return List.of(waitForRolloverReadyStep, rolloverStep, waitForActiveShardsStep, updateDateStep, setIndexingCompleteStep);
176175
}
177176

178177
@Override

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ public void evaluateCondition(Metadata metadata, Index index, Listener listener,
6767
response.getFailedShards(),
6868
failures == null
6969
? "n/a"
70-
: Strings.collectionToDelimitedString(
71-
Arrays.stream(failures).map(Strings::toString).collect(Collectors.toList()),
72-
","
73-
)
70+
: Strings.collectionToDelimitedString(Arrays.stream(failures).map(Strings::toString).toList(), ",")
7471
);
7572
listener.onResponse(true, new Info(-1));
7673
} else {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
2222

2323
import java.io.IOException;
24-
import java.util.Collections;
2524
import java.util.List;
2625
import java.util.Objects;
2726

@@ -101,7 +100,7 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
101100
Settings indexPriority = recoveryPriority == null
102101
? NULL_PRIORITY_SETTINGS
103102
: Settings.builder().put(IndexMetadata.INDEX_PRIORITY_SETTING.getKey(), recoveryPriority).build();
104-
return Collections.singletonList(new UpdateSettingsStep(key, nextStepKey, client, indexPriority));
103+
return List.of(new UpdateSettingsStep(key, nextStepKey, client, indexPriority));
105104
}
106105

107106
@Override

0 commit comments

Comments
 (0)