Skip to content

Commit a01f672

Browse files
committed
Rename 'custom' methods to use 'section'
1 parent 0c56507 commit a01f672

File tree

319 files changed

+1022
-991
lines changed

Some content is hidden

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

319 files changed

+1022
-991
lines changed

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/DatabaseNodeService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void checkDatabases(ClusterState state) {
251251
return;
252252
}
253253

254-
PersistentTasksMetadataSection persistentTasks = state.metadata().custom(PersistentTasksMetadataSection.TYPE);
254+
PersistentTasksMetadataSection persistentTasks = state.metadata().section(PersistentTasksMetadataSection.TYPE);
255255
if (persistentTasks == null) {
256256
logger.trace("Not checking databases because persistent tasks are null");
257257
return;

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/EnterpriseGeoIpDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void updateDatabases() throws IOException {
156156
}
157157

158158
logger.trace("Updating geoip databases");
159-
IngestGeoIpMetadata geoIpMeta = clusterState.metadata().custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
159+
IngestGeoIpMetadata geoIpMeta = clusterState.metadata().section(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
160160

161161
// if there are entries in the cs that aren't in the persistent task state,
162162
// then download those (only)

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/direct/TransportDeleteDatabaseConfigurationAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public TransportDeleteDatabaseConfigurationAction(
8787
protected void masterOperation(Task task, Request request, ClusterState state, ActionListener<AcknowledgedResponse> listener)
8888
throws Exception {
8989
final String id = request.getDatabaseId();
90-
final IngestGeoIpMetadata geoIpMeta = state.metadata().custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
90+
final IngestGeoIpMetadata geoIpMeta = state.metadata().section(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
9191
if (geoIpMeta.getDatabases().containsKey(id) == false) {
9292
throw new ResourceNotFoundException("Database configuration not found: {}", id);
9393
}
@@ -103,15 +103,15 @@ private record DeleteDatabaseConfigurationTask(ActionListener<AcknowledgedRespon
103103
ClusterStateTaskListener {
104104

105105
ClusterState execute(ClusterState currentState) throws Exception {
106-
final IngestGeoIpMetadata geoIpMeta = currentState.metadata().custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
106+
final IngestGeoIpMetadata geoIpMeta = currentState.metadata().section(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
107107

108108
logger.debug("deleting database configuration [{}]", databaseId);
109109
Map<String, DatabaseConfigurationMetadata> databases = new HashMap<>(geoIpMeta.getDatabases());
110110
databases.remove(databaseId);
111111

112112
Metadata currentMeta = currentState.metadata();
113113
return ClusterState.builder(currentState)
114-
.metadata(Metadata.builder(currentMeta).putCustom(IngestGeoIpMetadata.TYPE, new IngestGeoIpMetadata(databases)))
114+
.metadata(Metadata.builder(currentMeta).putSection(IngestGeoIpMetadata.TYPE, new IngestGeoIpMetadata(databases)))
115115
.build();
116116
}
117117

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/direct/TransportGetDatabaseConfigurationAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected void masterOperation(
7878
);
7979
}
8080

81-
final IngestGeoIpMetadata geoIpMeta = state.metadata().custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
81+
final IngestGeoIpMetadata geoIpMeta = state.metadata().section(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
8282
List<DatabaseConfigurationMetadata> results = new ArrayList<>();
8383

8484
for (String id : ids) {

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/direct/TransportPutDatabaseConfigurationAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static boolean isNoopUpdate(@Nullable DatabaseConfigurationMetadata existingData
108108

109109
static void validatePrerequisites(DatabaseConfiguration database, ClusterState state) {
110110
// we need to verify that the database represents a unique file (name) among the various databases for this same provider
111-
IngestGeoIpMetadata geoIpMeta = state.metadata().custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
111+
IngestGeoIpMetadata geoIpMeta = state.metadata().section(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
112112

113113
Optional<DatabaseConfiguration> sameName = geoIpMeta.getDatabases()
114114
.values()
@@ -131,7 +131,7 @@ private record UpdateDatabaseConfigurationTask(ActionListener<AcknowledgedRespon
131131
ClusterStateTaskListener {
132132

133133
ClusterState execute(ClusterState currentState) throws Exception {
134-
IngestGeoIpMetadata geoIpMeta = currentState.metadata().custom(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
134+
IngestGeoIpMetadata geoIpMeta = currentState.metadata().section(IngestGeoIpMetadata.TYPE, IngestGeoIpMetadata.EMPTY);
135135

136136
String id = database.id();
137137
final DatabaseConfigurationMetadata existingDatabase = geoIpMeta.getDatabases().get(id);
@@ -161,7 +161,7 @@ ClusterState execute(ClusterState currentState) throws Exception {
161161

162162
Metadata currentMeta = currentState.metadata();
163163
return ClusterState.builder(currentState)
164-
.metadata(Metadata.builder(currentMeta).putCustom(IngestGeoIpMetadata.TYPE, geoIpMeta))
164+
.metadata(Metadata.builder(currentMeta).putSection(IngestGeoIpMetadata.TYPE, geoIpMeta))
165165
.build();
166166
}
167167

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/DatabaseNodeServiceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void testCheckDatabases_dontCheckDatabaseWhenNoDatabasesIndex() throws Ex
218218
PersistentTasksMetadataSection tasksCustomMetadata = new PersistentTasksMetadataSection(1L, Map.of(taskId, task));
219219

220220
ClusterState state = ClusterState.builder(new ClusterName("name"))
221-
.metadata(Metadata.builder().putCustom(TYPE, tasksCustomMetadata).build())
221+
.metadata(Metadata.builder().putSection(TYPE, tasksCustomMetadata).build())
222222
.nodes(new DiscoveryNodes.Builder().add(DiscoveryNodeUtils.create("_id1")).localNodeId("_id1"))
223223
.build();
224224

@@ -377,7 +377,7 @@ static ClusterState createClusterState(PersistentTasksMetadataSection tasksCusto
377377
shardRouting = shardRouting.moveToStarted(ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE);
378378
}
379379
return ClusterState.builder(new ClusterName("name"))
380-
.metadata(Metadata.builder().putCustom(TYPE, tasksCustomMetadata).put(idxMeta))
380+
.metadata(Metadata.builder().putSection(TYPE, tasksCustomMetadata).put(idxMeta))
381381
.nodes(DiscoveryNodes.builder().add(DiscoveryNodeUtils.create("_id1")).localNodeId("_id1"))
382382
.routingTable(
383383
RoutingTable.builder()

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTaskExecutorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void testHasAtLeastOneGeoipProcessorWhenDownloadDatabaseOnPipelineCreatio
3838
when(clusterState.getMetadata()).thenReturn(metadata);
3939

4040
final IngestMetadata[] ingestMetadata = new IngestMetadata[1];
41-
when(metadata.custom(IngestMetadata.TYPE)).thenAnswer(invocationOnmock -> ingestMetadata[0]);
41+
when(metadata.section(IngestMetadata.TYPE)).thenAnswer(invocationOnmock -> ingestMetadata[0]);
4242

4343
final Settings[] indexSettings = new Settings[1];
4444
IndexMetadata indexMetadata = mock(IndexMetadata.class);
@@ -68,7 +68,7 @@ public void testHasAtLeastOneGeoipProcessor() throws IOException {
6868
final IngestMetadata[] ingestMetadata = new IngestMetadata[1];
6969
ClusterState clusterState = mock(ClusterState.class);
7070
Metadata metadata = mock(Metadata.class);
71-
when(metadata.custom(IngestMetadata.TYPE)).thenAnswer(invocationOnmock -> ingestMetadata[0]);
71+
when(metadata.section(IngestMetadata.TYPE)).thenAnswer(invocationOnmock -> ingestMetadata[0]);
7272
when(clusterState.getMetadata()).thenReturn(metadata);
7373
List<String> expectHitsInputs = getPipelinesWithGeoIpProcessors(true);
7474
List<String> expectMissesInputs = getPipelinesWithoutGeoIpProcessors();

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public void testDefaultDatabaseWithTaskPresent() throws Exception {
455455
.updateTaskState(GeoIpDownloader.GEOIP_DOWNLOADER, GeoIpTaskState.EMPTY)
456456
.build();
457457
ClusterState clusterState = ClusterState.builder(ClusterState.EMPTY_STATE)
458-
.metadata(Metadata.builder().putCustom(PersistentTasksMetadataSection.TYPE, tasks))
458+
.metadata(Metadata.builder().putSection(PersistentTasksMetadataSection.TYPE, tasks))
459459
.build();
460460
when(clusterService.state()).thenReturn(clusterState);
461461
GeoIpProcessor.Factory factory = new GeoIpProcessor.Factory(databaseNodeService);

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/direct/TransportPutDatabaseConfigurationActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void testValidatePrerequisites() {
2323
String name = randomAlphaOfLengthBetween(1, 50);
2424
IngestGeoIpMetadata ingestGeoIpMetadata = randomIngestGeoIpMetadata(name);
2525
ClusterState state = ClusterState.builder(ClusterState.EMPTY_STATE)
26-
.metadata(Metadata.builder(Metadata.EMPTY_METADATA).putCustom(IngestGeoIpMetadata.TYPE, ingestGeoIpMetadata))
26+
.metadata(Metadata.builder(Metadata.EMPTY_METADATA).putSection(IngestGeoIpMetadata.TYPE, ingestGeoIpMetadata))
2727
.build();
2828
DatabaseConfiguration databaseConfiguration = randomDatabaseConfiguration(randomIdentifier(), name);
2929
expectThrows(

modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void testMigrateInternalManagedSystemIndex() throws Exception {
165165
assertThat(innerMap, hasEntry("innerKey", "innerValue"));
166166

167167
// We shouldn't have any results in the cluster state as no features have fully finished yet.
168-
FeatureMigrationResults currentResults = clusterState.metadata().custom(FeatureMigrationResults.TYPE);
168+
FeatureMigrationResults currentResults = clusterState.metadata().section(FeatureMigrationResults.TYPE);
169169
assertThat(currentResults, nullValue());
170170
postUpgradeHookCalled.set(true);
171171
});
@@ -198,7 +198,7 @@ public void testMigrateInternalManagedSystemIndex() throws Exception {
198198

199199
Metadata finalMetadata = clusterAdmin().prepareState().get().getState().metadata();
200200
// Check that the results metadata is what we expect.
201-
FeatureMigrationResults currentResults = finalMetadata.custom(FeatureMigrationResults.TYPE);
201+
FeatureMigrationResults currentResults = finalMetadata.section(FeatureMigrationResults.TYPE);
202202
assertThat(currentResults, notNullValue());
203203
assertThat(currentResults.getFeatureStatuses(), allOf(aMapWithSize(1), hasKey(FEATURE_NAME)));
204204
assertThat(currentResults.getFeatureStatuses().get(FEATURE_NAME).succeeded(), is(true));
@@ -276,7 +276,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
276276
)
277277
);
278278
Metadata newMetadata = Metadata.builder(currentState.metadata())
279-
.putCustom(FeatureMigrationResults.TYPE, newResults)
279+
.putSection(FeatureMigrationResults.TYPE, newResults)
280280
.build();
281281
return ClusterState.builder(currentState).metadata(newMetadata).build();
282282
}

0 commit comments

Comments
 (0)