diff --git a/branches.json b/branches.json new file mode 100644 index 0000000000000..3f6bcc88144da --- /dev/null +++ b/branches.json @@ -0,0 +1,17 @@ +{ + "notice": "This file is not maintained outside of the main branch and should only be used for tooling.", + "branches": [ + { + "branch": "main" + }, + { + "branch": "8.10" + }, + { + "branch": "8.9" + }, + { + "branch": "7.17" + } + ] +} diff --git a/docs/changelog/98961.yaml b/docs/changelog/98961.yaml new file mode 100644 index 0000000000000..cf282b4ad7562 --- /dev/null +++ b/docs/changelog/98961.yaml @@ -0,0 +1,5 @@ +pr: 98961 +summary: Fix NPE when `GetUser` with profile uid before profile index exists +area: Security +type: bug +issues: [] diff --git a/docs/reference/esql/index.asciidoc b/docs/reference/esql/index.asciidoc index fd126cf3b3c9a..12b99cd045d43 100644 --- a/docs/reference/esql/index.asciidoc +++ b/docs/reference/esql/index.asciidoc @@ -95,9 +95,8 @@ POST /_query?format=txt [discrete] ==== {kib} -{esql} can be used in Discover to explore a data set, and in Lens to visualize it. -First, enable the `enableTextBased` setting in *Advanced Settings*. Next, in -Discover or Lens, from the data view dropdown, select *{esql}*. +Use {esql} in Discover to explore a data set. From the data view dropdown, +select *Try {esql}* to get started. NOTE: {esql} queries in Discover and Lens are subject to the time range selected with the time filter. diff --git a/docs/reference/modules/threadpool.asciidoc b/docs/reference/modules/threadpool.asciidoc index 4ca0b1339ac40..ed4becbfbb6d0 100644 --- a/docs/reference/modules/threadpool.asciidoc +++ b/docs/reference/modules/threadpool.asciidoc @@ -42,7 +42,7 @@ There are several thread pools, but the important ones include: size of `16`. `write`:: - For single-document index/delete/update and bulk requests. Thread pool type + For single-document index/delete/update, ingest processors, and bulk requests. Thread pool type is `fixed` with a size of <>, queue_size of `10000`. The maximum size for this pool is `pass:[1 + ]`<>. diff --git a/docs/reference/search/search-your-data/semantic-search-elser.asciidoc b/docs/reference/search/search-your-data/semantic-search-elser.asciidoc index 257c3b5f7d6c2..301b76a61125d 100644 --- a/docs/reference/search/search-your-data/semantic-search-elser.asciidoc +++ b/docs/reference/search/search-your-data/semantic-search-elser.asciidoc @@ -361,3 +361,9 @@ PUT my-index * {ml-docs}/ml-nlp-elser.html[How to download and deploy ELSER] * {ml-docs}/ml-nlp-limitations.html#ml-nlp-elser-v1-limit-512[ELSER v1 limitation] * https://www.elastic.co/blog/may-2023-launch-information-retrieval-elasticsearch-ai-model[Improving information retrieval in the Elastic Stack: Introducing Elastic Learned Sparse Encoder, our new retrieval model] + +[discrete] +[[interactive-example]] +==== Interactive example + +* The `elasticsearch-labs` repo has an interactive example of running https://github.com/elastic/elasticsearch-labs/blob/main/notebooks/search/03-ELSER.ipynb[ELSER-powered semantic search] using the {es} Python client. diff --git a/docs/reference/search/search-your-data/semantic-search.asciidoc b/docs/reference/search/search-your-data/semantic-search.asciidoc index 1b1c59dc234b7..96281d12102bb 100644 --- a/docs/reference/search/search-your-data/semantic-search.asciidoc +++ b/docs/reference/search/search-your-data/semantic-search.asciidoc @@ -131,5 +131,7 @@ include::{es-repo-dir}/tab-widgets/semantic-search/hybrid-search-widget.asciidoc *** {blog-ref}improving-information-retrieval-elastic-stack-benchmarking-passage-retrieval[Part 2: Benchmarking passage retrieval] *** {blog-ref}may-2023-launch-information-retrieval-elasticsearch-ai-model[Part 3: Introducing Elastic Learned Sparse Encoder, our new retrieval model] *** {blog-ref}improving-information-retrieval-elastic-stack-hybrid[Part 4: Hybrid retrieval] +* Interactive examples: +** The https://github.com/elastic/elasticsearch-labs[`elasticsearch-labs`] repo contains a number of interactive semantic search examples in the form of executable Python notebooks, using the {es} Python client -include::semantic-search-elser.asciidoc[] \ No newline at end of file +include::semantic-search-elser.asciidoc[] diff --git a/docs/reference/troubleshooting/common-issues/hotspotting.asciidoc b/docs/reference/troubleshooting/common-issues/hotspotting.asciidoc index f4b5ce3deb74b..a8ca4c7d851d1 100644 --- a/docs/reference/troubleshooting/common-issues/hotspotting.asciidoc +++ b/docs/reference/troubleshooting/common-issues/hotspotting.asciidoc @@ -259,8 +259,14 @@ direct indices:data/read/eql 10m node_1 true // TEST[skip:illustrative response only] This surfaces a problematic <>. We can gain -further insight on it via <>. Its response -contains a `description` that reports this query: +further insight on it via <>, + +[source,console] +---- +GET _tasks?human&detailed +---- + +Its response contains a `description` that reports this query: [source,eql] ---- diff --git a/modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/histogram/InternalAutoDateHistogram.java b/modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/histogram/InternalAutoDateHistogram.java index f181c34329864..5db6109d606ca 100644 --- a/modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/histogram/InternalAutoDateHistogram.java +++ b/modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/histogram/InternalAutoDateHistogram.java @@ -237,7 +237,7 @@ public InternalAutoDateHistogram(StreamInput in) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException { bucketInfo.writeTo(out); out.writeNamedWriteable(format); - out.writeList(buckets); + out.writeCollection(buckets); out.writeVInt(targetBuckets); if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_3_0)) { out.writeVLong(bucketInnerInterval); diff --git a/modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSortPipelineAggregationBuilder.java b/modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSortPipelineAggregationBuilder.java index 80f9c66814f69..079c5f984758b 100644 --- a/modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSortPipelineAggregationBuilder.java +++ b/modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSortPipelineAggregationBuilder.java @@ -100,7 +100,7 @@ public BucketSortPipelineAggregationBuilder(StreamInput in) throws IOException { @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeList(sorts); + out.writeCollection(sorts); out.writeVInt(from); out.writeOptionalVInt(size); gapPolicy.writeTo(out); diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/ExplainDataStreamLifecycleAction.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/ExplainDataStreamLifecycleAction.java index 273f846775f14..1036efed49c0b 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/ExplainDataStreamLifecycleAction.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/ExplainDataStreamLifecycleAction.java @@ -165,7 +165,7 @@ public RolloverConfiguration getRolloverConfiguration() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(indices); + out.writeCollection(indices); out.writeOptionalWriteable(rolloverConfiguration); } diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/GetDataStreamLifecycleAction.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/GetDataStreamLifecycleAction.java index 78100f6c2bec3..7071cbfec2b26 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/GetDataStreamLifecycleAction.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/lifecycle/action/GetDataStreamLifecycleAction.java @@ -205,7 +205,7 @@ public RolloverConfiguration getRolloverConfiguration() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(dataStreamLifecycles); + out.writeCollection(dataStreamLifecycles); out.writeOptionalWriteable(rolloverConfiguration); } diff --git a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsAction.java b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsAction.java index 4364d164cd287..4e7337d23f4c1 100644 --- a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsAction.java +++ b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsAction.java @@ -103,7 +103,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java index b24198f10f1f3..40abce7f3bfe3 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java @@ -116,7 +116,7 @@ public MultiSearchTemplateRequest indicesOptions(IndicesOptions indicesOptions) public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(maxConcurrentSearchRequests); - out.writeList(requests); + out.writeCollection(requests); } @Override diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextClassInfo.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextClassInfo.java index 3e1158faebd4b..d38c08a9b9ba6 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextClassInfo.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextClassInfo.java @@ -135,11 +135,11 @@ public PainlessContextClassInfo(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { out.writeString(name); out.writeBoolean(imported); - out.writeList(constructors); - out.writeList(staticMethods); - out.writeList(methods); - out.writeList(staticFields); - out.writeList(fields); + out.writeCollection(constructors); + out.writeCollection(staticMethods); + out.writeCollection(methods); + out.writeCollection(staticFields); + out.writeCollection(fields); } public static PainlessContextClassInfo fromXContent(XContentParser parser) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextInfo.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextInfo.java index 798b73a96ce14..8e8a1b698c3a0 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextInfo.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextInfo.java @@ -157,10 +157,10 @@ public PainlessContextInfo(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(name); - out.writeList(classes); - out.writeList(importedMethods); - out.writeList(classBindings); - out.writeList(instanceBindings); + out.writeCollection(classes); + out.writeCollection(importedMethods); + out.writeCollection(classBindings); + out.writeCollection(instanceBindings); } public static PainlessContextInfo fromXContent(XContentParser parser) { diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/140_dense_vector_basic.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/140_dense_vector_basic.yml index 4418a7a602eae..291f014662995 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/140_dense_vector_basic.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/140_dense_vector_basic.yml @@ -12,6 +12,7 @@ setup: properties: vector: type: dense_vector + index: false dims: 5 indexed_vector: type: dense_vector diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/145_dense_vector_byte_basic.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/145_dense_vector_byte_basic.yml index 71a43a44305d2..ed1f93ccc33db 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/145_dense_vector_byte_basic.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/145_dense_vector_byte_basic.yml @@ -14,6 +14,7 @@ setup: properties: vector: type: dense_vector + index: false element_type: byte dims: 5 indexed_vector: diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/150_dense_vector_l1l2.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/150_dense_vector_l1l2.yml index d0e3d4dcdf0c5..bd96bed42b6e0 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/150_dense_vector_l1l2.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/150_dense_vector_l1l2.yml @@ -11,6 +11,7 @@ setup: mappings: properties: my_dense_vector: + index: false type: dense_vector dims: 5 - do: diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/155_dense_vector_byte_l1l2.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/155_dense_vector_byte_l1l2.yml index cbf5dcae8b783..8b2a4f9887f95 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/155_dense_vector_byte_l1l2.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/155_dense_vector_byte_l1l2.yml @@ -13,6 +13,7 @@ setup: mappings: properties: my_dense_vector: + index: false type: dense_vector element_type: byte dims: 5 diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/160_dense_vector_special_cases.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/160_dense_vector_special_cases.yml index 7289628872c97..fc24964feafe2 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/160_dense_vector_special_cases.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/160_dense_vector_special_cases.yml @@ -13,6 +13,7 @@ setup: properties: vector: type: dense_vector + index: false dims: 3 indexed_vector: type: dense_vector diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/165_dense_vector_byte_special_cases.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/165_dense_vector_byte_special_cases.yml index 11531bd0c1461..4848b1d576458 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/165_dense_vector_byte_special_cases.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/165_dense_vector_byte_special_cases.yml @@ -15,6 +15,7 @@ setup: properties: vector: type: dense_vector + index: false element_type: byte dims: 3 indexed_vector: diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/170_dense_vector_script_access.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/170_dense_vector_script_access.yml index 38cb6fa856429..dd0cc8cde92b6 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/170_dense_vector_script_access.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/170_dense_vector_script_access.yml @@ -7,6 +7,7 @@ mappings: properties: v: + index: false type: dense_vector dims: 3 diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/175_dense_vector_byte_script_access.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/175_dense_vector_byte_script_access.yml index daa8344a1ee23..c361c0a082bcf 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/175_dense_vector_byte_script_access.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/175_dense_vector_byte_script_access.yml @@ -13,6 +13,7 @@ setup: properties: v: type: dense_vector + index: false element_type: byte dims: 3 diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/180_knn_and_binary_dv_fields_api.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/180_knn_and_binary_dv_fields_api.yml index b141eca102e08..75d2ca8d3a7a9 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/180_knn_and_binary_dv_fields_api.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/180_knn_and_binary_dv_fields_api.yml @@ -14,6 +14,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -100,6 +101,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -186,6 +188,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -306,6 +309,7 @@ bdv: type: dense_vector dims: 3 + index: false knn: type: dense_vector dims: 3 @@ -423,6 +427,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -499,6 +504,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -601,6 +607,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -719,6 +726,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -817,6 +825,7 @@ properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector diff --git a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/185_knn_and_binary_byte_dv_fields_api.yml b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/185_knn_and_binary_byte_dv_fields_api.yml index 6867230ea9978..643f694e12c3b 100644 --- a/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/185_knn_and_binary_byte_dv_fields_api.yml +++ b/modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/185_knn_and_binary_byte_dv_fields_api.yml @@ -15,6 +15,7 @@ setup: properties: bdv: type: dense_vector + index: false element_type: byte dims: 3 knn: @@ -99,6 +100,7 @@ setup: properties: bdv: type: dense_vector + index: false dims: 3 knn: type: dense_vector @@ -181,6 +183,7 @@ setup: properties: bdv: type: dense_vector + index: false element_type: byte dims: 3 knn: @@ -298,6 +301,7 @@ setup: bdv: type: dense_vector element_type: byte + index: false dims: 3 knn: type: dense_vector @@ -411,6 +415,7 @@ setup: properties: bdv: type: dense_vector + index: false element_type: byte dims: 3 knn: @@ -485,6 +490,7 @@ setup: properties: bdv: type: dense_vector + index: false element_type: byte dims: 3 knn: @@ -583,6 +589,7 @@ setup: properties: bdv: type: dense_vector + index: false element_type: byte dims: 3 knn: @@ -697,6 +704,7 @@ setup: properties: bdv: type: dense_vector + index: false element_type: byte dims: 3 knn: @@ -792,6 +800,7 @@ setup: properties: bdv: type: dense_vector + index: false element_type: byte dims: 3 knn: diff --git a/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiLineStringBuilder.java b/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiLineStringBuilder.java index da92929699737..9756856b072d7 100644 --- a/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiLineStringBuilder.java +++ b/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiLineStringBuilder.java @@ -49,7 +49,7 @@ public MultiLineStringBuilder() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(lines); + out.writeCollection(lines); } public MultiLineStringBuilder linestring(LineStringBuilder line) { diff --git a/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiPolygonBuilder.java b/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiPolygonBuilder.java index 59ed15bbdca4e..be943c3f5066d 100644 --- a/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiPolygonBuilder.java +++ b/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/MultiPolygonBuilder.java @@ -63,7 +63,7 @@ public MultiPolygonBuilder(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { orientation.writeTo(out); - out.writeList(polygons); + out.writeCollection(polygons); } public Orientation orientation() { diff --git a/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/PolygonBuilder.java b/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/PolygonBuilder.java index f9a01028f8650..46cc6a131415f 100644 --- a/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/PolygonBuilder.java +++ b/modules/legacy-geo/src/main/java/org/elasticsearch/legacygeo/builders/PolygonBuilder.java @@ -93,7 +93,7 @@ public PolygonBuilder(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { shell.writeTo(out); orientation.writeTo(out); - out.writeList(holes); + out.writeCollection(holes); } public Orientation orientation() { diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/EvalQueryQuality.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/EvalQueryQuality.java index 5436aa41c285b..a5ed5a109bbe3 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/EvalQueryQuality.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/EvalQueryQuality.java @@ -59,7 +59,7 @@ private EvalQueryQuality(String queryId, ParsedEvalQueryQuality builder) { public void writeTo(StreamOutput out) throws IOException { out.writeString(queryId); out.writeDouble(metricScore); - out.writeList(ratedHits); + out.writeCollection(ratedHits); out.writeOptionalNamedWriteable(this.optionalMetricDetails); } diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java index 89d5561f72ed0..9eec71cc8bbc1 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java @@ -96,7 +96,7 @@ public RankEvalSpec(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(ratedRequests); + out.writeCollection(ratedRequests); out.writeNamedWriteable(metric); out.writeMap(templates, StreamOutput::writeString, (o, v) -> v.writeTo(o)); out.writeVInt(maxConcurrentSearches); diff --git a/modules/reindex/src/test/java/org/elasticsearch/reindex/DeleteByQueryBasicTests.java b/modules/reindex/src/test/java/org/elasticsearch/reindex/DeleteByQueryBasicTests.java index e77fd22588ea5..e159d214c0dab 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/reindex/DeleteByQueryBasicTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/reindex/DeleteByQueryBasicTests.java @@ -244,6 +244,7 @@ public void testDeleteByQueryOnReadOnlyAllowDeleteIndex() throws Exception { if (diskAllocationDeciderEnabled == false) { // Disable the disk allocation decider to ensure the read_only_allow_delete block cannot be released setDiskAllocationDeciderEnabled(false); + refreshClusterInfo(); // ensures the logic for removing blocks upon disabling the decider is executed once } // When a read_only_allow_delete block is set on the index, // it will trigger a retry policy in the delete by query request because the rest status of the block is 429 diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpHeaderValidatorTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpHeaderValidatorTests.java index 80356e2e37172..a2c034acdcb8d 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpHeaderValidatorTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpHeaderValidatorTests.java @@ -632,32 +632,36 @@ public void testFullRequestValidationSuccess() { assertThat(netty4HttpHeaderValidator.getState(), equalTo(WAITING_TO_START)); ByteBuf buf = channel.alloc().buffer(); - ByteBufUtil.copy(AsciiString.of("test full http request"), buf); - final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/uri", buf); - channel.writeInbound(request); + try { + ByteBufUtil.copy(AsciiString.of("test full http request"), buf); + final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/uri", buf); + channel.writeInbound(request); - // request got through to validation - assertThat(header.get(), sameInstance(request)); - // channel is paused - assertThat(channel.readInbound(), nullValue()); - assertFalse(channel.config().isAutoRead()); + // request got through to validation + assertThat(header.get(), sameInstance(request)); + // channel is paused + assertThat(channel.readInbound(), nullValue()); + assertFalse(channel.config().isAutoRead()); - // validation succeeds - listener.get().onResponse(null); - channel.runPendingTasks(); + // validation succeeds + listener.get().onResponse(null); + channel.runPendingTasks(); - // channel is resumed and waiting for next request - assertTrue(channel.config().isAutoRead()); - assertThat(netty4HttpHeaderValidator.getState(), equalTo(WAITING_TO_START)); + // channel is resumed and waiting for next request + assertTrue(channel.config().isAutoRead()); + assertThat(netty4HttpHeaderValidator.getState(), equalTo(WAITING_TO_START)); - DefaultFullHttpRequest throughRequest = channel.readInbound(); - // request goes through unaltered - assertThat(throughRequest, sameInstance(request)); - assertFalse(throughRequest.decoderResult().isFailure()); - // the content is unaltered - assertThat(new String(ByteBufUtil.getBytes(throughRequest.content()), StandardCharsets.UTF_8), is("test full http request")); - assertThat(buf.refCnt(), is(1)); - assertThat(throughRequest.decoderResult().cause(), nullValue()); + DefaultFullHttpRequest throughRequest = channel.readInbound(); + // request goes through unaltered + assertThat(throughRequest, sameInstance(request)); + assertFalse(throughRequest.decoderResult().isFailure()); + // the content is unaltered + assertThat(new String(ByteBufUtil.getBytes(throughRequest.content()), StandardCharsets.UTF_8), is("test full http request")); + assertThat(buf.refCnt(), is(1)); + assertThat(throughRequest.decoderResult().cause(), nullValue()); + } finally { + buf.release(); + } } public void testFullRequestWithDecoderException() { @@ -665,27 +669,31 @@ public void testFullRequestWithDecoderException() { assertThat(netty4HttpHeaderValidator.getState(), equalTo(WAITING_TO_START)); ByteBuf buf = channel.alloc().buffer(); - ByteBufUtil.copy(AsciiString.of("test full http request"), buf); - // a request with a decoder error prior to validation - final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/uri", buf); - Exception cause = new ElasticsearchException("Boom"); - request.setDecoderResult(DecoderResult.failure(cause)); - channel.writeInbound(request); + try { + ByteBufUtil.copy(AsciiString.of("test full http request"), buf); + // a request with a decoder error prior to validation + final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/uri", buf); + Exception cause = new ElasticsearchException("Boom"); + request.setDecoderResult(DecoderResult.failure(cause)); + channel.writeInbound(request); - // request goes through without invoking the validator - assertThat(header.get(), nullValue()); - assertThat(listener.get(), nullValue()); - // channel is NOT paused - assertTrue(channel.config().isAutoRead()); - assertThat(netty4HttpHeaderValidator.getState(), equalTo(WAITING_TO_START)); + // request goes through without invoking the validator + assertThat(header.get(), nullValue()); + assertThat(listener.get(), nullValue()); + // channel is NOT paused + assertTrue(channel.config().isAutoRead()); + assertThat(netty4HttpHeaderValidator.getState(), equalTo(WAITING_TO_START)); - DefaultFullHttpRequest throughRequest = channel.readInbound(); - // request goes through unaltered - assertThat(throughRequest, sameInstance(request)); - assertTrue(throughRequest.decoderResult().isFailure()); - assertThat(throughRequest.decoderResult().cause(), equalTo(cause)); - // the content is unaltered - assertThat(new String(ByteBufUtil.getBytes(throughRequest.content()), StandardCharsets.UTF_8), is("test full http request")); - assertThat(buf.refCnt(), is(1)); + DefaultFullHttpRequest throughRequest = channel.readInbound(); + // request goes through unaltered + assertThat(throughRequest, sameInstance(request)); + assertTrue(throughRequest.decoderResult().isFailure()); + assertThat(throughRequest.decoderResult().cause(), equalTo(cause)); + // the content is unaltered + assertThat(new String(ByteBufUtil.getBytes(throughRequest.content()), StandardCharsets.UTF_8), is("test full http request")); + assertThat(buf.refCnt(), is(1)); + } finally { + buf.release(); + } } } diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedFullClusterRestartTestCase.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedFullClusterRestartTestCase.java index bb22311337cc0..4609b27db2909 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedFullClusterRestartTestCase.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedFullClusterRestartTestCase.java @@ -24,7 +24,7 @@ import static org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus.OLD; import static org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus.UPGRADED; -import static org.hamcrest.Matchers.lessThanOrEqualTo; +import static org.hamcrest.Matchers.lessThan; @TestCaseOrdering(FullClusterRestartTestOrdering.class) public abstract class ParameterizedFullClusterRestartTestCase extends ESRestTestCase { @@ -85,11 +85,7 @@ public static IndexVersion getOldClusterIndexVersion() { if (version.equals(org.elasticsearch.Version.CURRENT)) { return IndexVersion.current(); } else { - assertThat( - "Index version needs to be added to restart test parameters", - version, - lessThanOrEqualTo(org.elasticsearch.Version.V_8_10_0) - ); + assertThat("Index version needs to be added to restart test parameters", version, lessThan(org.elasticsearch.Version.V_8_11_0)); return IndexVersion.fromId(version.id); } } diff --git a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_vector_search.yml b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_vector_search.yml index b471fa56a47a5..11e9fdc2cca95 100644 --- a/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_vector_search.yml +++ b/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/30_vector_search.yml @@ -11,6 +11,7 @@ bdv: type: dense_vector dims: 3 + index: false knn: type: dense_vector dims: 3 @@ -125,6 +126,7 @@ bdv: type: dense_vector element_type: byte + index: false dims: 3 knn: type: dense_vector diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java index 1382e0c30adae..c1ee6adf0313a 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java @@ -457,7 +457,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeInt(id); node.writeTo(out); - out.writeList(subRequests); + out.writeCollection(subRequests); out.writeBoolean(timeout); } diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index fef6186608110..ad8bf411d718c 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -15,7 +15,6 @@ import org.elasticsearch.core.Assertions; import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.core.SuppressForbidden; -import org.elasticsearch.index.IndexVersion; import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.xcontent.ToXContentFragment; import org.elasticsearch.xcontent.XContentBuilder; @@ -30,7 +29,6 @@ import java.util.Locale; import java.util.Map; import java.util.NavigableMap; -import java.util.Objects; import java.util.TreeMap; public class Version implements VersionId, ToXContentFragment { @@ -51,105 +49,105 @@ public class Version implements VersionId, ToXContentFragment { */ public static final int V_EMPTY_ID = 0; - public static final Version V_EMPTY = new Version(V_EMPTY_ID, IndexVersion.ZERO); - public static final Version V_7_0_0 = new Version(7_00_00_99, IndexVersion.V_7_0_0); - public static final Version V_7_0_1 = new Version(7_00_01_99, IndexVersion.V_7_0_1); - public static final Version V_7_1_0 = new Version(7_01_00_99, IndexVersion.V_7_1_0); - public static final Version V_7_1_1 = new Version(7_01_01_99, IndexVersion.V_7_1_1); - public static final Version V_7_2_0 = new Version(7_02_00_99, IndexVersion.V_7_2_0); - public static final Version V_7_2_1 = new Version(7_02_01_99, IndexVersion.V_7_2_1); - public static final Version V_7_3_0 = new Version(7_03_00_99, IndexVersion.V_7_3_0); - public static final Version V_7_3_1 = new Version(7_03_01_99, IndexVersion.V_7_3_1); - public static final Version V_7_3_2 = new Version(7_03_02_99, IndexVersion.V_7_3_2); - public static final Version V_7_4_0 = new Version(7_04_00_99, IndexVersion.V_7_4_0); - public static final Version V_7_4_1 = new Version(7_04_01_99, IndexVersion.V_7_4_1); - public static final Version V_7_4_2 = new Version(7_04_02_99, IndexVersion.V_7_4_2); - public static final Version V_7_5_0 = new Version(7_05_00_99, IndexVersion.V_7_5_0); - public static final Version V_7_5_1 = new Version(7_05_01_99, IndexVersion.V_7_5_1); - public static final Version V_7_5_2 = new Version(7_05_02_99, IndexVersion.V_7_5_2); - public static final Version V_7_6_0 = new Version(7_06_00_99, IndexVersion.V_7_6_0); - public static final Version V_7_6_1 = new Version(7_06_01_99, IndexVersion.V_7_6_1); - public static final Version V_7_6_2 = new Version(7_06_02_99, IndexVersion.V_7_6_2); - public static final Version V_7_7_0 = new Version(7_07_00_99, IndexVersion.V_7_7_0); - public static final Version V_7_7_1 = new Version(7_07_01_99, IndexVersion.V_7_7_1); - public static final Version V_7_8_0 = new Version(7_08_00_99, IndexVersion.V_7_8_0); - public static final Version V_7_8_1 = new Version(7_08_01_99, IndexVersion.V_7_8_1); - public static final Version V_7_9_0 = new Version(7_09_00_99, IndexVersion.V_7_9_0); - public static final Version V_7_9_1 = new Version(7_09_01_99, IndexVersion.V_7_9_1); - public static final Version V_7_9_2 = new Version(7_09_02_99, IndexVersion.V_7_9_2); - public static final Version V_7_9_3 = new Version(7_09_03_99, IndexVersion.V_7_9_3); - public static final Version V_7_10_0 = new Version(7_10_00_99, IndexVersion.V_7_10_0); - public static final Version V_7_10_1 = new Version(7_10_01_99, IndexVersion.V_7_10_1); - public static final Version V_7_10_2 = new Version(7_10_02_99, IndexVersion.V_7_10_2); - public static final Version V_7_11_0 = new Version(7_11_00_99, IndexVersion.V_7_11_0); - public static final Version V_7_11_1 = new Version(7_11_01_99, IndexVersion.V_7_11_1); - public static final Version V_7_11_2 = new Version(7_11_02_99, IndexVersion.V_7_11_2); - public static final Version V_7_12_0 = new Version(7_12_00_99, IndexVersion.V_7_12_0); - public static final Version V_7_12_1 = new Version(7_12_01_99, IndexVersion.V_7_12_1); - public static final Version V_7_13_0 = new Version(7_13_00_99, IndexVersion.V_7_13_0); - public static final Version V_7_13_1 = new Version(7_13_01_99, IndexVersion.V_7_13_1); - public static final Version V_7_13_2 = new Version(7_13_02_99, IndexVersion.V_7_13_2); - public static final Version V_7_13_3 = new Version(7_13_03_99, IndexVersion.V_7_13_3); - public static final Version V_7_13_4 = new Version(7_13_04_99, IndexVersion.V_7_13_4); - public static final Version V_7_14_0 = new Version(7_14_00_99, IndexVersion.V_7_14_0); - public static final Version V_7_14_1 = new Version(7_14_01_99, IndexVersion.V_7_14_1); - public static final Version V_7_14_2 = new Version(7_14_02_99, IndexVersion.V_7_14_2); - public static final Version V_7_15_0 = new Version(7_15_00_99, IndexVersion.V_7_15_0); - public static final Version V_7_15_1 = new Version(7_15_01_99, IndexVersion.V_7_15_1); - public static final Version V_7_15_2 = new Version(7_15_02_99, IndexVersion.V_7_15_2); - public static final Version V_7_16_0 = new Version(7_16_00_99, IndexVersion.V_7_16_0); - public static final Version V_7_16_1 = new Version(7_16_01_99, IndexVersion.V_7_16_1); - public static final Version V_7_16_2 = new Version(7_16_02_99, IndexVersion.V_7_16_2); - public static final Version V_7_16_3 = new Version(7_16_03_99, IndexVersion.V_7_16_3); - public static final Version V_7_17_0 = new Version(7_17_00_99, IndexVersion.V_7_17_0); - public static final Version V_7_17_1 = new Version(7_17_01_99, IndexVersion.V_7_17_1); - public static final Version V_7_17_2 = new Version(7_17_02_99, IndexVersion.V_7_17_2); - public static final Version V_7_17_3 = new Version(7_17_03_99, IndexVersion.V_7_17_3); - public static final Version V_7_17_4 = new Version(7_17_04_99, IndexVersion.V_7_17_4); - public static final Version V_7_17_5 = new Version(7_17_05_99, IndexVersion.V_7_17_5); - public static final Version V_7_17_6 = new Version(7_17_06_99, IndexVersion.V_7_17_6); - public static final Version V_7_17_7 = new Version(7_17_07_99, IndexVersion.V_7_17_7); - public static final Version V_7_17_8 = new Version(7_17_08_99, IndexVersion.V_7_17_8); - public static final Version V_7_17_9 = new Version(7_17_09_99, IndexVersion.V_7_17_9); - public static final Version V_7_17_10 = new Version(7_17_10_99, IndexVersion.V_7_17_10); - public static final Version V_7_17_11 = new Version(7_17_11_99, IndexVersion.V_7_17_11); - public static final Version V_7_17_12 = new Version(7_17_12_99, IndexVersion.V_7_17_12); - public static final Version V_7_17_13 = new Version(7_17_13_99, IndexVersion.V_7_17_13); - public static final Version V_8_0_0 = new Version(8_00_00_99, IndexVersion.V_8_0_0); - public static final Version V_8_0_1 = new Version(8_00_01_99, IndexVersion.V_8_0_1); - public static final Version V_8_1_0 = new Version(8_01_00_99, IndexVersion.V_8_1_0); - public static final Version V_8_1_1 = new Version(8_01_01_99, IndexVersion.V_8_1_1); - public static final Version V_8_1_2 = new Version(8_01_02_99, IndexVersion.V_8_1_2); - public static final Version V_8_1_3 = new Version(8_01_03_99, IndexVersion.V_8_1_3); - public static final Version V_8_2_0 = new Version(8_02_00_99, IndexVersion.V_8_2_0); - public static final Version V_8_2_1 = new Version(8_02_01_99, IndexVersion.V_8_2_1); - public static final Version V_8_2_2 = new Version(8_02_02_99, IndexVersion.V_8_2_2); - public static final Version V_8_2_3 = new Version(8_02_03_99, IndexVersion.V_8_2_3); - public static final Version V_8_3_0 = new Version(8_03_00_99, IndexVersion.V_8_3_0); - public static final Version V_8_3_1 = new Version(8_03_01_99, IndexVersion.V_8_3_1); - public static final Version V_8_3_2 = new Version(8_03_02_99, IndexVersion.V_8_3_2); - public static final Version V_8_3_3 = new Version(8_03_03_99, IndexVersion.V_8_3_3); - public static final Version V_8_4_0 = new Version(8_04_00_99, IndexVersion.V_8_4_0); - public static final Version V_8_4_1 = new Version(8_04_01_99, IndexVersion.V_8_4_1); - public static final Version V_8_4_2 = new Version(8_04_02_99, IndexVersion.V_8_4_2); - public static final Version V_8_4_3 = new Version(8_04_03_99, IndexVersion.V_8_4_3); - public static final Version V_8_5_0 = new Version(8_05_00_99, IndexVersion.V_8_5_0); - public static final Version V_8_5_1 = new Version(8_05_01_99, IndexVersion.V_8_5_1); - public static final Version V_8_5_2 = new Version(8_05_02_99, IndexVersion.V_8_5_2); - public static final Version V_8_5_3 = new Version(8_05_03_99, IndexVersion.V_8_5_3); - public static final Version V_8_6_0 = new Version(8_06_00_99, IndexVersion.V_8_6_0); - public static final Version V_8_6_1 = new Version(8_06_01_99, IndexVersion.V_8_6_1); - public static final Version V_8_6_2 = new Version(8_06_02_99, IndexVersion.V_8_6_2); - public static final Version V_8_7_0 = new Version(8_07_00_99, IndexVersion.V_8_7_0); - public static final Version V_8_7_1 = new Version(8_07_01_99, IndexVersion.V_8_7_1); - public static final Version V_8_8_0 = new Version(8_08_00_99, IndexVersion.V_8_8_0); - public static final Version V_8_8_1 = new Version(8_08_01_99, IndexVersion.V_8_8_1); - public static final Version V_8_8_2 = new Version(8_08_02_99, IndexVersion.V_8_8_2); - public static final Version V_8_9_0 = new Version(8_09_00_99, IndexVersion.V_8_9_0); - public static final Version V_8_9_1 = new Version(8_09_01_99, IndexVersion.V_8_9_1); - public static final Version V_8_9_2 = new Version(8_09_02_99, IndexVersion.V_8_9_2); - public static final Version V_8_10_0 = new Version(8_10_00_99, IndexVersion.V_8_10_0); - public static final Version V_8_11_0 = new Version(8_11_00_99, IndexVersion.V_8_11_0); + public static final Version V_EMPTY = new Version(V_EMPTY_ID); + public static final Version V_7_0_0 = new Version(7_00_00_99); + public static final Version V_7_0_1 = new Version(7_00_01_99); + public static final Version V_7_1_0 = new Version(7_01_00_99); + public static final Version V_7_1_1 = new Version(7_01_01_99); + public static final Version V_7_2_0 = new Version(7_02_00_99); + public static final Version V_7_2_1 = new Version(7_02_01_99); + public static final Version V_7_3_0 = new Version(7_03_00_99); + public static final Version V_7_3_1 = new Version(7_03_01_99); + public static final Version V_7_3_2 = new Version(7_03_02_99); + public static final Version V_7_4_0 = new Version(7_04_00_99); + public static final Version V_7_4_1 = new Version(7_04_01_99); + public static final Version V_7_4_2 = new Version(7_04_02_99); + public static final Version V_7_5_0 = new Version(7_05_00_99); + public static final Version V_7_5_1 = new Version(7_05_01_99); + public static final Version V_7_5_2 = new Version(7_05_02_99); + public static final Version V_7_6_0 = new Version(7_06_00_99); + public static final Version V_7_6_1 = new Version(7_06_01_99); + public static final Version V_7_6_2 = new Version(7_06_02_99); + public static final Version V_7_7_0 = new Version(7_07_00_99); + public static final Version V_7_7_1 = new Version(7_07_01_99); + public static final Version V_7_8_0 = new Version(7_08_00_99); + public static final Version V_7_8_1 = new Version(7_08_01_99); + public static final Version V_7_9_0 = new Version(7_09_00_99); + public static final Version V_7_9_1 = new Version(7_09_01_99); + public static final Version V_7_9_2 = new Version(7_09_02_99); + public static final Version V_7_9_3 = new Version(7_09_03_99); + public static final Version V_7_10_0 = new Version(7_10_00_99); + public static final Version V_7_10_1 = new Version(7_10_01_99); + public static final Version V_7_10_2 = new Version(7_10_02_99); + public static final Version V_7_11_0 = new Version(7_11_00_99); + public static final Version V_7_11_1 = new Version(7_11_01_99); + public static final Version V_7_11_2 = new Version(7_11_02_99); + public static final Version V_7_12_0 = new Version(7_12_00_99); + public static final Version V_7_12_1 = new Version(7_12_01_99); + public static final Version V_7_13_0 = new Version(7_13_00_99); + public static final Version V_7_13_1 = new Version(7_13_01_99); + public static final Version V_7_13_2 = new Version(7_13_02_99); + public static final Version V_7_13_3 = new Version(7_13_03_99); + public static final Version V_7_13_4 = new Version(7_13_04_99); + public static final Version V_7_14_0 = new Version(7_14_00_99); + public static final Version V_7_14_1 = new Version(7_14_01_99); + public static final Version V_7_14_2 = new Version(7_14_02_99); + public static final Version V_7_15_0 = new Version(7_15_00_99); + public static final Version V_7_15_1 = new Version(7_15_01_99); + public static final Version V_7_15_2 = new Version(7_15_02_99); + public static final Version V_7_16_0 = new Version(7_16_00_99); + public static final Version V_7_16_1 = new Version(7_16_01_99); + public static final Version V_7_16_2 = new Version(7_16_02_99); + public static final Version V_7_16_3 = new Version(7_16_03_99); + public static final Version V_7_17_0 = new Version(7_17_00_99); + public static final Version V_7_17_1 = new Version(7_17_01_99); + public static final Version V_7_17_2 = new Version(7_17_02_99); + public static final Version V_7_17_3 = new Version(7_17_03_99); + public static final Version V_7_17_4 = new Version(7_17_04_99); + public static final Version V_7_17_5 = new Version(7_17_05_99); + public static final Version V_7_17_6 = new Version(7_17_06_99); + public static final Version V_7_17_7 = new Version(7_17_07_99); + public static final Version V_7_17_8 = new Version(7_17_08_99); + public static final Version V_7_17_9 = new Version(7_17_09_99); + public static final Version V_7_17_10 = new Version(7_17_10_99); + public static final Version V_7_17_11 = new Version(7_17_11_99); + public static final Version V_7_17_12 = new Version(7_17_12_99); + public static final Version V_7_17_13 = new Version(7_17_13_99); + public static final Version V_8_0_0 = new Version(8_00_00_99); + public static final Version V_8_0_1 = new Version(8_00_01_99); + public static final Version V_8_1_0 = new Version(8_01_00_99); + public static final Version V_8_1_1 = new Version(8_01_01_99); + public static final Version V_8_1_2 = new Version(8_01_02_99); + public static final Version V_8_1_3 = new Version(8_01_03_99); + public static final Version V_8_2_0 = new Version(8_02_00_99); + public static final Version V_8_2_1 = new Version(8_02_01_99); + public static final Version V_8_2_2 = new Version(8_02_02_99); + public static final Version V_8_2_3 = new Version(8_02_03_99); + public static final Version V_8_3_0 = new Version(8_03_00_99); + public static final Version V_8_3_1 = new Version(8_03_01_99); + public static final Version V_8_3_2 = new Version(8_03_02_99); + public static final Version V_8_3_3 = new Version(8_03_03_99); + public static final Version V_8_4_0 = new Version(8_04_00_99); + public static final Version V_8_4_1 = new Version(8_04_01_99); + public static final Version V_8_4_2 = new Version(8_04_02_99); + public static final Version V_8_4_3 = new Version(8_04_03_99); + public static final Version V_8_5_0 = new Version(8_05_00_99); + public static final Version V_8_5_1 = new Version(8_05_01_99); + public static final Version V_8_5_2 = new Version(8_05_02_99); + public static final Version V_8_5_3 = new Version(8_05_03_99); + public static final Version V_8_6_0 = new Version(8_06_00_99); + public static final Version V_8_6_1 = new Version(8_06_01_99); + public static final Version V_8_6_2 = new Version(8_06_02_99); + public static final Version V_8_7_0 = new Version(8_07_00_99); + public static final Version V_8_7_1 = new Version(8_07_01_99); + public static final Version V_8_8_0 = new Version(8_08_00_99); + public static final Version V_8_8_1 = new Version(8_08_01_99); + public static final Version V_8_8_2 = new Version(8_08_02_99); + public static final Version V_8_9_0 = new Version(8_09_00_99); + public static final Version V_8_9_1 = new Version(8_09_01_99); + public static final Version V_8_9_2 = new Version(8_09_02_99); + public static final Version V_8_10_0 = new Version(8_10_00_99); + public static final Version V_8_11_0 = new Version(8_11_00_99); public static final Version CURRENT = V_8_11_0; private static final NavigableMap VERSION_IDS; @@ -214,8 +212,7 @@ public static Version fromId(int id) { } private static Version fromIdSlow(int id) { - // TODO: assume this is an old version that has index version == release version - return new Version(id, IndexVersion.fromId(id)); + return new Version(id); } public static void writeVersion(Version version, StreamOutput out) throws IOException { @@ -298,18 +295,15 @@ private static Version fromStringSlow(String version) { public final byte minor; public final byte revision; public final byte build; - @Deprecated(forRemoval = true) - public final IndexVersion indexVersion; private final String toString; private final int previousMajorId; - Version(int id, IndexVersion indexVersion) { + Version(int id) { this.id = id; this.major = (byte) ((id / 1000000) % 100); this.minor = (byte) ((id / 10000) % 100); this.revision = (byte) ((id / 100) % 100); this.build = (byte) (id % 100); - this.indexVersion = Objects.requireNonNull(indexVersion); this.toString = major + "." + minor + "." + revision; this.previousMajorId = major > 0 ? (major - 1) * 1000000 + 99 : major; } @@ -324,11 +318,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws return builder.value(toString()); } - @Deprecated(forRemoval = true) - public org.apache.lucene.util.Version luceneVersion() { - return indexVersion.luceneVersion(); - } - /* * We need the declared versions when computing the minimum compatibility version. As computing the declared versions uses reflection it * is not cheap. Since computing the minimum compatibility version can occur often, we use this holder to compute the declared versions diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DesiredBalanceResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DesiredBalanceResponse.java index 168dc5c054dc4..8c938dbcfd2c5 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DesiredBalanceResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DesiredBalanceResponse.java @@ -169,7 +169,7 @@ public static DesiredShards from(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(current); + out.writeCollection(current); desired.writeTo(out); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java index fa95c4a7df69e..3a264bf69a109 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java @@ -71,7 +71,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(historyID); out.writeLong(version); - out.writeList(nodes); + out.writeCollection(nodes); if (out.getTransportVersion().onOrAfter(DRY_RUN_VERSION)) { out.writeBoolean(dryRun); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponse.java index 4c2b97af9bd26..bb396b8c57bbd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/GetFeatureUpgradeStatusResponse.java @@ -67,7 +67,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(this.featureUpgradeStatuses); + out.writeCollection(this.featureUpgradeStatuses); out.writeEnum(upgradeStatus); } @@ -178,7 +178,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(this.featureName); IndexVersion.writeVersion(this.minimumIndexVersion, out); out.writeEnum(this.upgradeStatus); - out.writeList(this.indexInfos); + out.writeCollection(this.indexInfos); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponse.java index d7ea624d3b9c2..f669593da67d6 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/migration/PostFeatureUpgradeResponse.java @@ -91,7 +91,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(this.accepted); - out.writeList(this.features); + out.writeCollection(this.features); out.writeOptionalString(this.reason); out.writeOptionalWriteable(this.elasticsearchException); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsResponse.java index edf7d88ae4a9a..fd81039fa5087 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsResponse.java @@ -52,7 +52,7 @@ protected List readNodesFrom(StreamInput in) throws IOException @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } private static class LinesIterator implements Iterator { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index f756f0e7929f1..2dc2d26450cde 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -49,7 +49,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/PluginsAndModules.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/PluginsAndModules.java index e6a91b152cad5..e5685b4532704 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/PluginsAndModules.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/PluginsAndModules.java @@ -42,11 +42,11 @@ public PluginsAndModules(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_3_0)) { - out.writeList(plugins); + out.writeCollection(plugins); } else { - out.writeList(plugins.stream().map(PluginRuntimeInfo::descriptor).toList()); + out.writeCollection(plugins.stream().map(PluginRuntimeInfo::descriptor).toList()); } - out.writeList(modules); + out.writeCollection(modules); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsResponse.java index d9ab1f6484833..2921cc764f993 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsResponse.java @@ -45,7 +45,7 @@ protected List readNodesFrom(Str @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/NodesRemovalPrevalidation.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/NodesRemovalPrevalidation.java index 4f6ea0d5b83d8..7630b70956863 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/NodesRemovalPrevalidation.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/NodesRemovalPrevalidation.java @@ -52,7 +52,7 @@ public static NodesRemovalPrevalidation readFrom(final StreamInput in) throws IO public void writeTo(final StreamOutput out) throws IOException { out.writeBoolean(isSafe); out.writeString(message); - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathResponse.java index 2bbaa6eb28270..e3a63fc507c92 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathResponse.java @@ -38,6 +38,6 @@ protected List readNodesFrom(StreamInput in) t @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java index 29c62c638d929..1a8cee6af5dd7 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java @@ -39,7 +39,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index d9e1790cd38ef..4ad3bf70ffbe5 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java @@ -66,7 +66,7 @@ public ListTasksResponse(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(tasks); + out.writeCollection(tasks); } protected static ConstructingObjectParser setupParser( diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageResponse.java index 136c99aca2145..508a421b1c821 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageResponse.java @@ -41,7 +41,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteClusterNodesAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteClusterNodesAction.java index e324b2a8433e3..80ea495e552f1 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteClusterNodesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteClusterNodesAction.java @@ -84,7 +84,7 @@ public Response(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public List getNodes() { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteInfoResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteInfoResponse.java index 1c9c0233102dd..a2b4fa5088678 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteInfoResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteInfoResponse.java @@ -38,7 +38,7 @@ public List getInfos() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(infos); + out.writeCollection(infos); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java index 7c90585b17356..6df1b76ac25f6 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java @@ -130,7 +130,7 @@ public VerifyRepositoryResponse(List nodes) { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public List getNodes() { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/GetSnapshottableFeaturesResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/GetSnapshottableFeaturesResponse.java index 4c1b3f4550b60..e4671239de549 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/GetSnapshottableFeaturesResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/GetSnapshottableFeaturesResponse.java @@ -38,7 +38,7 @@ public List getSnapshottableFeatures() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(snapshottableFeatures); + out.writeCollection(snapshottableFeatures); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/ResetFeatureStateResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/ResetFeatureStateResponse.java index 413b905dff738..19e7c69ddb04c 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/ResetFeatureStateResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/features/ResetFeatureStateResponse.java @@ -69,7 +69,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(this.resetFeatureStateStatusList); + out.writeCollection(this.resetFeatureStateStatusList); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java index 9e6e486aecdff..243e5555c7bd7 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java @@ -148,7 +148,7 @@ public int remaining() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(snapshots); + out.writeCollection(snapshots); if (out.getTransportVersion().onOrAfter(GetSnapshotsRequest.MULTIPLE_REPOSITORIES_SUPPORT_ADDED)) { out.writeMap(failures, StreamOutput::writeString, StreamOutput::writeException); out.writeOptionalString(next); diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java index 788867123a88c..b814a83ececd0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java @@ -164,7 +164,7 @@ public Map getIndices() { public void writeTo(StreamOutput out) throws IOException { snapshot.writeTo(out); out.writeByte(state.value()); - out.writeList(shards); + out.writeCollection(shards); out.writeOptionalBoolean(includeGlobalState); out.writeLong(stats.getStartTime()); out.writeLong(stats.getTime()); diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java index a8dd1d54d3a03..f4eae98f83dbf 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java @@ -52,7 +52,7 @@ public List getSnapshots() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(snapshots); + out.writeCollection(snapshots); } private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java index 658cfe297e2f5..3adc01c5c0a3d 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java @@ -164,7 +164,7 @@ protected List readNodesFrom(StreamInput in) throws IOExcept @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } @@ -184,7 +184,7 @@ public NodeRequest(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(snapshots); + out.writeCollection(snapshots); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java index 080edf8810d39..a237561db7272 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java @@ -131,7 +131,7 @@ protected List readNodesFrom(StreamInput in) throws IO @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { // nodeStats and indicesStats are rebuilt from nodes - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java index bde84b84eb0e7..41ab086b82a2a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java @@ -91,7 +91,7 @@ static final class Fields { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(pendingTasks); + out.writeCollection(pendingTasks); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java index e9f49efd4cb1c..a4f636a3deca6 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -624,7 +624,7 @@ public ActionRequestValidationException validate() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(allAliasActions); + out.writeCollection(allAliasActions); out.writeOptionalString(origin); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java index 1ea6be9fea91b..904affb249be9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java @@ -45,8 +45,8 @@ public Map> getDataStreamAliases() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeMap(aliases, StreamOutput::writeString, StreamOutput::writeList); - out.writeMap(dataStreamAliases, StreamOutput::writeString, StreamOutput::writeList); + out.writeMap(aliases, StreamOutput::writeString, (streamOutput1, list1) -> streamOutput1.writeCollection(list1)); + out.writeMap(dataStreamAliases, StreamOutput::writeString, (streamOutput, list) -> streamOutput.writeCollection(list)); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeAction.java index c7d77e7d39517..7fb424c56fe8c 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeAction.java @@ -251,8 +251,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(text); out.writeOptionalString(analyzer); out.writeOptionalWriteable(tokenizer); - out.writeList(tokenFilters); - out.writeList(charFilters); + out.writeCollection(tokenFilters); + out.writeCollection(charFilters); out.writeOptionalString(field); out.writeBoolean(explain); out.writeStringArray(attributes); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java index 44f743b3da4aa..cc77de8364d86 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java @@ -48,7 +48,7 @@ public List getIndices() { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); writeShardsAcknowledged(out); - out.writeList(indices); + out.writeCollection(indices); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexResponse.java index 55472e999e72d..28c4bc6479b1e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexResponse.java @@ -42,6 +42,6 @@ protected List readNodesFrom(StreamInput in) thro @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/NodeFindDanglingIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/NodeFindDanglingIndexResponse.java index 3e13c5b905dd7..83563987e0bac 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/NodeFindDanglingIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/NodeFindDanglingIndexResponse.java @@ -46,6 +46,6 @@ protected NodeFindDanglingIndexResponse(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(this.danglingIndexInfo); + out.writeCollection(this.danglingIndexInfo); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesResponse.java index 138df5f15881c..7eb9e68187419 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesResponse.java @@ -99,7 +99,7 @@ protected List readNodesFrom(StreamInput in) th @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } // visible for testing diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/NodeListDanglingIndicesResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/NodeListDanglingIndicesResponse.java index d5cde54bdc87a..e6c4c0bbecc14 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/NodeListDanglingIndicesResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/NodeListDanglingIndicesResponse.java @@ -40,6 +40,6 @@ protected NodeListDanglingIndicesResponse(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(this.indexMetaData); + out.writeCollection(this.indexMetaData); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java index bd9e827545b9e..1c8dcd84aa0cc 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java @@ -173,7 +173,7 @@ public String getSetting(String index, String setting) { public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(indices); MappingMetadata.writeMappingMetadata(out, mappings); - out.writeMap(aliases, StreamOutput::writeString, StreamOutput::writeList); + out.writeMap(aliases, StreamOutput::writeString, (streamOutput, list) -> streamOutput.writeCollection(list)); out.writeMap(settings, StreamOutput::writeString, (o, v) -> v.writeTo(o)); out.writeMap(defaultSettings, StreamOutput::writeString, (o, v) -> v.writeTo(o)); out.writeMap(dataStreams, StreamOutput::writeString, StreamOutput::writeOptionalString); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockResponse.java index 38bd9b6432abc..44ba4a4dc1b85 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockResponse.java @@ -49,7 +49,7 @@ public List getIndices() { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); writeShardsAcknowledged(out); - out.writeList(indices); + out.writeCollection(indices); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexAction.java index 6c1ba44125550..6a8665338df5e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexAction.java @@ -409,9 +409,9 @@ public List getDataStreams() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(indices); - out.writeList(aliases); - out.writeList(dataStreams); + out.writeCollection(indices); + out.writeCollection(aliases); + out.writeCollection(dataStreams); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java b/server/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java index e782de4b56b43..b35ac29a4be16 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java @@ -70,6 +70,6 @@ public int getNumberOfSearch() { @Override public void writeTo(StreamOutput out) throws IOException { shardRouting.writeTo(out); - out.writeList(segments); + out.writeCollection(segments); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java index 8e18e4c689133..33e1f6d855523 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java @@ -272,7 +272,7 @@ public void writeTo(StreamOutput out) throws IOException { StreamOutput::writeString, (o, v) -> o.writeMap(v, StreamOutput::writeInt, StreamOutput::writeCollection) ); - out.writeList(failures); + out.writeCollection(failures); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/FieldUsageStatsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/FieldUsageStatsResponse.java index 3b5f919816708..f82c9267c1771 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/FieldUsageStatsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/FieldUsageStatsResponse.java @@ -41,7 +41,7 @@ public class FieldUsageStatsResponse extends ChunkedBroadcastResponse { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeMap(stats, StreamOutput::writeString, StreamOutput::writeList); + out.writeMap(stats, StreamOutput::writeString, (streamOutput, list) -> streamOutput.writeCollection(list)); } public Map> getStats() { diff --git a/server/src/main/java/org/elasticsearch/action/datastreams/GetDataStreamAction.java b/server/src/main/java/org/elasticsearch/action/datastreams/GetDataStreamAction.java index ce9b9fe19ab0a..c439dd2cd3389 100644 --- a/server/src/main/java/org/elasticsearch/action/datastreams/GetDataStreamAction.java +++ b/server/src/main/java/org/elasticsearch/action/datastreams/GetDataStreamAction.java @@ -359,7 +359,7 @@ public RolloverConfiguration getRolloverConfiguration() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(dataStreams); + out.writeCollection(dataStreams); if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_010)) { out.writeOptionalWriteable(rolloverConfiguration); } diff --git a/server/src/main/java/org/elasticsearch/action/datastreams/ModifyDataStreamsAction.java b/server/src/main/java/org/elasticsearch/action/datastreams/ModifyDataStreamsAction.java index 58ab8bad3c956..3c10756006f1c 100644 --- a/server/src/main/java/org/elasticsearch/action/datastreams/ModifyDataStreamsAction.java +++ b/server/src/main/java/org/elasticsearch/action/datastreams/ModifyDataStreamsAction.java @@ -66,7 +66,7 @@ public Request(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(actions); + out.writeCollection(actions); } public Request(List actions) { diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java index 7979811561ee3..9868ba01ea573 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java @@ -114,8 +114,8 @@ static void writeList(StreamOutput output, List return new GroupByMappingHash(indices, indexMappingHash, responseMap); }) .toList(); - output.writeList(ungroupedResponses); - output.writeList(groupedResponses); + output.writeCollection(ungroupedResponses); + output.writeCollection(groupedResponses); } /** diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeRequest.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeRequest.java index cdb648ba2feba..4e1fd3cb8588d 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeRequest.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeRequest.java @@ -122,7 +122,7 @@ public long nowInMillis() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(shardIds); + out.writeCollection(shardIds); out.writeStringArray(fields); if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_2_0)) { out.writeStringArray(filters); diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java index 6398ffaa713c5..4390a7f830142 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java @@ -149,7 +149,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(indices); out.writeMap(responseMap, StreamOutput::writeString, FieldCapabilitiesResponse::writeField); FieldCapabilitiesIndexResponse.writeList(out, indexResponses); - out.writeList(failures); + out.writeCollection(failures); } private static void writeField(StreamOutput out, Map map) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java index 003495c9b4801..c53864c852a34 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -276,7 +276,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(preference); out.writeBoolean(refresh); out.writeBoolean(realtime); - out.writeList(items); + out.writeCollection(items); if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_4_0)) { out.writeBoolean(forceSyntheticSource); } else { diff --git a/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeRequest.java b/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeRequest.java index 8c5d828fff01f..9e0422e9bf684 100644 --- a/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeRequest.java +++ b/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeRequest.java @@ -188,7 +188,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(nowInMillis); out.writeOptionalString(clusterAlias); out.writeTimeValue(waitForCheckpointsTimeout); - out.writeList(shards); + out.writeCollection(shards); } public List getShardLevelRequests() { diff --git a/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeResponse.java b/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeResponse.java index 05aaaa56583ed..036200f6f2d2e 100644 --- a/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeResponse.java +++ b/server/src/main/java/org/elasticsearch/action/search/CanMatchNodeResponse.java @@ -33,7 +33,7 @@ public CanMatchNodeResponse(List responses) { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(responses); + out.writeCollection(responses); } public List getResponses() { diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java b/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java index 02f0e4f9db129..d797cb68c1b25 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java @@ -568,9 +568,9 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_053)) { if (clusterInfo != null) { List clusterList = clusterInfo.values().stream().map(AtomicReference::get).toList(); - out.writeList(clusterList); + out.writeCollection(clusterList); } else { - out.writeList(Collections.emptyList()); + out.writeCollection(Collections.emptyList()); } } } @@ -869,7 +869,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalInt(failedShards); out.writeOptionalLong(took == null ? null : took.millis()); out.writeBoolean(timedOut); - out.writeList(failures); + out.writeCollection(failures); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java b/server/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java index e66785d5453f5..a6f32dfe8c536 100644 --- a/server/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java @@ -507,7 +507,7 @@ public void writeTo(StreamOutput out) throws IOException { assert indicesLevelRequest.hasReferences(); super.writeTo(out); indicesLevelRequest.writeTo(out); - out.writeList(shards); + out.writeCollection(shards); out.writeString(nodeId); } @@ -599,7 +599,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeCollection(results, StreamOutput::writeOptionalWriteable); out.writeBoolean(exceptions != null); if (exceptions != null) { - out.writeList(exceptions); + out.writeCollection(exceptions); } } } diff --git a/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesResponse.java b/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesResponse.java index 263ff462c9e5f..f62b76d8c11a6 100644 --- a/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesResponse.java +++ b/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesResponse.java @@ -97,7 +97,7 @@ public Map getNodesMap() { public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); writeNodesTo(out, nodes); - out.writeList(failures); + out.writeCollection(failures); } /** diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterSnapshotStats.java b/server/src/main/java/org/elasticsearch/cluster/ClusterSnapshotStats.java index b656759b514ed..8a264861ae084 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterSnapshotStats.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterSnapshotStats.java @@ -175,7 +175,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(incompleteShardSnapshotCount); out.writeVInt(deletionsInProgressCount); out.writeVInt(cleanupsInProgressCount); - out.writeList(statsByRepository); + out.writeCollection(statsByRepository); } public static ClusterSnapshotStats readFrom(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/cluster/RepositoryCleanupInProgress.java b/server/src/main/java/org/elasticsearch/cluster/RepositoryCleanupInProgress.java index 7df9bb605bc8f..4a4d1dd458d91 100644 --- a/server/src/main/java/org/elasticsearch/cluster/RepositoryCleanupInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/RepositoryCleanupInProgress.java @@ -64,7 +64,7 @@ public String getWriteableName() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(entries); + out.writeCollection(entries); } @Override diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java index 85e28f1a1ddfa..b7bb6bc9e5134 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java @@ -153,7 +153,7 @@ public int hashCode() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(entries); + out.writeCollection(entries); } public static NamedDiff readDiffFrom(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index e15f3578bc140..7b31e4f7625f4 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -1344,7 +1344,7 @@ public void writeTo(StreamOutput out) throws IOException { } else { out.writeMap(shardStatusByRepoShardId); } - out.writeList(featureStates); + out.writeCollection(featureStates); } @Override @@ -1661,7 +1661,7 @@ private ByRepo(List entries) { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(entries); + out.writeCollection(entries); } @Override diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java b/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java index 50bc9479ee540..9a67684646d98 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java @@ -383,8 +383,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeLong(acceptedTerm); lastAcceptedConfiguration.writeTo(out); lastCommittedConfiguration.writeTo(out); - out.writeList(resolvedAddresses); - out.writeList(foundPeers); + out.writeCollection(resolvedAddresses); + out.writeCollection(foundPeers); out.writeLong(currentTerm); out.writeBoolean(hasDiscoveredQuorum); statusInfo.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java b/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java index bd2fccd70f770..f253cf969c15f 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsService.java @@ -1323,7 +1323,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(false); } else { out.writeBoolean(true); - out.writeList(recentMasters); + out.writeCollection(recentMasters); } out.writeOptionalString(remoteExceptionMessage); out.writeOptionalString(remoteExceptionStackTrace); diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/PeersResponse.java b/server/src/main/java/org/elasticsearch/cluster/coordination/PeersResponse.java index 6afd06018939f..6fe31e51333fb 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/PeersResponse.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/PeersResponse.java @@ -40,7 +40,7 @@ public PeersResponse(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(masterNode.orElse(null)); - out.writeList(knownPeers); + out.writeCollection(knownPeers); out.writeLong(term); } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java index 40142a2246b8c..a60e194a3c6ff 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java @@ -805,7 +805,7 @@ public static Diff readDiffFrom(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { out.writeString(name); out.writeString(TIMESTAMP_FIELD_NAME); - out.writeList(indices); + out.writeCollection(indices); out.writeVLong(generation); out.writeGenericMap(metadata); out.writeBoolean(hidden); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexGraveyard.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexGraveyard.java index d244df15579b6..33aa25d563557 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexGraveyard.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexGraveyard.java @@ -141,7 +141,7 @@ public String toString() { @Override public void writeTo(final StreamOutput out) throws IOException { - out.writeList(tombstones); + out.writeCollection(tombstones); } @Override @@ -298,7 +298,7 @@ public static final class IndexGraveyardDiff implements NamedDiff readDiffFrom(StreamInput in) throws IOException */ @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(repositories); + out.writeCollection(repositories); } public static RepositoriesMetadata fromXContent(XContentParser parser) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java index bbfdf856cf787..121f8e11d543f 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java @@ -83,7 +83,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(targetNode); if (nodeDecisions != null) { out.writeBoolean(true); - out.writeList(nodeDecisions); + out.writeCollection(nodeDecisions); } else { out.writeBoolean(false); } diff --git a/server/src/main/java/org/elasticsearch/common/collect/Iterators.java b/server/src/main/java/org/elasticsearch/common/collect/Iterators.java index 436b9580d47f6..ea6256a5b0717 100644 --- a/server/src/main/java/org/elasticsearch/common/collect/Iterators.java +++ b/server/src/main/java/org/elasticsearch/common/collect/Iterators.java @@ -14,8 +14,10 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Objects; +import java.util.function.BiPredicate; import java.util.function.Function; import java.util.function.IntFunction; +import java.util.function.ToIntFunction; public class Iterators { @@ -228,4 +230,36 @@ public U next() { } } + public static boolean equals(Iterator iterator1, Iterator iterator2, BiPredicate itemComparer) { + if (iterator1 == null) { + return iterator2 == null; + } + if (iterator2 == null) { + return false; + } + + while (iterator1.hasNext()) { + if (iterator2.hasNext() == false) { + return false; + } + + if (itemComparer.test(iterator1.next(), iterator2.next()) == false) { + return false; + } + } + + return iterator2.hasNext() == false; + } + + public static int hashCode(Iterator iterator, ToIntFunction itemHashcode) { + if (iterator == null) { + return 0; + } + int result = 1; + while (iterator.hasNext()) { + result = 31 * result + itemHashcode.applyAsInt(iterator.next()); + } + return result; + } + } diff --git a/server/src/main/java/org/elasticsearch/common/document/DocumentField.java b/server/src/main/java/org/elasticsearch/common/document/DocumentField.java index bae4c2255d7fc..8258926705d1c 100644 --- a/server/src/main/java/org/elasticsearch/common/document/DocumentField.java +++ b/server/src/main/java/org/elasticsearch/common/document/DocumentField.java @@ -118,7 +118,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeCollection(ignoredValues, StreamOutput::writeGenericValue); } if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_2_0)) { - out.writeList(lookupFields); + out.writeCollection(lookupFields); } else { if (lookupFields.isEmpty() == false) { assert false : "Lookup fields require all nodes be on 8.2 or later"; diff --git a/server/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/server/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java index 6b43e59177cde..4b59829eb8371 100644 --- a/server/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java +++ b/server/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java @@ -1077,7 +1077,7 @@ public C readOptionalNamedWriteable(Class category } /** - * Reads a list of objects. The list is expected to have been written using {@link StreamOutput#writeList(List)}. + * Reads a list of objects. The list is expected to have been written using {@link StreamOutput#writeCollection}. * If the returned list contains any entries it will be mutable. If it is empty it might be immutable. * * @return the list of objects @@ -1088,7 +1088,7 @@ public List readList(final Writeable.Reader reader) throws IOException } /** - * Reads an list of objects. The list is expected to have been written using {@link StreamOutput#writeList(List)}. + * Reads an list of objects. The list is expected to have been written using {@link StreamOutput#writeCollection}. * The returned list is immutable. * * @return the list of objects diff --git a/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java b/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java index f0456d8fbb04f..f6df7b6d01fde 100644 --- a/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java +++ b/server/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java @@ -1041,13 +1041,6 @@ public void writeCollection(final Collection collection) th writeCollection(collection, (o, v) -> v.writeTo(o)); } - /** - * Writes a list of {@link Writeable} objects - */ - public void writeList(List list) throws IOException { - writeCollection(list); - } - /** * Writes a collection of objects via a {@link Writer}. * diff --git a/server/src/main/java/org/elasticsearch/common/util/SetBackedScalingCuckooFilter.java b/server/src/main/java/org/elasticsearch/common/util/SetBackedScalingCuckooFilter.java index 88566acd46ae1..443f202c8e8ef 100644 --- a/server/src/main/java/org/elasticsearch/common/util/SetBackedScalingCuckooFilter.java +++ b/server/src/main/java/org/elasticsearch/common/util/SetBackedScalingCuckooFilter.java @@ -129,7 +129,7 @@ public void writeTo(StreamOutput out) throws IOException { if (isSetMode) { out.writeCollection(hashes, StreamOutput::writeZLong); } else { - out.writeList(filters); + out.writeCollection(filters); } } diff --git a/server/src/main/java/org/elasticsearch/discovery/PeersRequest.java b/server/src/main/java/org/elasticsearch/discovery/PeersRequest.java index 78e35ebcf78a7..b884edbe07ac6 100644 --- a/server/src/main/java/org/elasticsearch/discovery/PeersRequest.java +++ b/server/src/main/java/org/elasticsearch/discovery/PeersRequest.java @@ -37,7 +37,7 @@ public PeersRequest(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); sourceNode.writeTo(out); - out.writeList(knownPeers); + out.writeCollection(knownPeers); } public List getKnownPeers() { diff --git a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java index 3b594fa83e70a..46e5b5779e75f 100644 --- a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java +++ b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java @@ -248,7 +248,7 @@ protected List readNodesFrom(StreamInput in) throws IO @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } diff --git a/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java b/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java index 25714f3992c72..96b444f322c64 100644 --- a/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java +++ b/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java @@ -94,7 +94,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public Counters getStats() { diff --git a/server/src/main/java/org/elasticsearch/http/HttpStats.java b/server/src/main/java/org/elasticsearch/http/HttpStats.java index 9a77428b04535..a57619e176413 100644 --- a/server/src/main/java/org/elasticsearch/http/HttpStats.java +++ b/server/src/main/java/org/elasticsearch/http/HttpStats.java @@ -38,7 +38,7 @@ public HttpStats(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { out.writeVLong(serverOpen); out.writeVLong(totalOpen); - out.writeList(clientStats); + out.writeCollection(clientStats); } public long getServerOpen() { diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersion.java b/server/src/main/java/org/elasticsearch/index/IndexVersion.java index 417a22e2134a5..a10840bc5db42 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersion.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersion.java @@ -84,101 +84,37 @@ private static IndexVersion registerIndexVersion(int id, Version luceneVersion, public static final IndexVersion ZERO = registerIndexVersion(0, Version.LATEST, "00000000-0000-0000-0000-000000000000"); public static final IndexVersion V_7_0_0 = registerIndexVersion(7_00_00_99, Version.LUCENE_8_0_0, "b32be92d-c403-4858-a4a3-20d699a47ae6"); - public static final IndexVersion V_7_0_1 = registerIndexVersion(7_00_01_99, Version.LUCENE_8_0_0, "a03ed728-eac8-4e50-bcce-864806bb10e0"); public static final IndexVersion V_7_1_0 = registerIndexVersion(7_01_00_99, Version.LUCENE_8_0_0, "f9964d87-9f20-4b26-af32-be1f979216ec"); - public static final IndexVersion V_7_1_1 = registerIndexVersion(7_01_01_99, Version.LUCENE_8_0_0, "29a3fb69-55d0-4389-aea9-96c98ce23830"); public static final IndexVersion V_7_2_0 = registerIndexVersion(7_02_00_99, Version.LUCENE_8_0_0, "dba49448-87d4-45bb-ba19-f7b4eb85c757"); public static final IndexVersion V_7_2_1 = registerIndexVersion(7_02_01_99, Version.LUCENE_8_0_0, "58874b45-f9f8-4c04-92a9-67548a8b21c3"); public static final IndexVersion V_7_3_0 = registerIndexVersion(7_03_00_99, Version.LUCENE_8_1_0, "3d8a21df-58a4-4d7a-ba5d-438c92c16a7b"); - public static final IndexVersion V_7_3_1 = registerIndexVersion(7_03_01_99, Version.LUCENE_8_1_0, "5687797f-448b-490d-94d4-d7e8cfac0c98"); - public static final IndexVersion V_7_3_2 = registerIndexVersion(7_03_02_99, Version.LUCENE_8_1_0, "5a3462e5-d2fe-4b7b-9a7e-c0234412271f"); public static final IndexVersion V_7_4_0 = registerIndexVersion(7_04_00_99, Version.LUCENE_8_2_0, "c1fe73ba-0173-476c-aba2-855c2b31ac18"); - public static final IndexVersion V_7_4_1 = registerIndexVersion(7_04_01_99, Version.LUCENE_8_2_0, "8a917374-bd4f-45e3-9052-575c4cf741cd"); - public static final IndexVersion V_7_4_2 = registerIndexVersion(7_04_02_99, Version.LUCENE_8_2_0, "f073a867-cba2-41e4-8150-a2f2a96f1e0b"); public static final IndexVersion V_7_5_0 = registerIndexVersion(7_05_00_99, Version.LUCENE_8_3_0, "ab08ae25-ede2-4e57-a43f-89d96aa989e4"); - public static final IndexVersion V_7_5_1 = registerIndexVersion(7_05_01_99, Version.LUCENE_8_3_0, "a386d62e-cb85-4a37-b5f9-c9468bbfc457"); public static final IndexVersion V_7_5_2 = registerIndexVersion(7_05_02_99, Version.LUCENE_8_3_0, "706715ca-3b91-40d2-8c2e-c34c459b5d0d"); public static final IndexVersion V_7_6_0 = registerIndexVersion(7_06_00_99, Version.LUCENE_8_4_0, "63acbdb9-51c8-4976-bb3d-e55052a4fbd4"); - public static final IndexVersion V_7_6_1 = registerIndexVersion(7_06_01_99, Version.LUCENE_8_4_0, "1acc33d3-28dc-448d-953a-664dad3bf1f5"); - public static final IndexVersion V_7_6_2 = registerIndexVersion(7_06_02_99, Version.LUCENE_8_4_0, "3aa17069-fa04-4bf9-96af-fe8b903faa75"); public static final IndexVersion V_7_7_0 = registerIndexVersion(7_07_00_99, Version.LUCENE_8_5_1, "6fff8238-e6ce-4fb2-85de-196492026e49"); - public static final IndexVersion V_7_7_1 = registerIndexVersion(7_07_01_99, Version.LUCENE_8_5_1, "4ce6641d-157b-4c59-8261-7997ac0f6e40"); public static final IndexVersion V_7_8_0 = registerIndexVersion(7_08_00_99, Version.LUCENE_8_5_1, "81d7d459-f386-4c20-8235-f8fce8af7f0e"); - public static final IndexVersion V_7_8_1 = registerIndexVersion(7_08_01_99, Version.LUCENE_8_5_1, "a1b015bc-d020-453f-85a6-9413e169304a"); public static final IndexVersion V_7_9_0 = registerIndexVersion(7_09_00_99, Version.LUCENE_8_6_0, "0fa951a2-43ce-4f76-91bf-066c1ecf8a93"); - public static final IndexVersion V_7_9_1 = registerIndexVersion(7_09_01_99, Version.LUCENE_8_6_2, "5fc4aabc-080e-4840-af4f-a724deba98b1"); - public static final IndexVersion V_7_9_2 = registerIndexVersion(7_09_02_99, Version.LUCENE_8_6_2, "ef824617-332e-4b63-969e-ebb73a868462"); - public static final IndexVersion V_7_9_3 = registerIndexVersion(7_09_03_99, Version.LUCENE_8_6_2, "499c810a-0f37-4dfd-92ad-55e4936f3578"); public static final IndexVersion V_7_10_0 = registerIndexVersion(7_10_00_99, Version.LUCENE_8_7_0, "92ccd91c-0251-4263-8873-9f1abfac3c10"); - public static final IndexVersion V_7_10_1 = registerIndexVersion(7_10_01_99, Version.LUCENE_8_7_0, "8ce37467-964f-43eb-ad2d-a51a50116868"); - public static final IndexVersion V_7_10_2 = registerIndexVersion(7_10_02_99, Version.LUCENE_8_7_0, "cb277ccb-3081-4238-be2c-c3167316a435"); public static final IndexVersion V_7_11_0 = registerIndexVersion(7_11_00_99, Version.LUCENE_8_7_0, "e6d65f96-26d5-4669-ac5a-2964b9b1699f"); - public static final IndexVersion V_7_11_1 = registerIndexVersion(7_11_01_99, Version.LUCENE_8_7_0, "e3655b78-14f7-4432-aa28-34cd1ef2d229"); - public static final IndexVersion V_7_11_2 = registerIndexVersion(7_11_02_99, Version.LUCENE_8_7_0, "1ecfd0ee-4868-4384-b2a0-af6ecb01e496"); public static final IndexVersion V_7_12_0 = registerIndexVersion(7_12_00_99, Version.LUCENE_8_8_0, "39e2989a-a9a4-4f1a-b185-2e6015f74b1c"); - public static final IndexVersion V_7_12_1 = registerIndexVersion(7_12_01_99, Version.LUCENE_8_8_0, "a8307f67-8295-4567-a7eb-2a6e69046282"); public static final IndexVersion V_7_13_0 = registerIndexVersion(7_13_00_99, Version.LUCENE_8_8_2, "28b21fe0-4d1f-4c04-95cc-74df494ae0cf"); - public static final IndexVersion V_7_13_1 = registerIndexVersion(7_13_01_99, Version.LUCENE_8_8_2, "4952d7a7-d9f5-443b-b362-8c5ebdc57f81"); - public static final IndexVersion V_7_13_2 = registerIndexVersion(7_13_02_99, Version.LUCENE_8_8_2, "d77c4245-9d26-4da3-aa61-78ab34c3c792"); - public static final IndexVersion V_7_13_3 = registerIndexVersion(7_13_03_99, Version.LUCENE_8_8_2, "a263a47e-4075-4c68-8a42-15a37455c30f"); - public static final IndexVersion V_7_13_4 = registerIndexVersion(7_13_04_99, Version.LUCENE_8_8_2, "d17644c8-3144-495d-8f6c-42cd36698e98"); public static final IndexVersion V_7_14_0 = registerIndexVersion(7_14_00_99, Version.LUCENE_8_9_0, "b45bb223-bb73-4379-a46f-7dc74d38aaca"); - public static final IndexVersion V_7_14_1 = registerIndexVersion(7_14_01_99, Version.LUCENE_8_9_0, "ee4a6d62-9e05-490b-93dd-b316f9a62d71"); - public static final IndexVersion V_7_14_2 = registerIndexVersion(7_14_02_99, Version.LUCENE_8_9_0, "285d3293-2896-431c-97dd-180890840947"); public static final IndexVersion V_7_15_0 = registerIndexVersion(7_15_00_99, Version.LUCENE_8_9_0, "ab666b02-b866-4b64-9ba3-d511e86c55b5"); - public static final IndexVersion V_7_15_1 = registerIndexVersion(7_15_01_99, Version.LUCENE_8_9_0, "5643957d-9b68-414a-8917-ea75cf549f67"); - public static final IndexVersion V_7_15_2 = registerIndexVersion(7_15_02_99, Version.LUCENE_8_9_0, "1a618039-d665-47ce-b6ca-886e88c64051"); public static final IndexVersion V_7_16_0 = registerIndexVersion(7_16_00_99, Version.LUCENE_8_10_1, "a582e900-2d92-474c-9be3-2e08fa88be4b"); - public static final IndexVersion V_7_16_1 = registerIndexVersion(7_16_01_99, Version.LUCENE_8_10_1, "bf666306-9b0d-468b-99dc-f2706dae9c11"); - public static final IndexVersion V_7_16_2 = registerIndexVersion(7_16_02_99, Version.LUCENE_8_10_1, "167c6d69-cae2-4281-8f37-984231620ee9"); - public static final IndexVersion V_7_16_3 = registerIndexVersion(7_16_03_99, Version.LUCENE_8_10_1, "5d25a795-2be6-4663-93dc-10d88efb7e3d"); public static final IndexVersion V_7_17_0 = registerIndexVersion(7_17_00_99, Version.LUCENE_8_11_1, "18766ab8-4691-40a2-94f1-526f3b71420c"); - public static final IndexVersion V_7_17_1 = registerIndexVersion(7_17_01_99, Version.LUCENE_8_11_1, "8ad49144-4a1c-4322-b33d-614a569fba9b"); - public static final IndexVersion V_7_17_2 = registerIndexVersion(7_17_02_99, Version.LUCENE_8_11_1, "50033cde-c905-4923-83d6-8139f3f110e1"); - public static final IndexVersion V_7_17_3 = registerIndexVersion(7_17_03_99, Version.LUCENE_8_11_1, "460b91d1-4f3d-4f56-8dca-8d9e15f5b862"); - public static final IndexVersion V_7_17_4 = registerIndexVersion(7_17_04_99, Version.LUCENE_8_11_1, "26e40d6f-ac7c-43a3-bd0c-1ec6c3093f66"); - public static final IndexVersion V_7_17_5 = registerIndexVersion(7_17_05_99, Version.LUCENE_8_11_1, "d80bc13c-7139-4ff9-979d-42701d480e33"); - public static final IndexVersion V_7_17_6 = registerIndexVersion(7_17_06_99, Version.LUCENE_8_11_1, "0b47328e-341a-4f97-927d-c49f5050778d"); - public static final IndexVersion V_7_17_7 = registerIndexVersion(7_17_07_99, Version.LUCENE_8_11_1, "b672ff6b-8078-4f6e-b426-6fcf7f8687b4"); - public static final IndexVersion V_7_17_8 = registerIndexVersion(7_17_08_99, Version.LUCENE_8_11_1, "0faffa1b-5fb3-4439-9367-f154fb25395f"); - public static final IndexVersion V_7_17_9 = registerIndexVersion(7_17_09_99, Version.LUCENE_8_11_1, "8044989f-77ef-4d6d-9dd8-1bdd805cef74"); - public static final IndexVersion V_7_17_10 = registerIndexVersion(7_17_10_99, Version.LUCENE_8_11_1, "66b743fb-8be6-443f-8920-d8c5ed561857"); - public static final IndexVersion V_7_17_11 = registerIndexVersion(7_17_11_99, Version.LUCENE_8_11_1, "f1935acc-1af9-44b0-97e9-67112d333753"); - public static final IndexVersion V_7_17_12 = registerIndexVersion(7_17_12_99, Version.LUCENE_8_11_1, "1a0719f2-96f4-4df5-b20d-62244e27d7d4"); - public static final IndexVersion V_7_17_13 = registerIndexVersion(7_17_13_99, Version.LUCENE_8_11_1, "171a73c6-3ece-4f10-804f-7104a97b557c"); public static final IndexVersion V_8_0_0 = registerIndexVersion(8_00_00_99, Version.LUCENE_9_0_0, "ff18a13c-1fa7-4cf7-a3b1-4fdcd9461d5b"); - public static final IndexVersion V_8_0_1 = registerIndexVersion(8_00_01_99, Version.LUCENE_9_0_0, "4bd5650f-3eff-418f-a7a6-ad46b2a9c941"); public static final IndexVersion V_8_1_0 = registerIndexVersion(8_01_00_99, Version.LUCENE_9_0_0, "b4742461-ee43-4fd0-a260-29f8388b82ec"); - public static final IndexVersion V_8_1_1 = registerIndexVersion(8_01_01_99, Version.LUCENE_9_0_0, "3883e088-9a1c-4494-8d71-768820485f33"); - public static final IndexVersion V_8_1_2 = registerIndexVersion(8_01_02_99, Version.LUCENE_9_0_0, "859a745a-81d3-463e-af58-615179a22d4f"); - public static final IndexVersion V_8_1_3 = registerIndexVersion(8_01_03_99, Version.LUCENE_9_0_0, "27a49f3f-d3ac-4b0e-8bba-1be24daf4a56"); public static final IndexVersion V_8_2_0 = registerIndexVersion(8_02_00_99, Version.LUCENE_9_1_0, "af0ed990-2f32-42b5-aaf3-59d21a3dca7a"); - public static final IndexVersion V_8_2_1 = registerIndexVersion(8_02_01_99, Version.LUCENE_9_1_0, "6e2a3812-062a-4d08-8c35-ddc930e8e246"); - public static final IndexVersion V_8_2_2 = registerIndexVersion(8_02_02_99, Version.LUCENE_9_1_0, "93d1434c-3956-408b-8204-93be8ab78856"); - public static final IndexVersion V_8_2_3 = registerIndexVersion(8_02_03_99, Version.LUCENE_9_1_0, "026f6904-2a04-4476-8097-02a75e37e0f7"); public static final IndexVersion V_8_3_0 = registerIndexVersion(8_03_00_99, Version.LUCENE_9_2_0, "eca8e8a3-0724-4247-a58d-e4eafcec4b3f"); - public static final IndexVersion V_8_3_1 = registerIndexVersion(8_03_01_99, Version.LUCENE_9_2_0, "dac08798-c0b5-46c9-bf27-d82c617ce41f"); - public static final IndexVersion V_8_3_2 = registerIndexVersion(8_03_02_99, Version.LUCENE_9_2_0, "2a0c5fb9-e8a5-4788-89f8-f5723bd68cee"); - public static final IndexVersion V_8_3_3 = registerIndexVersion(8_03_03_99, Version.LUCENE_9_2_0, "440a5f5c-767a-49f7-8593-dc7627b30397"); public static final IndexVersion V_8_4_0 = registerIndexVersion(8_04_00_99, Version.LUCENE_9_3_0, "d27324da-b36c-452a-93a8-9b69a6c302a1"); - public static final IndexVersion V_8_4_1 = registerIndexVersion(8_04_01_99, Version.LUCENE_9_3_0, "44108ecd-839b-423e-9ef1-9d457f244fff"); - public static final IndexVersion V_8_4_2 = registerIndexVersion(8_04_02_99, Version.LUCENE_9_3_0, "9c20ed39-8c32-4cf0-9f06-42735cbf604e"); - public static final IndexVersion V_8_4_3 = registerIndexVersion(8_04_03_99, Version.LUCENE_9_3_0, "e7d17607-47c0-4662-b308-beeb9a8ec552"); public static final IndexVersion V_8_5_0 = registerIndexVersion(8_05_00_99, Version.LUCENE_9_4_1, "c5284b51-7fee-4f34-a837-241bb57a7aa6"); - public static final IndexVersion V_8_5_1 = registerIndexVersion(8_05_01_99, Version.LUCENE_9_4_1, "b23a983c-9630-4a2b-8352-0f52b55ff87e"); - public static final IndexVersion V_8_5_2 = registerIndexVersion(8_05_02_99, Version.LUCENE_9_4_1, "cfc80b6f-cb5c-4a4c-b3af-5fa1000508a8"); - public static final IndexVersion V_8_5_3 = registerIndexVersion(8_05_03_99, Version.LUCENE_9_4_2, "f8ac8061-1b17-4cab-b2f6-94df31f7552e"); public static final IndexVersion V_8_6_0 = registerIndexVersion(8_06_00_99, Version.LUCENE_9_4_2, "5e78c76c-74aa-464e-9383-89bdffb74db9"); - public static final IndexVersion V_8_6_1 = registerIndexVersion(8_06_01_99, Version.LUCENE_9_4_2, "8dc502be-ef27-43b3-a27b-1cb925cbef7d"); - public static final IndexVersion V_8_6_2 = registerIndexVersion(8_06_02_99, Version.LUCENE_9_4_2, "e1e73b88-d188-4d82-b5e1-dee261418783"); public static final IndexVersion V_8_7_0 = registerIndexVersion(8_07_00_99, Version.LUCENE_9_5_0, "f9227941-d6f4-462b-957f-2bcd36c28382"); - public static final IndexVersion V_8_7_1 = registerIndexVersion(8_07_01_99, Version.LUCENE_9_5_0, "758780b8-4b0c-44c6-af5d-fdac10b6093a"); public static final IndexVersion V_8_8_0 = registerIndexVersion(8_08_00_99, Version.LUCENE_9_6_0, "d6ffc8d7-f6bd-469b-8495-01688c310000"); - public static final IndexVersion V_8_8_1 = registerIndexVersion(8_08_01_99, Version.LUCENE_9_6_0, "a613499e-ec1a-4b0b-81d3-a766aff3c27c"); public static final IndexVersion V_8_8_2 = registerIndexVersion(8_08_02_99, Version.LUCENE_9_6_0, "9db9d888-6be8-4a58-825c-f423fd8c6b00"); public static final IndexVersion V_8_9_0 = registerIndexVersion(8_09_00_99, Version.LUCENE_9_7_0, "32f6dbab-cc24-4f5b-87b5-015a848480d9"); public static final IndexVersion V_8_9_1 = registerIndexVersion(8_09_01_99, Version.LUCENE_9_7_0, "955a80ac-f70c-40a5-9399-1d8a1e5d342d"); - public static final IndexVersion V_8_9_2 = registerIndexVersion(8_09_02_99, Version.LUCENE_9_7_0, "14c7d64c-9e25-4265-b4fa-e0c5aca67f14"); public static final IndexVersion V_8_10_0 = registerIndexVersion(8_10_00_99, Version.LUCENE_9_7_0, "2e107286-12ad-4c51-9a6f-f8943663b6e7"); public static final IndexVersion V_8_11_0 = registerIndexVersion(8_11_00_99, Version.LUCENE_9_7_0, "f08382c0-06ab-41f4-a56a-cf5397275627"); /* diff --git a/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java b/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java index 39b62b54bf087..63ee2d0961b32 100644 --- a/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java @@ -209,7 +209,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(storedFieldsContext); out.writeBoolean(docValueFields != null); if (docValueFields != null) { - out.writeList(docValueFields); + out.writeCollection(docValueFields); } boolean hasScriptFields = scriptFields != null; out.writeBoolean(hasScriptFields); @@ -232,7 +232,7 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) { out.writeBoolean(fetchFields != null); if (fetchFields != null) { - out.writeList(fetchFields); + out.writeCollection(fetchFields); } } } diff --git a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java index de168614ccdd7..e744a691a5ffb 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java @@ -515,9 +515,9 @@ public MoreLikeThisQueryBuilder(StreamInput in) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException { out.writeOptionalStringArray(fields); out.writeStringArray(likeTexts); - out.writeList(Arrays.asList(likeItems)); + out.writeCollection(Arrays.asList(likeItems)); out.writeStringArray(unlikeTexts); - out.writeList(Arrays.asList(unlikeItems)); + out.writeCollection(Arrays.asList(unlikeItems)); out.writeVInt(maxQueryTerms); out.writeVInt(minTermFreq); out.writeVInt(minDocFreq); diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java index 57ce77eda5bd6..e3d6f68b93b2c 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java @@ -148,7 +148,7 @@ public FunctionScoreQueryBuilder(StreamInput in) throws IOException { @Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(query); - out.writeList(Arrays.asList(filterFunctionBuilders)); + out.writeCollection(Arrays.asList(filterFunctionBuilders)); out.writeFloat(maxBoost); out.writeOptionalFloat(minScore); out.writeOptionalWriteable(boostMode); diff --git a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java index eca77904e998f..caa23719348f5 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java @@ -185,8 +185,8 @@ public boolean isTimedOut() { public void writeTo(StreamOutput out) throws IOException { out.writeTimeValue(took); status.writeTo(out); - out.writeList(bulkFailures); - out.writeList(searchFailures); + out.writeCollection(bulkFailures); + out.writeCollection(searchFailures); out.writeBoolean(timedOut); } diff --git a/server/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java b/server/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java index 033624ec79e40..58e9baefe087c 100644 --- a/server/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java +++ b/server/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java @@ -206,7 +206,7 @@ public DenseVectorStats getDenseVectorStats() { @Override public void writeTo(StreamOutput out) throws IOException { stats.writeTo(out); - out.writeMap(statsByShard, (o, k) -> k.writeTo(o), StreamOutput::writeList); + out.writeMap(statsByShard, (o, k) -> k.writeTo(o), (streamOutput, list) -> streamOutput.writeCollection(list)); if (out.getTransportVersion().onOrAfter(VERSION_SUPPORTING_STATS_BY_INDEX)) { out.writeMap(statsByIndex, (o, k) -> k.writeTo(o), (o, v) -> v.writeTo(o)); } diff --git a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java index 9089e209d29b6..3fa1263e26d6b 100644 --- a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java +++ b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java @@ -225,7 +225,7 @@ public void writeTo(StreamOutput out) throws IOException { assert out.getTransportVersion().onOrAfter(TransportVersion.V_7_17_0) : out.getTransportVersion(); } metadataSnapshot.writeTo(out); - out.writeList(peerRecoveryRetentionLeases); + out.writeCollection(peerRecoveryRetentionLeases); } public boolean isEmpty() { @@ -334,7 +334,7 @@ protected List readNodesFrom(StreamInput in) throws IOEx @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } diff --git a/server/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java b/server/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java index bc00bd668ce50..e630bc7ef8ea4 100644 --- a/server/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java +++ b/server/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java @@ -178,7 +178,7 @@ public void writeTo(StreamOutput out) throws IOException { mem.writeTo(out); threads.writeTo(out); gc.writeTo(out); - out.writeList(bufferPools); + out.writeCollection(bufferPools); classes.writeTo(out); } @@ -516,7 +516,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(nonHeapCommitted); out.writeVLong(nonHeapUsed); out.writeVLong(heapMax); - out.writeList(pools); + out.writeCollection(pools); } @Override diff --git a/server/src/main/java/org/elasticsearch/script/ScriptStats.java b/server/src/main/java/org/elasticsearch/script/ScriptStats.java index 3b21d8746e5f5..64009b9f2843f 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptStats.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptStats.java @@ -161,7 +161,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(cacheEvictions); } out.writeVLong(compilationLimitTriggered); - out.writeList(contextStats); + out.writeCollection(contextStats); } public List getContextStats() { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/InternalComposite.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/InternalComposite.java index 558698e6bc132..57759b7524fb6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/InternalComposite.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/InternalComposite.java @@ -122,7 +122,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_16_0)) { out.writeArray((o, order) -> order.writeTo(o), missingOrders); } - out.writeList(buckets); + out.writeCollection(buckets); out.writeOptionalWriteable(afterKey); if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_6_0)) { out.writeBoolean(earlyTerminated); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilters.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilters.java index c86b0aea6f514..8f0d8a2f10be9 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilters.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilters.java @@ -163,7 +163,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_8_0)) { out.writeBoolean(keyedBucket); } - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java index 9348be3903cc3..a837b83caa7fd 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoGrid.java @@ -61,7 +61,7 @@ public InternalGeoGrid(StreamInput in) throws IOException { @Override protected void doWriteTo(StreamOutput out) throws IOException { writeSize(requiredSize, out); - out.writeList(buckets); + out.writeCollection(buckets); } protected abstract InternalGeoGrid create( diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java index a94ab7aab4481..8b9850805f288 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java @@ -256,7 +256,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeLong(offset); out.writeNamedWriteable(format); out.writeBoolean(keyed); - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java index 77891e9a73beb..fb4b03f6ed66e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java @@ -250,7 +250,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { } out.writeNamedWriteable(format); out.writeBoolean(keyed); - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java index 1acf0b0ce385f..4b4b6a2192f43 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java @@ -268,7 +268,7 @@ public InternalVariableWidthHistogram(StreamInput in) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException { emptyBucketInfo.writeTo(out); out.writeNamedWriteable(format); - out.writeList(buckets); + out.writeCollection(buckets); out.writeVInt(targetNumBuckets); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/InternalIpPrefix.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/InternalIpPrefix.java index 01e16341e2a5d..ab9444499d5dd 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/InternalIpPrefix.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/InternalIpPrefix.java @@ -216,7 +216,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); out.writeBoolean(keyed); out.writeVLong(minDocCount); - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java index 87f726b47579e..cbe6044210ac5 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeBuilder.java @@ -109,7 +109,7 @@ protected int compare(int i, int j) { @Override protected void innerWriteTo(StreamOutput out) throws IOException { - out.writeList(ranges); + out.writeCollection(ranges); out.writeBoolean(keyed); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java index 61ee79c633aa8..4da11de4b100e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java @@ -311,7 +311,7 @@ public GeoPoint origin() { protected void innerWriteTo(StreamOutput out) throws IOException { out.writeDouble(origin.lat()); out.writeDouble(origin.lon()); - out.writeList(ranges); + out.writeCollection(ranges); out.writeBoolean(keyed); distanceType.writeTo(out); unit.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java index 88777f8a29286..f6c4829247a92 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java @@ -223,7 +223,7 @@ public InternalBinaryRange(StreamInput in) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); out.writeBoolean(keyed); - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java index 87c6ff5a462de..f534fce37c4d3 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java @@ -79,7 +79,7 @@ SetBackedScalingCuckooFilter getFilter() { @Override protected void writeTermTypeInfoTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); - out.writeList(buckets); + out.writeCollection(buckets); filter.writeTo(out); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java index ea32df7683e49..0d9f03c6198eb 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java @@ -67,7 +67,7 @@ protected final void writeTermTypeInfoTo(StreamOutput out) throws IOException { out.writeVLong(subsetSize); out.writeVLong(supersetSize); out.writeNamedWriteable(significanceHeuristic); - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedTerms.java index fb3b262e5f0b2..d7a310f5154b6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedTerms.java @@ -95,7 +95,7 @@ protected final void writeTermTypeInfoTo(StreamOutput out) throws IOException { writeSize(shardSize, out); out.writeBoolean(showTermDocCountError); out.writeVLong(otherDocCount); - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java index 3772eec79871b..af6f420690170 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java @@ -143,7 +143,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { boolean hasFieldDataFields = docValueFields != null; out.writeBoolean(hasFieldDataFields); if (hasFieldDataFields) { - out.writeList(docValueFields); + out.writeCollection(docValueFields); } out.writeOptionalWriteable(storedFieldsContext); out.writeVInt(from); @@ -165,7 +165,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) { out.writeBoolean(fetchFields != null); if (fetchFields != null) { - out.writeList(fetchFields); + out.writeCollection(fetchFields); } } } diff --git a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 8dab3cac700cb..2c1eb21a8136c 100644 --- a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -282,16 +282,16 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(fetchSourceContext); out.writeBoolean(docValueFields != null); if (docValueFields != null) { - out.writeList(docValueFields); + out.writeCollection(docValueFields); } out.writeOptionalWriteable(storedFieldsContext); out.writeVInt(from); out.writeOptionalWriteable(highlightBuilder); - out.writeList(indexBoosts); + out.writeCollection(indexBoosts); out.writeOptionalFloat(minScore); out.writeOptionalNamedWriteable(postQueryBuilder); if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_013)) { - out.writeList(subSearchSourceBuilders); + out.writeCollection(subSearchSourceBuilders); } else if (out.getTransportVersion().before(TransportVersion.V_8_4_0) && subSearchSourceBuilders.size() >= 2) { throw new IllegalArgumentException("cannot serialize [sub_searches] to version [" + out.getTransportVersion() + "]"); } else { @@ -305,7 +305,7 @@ public void writeTo(StreamOutput out) throws IOException { boolean hasScriptFields = scriptFields != null; out.writeBoolean(hasScriptFields); if (hasScriptFields) { - out.writeList(scriptFields); + out.writeCollection(scriptFields); } out.writeVInt(size); boolean hasSorts = sorts != null; @@ -333,7 +333,7 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) { out.writeBoolean(fetchFields != null); if (fetchFields != null) { - out.writeList(fetchFields); + out.writeCollection(fetchFields); } out.writeOptionalWriteable(pointInTimeBuilder); } diff --git a/server/src/main/java/org/elasticsearch/search/collapse/CollapseBuilder.java b/server/src/main/java/org/elasticsearch/search/collapse/CollapseBuilder.java index 03882eba07c41..bb0871240fb16 100644 --- a/server/src/main/java/org/elasticsearch/search/collapse/CollapseBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/collapse/CollapseBuilder.java @@ -85,7 +85,7 @@ public CollapseBuilder(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { out.writeString(field); out.writeVInt(maxConcurrentGroupRequests); - out.writeList(innerHits); + out.writeCollection(innerHits); } public static CollapseBuilder fromXContent(XContentParser parser) { diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilder.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilder.java index bd0b3770f9f49..df0989fd6816d 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilder.java @@ -136,7 +136,7 @@ public HighlightBuilder(StreamInput in) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException { out.writeOptionalString(encoder); out.writeBoolean(useExplicitFieldOrder); - out.writeList(fields); + out.writeCollection(fields); } /** diff --git a/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java b/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java index e34cc1a1bcd77..9fe66a0c112de 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java +++ b/server/src/main/java/org/elasticsearch/search/profile/ProfileResult.java @@ -92,7 +92,7 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_9_0)) { out.writeMap(debug, StreamOutput::writeString, StreamOutput::writeGenericValue); } - out.writeList(children); + out.writeCollection(children); } /** diff --git a/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java b/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java index f9f85749bbd52..c6cf1a9b6d7a8 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java +++ b/server/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java @@ -64,7 +64,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(getName()); out.writeString(getReason()); out.writeLong(getTime()); - out.writeList(getChildrenResults()); + out.writeCollection(getChildrenResults()); } /** diff --git a/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java b/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java index 4dad6f779375a..43ac611b220c6 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java @@ -317,7 +317,7 @@ public void trim() { public void writeTo(StreamOutput out) throws IOException { out.writeString(name); out.writeVInt(size); - out.writeList(entries); + out.writeCollection(entries); } @Override diff --git a/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java b/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java index c2252023fde96..36511e6729b6c 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java @@ -161,7 +161,7 @@ public void doWriteTo(StreamOutput out) throws IOException { } out.writeMapWithConsistentOrder(collateParams); out.writeOptionalBoolean(collatePrune); - out.writeMap(this.generators, StreamOutput::writeString, StreamOutput::writeList); + out.writeMap(this.generators, StreamOutput::writeString, (streamOutput, list) -> streamOutput.writeCollection(list)); } /** diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java index 32cd9b8b74462..325de0c6d7178 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java @@ -1032,7 +1032,7 @@ public void writeTo(final StreamOutput out) throws IOException { out.writeVLong(endTime); out.writeVInt(totalShards); out.writeVInt(successfulShards); - out.writeList(shardFailures); + out.writeCollection(shardFailures); if (version != null) { out.writeBoolean(true); IndexVersion.writeVersion(version, out); @@ -1042,7 +1042,7 @@ public void writeTo(final StreamOutput out) throws IOException { out.writeOptionalBoolean(includeGlobalState); out.writeGenericMap(userMetadata); out.writeStringCollection(dataStreams); - out.writeList(featureStates); + out.writeCollection(featureStates); out.writeMap(indexSnapshotDetails, StreamOutput::writeString, (stream, value) -> value.writeTo(stream)); } diff --git a/server/src/main/java/org/elasticsearch/threadpool/ThreadPoolInfo.java b/server/src/main/java/org/elasticsearch/threadpool/ThreadPoolInfo.java index 6e809aec0705a..5f165ac8bce49 100644 --- a/server/src/main/java/org/elasticsearch/threadpool/ThreadPoolInfo.java +++ b/server/src/main/java/org/elasticsearch/threadpool/ThreadPoolInfo.java @@ -31,7 +31,7 @@ public ThreadPoolInfo(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(infos); + out.writeCollection(infos); } @Override diff --git a/server/src/test/java/org/elasticsearch/VersionTests.java b/server/src/test/java/org/elasticsearch/VersionTests.java index 2e84465648650..99f78f4e8d023 100644 --- a/server/src/test/java/org/elasticsearch/VersionTests.java +++ b/server/src/test/java/org/elasticsearch/VersionTests.java @@ -8,10 +8,8 @@ package org.elasticsearch; -import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.VersionUtils; -import org.hamcrest.Matchers; import java.lang.reflect.Modifier; import java.util.HashMap; @@ -80,12 +78,10 @@ public void testMax() { public void testVersionConstantPresent() { assertThat(Version.CURRENT, sameInstance(Version.fromId(Version.CURRENT.id))); - assertThat(Version.CURRENT.luceneVersion(), equalTo(org.apache.lucene.util.Version.LATEST)); final int iters = scaledRandomIntBetween(20, 100); for (int i = 0; i < iters; i++) { Version version = randomVersion(random()); assertThat(version, sameInstance(Version.fromId(version.id))); - assertThat(version.luceneVersion(), sameInstance(Version.fromId(version.id).luceneVersion())); } } @@ -167,7 +163,7 @@ public void testParseVersion() { for (int i = 0; i < iters; i++) { Version version = randomVersion(random()); if (random().nextBoolean()) { - version = new Version(version.id, version.indexVersion); + version = new Version(version.id); } Version parsedVersion = Version.fromString(version.toString()); assertEquals(version, parsedVersion); @@ -181,15 +177,6 @@ public void testParseVersion() { expectThrows(IllegalArgumentException.class, () -> { Version.fromString("5.0.0-SNAPSHOT"); }); } - public void testParseLenient() { - // note this is just a silly sanity check, we test it in lucene - for (Version version : VersionUtils.allReleasedVersions()) { - org.apache.lucene.util.Version luceneVersion = version.luceneVersion(); - String string = luceneVersion.toString().toUpperCase(Locale.ROOT).replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2"); - assertThat(luceneVersion, Matchers.equalTo(Lucene.parseVersionLenient(string, null))); - } - } - public void testAllVersionsMatchId() throws Exception { final Set releasedVersions = new HashSet<>(VersionUtils.allReleasedVersions()); final Set unreleasedVersions = new HashSet<>(VersionUtils.allUnreleasedVersions()); @@ -237,25 +224,6 @@ public void testAllVersionsMatchId() throws Exception { } } - // this test ensures we never bump the lucene version in a bugfix release - public void testLuceneVersionIsSameOnMinorRelease() { - for (Version version : VersionUtils.allReleasedVersions()) { - for (Version other : VersionUtils.allReleasedVersions()) { - if (other.onOrAfter(version)) { - assertTrue( - "lucene versions must be " + other + " >= " + version, - other.luceneVersion().onOrAfter(version.luceneVersion()) - ); - } - if (other.major == version.major && other.minor == version.minor) { - assertEquals(version + " vs. " + other, other.luceneVersion().major, version.luceneVersion().major); - assertEquals(version + " vs. " + other, other.luceneVersion().minor, version.luceneVersion().minor); - // should we also assert the lucene bugfix version? - } - } - } - } - public static void assertUnknownVersion(Version version) { assertFalse( "Version " + version + " has been releaed don't use a new instance of this version", diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java index 627cbd6039f1b..8ba248535416f 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java @@ -124,7 +124,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public int failureCount() { diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java index 819e37a32bfe7..b1fe493817bfa 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java @@ -146,7 +146,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public int getFailureCount() { diff --git a/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java b/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java index 2e90efd216593..8c5bb0efe53e0 100644 --- a/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java @@ -389,7 +389,7 @@ protected List readNodesFrom(StreamInput in) throws IOExceptio @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } diff --git a/server/src/test/java/org/elasticsearch/common/collect/IteratorsTests.java b/server/src/test/java/org/elasticsearch/common/collect/IteratorsTests.java index 3f9a3562008a2..341ebea2a2a0c 100644 --- a/server/src/test/java/org/elasticsearch/common/collect/IteratorsTests.java +++ b/server/src/test/java/org/elasticsearch/common/collect/IteratorsTests.java @@ -17,7 +17,10 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.BiPredicate; +import java.util.function.ToIntFunction; import java.util.stream.IntStream; public class IteratorsTests extends ESTestCase { @@ -208,6 +211,48 @@ public void testMap() { assertEquals(array.length, index.get()); } + public void testEquals() { + final BiPredicate notCalled = (a, b) -> { throw new AssertionError("not called"); }; + + assertTrue(Iterators.equals(null, null, notCalled)); + assertFalse(Iterators.equals(Collections.emptyIterator(), null, notCalled)); + assertFalse(Iterators.equals(null, Collections.emptyIterator(), notCalled)); + assertTrue(Iterators.equals(Collections.emptyIterator(), Collections.emptyIterator(), notCalled)); + + assertFalse(Iterators.equals(Collections.emptyIterator(), List.of(1).iterator(), notCalled)); + assertFalse(Iterators.equals(List.of(1).iterator(), Collections.emptyIterator(), notCalled)); + assertTrue(Iterators.equals(List.of(1).iterator(), List.of(1).iterator(), Objects::equals)); + assertFalse(Iterators.equals(List.of(1).iterator(), List.of(2).iterator(), Objects::equals)); + assertFalse(Iterators.equals(List.of(1, 2).iterator(), List.of(1).iterator(), Objects::equals)); + assertFalse(Iterators.equals(List.of(1).iterator(), List.of(1, 2).iterator(), Objects::equals)); + + final var strings1 = randomList(10, () -> randomAlphaOfLength(10)); + final var strings2 = new ArrayList<>(strings1); + + assertTrue(Iterators.equals(strings1.iterator(), strings2.iterator(), Objects::equals)); + + if (strings2.size() == 0 || randomBoolean()) { + strings2.add(randomAlphaOfLength(10)); + } else { + final var index = between(0, strings2.size() - 1); + if (randomBoolean()) { + strings2.remove(index); + } else { + strings2.set(index, randomValueOtherThan(strings2.get(index), () -> randomAlphaOfLength(10))); + } + } + assertFalse(Iterators.equals(strings1.iterator(), strings2.iterator(), Objects::equals)); + } + + public void testHashCode() { + final ToIntFunction notCalled = (a) -> { throw new AssertionError("not called"); }; + assertEquals(0, Iterators.hashCode(null, notCalled)); + assertEquals(1, Iterators.hashCode(Collections.emptyIterator(), notCalled)); + + final var numbers = randomIntegerArray(); + assertEquals(Arrays.hashCode(numbers), Iterators.hashCode(Arrays.stream(numbers).iterator(), Objects::hashCode)); + } + private static Integer[] randomIntegerArray() { return Randomness.get().ints(randomIntBetween(0, 1000)).boxed().toArray(Integer[]::new); } diff --git a/server/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java b/server/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java index 740f72ce02bd6..4e9bfdd29b3c6 100644 --- a/server/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java +++ b/server/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java @@ -476,7 +476,7 @@ public void testWriteWriteableList() throws IOException { } final BytesStreamOutput out = new BytesStreamOutput(); - out.writeList(expected); + out.writeCollection(expected); final StreamInput in = StreamInput.wrap(BytesReference.toBytes(out.bytes())); diff --git a/server/src/test/java/org/elasticsearch/common/io/stream/RecyclerBytesStreamOutputTests.java b/server/src/test/java/org/elasticsearch/common/io/stream/RecyclerBytesStreamOutputTests.java index 63fe28d7fc37b..acfc1d45ecabc 100644 --- a/server/src/test/java/org/elasticsearch/common/io/stream/RecyclerBytesStreamOutputTests.java +++ b/server/src/test/java/org/elasticsearch/common/io/stream/RecyclerBytesStreamOutputTests.java @@ -516,7 +516,7 @@ public void testWriteWriteableList() throws IOException { } final RecyclerBytesStreamOutput out = new RecyclerBytesStreamOutput(recycler); - out.writeList(expected); + out.writeCollection(expected); final StreamInput in = StreamInput.wrap(BytesReference.toBytes(out.bytes())); diff --git a/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java b/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java index be0ff95e8603e..976add854c584 100644 --- a/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java +++ b/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java @@ -18,7 +18,6 @@ import org.apache.lucene.index.Term; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.IndexRouting; @@ -31,7 +30,7 @@ import org.elasticsearch.index.mapper.VersionFieldMapper; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import java.io.IOException; import java.util.ArrayList; @@ -201,23 +200,24 @@ public void testCacheFilterReader() throws Exception { public void testLuceneVersionOnUnknownVersions() { // between two known versions, should use the lucene version of the previous version - Version version = VersionUtils.getPreviousVersion(Version.CURRENT); - final Version nextVersion = Version.fromId(version.id + 100); - if (Version.getDeclaredVersions(Version.class).contains(nextVersion) == false) { + IndexVersion version = IndexVersionUtils.getPreviousVersion(); + final IndexVersion nextVersion = IndexVersion.fromId(version.id() + 100); + if (IndexVersionUtils.allReleasedVersions().contains(nextVersion) == false) { // the version is not known, we make an assumption the Lucene version stays the same - assertEquals(nextVersion.luceneVersion(), version.luceneVersion()); + assertThat(version.luceneVersion(), equalTo(nextVersion.luceneVersion())); } else { // the version is known, the most we can assert is that the Lucene version is not earlier + // Version does not implement Comparable :( assertTrue(nextVersion.luceneVersion().onOrAfter(version.luceneVersion())); } // too old version, major should be the oldest supported lucene version minus 1 - version = Version.fromString("5.2.1"); - assertEquals(VersionUtils.getFirstVersion().luceneVersion().major - 1, version.luceneVersion().major); + version = IndexVersion.fromId(5020199); + assertThat(version.luceneVersion().major, equalTo(IndexVersionUtils.getFirstVersion().luceneVersion().major - 1)); // future version, should be the same version as today - version = Version.fromId(Version.CURRENT.id + 100); - assertEquals(Version.CURRENT.luceneVersion(), version.luceneVersion()); + version = IndexVersion.fromId(IndexVersion.current().id() + 100); + assertThat(version.luceneVersion(), equalTo(IndexVersion.current().luceneVersion())); } public void testTimeSeriesLoadDocIdAndVersion() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java index 89d6b880bfd42..4ffd98eb4d8a9 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java @@ -9,11 +9,14 @@ package org.elasticsearch.index; import org.apache.lucene.util.Version; +import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.index.IndexVersionUtils; +import org.hamcrest.Matchers; import java.lang.reflect.Modifier; import java.util.Collections; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; @@ -163,11 +166,13 @@ public void testMinimumCompatibleVersion() { public void testVersionConstantPresent() { Set ignore = Set.of(IndexVersion.ZERO, IndexVersion.current(), IndexVersion.MINIMUM_COMPATIBLE); assertThat(IndexVersion.current(), sameInstance(IndexVersion.fromId(IndexVersion.current().id()))); + assertThat(IndexVersion.current().luceneVersion(), equalTo(org.apache.lucene.util.Version.LATEST)); final int iters = scaledRandomIntBetween(20, 100); for (int i = 0; i < iters; i++) { IndexVersion version = IndexVersionUtils.randomVersion(ignore); assertThat(version, sameInstance(IndexVersion.fromId(version.id()))); + assertThat(version.luceneVersion(), sameInstance(IndexVersion.fromId(version.id()).luceneVersion())); } } @@ -182,4 +187,13 @@ public void testToString() { assertEquals("2000099", IndexVersion.fromId(2_00_00_99).toString()); assertEquals("5000099", IndexVersion.fromId(5_00_00_99).toString()); } + + public void testParseLenient() { + // note this is just a silly sanity check, we test it in lucene + for (IndexVersion version : IndexVersionUtils.allReleasedVersions()) { + org.apache.lucene.util.Version luceneVersion = version.luceneVersion(); + String string = luceneVersion.toString().toUpperCase(Locale.ROOT).replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2"); + assertThat(luceneVersion, Matchers.equalTo(Lucene.parseVersionLenient(string, null))); + } + } } diff --git a/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java b/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java index 1b852bd7cd4d9..0018c9cf1d7da 100644 --- a/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java +++ b/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java @@ -69,7 +69,9 @@ public void testThatInstancesAreCachedAndReused() { ); // Same Lucene version should be cached: - assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(IndexVersion.V_8_0_0), PreBuiltAnalyzers.STOP.getAnalyzer(IndexVersion.V_8_0_1)); + IndexVersion v1 = IndexVersionUtils.randomVersion(random()); + IndexVersion v2 = new IndexVersion(v1.id() - 1, v1.luceneVersion()); + assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(v1), PreBuiltAnalyzers.STOP.getAnalyzer(v2)); } public void testThatAnalyzersAreUsedInMapping() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapperTests.java index 9fc812028609b..560108541271c 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapperTests.java @@ -998,6 +998,8 @@ private void mapping(XContentBuilder b) throws IOException { b.field("ef_construction", 50); b.endObject(); } + } else { + b.field("index", false); } } diff --git a/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java b/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java index 50b4750a72c85..b6b2b67b491b7 100644 --- a/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java +++ b/server/src/test/java/org/elasticsearch/persistent/TestPersistentTasksPlugin.java @@ -519,7 +519,7 @@ public TestTasksResponse(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(tasks); + out.writeCollection(tasks); } public List getTasks() { diff --git a/test/external-modules/error-query/src/main/java/org/elasticsearch/test/errorquery/ErrorQueryBuilder.java b/test/external-modules/error-query/src/main/java/org/elasticsearch/test/errorquery/ErrorQueryBuilder.java index 39a8191453686..89b3d205acf20 100644 --- a/test/external-modules/error-query/src/main/java/org/elasticsearch/test/errorquery/ErrorQueryBuilder.java +++ b/test/external-modules/error-query/src/main/java/org/elasticsearch/test/errorquery/ErrorQueryBuilder.java @@ -95,7 +95,7 @@ public ErrorQueryBuilder(StreamInput in) throws IOException { @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeList(indices); + out.writeCollection(indices); } @Override diff --git a/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/NodeSeekStats.java b/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/NodeSeekStats.java index db743c1d976e1..152af86197e44 100644 --- a/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/NodeSeekStats.java +++ b/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/NodeSeekStats.java @@ -37,7 +37,7 @@ public NodeSeekStats(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeMap(seeks, StreamOutput::writeString, StreamOutput::writeList); + out.writeMap(seeks, StreamOutput::writeString, (streamOutput, list) -> streamOutput.writeCollection(list)); } @Override diff --git a/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekStatsResponse.java b/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekStatsResponse.java index 8696c19b76220..6695d5c80974d 100644 --- a/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekStatsResponse.java +++ b/test/external-modules/seek-tracking-directory/src/main/java/org/elasticsearch/test/seektracker/SeekStatsResponse.java @@ -41,7 +41,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index fe104d36b9cf0..d5c5d8ed304b2 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -24,9 +24,11 @@ import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteResponse; +import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodeHotThreads; +import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; @@ -53,6 +55,8 @@ import org.elasticsearch.action.support.DefaultShardOperationFailedException; import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.action.support.IndicesOptions; +import org.elasticsearch.action.support.PlainActionFuture; +import org.elasticsearch.action.support.RefCountingListener; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.internal.AdminClient; @@ -177,6 +181,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -961,32 +966,54 @@ private ClusterHealthStatus ensureColor( // been removed by the master so that the health check applies to the set of nodes we expect to be part of the cluster. .waitForNodes(Integer.toString(cluster().size())); - ClusterHealthResponse actionGet = clusterAdmin().health(healthRequest).actionGet(); - if (actionGet.isTimedOut()) { - final String hotThreads = clusterAdmin().prepareNodesHotThreads() - .setThreads(99999) - .setIgnoreIdleThreads(false) - .get() - .getNodes() - .stream() - .map(NodeHotThreads::getHotThreads) - .collect(Collectors.joining("\n")); + final ClusterHealthResponse clusterHealthResponse = clusterAdmin().health(healthRequest).actionGet(); + if (clusterHealthResponse.isTimedOut()) { + final var allocationExplainRef = new AtomicReference(); + final var clusterStateRef = new AtomicReference(); + final var pendingTasksRef = new AtomicReference(); + final var hotThreadsRef = new AtomicReference(); + + final var detailsFuture = new PlainActionFuture(); + try (var listeners = new RefCountingListener(detailsFuture)) { + clusterAdmin().prepareAllocationExplain().execute(listeners.acquire(allocationExplainRef::set)); + clusterAdmin().prepareState().execute(listeners.acquire(clusterStateRef::set)); + clusterAdmin().preparePendingClusterTasks().execute(listeners.acquire(pendingTasksRef::set)); + clusterAdmin().prepareNodesHotThreads() + .setThreads(9999) + .setIgnoreIdleThreads(false) + .execute(listeners.acquire(hotThreadsRef::set)); + } + + try { + detailsFuture.get(60, TimeUnit.SECONDS); + } catch (Exception e) { + logger.error("failed to get full debug details within 60s timeout", e); + } + logger.info( - "{} timed out, cluster state:\n{}\npending tasks:\n{}\nhot threads:\n{}\n", + "{} timed out\nallocation explain:\n{}\ncluster state:\n{}\npending tasks:\n{}\nhot threads:\n{}\n", method, - clusterAdmin().prepareState().get().getState(), - clusterAdmin().preparePendingClusterTasks().get(), - hotThreads + safeFormat(allocationExplainRef.get(), r -> Strings.toString(r.getExplanation(), true, true)), + safeFormat(clusterStateRef.get(), r -> r.getState().toString()), + safeFormat(pendingTasksRef.get(), r -> Strings.toString(r, true, true)), + safeFormat( + hotThreadsRef.get(), + r -> r.getNodes().stream().map(NodeHotThreads::getHotThreads).collect(Collectors.joining("\n")) + ) ); fail("timed out waiting for " + color + " state"); } assertThat( - "Expected at least " + clusterHealthStatus + " but got " + actionGet.getStatus(), - actionGet.getStatus().value(), + "Expected at least " + clusterHealthStatus + " but got " + clusterHealthResponse.getStatus(), + clusterHealthResponse.getStatus().value(), lessThanOrEqualTo(clusterHealthStatus.value()) ); logger.debug("indices {} are {}", indices.length == 0 ? "[_all]" : indices, color); - return actionGet.getStatus(); + return clusterHealthResponse.getStatus(); + } + + private static String safeFormat(@Nullable T value, Function formatter) { + return value == null ? null : formatter.apply(value); } /** diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java index 0189b55d43b1d..c949c0cbf9868 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java @@ -346,7 +346,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeVLong(otherDocCount); out.writeCollection(formats, StreamOutput::writeNamedWriteable); out.writeCollection(keyConverters, StreamOutput::writeEnum); - out.writeList(buckets); + out.writeCollection(buckets); } @Override diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationBuilder.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationBuilder.java index 1df2f6634ba1d..4d0934fdea8f8 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationBuilder.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationBuilder.java @@ -196,7 +196,7 @@ public BucketCardinality bucketCardinality() { @Override protected final void doWriteTo(StreamOutput out) throws IOException { - out.writeList(terms); + out.writeCollection(terms); order.writeTo(out); out.writeOptionalWriteable(collectMode); bucketCountThresholds.writeTo(out); diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetrics.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetrics.java index b8ca3c22fbb74..c449bdcffc636 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetrics.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/InternalTopMetrics.java @@ -77,7 +77,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { sortOrder.writeTo(out); out.writeStringCollection(metricNames); out.writeVInt(size); - out.writeList(topMetrics); + out.writeCollection(topMetrics); } @Override diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java index 931aba50d3eb2..741ad501b97ba 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java @@ -167,7 +167,7 @@ public boolean supportsSampling() { protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteableList(sortBuilders); out.writeVInt(size); - out.writeList(metricFields); + out.writeCollection(metricFields); } @Override diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/NodeDecisions.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/NodeDecisions.java index 709e19ccbfbcd..6bf9c081f950f 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/NodeDecisions.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/NodeDecisions.java @@ -44,7 +44,7 @@ NodeDecision canRemainDecision() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(canAllocateDecisions); + out.writeCollection(canAllocateDecisions); out.writeOptionalWriteable(canRemainDecision); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/GetFeatureUsageResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/GetFeatureUsageResponse.java index 91380980a58a7..91ab5cf58dd7e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/GetFeatureUsageResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/GetFeatureUsageResponse.java @@ -113,7 +113,7 @@ public List getFeatures() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(features); + out.writeCollection(features); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/Hop.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/Hop.java index cc03b58631eeb..05a617002d9cc 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/Hop.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/Hop.java @@ -71,7 +71,7 @@ void writeTo(StreamOutput out) throws IOException { if (vertices == null) { out.writeVInt(0); } else { - out.writeList(vertices); + out.writeCollection(vertices); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/RemoteClusterFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/RemoteClusterFeatureSetUsage.java index a251bbfd65303..c3eb7dc8baa69 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/RemoteClusterFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/RemoteClusterFeatureSetUsage.java @@ -39,7 +39,7 @@ public TransportVersion getMinimalSupportedVersion() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(remoteConnectionInfos); + out.writeCollection(remoteConnectionInfos); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/util/QueryPage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/util/QueryPage.java index b1303246337b0..8bb62ec86e9e9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/util/QueryPage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/util/QueryPage.java @@ -54,7 +54,7 @@ public static ResourceNotFoundException emptyQueryPage(ParseField resultsField) @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(resultsField.getPreferredName()); - out.writeList(results); + out.writeCollection(results); out.writeLong(count); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java index dd0ed88d5f13e..bbbcdb06b5ae9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java @@ -112,7 +112,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public EnumCounters getStats() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowInfoAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowInfoAction.java index 037e413c89b42..4ea603955c56f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowInfoAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowInfoAction.java @@ -102,7 +102,7 @@ public Response(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(followInfos); + out.writeCollection(followInfos); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java index ac7d27d7f28bc..82c4515fae344 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java @@ -70,7 +70,7 @@ public StatsResponses(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(statsResponse); + out.writeCollection(statsResponse); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/EnrichStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/EnrichStatsAction.java index 9f66164270884..97b463d8b4c44 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/EnrichStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/EnrichStatsAction.java @@ -79,10 +79,10 @@ public List getCacheStats() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(executingPolicies); - out.writeList(coordinatorStats); + out.writeCollection(executingPolicies); + out.writeCollection(coordinatorStats); if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_16_0)) { - out.writeList(cacheStats); + out.writeCollection(cacheStats); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/GetEnrichPolicyAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/GetEnrichPolicyAction.java index 7396d22f184c3..0890a0ba4104d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/GetEnrichPolicyAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/enrich/action/GetEnrichPolicyAction.java @@ -99,7 +99,7 @@ public Response(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(policies); + out.writeCollection(policies); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java index 19bc639a7e595..ce7de69876a28 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/IndexLifecycleFeatureSetUsage.java @@ -48,7 +48,7 @@ public void writeTo(StreamOutput out) throws IOException { boolean hasPolicyStats = policyStats != null; out.writeBoolean(hasPolicyStats); if (hasPolicyStats) { - out.writeList(policyStats); + out.writeCollection(policyStats); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/GetLifecycleAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/GetLifecycleAction.java index abfbbe975a032..39d8c7535dfea 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/GetLifecycleAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/GetLifecycleAction.java @@ -58,7 +58,7 @@ public List getPolicies() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(policies); + out.writeCollection(policies); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java index 04a893918a470..5018028ab02bc 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java @@ -191,7 +191,7 @@ public Response(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(fieldSelection); + out.writeCollection(fieldSelection); memoryEstimation.writeTo(out); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetDataFrameAnalyticsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetDataFrameAnalyticsStatsAction.java index 07d2e4f442035..59a1df31b5bdc 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetDataFrameAnalyticsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/GetDataFrameAnalyticsStatsAction.java @@ -312,7 +312,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(id); state.writeTo(out); out.writeOptionalString(failureReason); - out.writeList(progress); + out.writeCollection(progress); dataCounts.writeTo(out); memoryUsage.writeTo(out); out.writeOptionalNamedWriteable(analysisStats); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/MlMemoryAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/MlMemoryAction.java index 06b5418d5ee97..4e847726bb50c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/MlMemoryAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/MlMemoryAction.java @@ -323,7 +323,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostCalendarEventsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostCalendarEventsAction.java index b396e1be1af1f..4a877c3c6605b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostCalendarEventsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/PostCalendarEventsAction.java @@ -97,7 +97,7 @@ public ActionRequestValidationException validate() { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(calendarId); - out.writeList(scheduledEvents); + out.writeCollection(scheduledEvents); } @Override @@ -133,7 +133,7 @@ public Response(List scheduledEvents) { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(scheduledEvents); + out.writeCollection(scheduledEvents); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java index b14d42088a26d..069186f50d6b0 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java @@ -131,7 +131,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateProcessAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateProcessAction.java index b6bd1fb0a2c0a..8326adadd4230 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateProcessAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateProcessAction.java @@ -115,7 +115,7 @@ public void writeTo(StreamOutput out) throws IOException { boolean hasDetectorUpdates = detectorUpdates != null; out.writeBoolean(hasDetectorUpdates); if (hasDetectorUpdates) { - out.writeList(detectorUpdates); + out.writeCollection(detectorUpdates); } out.writeOptionalWriteable(filter); out.writeBoolean(updateScheduledEvents); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java index 486fd56fefbbf..535bf4b1d1300 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java @@ -529,7 +529,7 @@ public void writeTo(StreamOutput out) throws IOException { if (scriptFields != null) { out.writeBoolean(true); - out.writeList(scriptFields); + out.writeCollection(scriptFields); } else { out.writeBoolean(false); } @@ -837,7 +837,7 @@ public void writeTo(StreamOutput out) throws IOException { if (scriptFields != null) { out.writeBoolean(true); - out.writeList(scriptFields); + out.writeCollection(scriptFields); } else { out.writeBoolean(false); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java index 6e7575100e84e..5eb201ea6d0a4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedUpdate.java @@ -194,7 +194,7 @@ public void writeTo(StreamOutput out) throws IOException { if (scriptFields != null) { out.writeBoolean(true); - out.writeList(scriptFields); + out.writeCollection(scriptFields); } else { out.writeBoolean(false); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Accuracy.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Accuracy.java index 1c9e214308a32..6b6c238c95a7a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Accuracy.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Accuracy.java @@ -263,7 +263,7 @@ public double getOverallAccuracy() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(classes); + out.writeCollection(classes); out.writeDouble(overallAccuracy); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/MulticlassConfusionMatrix.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/MulticlassConfusionMatrix.java index ab9f54c7348e2..03ae283c02411 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/MulticlassConfusionMatrix.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/MulticlassConfusionMatrix.java @@ -310,7 +310,7 @@ public long getOtherActualClassCount() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(actualClasses); + out.writeCollection(actualClasses); out.writeVLong(otherActualClassCount); } @@ -406,7 +406,7 @@ public long getOtherPredictedClassDocCount() { public void writeTo(StreamOutput out) throws IOException { out.writeString(actualClass); out.writeVLong(actualClassDocCount); - out.writeList(predictedClasses); + out.writeCollection(predictedClasses); out.writeVLong(otherPredictedClassDocCount); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java index 0d873289e2fb9..79a21d599842e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Precision.java @@ -256,7 +256,7 @@ public double getAvgPrecision() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(classes); + out.writeCollection(classes); out.writeDouble(avgPrecision); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java index e2b3d35c73b90..81c2a46c55558 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/classification/Recall.java @@ -226,7 +226,7 @@ public double getAvgRecall() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(classes); + out.writeCollection(classes); out.writeDouble(avgRecall); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/common/AbstractAucRoc.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/common/AbstractAucRoc.java index cd74f4e86eb8b..e5d0b83afac65 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/common/AbstractAucRoc.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/common/AbstractAucRoc.java @@ -322,7 +322,7 @@ public String getMetricName() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeDouble(value); - out.writeList(curve); + out.writeCollection(curve); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java index d4a105a9ca605..a7f7649a2a0af 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java @@ -63,7 +63,7 @@ public ValidationLoss(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(lossType); - out.writeList(foldValues); + out.writeCollection(foldValues); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java index c647c784948fa..dd08dacc94c59 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java @@ -63,7 +63,7 @@ public ValidationLoss(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(lossType); - out.writeList(foldValues); + out.writeCollection(foldValues); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/assignment/AssignmentStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/assignment/AssignmentStats.java index 301e895c57f37..71b35f53184fd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/assignment/AssignmentStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/assignment/AssignmentStats.java @@ -632,7 +632,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalVInt(numberOfAllocations); out.writeOptionalVInt(queueCapacity); out.writeInstant(startTime); - out.writeList(nodeStats); + out.writeCollection(nodeStats); if (AssignmentState.FAILED.equals(state) && out.getTransportVersion().before(TransportVersion.V_8_4_0)) { out.writeOptionalEnum(AssignmentState.STARTING); } else { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationFeatureImportance.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationFeatureImportance.java index ef918209bf19e..c45335c55b970 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationFeatureImportance.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationFeatureImportance.java @@ -85,7 +85,7 @@ public double getTotalImportance() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(featureName); - out.writeList(classImportance); + out.writeCollection(classImportance); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationInferenceResults.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationInferenceResults.java index cb008062cc0b2..d0870b6bf7fea 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationInferenceResults.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/ClassificationInferenceResults.java @@ -147,7 +147,7 @@ public List getFeatureImportance() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(featureImportance); + out.writeCollection(featureImportance); out.writeOptionalString(classificationLabel); out.writeCollection(topClasses); out.writeString(topNumClassesField); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/NerResults.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/NerResults.java index fd1751387942c..092d10fe94bae 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/NerResults.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/NerResults.java @@ -62,7 +62,7 @@ public String getWriteableName() { @Override void doWriteTo(StreamOutput out) throws IOException { - out.writeList(entityGroups); + out.writeCollection(entityGroups); out.writeString(resultsField); out.writeString(annotatedResult); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/RegressionInferenceResults.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/RegressionInferenceResults.java index dcab4d9508c80..6537d34c55747 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/RegressionInferenceResults.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/RegressionInferenceResults.java @@ -81,7 +81,7 @@ public RegressionInferenceResults(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(featureImportance); + out.writeCollection(featureImportance); out.writeString(resultsField); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/TextExpansionResults.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/TextExpansionResults.java index 93f6780f05eec..3340cecd61153 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/TextExpansionResults.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/results/TextExpansionResults.java @@ -112,7 +112,7 @@ public int hashCode() { @Override void doWriteTo(StreamOutput out) throws IOException { out.writeString(resultsField); - out.writeList(weightedTokens); + out.writeCollection(weightedTokens); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/FeatureImportanceBaseline.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/FeatureImportanceBaseline.java index 59108d7cb8742..7795bea9e447b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/FeatureImportanceBaseline.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/FeatureImportanceBaseline.java @@ -72,7 +72,7 @@ public FeatureImportanceBaseline(Double baseline, List classBasel @Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalDouble(baseline); - out.writeList(classBaselines); + out.writeCollection(classBaselines); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TotalFeatureImportance.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TotalFeatureImportance.java index fbe2d16211183..4f83400716485 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TotalFeatureImportance.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TotalFeatureImportance.java @@ -86,7 +86,7 @@ public TotalFeatureImportance(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { out.writeString(featureName); out.writeOptionalWriteable(importance); - out.writeList(classImportances); + out.writeCollection(classImportances); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TrainedModelMetadata.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TrainedModelMetadata.java index ee8f807b00010..5bb9315d002cd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TrainedModelMetadata.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/metadata/TrainedModelMetadata.java @@ -142,9 +142,9 @@ public int hashCode() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(modelId); - out.writeList(totalFeatureImportances); + out.writeCollection(totalFeatureImportances); out.writeOptionalWriteable(featureImportanceBaselines); - out.writeList(hyperparameters); + out.writeCollection(hyperparameters); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisConfig.java index ca648cfc18fe8..aaaf16f9df59a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisConfig.java @@ -200,7 +200,7 @@ public void writeTo(StreamOutput out) throws IOException { perPartitionCategorizationConfig.writeTo(out); out.writeOptionalTimeValue(latency); out.writeOptionalString(summaryCountFieldName); - out.writeList(detectors); + out.writeCollection(detectors); out.writeStringCollection(influencers); out.writeOptionalBoolean(multivariateByFields); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/CategorizationAnalyzerConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/CategorizationAnalyzerConfig.java index fca4979261dd0..be559d6d9e00c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/CategorizationAnalyzerConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/CategorizationAnalyzerConfig.java @@ -237,9 +237,9 @@ public CategorizationAnalyzerConfig(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(analyzer); - out.writeList(charFilters); + out.writeCollection(charFilters); out.writeOptionalWriteable(tokenizer); - out.writeList(tokenFilters); + out.writeCollection(tokenFilters); } public String getAnalyzer() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/DetectionRule.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/DetectionRule.java index ddfccfc7f62e0..bc2375d441161 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/DetectionRule.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/DetectionRule.java @@ -69,7 +69,7 @@ public DetectionRule(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { out.writeEnumSet(actions); scope.writeTo(out); - out.writeList(conditions); + out.writeCollection(conditions); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java index 9cd8afe44587c..d7ad3c9a1d9b5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java @@ -243,7 +243,7 @@ public void writeTo(StreamOutput out) throws IOException { } else { out.writeBoolean(false); } - out.writeList(rules); + out.writeCollection(rules); out.writeInt(detectorIndex); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java index aa1b48ba6fd53..d1702d57443e5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java @@ -205,7 +205,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(description); out.writeBoolean(detectorUpdates != null); if (detectorUpdates != null) { - out.writeList(detectorUpdates); + out.writeCollection(detectorUpdates); } out.writeOptionalWriteable(modelPlotConfig); out.writeOptionalWriteable(analysisLimits); @@ -725,7 +725,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(description); out.writeBoolean(rules != null); if (rules != null) { - out.writeList(rules); + out.writeCollection(rules); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyCause.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyCause.java index 685dc93cf962c..cf62e4e02526b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyCause.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyCause.java @@ -157,7 +157,7 @@ public void writeTo(StreamOutput out) throws IOException { boolean hasInfluencers = influencers != null; out.writeBoolean(hasInfluencers); if (hasInfluencers) { - out.writeList(influencers); + out.writeCollection(influencers); } out.writeOptionalWriteable(geoResults); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java index 2454a169685e0..aae9326678152 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java @@ -252,7 +252,7 @@ public void writeTo(StreamOutput out) throws IOException { boolean hasCauses = causes != null; out.writeBoolean(hasCauses); if (hasCauses) { - out.writeList(causes); + out.writeCollection(causes); } out.writeDouble(recordScore); out.writeDouble(initialRecordScore); @@ -261,7 +261,7 @@ public void writeTo(StreamOutput out) throws IOException { boolean hasInfluencers = influences != null; out.writeBoolean(hasInfluencers); if (hasInfluencers) { - out.writeList(influences); + out.writeCollection(influences); } out.writeOptionalWriteable(geoResults); if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_6_0)) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java index 92600df4f0569..ac2a231432c0c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java @@ -161,10 +161,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeDouble(anomalyScore); out.writeLong(bucketSpan); out.writeDouble(initialAnomalyScore); - out.writeList(records); + out.writeCollection(records); out.writeLong(eventCount); out.writeBoolean(isInterim); - out.writeList(bucketInfluencers); + out.writeCollection(bucketInfluencers); out.writeLong(processingTimeMs); out.writeStringCollection(scheduledEvents); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java index a7d46cfd981e4..9e7aac89b838d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java @@ -64,7 +64,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeLong(timestamp.getTime()); out.writeLong(bucketSpan); out.writeDouble(overallScore); - out.writeList(jobs); + out.writeCollection(jobs); out.writeBoolean(isInterim); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java index 11e956c3ae780..823ac4cb55d28 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java @@ -120,6 +120,6 @@ public MonitoringBulkRequest add( @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(docs); + out.writeCollection(docs); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringMigrateAlertsResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringMigrateAlertsResponse.java index 1e88ee7624a16..60b5b0cd62694 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringMigrateAlertsResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringMigrateAlertsResponse.java @@ -36,7 +36,7 @@ public MonitoringMigrateAlertsResponse(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(exporters); + out.writeCollection(exporters); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java index a71142cf718a1..134b9a58b585e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupJobsAction.java @@ -149,7 +149,7 @@ public Response(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(jobs); + out.writeCollection(jobs); } public List getJobs() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollableIndexCaps.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollableIndexCaps.java index 411f8b0db497e..b853313da1c26 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollableIndexCaps.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollableIndexCaps.java @@ -52,7 +52,7 @@ public List getJobCaps() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(indexName); - out.writeList(jobCaps); + out.writeCollection(jobCaps); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfig.java index 73c480353511b..7ad50fff5591b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobConfig.java @@ -252,7 +252,7 @@ public void writeTo(final StreamOutput out) throws IOException { out.writeString(rollupIndex); out.writeString(cron); out.writeOptionalWriteable(groupConfig); - out.writeList(metricsConfig); + out.writeCollection(metricsConfig); out.writeTimeValue(timeout); out.writeInt(pageSize); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/searchablesnapshots/SearchableSnapshotShardStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/searchablesnapshots/SearchableSnapshotShardStats.java index 068a7dda5f7f3..3095c7080318f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/searchablesnapshots/SearchableSnapshotShardStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/searchablesnapshots/SearchableSnapshotShardStats.java @@ -56,7 +56,7 @@ public void writeTo(StreamOutput out) throws IOException { shardRouting.writeTo(out); snapshotId.writeTo(out); indexId.writeTo(out); - out.writeList(inputStats); + out.writeCollection(inputStats); } public ShardRouting getShardRouting() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheResponse.java index 41b36deb0f2ae..f26f393c14383 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheResponse.java @@ -37,7 +37,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateApiKeyRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateApiKeyRequest.java index 7ea53c9f11fc8..341baf84e9d10 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateApiKeyRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateApiKeyRequest.java @@ -127,7 +127,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(name); } out.writeOptionalTimeValue(expiration); - out.writeList(getRoleDescriptors()); + out.writeCollection(getRoleDescriptors()); refreshPolicy.writeTo(out); if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_13_0)) { out.writeGenericMap(metadata); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateCrossClusterApiKeyRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateCrossClusterApiKeyRequest.java index 2b993155b4fc4..05a99977dfbaa 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateCrossClusterApiKeyRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/CreateCrossClusterApiKeyRequest.java @@ -73,7 +73,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(id); out.writeString(name); out.writeOptionalTimeValue(expiration); - out.writeList(roleDescriptors); + out.writeCollection(roleDescriptors); refreshPolicy.writeTo(out); out.writeGenericMap(metadata); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/QueryApiKeyRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/QueryApiKeyRequest.java index e315d81975d62..5f4eb60ea64b2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/QueryApiKeyRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/apikey/QueryApiKeyRequest.java @@ -133,7 +133,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(false); } else { out.writeBoolean(true); - out.writeList(fieldSortBuilders); + out.writeCollection(fieldSortBuilders); } out.writeOptionalWriteable(searchAfterBuilder); if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_5_0)) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheResponse.java index 9bb11ac8e6893..c1d08cecf461a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheResponse.java @@ -37,7 +37,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/PutPrivilegesRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/PutPrivilegesRequest.java index 77d4ac677e17e..2e73cff8dbcad 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/PutPrivilegesRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/PutPrivilegesRequest.java @@ -127,7 +127,7 @@ public String toString() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(privileges); + out.writeCollection(privileges); refreshPolicy.writeTo(out); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/profile/GetProfilesResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/profile/GetProfilesResponse.java index 08239f2a1d4b9..4338b042df716 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/profile/GetProfilesResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/profile/GetProfilesResponse.java @@ -45,7 +45,7 @@ public Map getErrors() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(profiles); + out.writeCollection(profiles); out.writeMap(errors, StreamOutput::writeString, StreamOutput::writeException); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheResponse.java index 3ab93fc85ffbd..87576a65e9685 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheResponse.java @@ -37,7 +37,7 @@ protected List readNodesFrom(StreamInput in) throw @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheResponse.java index c4310663d3a3f..84900684b8df4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheResponse.java @@ -40,7 +40,7 @@ protected List readNodesFrom(StreamInput in) throw @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequest.java index bda2542c720d2..c431bc278e281 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequest.java @@ -209,7 +209,7 @@ public void writeTo(StreamOutput out) throws IOException { for (RoleDescriptor.IndicesPrivileges index : indicesPrivileges) { index.writeTo(out); } - out.writeList(applicationPrivileges); + out.writeCollection(applicationPrivileges); ConfigurableClusterPrivileges.writeArray(out, this.configurableClusterPrivileges); out.writeStringArray(runAs); refreshPolicy.writeTo(out); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/rolemapping/PutRoleMappingRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/rolemapping/PutRoleMappingRequest.java index 89b092b0ea1a2..c9762621ad435 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/rolemapping/PutRoleMappingRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/rolemapping/PutRoleMappingRequest.java @@ -156,7 +156,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(enabled); out.writeStringCollection(roles); if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) { - out.writeList(roleTemplates); + out.writeCollection(roleTemplates); } ExpressionParser.writeExpression(rules, out); out.writeGenericMap(metadata); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesResponse.java index 34299c85a29fb..10ef80486123e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesResponse.java @@ -50,7 +50,7 @@ protected List readNodesFrom(Str @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public List getFileTokenInfos() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsResponse.java index 1d2e8f7462137..f0a79b3a3cf31 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsResponse.java @@ -56,7 +56,7 @@ public GetServiceAccountCredentialsNodesResponse getNodesResponse() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(principal); - out.writeList(indexTokenInfos); + out.writeCollection(indexTokenInfos); nodesResponse.writeTo(out); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/TokenMetadata.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/TokenMetadata.java index 153f3be38f605..ea2254f5e8887 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/TokenMetadata.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/TokenMetadata.java @@ -52,7 +52,7 @@ public TokenMetadata(StreamInput input) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeByteArray(currentKeyHash); - out.writeList(keys); + out.writeCollection(keys); } public static NamedDiff readDiffFrom(StreamInput in) throws IOException { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/ExpressionRoleMapping.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/ExpressionRoleMapping.java index cbe1e71d8fc05..4da5ae6c399ea 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/ExpressionRoleMapping.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/ExpressionRoleMapping.java @@ -112,7 +112,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(enabled); out.writeStringCollection(roles); if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) { - out.writeList(roleTemplates); + out.writeCollection(roleTemplates); } ExpressionParser.writeExpression(expression, out); out.writeGenericMap(metadata); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/FieldExpression.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/FieldExpression.java index 1b640164d54b5..efd6b9e199004 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/FieldExpression.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/support/mapper/expressiondsl/FieldExpression.java @@ -51,7 +51,7 @@ public FieldExpression(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(field); - out.writeList(values); + out.writeCollection(values); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/action/GetSnapshotLifecycleAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/action/GetSnapshotLifecycleAction.java index 0e9fe37127476..e182a1168a7d6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/action/GetSnapshotLifecycleAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/action/GetSnapshotLifecycleAction.java @@ -116,7 +116,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(lifecycles); + out.writeCollection(lifecycles); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java index e9d179c68c378..43b1528f385e7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java @@ -106,7 +106,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } public EnumCounters getStats() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java index aed2daf0c2a4e..629f252c40973 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java @@ -200,7 +200,7 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_1_0)) { if (errors != null) { out.writeBoolean(true); - out.writeList(errors); + out.writeCollection(errors); } else { out.writeBoolean(false); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/QueryWatchesAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/QueryWatchesAction.java index 4bc5ab2fbc71e..6c5e0df82de8c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/QueryWatchesAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/QueryWatchesAction.java @@ -154,7 +154,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalNamedWriteable(query); if (sorts != null) { out.writeBoolean(true); - out.writeList(sorts); + out.writeCollection(sorts); } else { out.writeBoolean(false); } @@ -230,7 +230,7 @@ public long getWatchTotalCount() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(watches); + out.writeCollection(watches); out.writeVLong(watchTotalCount); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsResponse.java index c8838875cc2d8..8afaacc65de49 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsResponse.java @@ -59,7 +59,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override @@ -199,11 +199,11 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(snapshots != null); if (snapshots != null) { - out.writeList(snapshots); + out.writeCollection(snapshots); } out.writeBoolean(queuedWatches != null); if (queuedWatches != null) { - out.writeList(queuedWatches); + out.writeCollection(queuedWatches); } out.writeBoolean(stats != null); if (stats != null) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/MockAction.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/MockAction.java index 571eee9270161..85e85230d0d16 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/MockAction.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/MockAction.java @@ -77,7 +77,7 @@ public List toSteps(Client client, String phase, Step.StepKey nextStepKey) @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(steps.stream().map(MockStep::new).collect(Collectors.toList())); + out.writeCollection(steps.stream().map(MockStep::new).collect(Collectors.toList())); out.writeBoolean(safe); } diff --git a/x-pack/plugin/core/template-resources/src/main/resources/fleet-agents.json b/x-pack/plugin/core/template-resources/src/main/resources/fleet-agents.json index f098e7ce6d96b..5de8ce4bef402 100644 --- a/x-pack/plugin/core/template-resources/src/main/resources/fleet-agents.json +++ b/x-pack/plugin/core/template-resources/src/main/resources/fleet-agents.json @@ -59,15 +59,8 @@ } }, "components": { - "type": "nested", - "properties": { - "id": { - "type": "keyword" - }, - "status": { - "type": "keyword" - } - } + "type": "object", + "enabled": false }, "last_updated": { "type": "date" diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java index 8ec978d175f22..47d171be9352d 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java @@ -201,11 +201,11 @@ public Map> getPluginSettingsIssues() { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(clusterSettingsIssues); - out.writeList(nodeSettingsIssues); + out.writeCollection(clusterSettingsIssues); + out.writeCollection(nodeSettingsIssues); out.writeMapOfLists(indexSettingsIssues, StreamOutput::writeString, (o, v) -> v.writeTo(o)); if (out.getTransportVersion().before(TransportVersion.V_7_11_0)) { - out.writeList(pluginSettingsIssues.getOrDefault("ml_settings", Collections.emptyList())); + out.writeCollection(pluginSettingsIssues.getOrDefault("ml_settings", Collections.emptyList())); } else { out.writeMapOfLists(pluginSettingsIssues, StreamOutput::writeString, (o, v) -> v.writeTo(o)); } diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java index 2737464cd8398..e24602085df80 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java @@ -69,7 +69,7 @@ public NodeResponse(DiscoveryNode node, List deprecationIssues @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(this.deprecationIssues); + out.writeCollection(this.deprecationIssues); } public List getDeprecationIssues() { diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckResponse.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckResponse.java index 4708ae8eb90c5..824a55e4f4c09 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckResponse.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckResponse.java @@ -38,7 +38,7 @@ protected List readNodesFrom(StreamInp @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java index c69e4e2903124..5881663821e1f 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java @@ -86,7 +86,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java index 12cf251c63f92..d05009fc704c6 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java @@ -84,7 +84,7 @@ protected List readNodesFrom(StreamInput in) throws IOException { @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/action/GetAnalyticsCollectionAction.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/action/GetAnalyticsCollectionAction.java index c4568da72c30b..caeff2bf8f93c 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/action/GetAnalyticsCollectionAction.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/analytics/action/GetAnalyticsCollectionAction.java @@ -134,7 +134,7 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(collections); + out.writeCollection(collections); } public List getAnalyticsCollections() { diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRule.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRule.java index 04de4e6feaf47..217370c4fcb60 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRule.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRule.java @@ -148,7 +148,7 @@ private void validatePinnedAction(Object action) { public void writeTo(StreamOutput out) throws IOException { out.writeString(id); out.writeString(type.toString()); - out.writeList(criteria); + out.writeCollection(criteria); out.writeGenericMap(actions); } diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRuleset.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRuleset.java index 10f50c20476a6..ef5d574013ef0 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRuleset.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRuleset.java @@ -133,7 +133,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(id); - out.writeList(rules); + out.writeCollection(rules); } public String id() { diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java index 6edc7087f82a5..0274e5ae70247 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java @@ -463,7 +463,7 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_13_0)) { out.writeBoolean(fetchFields != null); if (fetchFields != null) { - out.writeList(fetchFields); + out.writeCollection(fetchFields); } out.writeGenericMap(runtimeMappings); } diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchResponse.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchResponse.java index cbabfb8381b7d..48cb86eb40f80 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchResponse.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchResponse.java @@ -449,7 +449,7 @@ public static Sequence fromXContent(XContentParser parser) { @Override public void writeTo(StreamOutput out) throws IOException { out.writeGenericValue(joinKeys); - out.writeList(events); + out.writeCollection(events); } @Override @@ -534,13 +534,13 @@ public void writeTo(StreamOutput out) throws IOException { } if (events != null) { out.writeBoolean(true); - out.writeList(events); + out.writeCollection(events); } else { out.writeBoolean(false); } if (sequences != null) { out.writeBoolean(true); - out.writeList(sequences); + out.writeCollection(sequences); } else { out.writeBoolean(false); } diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsResponse.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsResponse.java index 61417c94c6ff6..e504ee2937761 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsResponse.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsResponse.java @@ -38,7 +38,7 @@ protected List readNodesFrom(StreamInput in) throws IOExcepti @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/AbstractBlockBuilder.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/AbstractBlockBuilder.java index 95de2a05e4145..88e7b27adf915 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/AbstractBlockBuilder.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/AbstractBlockBuilder.java @@ -24,6 +24,7 @@ abstract class AbstractBlockBuilder implements Block.Builder { protected boolean positionEntryIsOpen; protected boolean hasNonNullValue; + protected boolean hasMultiValues; protected Block.MvOrdering mvOrdering = Block.MvOrdering.UNORDERED; @@ -70,6 +71,9 @@ public AbstractBlockBuilder beginPositionEntry() { public AbstractBlockBuilder endPositionEntry() { positionCount++; positionEntryIsOpen = false; + if (hasMultiValues == false && valueCount != positionCount) { + hasMultiValues = true; + } return this; } @@ -78,7 +82,7 @@ protected final boolean isDense() { } protected final boolean singleValued() { - return firstValueIndexes == null; + return hasMultiValues == false; } protected final void updatePosition() { diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/DriverStatus.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/DriverStatus.java index 36bd6fc8cc53f..2b36d753de215 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/DriverStatus.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/DriverStatus.java @@ -67,7 +67,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(sessionId); out.writeLong(lastUpdated); out.writeString(status.toString()); - out.writeList(activeOperators); + out.writeCollection(activeOperators); } @Override diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java index d79e99cb28225..313ba6ace5a9d 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java @@ -182,7 +182,7 @@ public void testSerializationListPages() throws IOException { new Page(BytesRefBlock.newConstantBlockWith(new BytesRef("Hello World"), positions)) ); final BytesStreamOutput out = new BytesStreamOutput(); - out.writeList(origPages); + out.writeCollection(origPages); StreamInput in = new NamedWriteableAwareStreamInput(ByteBufferStreamInput.wrap(BytesReference.toBytes(out.bytes())), registry); List deserPages = in.readList(new Page.PageReader()); diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockValueAsserter.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockValueAsserter.java index 6ad66c54b7568..e03de38d637db 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockValueAsserter.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockValueAsserter.java @@ -77,7 +77,13 @@ private static void assertBytesRefRowValues(BytesRefBlock block, int firstValueI private static void assertBooleanRowValues(BooleanBlock block, int firstValueIndex, int valueCount, List expectedRowValues) { for (int valueIndex = 0; valueIndex < valueCount; valueIndex++) { - boolean expectedValue = (Boolean) expectedRowValues.get(valueIndex); + Object value = expectedRowValues.get(valueIndex); + boolean expectedValue; + if (value instanceof Number number) { + expectedValue = number.intValue() % 2 == 0; + } else { + expectedValue = (Boolean) expectedRowValues.get(valueIndex); + } assertThat(block.getBoolean(firstValueIndex + valueIndex), is(equalTo(expectedValue))); } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/MultiValueBlockTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/MultiValueBlockTests.java index 9e809ac511a79..482a61a329a94 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/MultiValueBlockTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/MultiValueBlockTests.java @@ -16,6 +16,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; public class MultiValueBlockTests extends SerializationTestCase { @@ -233,4 +234,84 @@ public void testMultiValuesAndNulls() { BlockValueAsserter.assertBlockValues(bytesRefBlock, blockValues); EqualsHashCodeTestUtils.checkEqualsAndHashCode(intBlock, block -> serializeDeserializeBlock(block)); } + + // Tests that the use of Block builder beginPositionEntry (or not) with just a single value, + // and no nulls, builds a block backed by a vector. + public void testSingleNonNullValues() { + List blockValues = new ArrayList<>(); + int positions = randomInt(512); + for (int i = 0; i < positions; i++) { + blockValues.add(randomInt()); + } + + var blocks = List.of( + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.BOOLEAN), + TestBlockBuilder.blockFromValues(blockValues.stream().map(List::of).toList(), ElementType.BOOLEAN), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.INT), + TestBlockBuilder.blockFromValues(blockValues.stream().map(List::of).toList(), ElementType.INT), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.LONG), + TestBlockBuilder.blockFromValues(blockValues.stream().map(List::of).toList(), ElementType.LONG), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.DOUBLE), + TestBlockBuilder.blockFromValues(blockValues.stream().map(List::of).toList(), ElementType.DOUBLE), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.BYTES_REF), + TestBlockBuilder.blockFromValues(blockValues.stream().map(List::of).toList(), ElementType.BYTES_REF) + ); + for (Block block : blocks) { + assertThat(block.asVector(), is(notNullValue())); + BlockValueAsserter.assertBlockValues(block, blockValues.stream().map(List::of).toList()); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(block, unused -> serializeDeserializeBlock(block)); + } + } + + // A default max iteration times, just to avoid an infinite loop. + static final int TIMES = 10_000; + + // Tests that the use of Block builder beginPositionEntry (or not) with just a single value, + // with nulls, builds a block not backed by a vector. + public void testSingleWithNullValues() { + List blockValues = new ArrayList<>(); + boolean atLeastOneNull = false; + int positions = randomIntBetween(1, 512); // we must have at least one null entry + int times = 0; + while (atLeastOneNull == false && times < TIMES) { + times++; + for (int i = 0; i < positions; i++) { + boolean isNull = randomBoolean(); + if (isNull) { + atLeastOneNull = true; + blockValues.add(null); // empty / null + } else { + blockValues.add(randomInt()); + } + } + } + assert atLeastOneNull : "Failed to create a values block with at least one null in " + times + " times"; + + var blocks = List.of( + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.BOOLEAN), + TestBlockBuilder.blockFromValues(blockValues.stream().map(MultiValueBlockTests::mapToList).toList(), ElementType.BOOLEAN), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.INT), + TestBlockBuilder.blockFromValues(blockValues.stream().map(MultiValueBlockTests::mapToList).toList(), ElementType.INT), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.LONG), + TestBlockBuilder.blockFromValues(blockValues.stream().map(MultiValueBlockTests::mapToList).toList(), ElementType.LONG), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.DOUBLE), + TestBlockBuilder.blockFromValues(blockValues.stream().map(MultiValueBlockTests::mapToList).toList(), ElementType.DOUBLE), + TestBlockBuilder.blockFromSingleValues(blockValues, ElementType.BYTES_REF), + TestBlockBuilder.blockFromValues(blockValues.stream().map(MultiValueBlockTests::mapToList).toList(), ElementType.BYTES_REF) + ); + for (Block block : blocks) { + assertThat(block.asVector(), is(nullValue())); + BlockValueAsserter.assertBlockValues(block, blockValues.stream().map(MultiValueBlockTests::mapToList).toList()); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(block, unused -> serializeDeserializeBlock(block)); + } + } + + // Returns a list containing the given obj, or an empty list if obj is null + static List mapToList(Object obj) { + if (obj == null) { + return List.of(); + } else { + return List.of(obj); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/TestBlockBuilder.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/TestBlockBuilder.java index 37e43571bc9a5..4684da93a661a 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/TestBlockBuilder.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/TestBlockBuilder.java @@ -44,6 +44,20 @@ public static Block blockFromValues(List> blockValues, ElementType return builder.build(); } + // Builds a block of single values. Each value can be null or non-null. + // Differs from blockFromValues, as it does not use begin/endPositionEntry + public static Block blockFromSingleValues(List blockValues, ElementType elementType) { + TestBlockBuilder builder = builderOf(elementType); + for (Object rowValue : blockValues) { + if (rowValue == null) { + builder.appendNull(); + } else { + builder.appendObject(rowValue); + } + } + return builder.build(); + } + static TestBlockBuilder builderOf(ElementType type) { return switch (type) { case INT -> new TestIntBlockBuilder(0); @@ -305,6 +319,9 @@ private static class TestBooleanBlockBuilder extends TestBlockBuilder { @Override public TestBlockBuilder appendObject(Object object) { + if (object instanceof Number number) { + object = number.intValue() % 2 == 0; + } builder.appendBoolean((boolean) object); return this; } diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvAssert.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvAssert.java index dba1d29656c95..14d10dcff51d6 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvAssert.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvAssert.java @@ -16,6 +16,7 @@ import org.hamcrest.Matchers; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -150,6 +151,15 @@ static void assertData(ExpectedResults expected, ActualResults actual, Logger lo assertData(expected, actual.values(), logger, Function.identity()); } + public static void assertData( + ExpectedResults expected, + Iterator> actualValuesIterator, + Logger logger, + Function valueTransformer + ) { + assertData(expected, EsqlTestUtils.getValuesList(actualValuesIterator), logger, valueTransformer); + } + public static void assertData( ExpectedResults expected, List> actualValues, diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java index f1baa3bbfd31d..c4212b67aaa97 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -383,7 +384,7 @@ record ActualResults( List pages, Map> responseHeaders ) { - List> values() { + Iterator> values() { return EsqlQueryResponse.pagesToValues(dataTypes(), pages); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java similarity index 86% rename from x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java rename to x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java index a9a5e411c0298..dd86742785d15 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java @@ -10,6 +10,7 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.compute.data.BlockUtils; +import org.elasticsearch.xpack.esql.action.EsqlQueryResponse; import org.elasticsearch.xpack.esql.analysis.EnrichResolution; import org.elasticsearch.xpack.esql.plan.logical.local.LocalRelation; import org.elasticsearch.xpack.esql.plan.logical.local.LocalSupplier; @@ -28,6 +29,8 @@ import org.elasticsearch.xpack.ql.type.TypesTests; import org.junit.Assert; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -124,4 +127,18 @@ public boolean exists(String field) { } }; } + + public static List> getValuesList(EsqlQueryResponse results) { + return getValuesList(results.values()); + } + + public static List> getValuesList(Iterator> values) { + var valuesList = new ArrayList>(); + values.forEachRemaining(row -> { + var rowValues = new ArrayList<>(); + row.forEachRemaining(rowValues::add); + valuesList.add(rowValues); + }); + return valuesList; + } } diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionIT.java index 12be88a28a2f7..c567edda97018 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionIT.java @@ -51,6 +51,7 @@ import static java.util.Comparator.naturalOrder; import static java.util.Comparator.reverseOrder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.contains; @@ -77,21 +78,21 @@ public void setupIndex() { public void testProjectConstant() { EsqlQueryResponse results = run("from test | eval x = 1 | keep x"); assertThat(results.columns(), equalTo(List.of(new ColumnInfo("x", "integer")))); - assertThat(results.values().size(), equalTo(40)); - assertThat(results.values().get(0).get(0), equalTo(1)); + assertThat(getValuesList(results).size(), equalTo(40)); + assertThat(getValuesList(results).get(0).get(0), equalTo(1)); } public void testStatsOverConstant() { EsqlQueryResponse results = run("from test | eval x = 1 | stats x = count(x)"); assertThat(results.columns(), equalTo(List.of(new ColumnInfo("x", "long")))); - assertThat(results.values().size(), equalTo(1)); - assertThat(results.values().get(0).get(0), equalTo(40L)); + assertThat(getValuesList(results).size(), equalTo(1)); + assertThat(getValuesList(results).get(0).get(0), equalTo(40L)); } public void testRow() { long value = randomLongBetween(0, Long.MAX_VALUE); EsqlQueryResponse response = run("row " + value); - assertEquals(List.of(List.of(value)), response.values()); + assertEquals(List.of(List.of(value)), getValuesList(response)); } public void testFromStatsGroupingAvgWithSort() { @@ -120,7 +121,7 @@ private void testFromStatsGroupingAvgImpl(String command, String expectedGroupNa assertEquals("long", groupColumn.type()); // assert column values - List> valueValues = results.values(); + List> valueValues = getValuesList(results); assertEquals(2, valueValues.size()); // This is loathsome, find a declarative way to assert the expected output. if ((long) valueValues.get(0).get(1) == 1L) { @@ -158,7 +159,7 @@ private void testFromStatsGroupingCountImpl(String command, String expectedField assertEquals("long", valuesColumn.type()); // assert column values - List> valueValues = results.values(); + List> valueValues = getValuesList(results); assertEquals(2, valueValues.size()); // This is loathsome, find a declarative way to assert the expected output. if ((long) valueValues.get(0).get(1) == 1L) { @@ -179,7 +180,7 @@ public void testFromStatsGroupingByDate() { EsqlQueryResponse results = run("from test | stats avg(count) by time"); logger.info(results); Assert.assertEquals(2, results.columns().size()); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); // assert column metadata assertEquals("avg(count)", results.columns().get(0).name()); @@ -189,7 +190,11 @@ public void testFromStatsGroupingByDate() { // assert column values List expectedValues = LongStream.range(0, 40).map(i -> epoch + i).sorted().boxed().toList(); - List actualValues = IntStream.range(0, 40).mapToLong(i -> (Long) results.values().get(i).get(1)).sorted().boxed().toList(); + List actualValues = IntStream.range(0, 40) + .mapToLong(i -> (Long) getValuesList(results).get(i).get(1)) + .sorted() + .boxed() + .toList(); assertEquals(expectedValues, actualValues); } @@ -216,7 +221,7 @@ public void testFromGroupingByNumericFieldWithNulls() { record Group(Long data, Double avg) {} List expectedGroups = List.of(new Group(1L, 42.0), new Group(2L, 44.0), new Group(99L, null), new Group(null, 12.0)); - List actualGroups = results.values().stream().map(l -> new Group((Long) l.get(1), (Double) l.get(0))).toList(); + List actualGroups = getValuesList(results).stream().map(l -> new Group((Long) l.get(1), (Double) l.get(0))).toList(); assertThat(actualGroups, equalTo(expectedGroups)); } @@ -224,7 +229,7 @@ public void testFromStatsGroupingByKeyword() { EsqlQueryResponse results = run("from test | stats avg(count) by color"); logger.info(results); Assert.assertEquals(2, results.columns().size()); - Assert.assertEquals(3, results.values().size()); + Assert.assertEquals(3, getValuesList(results).size()); // assert column metadata assertEquals("avg(count)", results.columns().get(0).name()); @@ -235,8 +240,7 @@ record Group(String color, double avg) { } List expectedGroups = List.of(new Group("blue", 42.0), new Group("green", 44.0), new Group("red", 43)); - List actualGroups = results.values() - .stream() + List actualGroups = getValuesList(results).stream() .map(l -> new Group((String) l.get(1), (Double) l.get(0))) .sorted(comparing(c -> c.color)) .toList(); @@ -259,7 +263,7 @@ public void testFromStatsGroupingByKeywordWithNulls() { EsqlQueryResponse results = run("from test | stats avg = avg(" + field + ") by color"); logger.info(results); Assert.assertEquals(2, results.columns().size()); - Assert.assertEquals(4, results.values().size()); + Assert.assertEquals(4, getValuesList(results).size()); // assert column metadata assertEquals("avg", results.columns().get(0).name()); @@ -275,8 +279,7 @@ record Group(String color, Double avg) { new Group("red", 43.0), new Group("yellow", null) ); - List actualGroups = results.values() - .stream() + List actualGroups = getValuesList(results).stream() .map(l -> new Group((String) l.get(1), (Double) l.get(0))) .sorted(comparing(c -> c.color)) .toList(); @@ -298,7 +301,7 @@ public void testFromStatsMultipleAggs() { ); logger.info(results); Assert.assertEquals(6, results.columns().size()); - Assert.assertEquals(3, results.values().size()); + Assert.assertEquals(3, getValuesList(results).size()); // assert column metadata assertEquals("a", results.columns().get(0).name()); @@ -320,8 +323,7 @@ record Group(double avg, long mi, long ma, long s, long c, String color) {} new Group(43, 40, 46, 860, 20, "red") ); // TODO: each aggregator returns Double now, it should in fact mirror the data type of the fields it's aggregating - List actualGroups = results.values() - .stream() + List actualGroups = getValuesList(results).stream() .map(l -> new Group((Double) l.get(0), (Long) l.get(1), (Long) l.get(2), (Long) l.get(3), (Long) l.get(4), (String) l.get(5))) .sorted(comparing(c -> c.color)) .toList(); @@ -332,7 +334,7 @@ public void testFromSortWithTieBreakerLimit() { EsqlQueryResponse results = run("from test | sort data, count desc, time | limit 5 | keep data, count, time"); logger.info(results); assertThat( - results.values(), + getValuesList(results), contains( List.of(1L, 44L, epoch + 2), List.of(1L, 44L, epoch + 6), @@ -348,7 +350,7 @@ public void testFromStatsProjectGroup() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("data")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("long")); - assertThat(results.values(), containsInAnyOrder(List.of(1L), List.of(2L))); + assertThat(getValuesList(results), containsInAnyOrder(List.of(1L), List.of(2L))); } public void testRowStatsProjectGroupByInt() { @@ -356,7 +358,7 @@ public void testRowStatsProjectGroupByInt() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("integer")); - assertThat(results.values(), contains(List.of(1))); + assertThat(getValuesList(results), contains(List.of(1))); } public void testRowStatsProjectGroupByLong() { @@ -364,7 +366,7 @@ public void testRowStatsProjectGroupByLong() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("long")); - assertThat(results.values(), contains(List.of(1000000000000L))); + assertThat(getValuesList(results), contains(List.of(1000000000000L))); } public void testRowStatsProjectGroupByDouble() { @@ -372,7 +374,7 @@ public void testRowStatsProjectGroupByDouble() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double")); - assertThat(results.values(), contains(List.of(1.0))); + assertThat(getValuesList(results), contains(List.of(1.0))); } public void testRowStatsProjectGroupByKeyword() { @@ -380,7 +382,7 @@ public void testRowStatsProjectGroupByKeyword() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("keyword")); - assertThat(results.values(), contains(List.of("hello"))); + assertThat(getValuesList(results), contains(List.of("hello"))); } public void testFromStatsProjectGroupByDouble() { @@ -388,7 +390,7 @@ public void testFromStatsProjectGroupByDouble() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("data_d")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double")); - assertThat(results.values(), containsInAnyOrder(List.of(1.0), List.of(2.0))); + assertThat(getValuesList(results), containsInAnyOrder(List.of(1.0), List.of(2.0))); } public void testFromStatsProjectGroupWithAlias() { @@ -397,7 +399,7 @@ public void testFromStatsProjectGroupWithAlias() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("d", "d2")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("long", "long")); - assertThat(results.values(), containsInAnyOrder(List.of(1L, 1L), List.of(2L, 2L))); + assertThat(getValuesList(results), containsInAnyOrder(List.of(1L, 1L), List.of(2L, 2L))); } public void testFromStatsProjectAgg() { @@ -405,7 +407,7 @@ public void testFromStatsProjectAgg() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double")); - assertThat(results.values(), containsInAnyOrder(List.of(42d), List.of(44d))); + assertThat(getValuesList(results), containsInAnyOrder(List.of(42d), List.of(44d))); } public void testFromStatsProjectAggWithAlias() { @@ -413,7 +415,7 @@ public void testFromStatsProjectAggWithAlias() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("b")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double")); - assertThat(results.values(), containsInAnyOrder(List.of(42d), List.of(44d))); + assertThat(getValuesList(results), containsInAnyOrder(List.of(42d), List.of(44d))); } public void testFromProjectStatsGroupByAlias() { @@ -421,7 +423,7 @@ public void testFromProjectStatsGroupByAlias() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("avg(count)", "d")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double", "long")); - assertThat(results.values(), containsInAnyOrder(List.of(42d, 1L), List.of(44d, 2L))); + assertThat(getValuesList(results), containsInAnyOrder(List.of(42d, 1L), List.of(44d, 2L))); } public void testFromProjectStatsAggregateAlias() { @@ -429,36 +431,36 @@ public void testFromProjectStatsAggregateAlias() { logger.info(results); assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("avg(c)", "data")); assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double", "long")); - assertThat(results.values(), containsInAnyOrder(List.of(42d, 1L), List.of(44d, 2L))); + assertThat(getValuesList(results), containsInAnyOrder(List.of(42d, 1L), List.of(44d, 2L))); } public void testFromEvalStats() { EsqlQueryResponse results = run("from test | eval ratio = data_d / count_d | stats avg(ratio)"); logger.info(results); Assert.assertEquals(1, results.columns().size()); - Assert.assertEquals(1, results.values().size()); + Assert.assertEquals(1, getValuesList(results).size()); assertEquals("avg(ratio)", results.columns().get(0).name()); assertEquals("double", results.columns().get(0).type()); - assertEquals(1, results.values().get(0).size()); - assertEquals(0.034d, (double) results.values().get(0).get(0), 0.001d); + assertEquals(1, getValuesList(results).get(0).size()); + assertEquals(0.034d, (double) getValuesList(results).get(0).get(0), 0.001d); } public void testFromStatsEvalWithPragma() { assumeTrue("pragmas only enabled on snapshot builds", Build.current().isSnapshot()); EsqlQueryResponse results = run("from test | stats avg_count = avg(count) | eval x = avg_count + 7"); logger.info(results); - Assert.assertEquals(1, results.values().size()); - assertEquals(2, results.values().get(0).size()); - assertEquals(50, (double) results.values().get(0).get(results.columns().indexOf(new ColumnInfo("x", "double"))), 1d); - assertEquals(43, (double) results.values().get(0).get(results.columns().indexOf(new ColumnInfo("avg_count", "double"))), 1d); + Assert.assertEquals(1, getValuesList(results).size()); + assertEquals(2, getValuesList(results).get(0).size()); + assertEquals(50, (double) getValuesList(results).get(0).get(results.columns().indexOf(new ColumnInfo("x", "double"))), 1d); + assertEquals(43, (double) getValuesList(results).get(0).get(results.columns().indexOf(new ColumnInfo("avg_count", "double"))), 1d); } public void testWhere() { EsqlQueryResponse results = run("from test | where count > 40"); logger.info(results); - Assert.assertEquals(30, results.values().size()); + Assert.assertEquals(30, getValuesList(results).size()); var countIndex = results.columns().indexOf(new ColumnInfo("count", "long")); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Long) values.get(countIndex), greaterThan(40L)); } } @@ -466,9 +468,9 @@ public void testWhere() { public void testProjectWhere() { EsqlQueryResponse results = run("from test | keep count | where count > 40"); logger.info(results); - Assert.assertEquals(30, results.values().size()); + Assert.assertEquals(30, getValuesList(results).size()); int countIndex = results.columns().indexOf(new ColumnInfo("count", "long")); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Long) values.get(countIndex), greaterThan(40L)); } } @@ -476,9 +478,9 @@ public void testProjectWhere() { public void testEvalWhere() { EsqlQueryResponse results = run("from test | eval x = count / 2 | where x > 20"); logger.info(results); - Assert.assertEquals(30, results.values().size()); + Assert.assertEquals(30, getValuesList(results).size()); int countIndex = results.columns().indexOf(new ColumnInfo("x", "long")); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Long) values.get(countIndex), greaterThan(20L)); } } @@ -486,15 +488,15 @@ public void testEvalWhere() { public void testFilterWithNullAndEval() { EsqlQueryResponse results = run("row a = 1 | eval b = a + null | where b > 1"); logger.info(results); - Assert.assertEquals(0, results.values().size()); + Assert.assertEquals(0, getValuesList(results).size()); } public void testStringLength() { EsqlQueryResponse results = run("from test | eval l = length(color)"); logger.info(results); - assertThat(results.values(), hasSize(40)); + assertThat(getValuesList(results), hasSize(40)); int countIndex = results.columns().indexOf(new ColumnInfo("l", "integer")); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Integer) values.get(countIndex), greaterThanOrEqualTo(3)); } } @@ -506,11 +508,11 @@ public void testFilterWithNullAndEvalFromIndex() { client().admin().indices().prepareRefresh("test").get(); // sanity EsqlQueryResponse results = run("from test"); - Assert.assertEquals(41, results.values().size()); + Assert.assertEquals(41, getValuesList(results).size()); results = run("from test | eval newCount = count + 1 | where newCount > 1"); logger.info(results); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); assertThat(results.columns(), hasItem(equalTo(new ColumnInfo("count", "long")))); assertThat(results.columns(), hasItem(equalTo(new ColumnInfo("count_d", "double")))); assertThat(results.columns(), hasItem(equalTo(new ColumnInfo("data", "long")))); @@ -520,7 +522,7 @@ public void testFilterWithNullAndEvalFromIndex() { // restore index to original pre-test state client().prepareBulk().add(new DeleteRequest("test").id("no_count")).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); results = run("from test"); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); } public void testMultiConditionalWhere() { @@ -528,9 +530,9 @@ public void testMultiConditionalWhere() { "from test | eval abc = 1+2 | where (abc + count >= 44 or data_d == 2) and data == 1 | keep color, abc" ); logger.info(results); - Assert.assertEquals(10, results.values().size()); + Assert.assertEquals(10, getValuesList(results).size()); Assert.assertEquals(2, results.columns().size()); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((String) values.get(0), equalTo("green")); assertThat((Integer) values.get(1), equalTo(3)); } @@ -539,9 +541,9 @@ public void testMultiConditionalWhere() { public void testWhereNegatedCondition() { EsqlQueryResponse results = run("from test | eval abc=1+2 | where abc + count > 45 and data != 1 | keep color, data"); logger.info(results); - Assert.assertEquals(10, results.values().size()); + Assert.assertEquals(10, getValuesList(results).size()); Assert.assertEquals(2, results.columns().size()); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((String) values.get(0), equalTo("red")); assertThat((Long) values.get(1), equalTo(2L)); } @@ -550,11 +552,11 @@ public void testWhereNegatedCondition() { public void testEvalOverride() { EsqlQueryResponse results = run("from test | eval count = count + 1 | eval count = count + 1"); logger.info(results); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); Assert.assertEquals(1, results.columns().stream().filter(c -> c.name().equals("count")).count()); int countIndex = results.columns().size() - 1; Assert.assertEquals(new ColumnInfo("count", "long"), results.columns().get(countIndex)); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Long) values.get(countIndex), greaterThanOrEqualTo(42L)); } } @@ -562,9 +564,9 @@ public void testEvalOverride() { public void testProjectRename() { EsqlQueryResponse results = run("from test | eval y = count | rename count as x | keep x, y"); logger.info(results); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); assertThat(results.columns(), contains(new ColumnInfo("x", "long"), new ColumnInfo("y", "long"))); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Long) values.get(0), greaterThanOrEqualTo(40L)); assertThat(values.get(1), is(values.get(0))); } @@ -573,12 +575,12 @@ public void testProjectRename() { public void testProjectRenameEval() { EsqlQueryResponse results = run("from test | eval y = count | rename count as x | keep x, y | eval x2 = x + 1 | eval y2 = y + 2"); logger.info(results); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); assertThat( results.columns(), contains(new ColumnInfo("x", "long"), new ColumnInfo("y", "long"), new ColumnInfo("x2", "long"), new ColumnInfo("y2", "long")) ); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Long) values.get(0), greaterThanOrEqualTo(40L)); assertThat(values.get(1), is(values.get(0))); assertThat(values.get(2), is(((Long) values.get(0)) + 1)); @@ -589,9 +591,9 @@ public void testProjectRenameEval() { public void testProjectRenameEvalProject() { EsqlQueryResponse results = run("from test | eval y = count | rename count as x | keep x, y | eval z = x + y | keep x, y, z"); logger.info(results); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); assertThat(results.columns(), contains(new ColumnInfo("x", "long"), new ColumnInfo("y", "long"), new ColumnInfo("z", "long"))); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat((Long) values.get(0), greaterThanOrEqualTo(40L)); assertThat(values.get(1), is(values.get(0))); assertThat(values.get(2), is((Long) values.get(0) * 2)); @@ -601,9 +603,9 @@ public void testProjectRenameEvalProject() { public void testProjectOverride() { EsqlQueryResponse results = run("from test | eval cnt = count | rename count as data | keep cnt, data"); logger.info(results); - Assert.assertEquals(40, results.values().size()); + Assert.assertEquals(40, getValuesList(results).size()); assertThat(results.columns(), contains(new ColumnInfo("cnt", "long"), new ColumnInfo("data", "long"))); - for (List values : results.values()) { + for (List values : getValuesList(results)) { assertThat(values.get(1), is(values.get(0))); } } @@ -674,7 +676,7 @@ public void testRefreshSearchIdleShards() throws Exception { } EsqlQueryResponse results = run("from test_refresh | stats s = sum(value)"); logger.info(results); - assertThat(results.values().get(0), equalTo(List.of(totalValues.get()))); + assertThat(getValuesList(results).get(0), equalTo(List.of(totalValues.get()))); } public void testESFilter() throws Exception { @@ -708,9 +710,9 @@ public void testESFilter() throws Exception { logger.info(results); OptionalDouble avg = docs.values().stream().filter(v -> from <= v && v <= to).mapToLong(n -> n).average(); if (avg.isPresent()) { - assertEquals(avg.getAsDouble(), (double) results.values().get(0).get(0), 0.01d); + assertEquals(avg.getAsDouble(), (double) getValuesList(results).get(0).get(0), 0.01d); } else { - assertThat(results.values().get(0).get(0), nullValue()); + assertThat(getValuesList(results).get(0).get(0), nullValue()); } } @@ -744,12 +746,12 @@ record Doc(long val, String tag) { logger.info(results); // _doc, _segment, _shard are pruned assertThat(results.columns().size(), equalTo(2)); - assertThat(results.values(), hasSize(Math.min(limit, numDocs))); + assertThat(getValuesList(results), hasSize(Math.min(limit, numDocs))); assertThat(results.columns().get(1).name(), equalTo("val")); assertThat(results.columns().get(0).name(), equalTo("tag")); List actualDocs = new ArrayList<>(); - for (int i = 0; i < results.values().size(); i++) { - List values = results.values().get(i); + for (int i = 0; i < getValuesList(results).size(); i++) { + List values = getValuesList(results).get(i); actualDocs.add(new Doc((Long) values.get(1), (String) values.get(0))); } assertThat(actualDocs, equalTo(allDocs.stream().limit(limit).toList())); @@ -759,25 +761,25 @@ public void testEvalWithNullAndAvg() { EsqlQueryResponse results = run("from test | eval nullsum = count_d + null | stats avg(nullsum)"); logger.info(results); Assert.assertEquals(1, results.columns().size()); - Assert.assertEquals(1, results.values().size()); + Assert.assertEquals(1, getValuesList(results).size()); assertEquals("avg(nullsum)", results.columns().get(0).name()); assertEquals("double", results.columns().get(0).type()); - assertEquals(1, results.values().get(0).size()); - assertNull(results.values().get(0).get(0)); + assertEquals(1, getValuesList(results).get(0).size()); + assertNull(getValuesList(results).get(0).get(0)); } public void testFromStatsLimit() { EsqlQueryResponse results = run("from test | stats ac = avg(count) by data | limit 1"); logger.info(results); assertThat(results.columns(), contains(new ColumnInfo("ac", "double"), new ColumnInfo("data", "long"))); - assertThat(results.values(), contains(anyOf(contains(42.0, 1L), contains(44.0, 2L)))); + assertThat(getValuesList(results), contains(anyOf(contains(42.0, 1L), contains(44.0, 2L)))); } public void testFromLimit() { EsqlQueryResponse results = run("from test | keep data | limit 2"); logger.info(results); assertThat(results.columns(), contains(new ColumnInfo("data", "long"))); - assertThat(results.values(), contains(anyOf(contains(1L), contains(2L)), anyOf(contains(1L), contains(2L)))); + assertThat(getValuesList(results), contains(anyOf(contains(1L), contains(2L)), anyOf(contains(1L), contains(2L)))); } public void testDropAllColumns() { @@ -785,14 +787,14 @@ public void testDropAllColumns() { logger.info(results); assertThat(results.columns(), hasSize(1)); assertThat(results.columns(), contains(new ColumnInfo("a", "integer"))); - assertThat(results.values(), is(empty())); + assertThat(getValuesList(results), is(empty())); } public void testDropAllColumnsWithStats() { EsqlQueryResponse results = run("from test | stats g = count(data) | drop g"); logger.info(results); assertThat(results.columns(), is(empty())); - assertThat(results.values(), is(empty())); + assertThat(getValuesList(results), is(empty())); } public void testIndexPatterns() throws Exception { @@ -819,34 +821,34 @@ public void testIndexPatterns() throws Exception { } EsqlQueryResponse results = run("from test_index_patterns* | stats count(data), sum(count)"); - assertEquals(1, results.values().size()); - assertEquals(15L, results.values().get(0).get(0)); - assertEquals(120000L, results.values().get(0).get(1)); + assertEquals(1, getValuesList(results).size()); + assertEquals(15L, getValuesList(results).get(0).get(0)); + assertEquals(120000L, getValuesList(results).get(0).get(1)); results = run("from test_index_patterns_1,test_index_patterns_2 | stats count(data), sum(count)"); - assertEquals(1, results.values().size()); - assertEquals(10L, results.values().get(0).get(0)); - assertEquals(55000L, results.values().get(0).get(1)); + assertEquals(1, getValuesList(results).size()); + assertEquals(10L, getValuesList(results).get(0).get(0)); + assertEquals(55000L, getValuesList(results).get(0).get(1)); results = run("from test_index_patterns_1*,test_index_patterns_2* | stats count(data), sum(count)"); - assertEquals(1, results.values().size()); - assertEquals(10L, results.values().get(0).get(0)); - assertEquals(55000L, results.values().get(0).get(1)); + assertEquals(1, getValuesList(results).size()); + assertEquals(10L, getValuesList(results).get(0).get(0)); + assertEquals(55000L, getValuesList(results).get(0).get(1)); results = run("from test_index_patterns_*,-test_index_patterns_1 | stats count(data), sum(count)"); - assertEquals(1, results.values().size()); - assertEquals(10L, results.values().get(0).get(0)); - assertEquals(105000L, results.values().get(0).get(1)); + assertEquals(1, getValuesList(results).size()); + assertEquals(10L, getValuesList(results).get(0).get(0)); + assertEquals(105000L, getValuesList(results).get(0).get(1)); results = run("from * | stats count(data), sum(count)"); - assertEquals(1, results.values().size()); - assertEquals(55L, results.values().get(0).get(0)); - assertEquals(121720L, results.values().get(0).get(1)); + assertEquals(1, getValuesList(results).size()); + assertEquals(55L, getValuesList(results).get(0).get(0)); + assertEquals(121720L, getValuesList(results).get(0).get(1)); results = run("from test_index_patterns_2 | stats count(data), sum(count)"); - assertEquals(1, results.values().size()); - assertEquals(5L, results.values().get(0).get(0)); - assertEquals(40000L, results.values().get(0).get(1)); + assertEquals(1, getValuesList(results).size()); + assertEquals(5L, getValuesList(results).get(0).get(0)); + assertEquals(40000L, getValuesList(results).get(0).get(1)); } public void testOverlappingIndexPatterns() throws Exception { @@ -887,7 +889,7 @@ public void testEmptyIndex() { assertAcked(client().admin().indices().prepareCreate("test_empty").setMapping("k", "type=keyword", "v", "type=long").get()); EsqlQueryResponse results = run("from test_empty"); assertThat(results.columns(), equalTo(List.of(new ColumnInfo("k", "keyword"), new ColumnInfo("v", "long")))); - assertThat(results.values(), empty()); + assertThat(getValuesList(results), empty()); } public void testShowInfo() { @@ -896,22 +898,22 @@ public void testShowInfo() { results.columns(), equalTo(List.of(new ColumnInfo("version", "keyword"), new ColumnInfo("date", "keyword"), new ColumnInfo("hash", "keyword"))) ); - assertThat(results.values().size(), equalTo(1)); - assertThat(results.values().get(0).get(0), equalTo(Build.current().version())); - assertThat(results.values().get(0).get(1), equalTo(Build.current().date())); - assertThat(results.values().get(0).get(2), equalTo(Build.current().hash())); + assertThat(getValuesList(results).size(), equalTo(1)); + assertThat(getValuesList(results).get(0).get(0), equalTo(Build.current().version())); + assertThat(getValuesList(results).get(0).get(1), equalTo(Build.current().date())); + assertThat(getValuesList(results).get(0).get(2), equalTo(Build.current().hash())); } public void testShowFunctions() { EsqlQueryResponse results = run("show functions"); assertThat(results.columns(), equalTo(List.of(new ColumnInfo("name", "keyword"), new ColumnInfo("synopsis", "keyword")))); - assertThat(results.values().size(), equalTo(new EsqlFunctionRegistry().listFunctions().size())); + assertThat(getValuesList(results).size(), equalTo(new EsqlFunctionRegistry().listFunctions().size())); } public void testInWithNullValue() { EsqlQueryResponse results = run("from test | where null in (data, 2) | keep data"); assertThat(results.columns(), equalTo(List.of(new ColumnInfo("data", "long")))); - assertThat(results.values().size(), equalTo(0)); + assertThat(getValuesList(results).size(), equalTo(0)); } public void testTopNPushedToLucene() { @@ -948,7 +950,7 @@ public void testTopNPushedToLucene() { """); logger.info(results); Assert.assertEquals(3, results.columns().size()); - Assert.assertEquals(10, results.values().size()); + Assert.assertEquals(10, getValuesList(results).size()); // assert column metadata assertEquals("data", results.columns().get(0).name()); @@ -975,8 +977,7 @@ record Group(Long data, Long count, String color) { new Group(9L, null), new Group(9L, 90L) ); - List actualGroups = results.values() - .stream() + List actualGroups = getValuesList(results).stream() .map(l -> new Group((Long) l.get(0), (Long) l.get(1), (String) l.get(2))) .toList(); assertThat(actualGroups, equalTo(expectedGroups)); @@ -1002,7 +1003,7 @@ public void testTopNPushedToLuceneOnSortedIndex() { EsqlQueryResponse results = run("from sorted_test_index | sort time " + sortOrder + " | limit " + limit + " | keep time"); logger.info(results); Assert.assertEquals(1, results.columns().size()); - Assert.assertEquals(limit, results.values().size()); + Assert.assertEquals(limit, getValuesList(results).size()); // assert column metadata assertEquals("time", results.columns().get(0).name()); @@ -1015,7 +1016,7 @@ public void testTopNPushedToLuceneOnSortedIndex() { .sorted(sortedDesc ? reverseOrder() : naturalOrder()) .limit(limit) .toList(); - var actual = results.values().stream().map(l -> (Long) l.get(0)).toList(); + var actual = getValuesList(results).stream().map(l -> (Long) l.get(0)).toList(); assertThat(actual, equalTo(expected)); // clean-up @@ -1129,8 +1130,8 @@ private void assertNoNestedDocuments(String query, int docsCount, long minValue, EsqlQueryResponse results = run(query); assertThat(results.columns(), contains(new ColumnInfo("data", "long"))); assertThat(results.columns().size(), is(1)); - assertThat(results.values().size(), is(docsCount)); - for (List row : results.values()) { + assertThat(getValuesList(results).size(), is(docsCount)); + for (List row : getValuesList(results)) { assertThat(row.size(), is(1)); // check that all the values returned are the regular ones assertThat((Long) row.get(0), allOf(greaterThanOrEqualTo(minValue), lessThanOrEqualTo(maxValue))); diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionRuntimeFieldIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionRuntimeFieldIT.java index 6b271debcf2c3..bdbcd9a548f58 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionRuntimeFieldIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionRuntimeFieldIT.java @@ -34,6 +34,7 @@ import java.util.Set; import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList; import static org.hamcrest.Matchers.equalTo; /** @@ -53,19 +54,19 @@ protected Collection> nodePlugins() { public void testLong() throws InterruptedException, IOException { createIndexWithConstRuntimeField("long"); EsqlQueryResponse response = run("from test | stats sum(const)"); - assertThat(response.values(), equalTo(List.of(List.of((long) SIZE)))); + assertThat(getValuesList(response), equalTo(List.of(List.of((long) SIZE)))); } public void testDouble() throws InterruptedException, IOException { createIndexWithConstRuntimeField("double"); EsqlQueryResponse response = run("from test | stats sum(const)"); - assertThat(response.values(), equalTo(List.of(List.of((double) SIZE)))); + assertThat(getValuesList(response), equalTo(List.of(List.of((double) SIZE)))); } public void testKeyword() throws InterruptedException, IOException { createIndexWithConstRuntimeField("keyword"); EsqlQueryResponse response = run("from test | keep const | limit 1"); - assertThat(response.values(), equalTo(List.of(List.of("const")))); + assertThat(getValuesList(response), equalTo(List.of(List.of("const")))); } /** @@ -75,20 +76,20 @@ public void testKeyword() throws InterruptedException, IOException { public void testKeywordBy() throws InterruptedException, IOException { createIndexWithConstRuntimeField("keyword"); EsqlQueryResponse response = run("from test | stats max(foo) by const"); - assertThat(response.values(), equalTo(List.of(List.of(SIZE - 1L, "const")))); + assertThat(getValuesList(response), equalTo(List.of(List.of(SIZE - 1L, "const")))); } public void testBoolean() throws InterruptedException, IOException { createIndexWithConstRuntimeField("boolean"); EsqlQueryResponse response = run("from test | sort foo | limit 3"); - assertThat(response.values(), equalTo(List.of(List.of(true, 0L), List.of(true, 1L), List.of(true, 2L)))); + assertThat(getValuesList(response), equalTo(List.of(List.of(true, 0L), List.of(true, 1L), List.of(true, 2L)))); } public void testDate() throws InterruptedException, IOException { createIndexWithConstRuntimeField("date"); EsqlQueryResponse response = run(""" from test | eval d=date_format(const, "yyyy") | stats min (foo) by d"""); - assertThat(response.values(), equalTo(List.of(List.of(0L, "2023")))); + assertThat(getValuesList(response), equalTo(List.of(List.of(0L, "2023")))); } private void createIndexWithConstRuntimeField(String type) throws InterruptedException, IOException { diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/CanMatchIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/CanMatchIT.java index b88ba60b47b3b..d4d6e8100f152 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/CanMatchIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/CanMatchIT.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Set; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; @@ -78,22 +79,22 @@ public void testCanMatch() { }); } EsqlQueryResponse resp = run("from events_*", randomPragmas(), new RangeQueryBuilder("@timestamp").gte("2023-01-01")); - assertThat(resp.values(), hasSize(4)); + assertThat(getValuesList(resp), hasSize(4)); assertThat(queriedIndices, equalTo(Set.of("events_2023"))); queriedIndices.clear(); resp = run("from events_*", randomPragmas(), new RangeQueryBuilder("@timestamp").lt("2023-01-01")); - assertThat(resp.values(), hasSize(3)); + assertThat(getValuesList(resp), hasSize(3)); assertThat(queriedIndices, equalTo(Set.of("events_2022"))); queriedIndices.clear(); resp = run("from events_*", randomPragmas(), new RangeQueryBuilder("@timestamp").gt("2022-01-01").lt("2023-12-31")); - assertThat(resp.values(), hasSize(7)); + assertThat(getValuesList(resp), hasSize(7)); assertThat(queriedIndices, equalTo(Set.of("events_2022", "events_2023"))); queriedIndices.clear(); resp = run("from events_*", randomPragmas(), new RangeQueryBuilder("@timestamp").gt("2021-01-01").lt("2021-12-31")); - assertThat(resp.values(), hasSize(0)); + assertThat(getValuesList(resp), hasSize(0)); assertThat(queriedIndices, empty()); queriedIndices.clear(); @@ -131,47 +132,47 @@ public void testAliasFilters() { EsqlQueryResponse resp; // employees index resp = run("from employees | stats count(emp_no)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(6L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(6L))); resp = run("from employees | stats avg(salary)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(26.95d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(26.95d))); resp = run("from employees | stats count(emp_no)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(4L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(4L))); resp = run("from employees | stats avg(salary)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(26.65d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(26.65d))); // match both employees index and engineers alias -> employees resp = run("from e* | stats count(emp_no)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(6L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(6L))); resp = run("from employees | stats avg(salary)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(26.95d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(26.95d))); resp = run("from e* | stats count(emp_no)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(4L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(4L))); resp = run("from e* | stats avg(salary)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(26.65d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(26.65d))); // engineers alias resp = run("from engineer* | stats count(emp_no)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(4L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(4L))); resp = run("from engineer* | stats avg(salary)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(26.65d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(26.65d))); resp = run("from engineer* | stats count(emp_no)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(3L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(3L))); resp = run("from engineer* | stats avg(salary)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(27.2d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(27.2d))); // sales alias resp = run("from sales | stats count(emp_no)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(2L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(2L))); resp = run("from sales | stats avg(salary)", randomPragmas()); - assertThat(resp.values().get(0), equalTo(List.of(27.55d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(27.55d))); resp = run("from sales | stats count(emp_no)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(1L))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(1L))); resp = run("from sales | stats avg(salary)", randomPragmas(), new RangeQueryBuilder("hired").lt("2012-04-30")); - assertThat(resp.values().get(0), equalTo(List.of(25.0d))); + assertThat(getValuesList(resp).get(0), equalTo(List.of(25.0d))); } public void testFailOnUnavailableShards() throws Exception { @@ -211,7 +212,7 @@ public void testFailOnUnavailableShards() throws Exception { .add(new IndexRequest().source("timestamp", 11, "message", "bb")) .get(); EsqlQueryResponse resp = run("from events,logs | KEEP timestamp,message"); - assertThat(resp.values(), hasSize(5)); + assertThat(getValuesList(resp), hasSize(5)); internalCluster().stopNode(logsOnlyNode); ensureClusterSizeConsistency(); Exception error = expectThrows(Exception.class, () -> run("from events,logs | KEEP timestamp,message")); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryResponse.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryResponse.java index bcdd2697ad5ce..4bf884ddc18e2 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryResponse.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryResponse.java @@ -87,8 +87,8 @@ public EsqlQueryResponse(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(columns); - out.writeList(pages); + out.writeCollection(columns); + out.writeCollection(pages); out.writeBoolean(columnar); } @@ -100,7 +100,7 @@ List pages() { return pages; } - public List> values() { + public Iterator> values() { return pagesToValues(columns.stream().map(ColumnInfo::type).toList(), pages); } @@ -175,12 +175,14 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; EsqlQueryResponse that = (EsqlQueryResponse) o; - return Objects.equals(columns, that.columns) && Objects.equals(values(), that.values()) && columnar == that.columnar; + return Objects.equals(columns, that.columns) + && columnar == that.columnar + && Iterators.equals(values(), that.values(), (row1, row2) -> Iterators.equals(row1, row2, Objects::equals)); } @Override public int hashCode() { - return Objects.hash(columns, values(), columnar); + return Objects.hash(columns, Iterators.hashCode(values(), row -> Iterators.hashCode(row, Objects::hashCode)), columnar); } @Override @@ -188,40 +190,33 @@ public String toString() { return Strings.toString(ChunkedToXContent.wrapAsToXContent(this)); } - public static List> pagesToValues(List dataTypes, List pages) { + public static Iterator> pagesToValues(List dataTypes, List pages) { BytesRef scratch = new BytesRef(); - List> result = new ArrayList<>(); - for (Page page : pages) { - for (int p = 0; p < page.getPositionCount(); p++) { - List row = new ArrayList<>(page.getBlockCount()); - for (int b = 0; b < page.getBlockCount(); b++) { - Block block = page.getBlock(b); - if (block.isNull(p)) { - row.add(null); - continue; - } - /* - * Use the ESQL data type to map to the output to make sure compute engine - * respects its types. See the INTEGER clause where is doesn't always - * respect it. - */ - int count = block.getValueCount(p); - int start = block.getFirstValueIndex(p); - if (count == 1) { - row.add(valueAt(dataTypes.get(b), block, start, scratch)); - continue; - } - List thisResult = new ArrayList<>(count); - int end = count + start; - for (int i = start; i < end; i++) { - thisResult.add(valueAt(dataTypes.get(b), block, i, scratch)); - } - row.add(thisResult); + return Iterators.flatMap( + pages.iterator(), + page -> Iterators.forRange(0, page.getPositionCount(), p -> Iterators.forRange(0, page.getBlockCount(), b -> { + Block block = page.getBlock(b); + if (block.isNull(p)) { + return null; } - result.add(row); - } - } - return result; + /* + * Use the ESQL data type to map to the output to make sure compute engine + * respects its types. See the INTEGER clause where is doesn't always + * respect it. + */ + int count = block.getValueCount(p); + int start = block.getFirstValueIndex(p); + if (count == 1) { + return valueAt(dataTypes.get(b), block, start, scratch); + } + List thisResult = new ArrayList<>(count); + int end = count + start; + for (int i = start; i < end; i++) { + thisResult.add(valueAt(dataTypes.get(b), block, i, scratch)); + } + return thisResult; + })) + ); } private static Object valueAt(String dataType, Block block, int offset, BytesRef scratch) { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormat.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormat.java index dc44514609066..322b88e54f718 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormat.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormat.java @@ -286,13 +286,12 @@ public Set headerValues() { public Iterator> format(RestRequest request, EsqlQueryResponse esqlResponse) { final var delimiter = delimiter(request); - return Iterators.concat(hasHeader(request) && esqlResponse.columns() != null ? - // if the header is requested return the info - Iterators.single(writer -> row(writer, esqlResponse.columns(), ColumnInfo::name, delimiter)) : Collections.emptyIterator(), - Iterators.map( - esqlResponse.values().iterator(), - row -> writer -> row(writer, row, f -> Objects.toString(f, StringUtils.EMPTY), delimiter) - ) + return Iterators.concat( + // if the header is requested return the info + hasHeader(request) && esqlResponse.columns() != null + ? Iterators.single(writer -> row(writer, esqlResponse.columns().iterator(), ColumnInfo::name, delimiter)) + : Collections.emptyIterator(), + Iterators.map(esqlResponse.values(), row -> writer -> row(writer, row, f -> Objects.toString(f, StringUtils.EMPTY), delimiter)) ); } @@ -315,12 +314,15 @@ public String contentType(RestRequest request) { } // utility method for consuming a row. - void row(Writer writer, List row, Function toString, Character delimiter) throws IOException { - for (int i = 0; i < row.size(); i++) { - writeEscaped(toString.apply(row.get(i)), delimiter, writer); - if (i < row.size() - 1) { + void row(Writer writer, Iterator row, Function toString, Character delimiter) throws IOException { + boolean firstColumn = true; + while (row.hasNext()) { + if (firstColumn) { + firstColumn = false; + } else { writer.append(delimiter); } + writeEscaped(toString.apply(row.next()), delimiter, writer); } writer.append(eol()); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormatter.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormatter.java index da89accb2d6bf..0535e4adfe346 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormatter.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/formatter/TextFormatter.java @@ -46,10 +46,14 @@ public TextFormatter(EsqlQueryResponse response) { } // 2. Expand columns to fit the largest value - for (var row : response.values()) { + var iterator = response.values(); + while (iterator.hasNext()) { + var row = iterator.next(); for (int i = 0; i < width.length; i++) { - width[i] = Math.max(width[i], FORMATTER.apply(row.get(i)).length()); + assert row.hasNext(); + width[i] = Math.max(width[i], FORMATTER.apply(row.next()).length()); } + assert row.hasNext() == false; } } @@ -91,12 +95,13 @@ private void formatHeader(Writer writer) throws IOException { } private Iterator> formatResults() { - return Iterators.map(response.values().iterator(), row -> writer -> { + return Iterators.map(response.values(), row -> writer -> { for (int i = 0; i < width.length; i++) { + assert row.hasNext(); if (i > 0) { writer.append('|'); } - String string = FORMATTER.apply(row.get(i)); + String string = FORMATTER.apply(row.next()); if (string.length() <= width[i]) { // Pad writer.append(string); @@ -107,6 +112,7 @@ private Iterator> formatResults() { writer.append('~'); } } + assert row.hasNext() == false; writer.append('\n'); }); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java index 0a2dfae30a1fc..7deed7c7a0a82 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java @@ -67,7 +67,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(sessionId); configuration.writeTo(out); - out.writeList(shardIds); + out.writeCollection(shardIds); out.writeMap(aliasFilters); new PlanStreamOutput(out, planNameRegistry).writePhysicalPlanNode(plan); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsResponse.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsResponse.java index d70416cdbda82..aa294d64bb27d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsResponse.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsResponse.java @@ -38,7 +38,7 @@ protected List readNodesFrom(StreamInput in) throws IOExcepti @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java index ce4f79f1dcfc8..1c41b8f7db00f 100644 --- a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java @@ -595,7 +595,7 @@ public static ObservableAction readObservableAction(StreamInput in) throws IOExc @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(getSteps().stream().map(s -> (ObservableClusterStateWaitStep) s).collect(Collectors.toList())); + out.writeCollection(getSteps().stream().map(s -> (ObservableClusterStateWaitStep) s).collect(Collectors.toList())); out.writeBoolean(isSafeAction()); } } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/InternalCategorizationAggregation.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/InternalCategorizationAggregation.java index 9d63eeb8d3817..ad78f6740ce00 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/InternalCategorizationAggregation.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/categorization/InternalCategorizationAggregation.java @@ -266,7 +266,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { ); } out.writeVInt(similarityThreshold); - out.writeList(buckets); + out.writeCollection(buckets); writeSize(requiredSize, out); out.writeVLong(minDocCount); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/FrequentItemSetsAggregationBuilder.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/FrequentItemSetsAggregationBuilder.java index 3cb864b2da09b..b64274dade21b 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/FrequentItemSetsAggregationBuilder.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/FrequentItemSetsAggregationBuilder.java @@ -198,7 +198,7 @@ public String getType() { @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeList(fields); + out.writeCollection(fields); out.writeDouble(minimumSupport); out.writeVInt(minimumSetSize); out.writeVInt(size); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/mr/InternalItemSetMapReduceAggregation.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/mr/InternalItemSetMapReduceAggregation.java index a4e8d88a299a2..0aaaf19e31f40 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/mr/InternalItemSetMapReduceAggregation.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/frequentitemsets/mr/InternalItemSetMapReduceAggregation.java @@ -101,7 +101,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { mapReducer.writeTo(out); out.writeOptionalWriteable(mapFinalContext); out.writeOptionalWriteable(mapReduceResult); - out.writeList(fields); + out.writeCollection(fields); out.writeBoolean(profiling); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java index 4099ede5ef1d1..ba2474f39bf9a 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java @@ -225,7 +225,7 @@ private static void writeNullable(List writeables, StreamOu boolean isPresent = writeables != null; out.writeBoolean(isPresent); if (isPresent) { - out.writeList(writeables); + out.writeCollection(writeables); } } diff --git a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringResponse.java b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringResponse.java index 209f9a4c00278..1ada3ecd3ab0e 100644 --- a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringResponse.java +++ b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringResponse.java @@ -39,7 +39,7 @@ protected List readNodesFrom(StreamInput in) t @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesNodeMeteringResponse.java b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesNodeMeteringResponse.java index 31d7486a72dbb..11afda79ca5e9 100644 --- a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesNodeMeteringResponse.java +++ b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesNodeMeteringResponse.java @@ -46,6 +46,6 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeList(repositoryStatsSnapshots); + out.writeCollection(repositoryStatsSnapshots); } } diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java index a2a3eb26e98cf..5954cbcc3d5e5 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java @@ -178,7 +178,7 @@ static RollupIndexCaps parseMetadataXContent(BytesReference source, String index @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(rollupIndexName); - out.writeList(jobCaps); + out.writeCollection(jobCaps); } @Override diff --git a/x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilder.java b/x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilder.java index 1d8e5b6c6a132..b4505f6ae9dca 100644 --- a/x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilder.java +++ b/x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilder.java @@ -239,7 +239,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeBoolean(false); } else { out.writeBoolean(true); - out.writeList(docs); + out.writeCollection(docs); } } out.writeNamedWriteable(organicQuery); diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/SearchableSnapshotsStatsResponse.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/SearchableSnapshotsStatsResponse.java index 1270d02325a45..4a8e7ec0f06e8 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/SearchableSnapshotsStatsResponse.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/SearchableSnapshotsStatsResponse.java @@ -73,7 +73,7 @@ private static List computeCompound(Stream readNodesFrom(StreamInput in) throws IOEx @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } } } diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java index e85ea6948292f..03f98fb21c24d 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java @@ -294,7 +294,7 @@ protected List readNodesFrom(StreamInput in) throws IOE @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/security/qa/profile/src/javaRestTest/java/org/elasticsearch/xpack/security/profile/ProfileIT.java b/x-pack/plugin/security/qa/profile/src/javaRestTest/java/org/elasticsearch/xpack/security/profile/ProfileIT.java index fc25bda6d89b8..f2f753e9bb3ab 100644 --- a/x-pack/plugin/security/qa/profile/src/javaRestTest/java/org/elasticsearch/xpack/security/profile/ProfileIT.java +++ b/x-pack/plugin/security/qa/profile/src/javaRestTest/java/org/elasticsearch/xpack/security/profile/ProfileIT.java @@ -443,14 +443,18 @@ public void testGetUsersWithProfileUid() throws IOException { final Request putUserRequest = new Request("PUT", "_security/user/" + username); putUserRequest.setJsonEntity("{\"password\":\"x-pack-test-password\",\"roles\":[\"superuser\"]}"); assertOK(adminClient().performRequest(putUserRequest)); - final Map profile = doActivateProfile(username, "x-pack-test-password"); + // Get user with profile uid before profile index exists will not show any profile_uid final Request getUserRequest = new Request("GET", "_security/user" + (randomBoolean() ? "/" + username : "")); getUserRequest.addParameter("with_profile_uid", "true"); - final Response getUserResponse = adminClient().performRequest(getUserRequest); - assertOK(getUserResponse); + final Response getUserResponse1 = adminClient().performRequest(getUserRequest); + assertOK(getUserResponse1); + responseAsMap(getUserResponse1).forEach((k, v) -> assertThat(castToMap(v), not(hasKey("profile_uid")))); - responseAsMap(getUserResponse).forEach((k, v) -> { + // The profile_uid is retrieved for the user after the profile gets activated + final Map profile = doActivateProfile(username, "x-pack-test-password"); + final Response getUserResponse2 = adminClient().performRequest(getUserRequest); + responseAsMap(getUserResponse2).forEach((k, v) -> { if (username.equals(k)) { assertThat(castToMap(v).get("profile_uid"), equalTo(profile.get("uid"))); } else { diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java index e698b9de59079..165235181de41 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileIntegTests.java @@ -834,6 +834,17 @@ public void testGetUsersWithProfileUid() throws IOException { ); } + public void testGetUsersWithProfileUidWhenProfileIndexDoesNotExists() { + final GetUsersRequest getUsersRequest = new GetUsersRequest(); + getUsersRequest.setWithProfileUid(true); + if (randomBoolean()) { + getUsersRequest.usernames(ElasticUser.NAME, RAC_USER_NAME); + } + final GetUsersResponse getUsersResponse = client().execute(GetUsersAction.INSTANCE, getUsersRequest).actionGet(); + // When profile index does not exist, profile lookup is null + assertThat(getUsersResponse.getProfileUidLookup(), nullValue()); + } + private SuggestProfilesResponse.ProfileHit[] doSuggest(String name) { return doSuggest(name, Set.of()); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java index 2cfb1597f3b60..1f817ad9b6f2f 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java @@ -144,7 +144,10 @@ private void resolveProfileUids(List users, ActionListener { - if (resultsAndErrors.errors().isEmpty()) { + if (resultsAndErrors == null) { + // profile index does not exist + listener.onResponse(null); + } else if (resultsAndErrors.errors().isEmpty()) { assert users.size() == resultsAndErrors.results().size(); final Map profileUidLookup = resultsAndErrors.results() .stream() diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java index 476581132c30d..00f478f68b6ba 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java @@ -83,6 +83,7 @@ public class TransportGetUsersActionTests extends ESTestCase { private boolean hasAnonymousProfile; private boolean hasReservedProfile; private boolean hasNativeProfile; + private boolean profileIndexExists; @Before public void maybeEnableAnonymous() { @@ -96,6 +97,7 @@ public void maybeEnableAnonymous() { hasAnonymousProfile = randomBoolean(); hasReservedProfile = randomBoolean(); hasNativeProfile = randomBoolean(); + profileIndexExists = randomBoolean(); } @After @@ -163,7 +165,7 @@ public void onFailure(Exception e) { } else { assertThat("expected an empty array but got: " + Arrays.toString(users), users, emptyArray()); } - if (withProfileUid) { + if (profileIndexExists && withProfileUid) { assertThat( responseRef.get().getProfileUidLookup(), equalTo( @@ -248,7 +250,7 @@ public void onFailure(Exception e) { assertThat(throwableRef.get(), is(nullValue())); assertThat(responseRef.get(), is(notNullValue())); assertThat(users, arrayContaining(reservedUsers.toArray(new User[reservedUsers.size()]))); - if (withProfileUid) { + if (profileIndexExists && withProfileUid) { assertThat(responseRef.get().getProfileUidLookup(), equalTo(reservedUsers.stream().filter(user -> { if (user instanceof AnonymousUser) { return hasAnonymousProfile; @@ -340,7 +342,7 @@ public void onFailure(Exception e) { assertThat(throwableRef.get(), is(nullValue())); assertThat(responseRef.get(), is(notNullValue())); assertThat(responseRef.get().users(), arrayContaining(expectedList.toArray(new User[expectedList.size()]))); - if (withProfileUid) { + if (profileIndexExists && withProfileUid) { assertThat(responseRef.get().getProfileUidLookup(), equalTo(expectedList.stream().filter(user -> { if (user instanceof AnonymousUser) { return hasAnonymousProfile; @@ -399,6 +401,7 @@ public void testGetUsersWithProfileUidException() { null, Collections.emptySet() ); + profileIndexExists = true; // profile index must exist to simulate exception on search TransportGetUsersAction action = new TransportGetUsersAction( Settings.EMPTY, mock(ActionFilters.class), @@ -496,7 +499,7 @@ public void onFailure(Exception e) { assertThat(throwableRef.get(), is(nullValue())); assertThat(responseRef.get(), is(notNullValue())); assertThat(responseRef.get().users(), arrayContaining(expectedList.toArray(new User[expectedList.size()]))); - if (withProfileUid) { + if (profileIndexExists && withProfileUid) { assertThat( responseRef.get().getProfileUidLookup(), equalTo( @@ -611,8 +614,12 @@ private ProfileService mockProfileService() { private ProfileService mockProfileService(boolean randomException) { final ProfileService profileService = mock(ProfileService.class); doAnswer(invocation -> { - final List subjects = (List) invocation.getArguments()[0]; final var listener = (ActionListener>) invocation.getArguments()[1]; + if (false == profileIndexExists) { + listener.onResponse(null); + return null; + } + final List subjects = (List) invocation.getArguments()[0]; List> results = subjects.stream().map(subject -> { final User user = subject.getUser(); if (user instanceof AnonymousUser) { diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/GetShutdownStatusAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/GetShutdownStatusAction.java index 96676ea0f5598..655f7e3aaac99 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/GetShutdownStatusAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/GetShutdownStatusAction.java @@ -102,7 +102,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { - out.writeList(shutdownStatuses); + out.writeCollection(shutdownStatuses); } @Override diff --git a/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/BlobAnalyzeAction.java b/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/BlobAnalyzeAction.java index 89a9b7c93113e..64e76fd091a77 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/BlobAnalyzeAction.java +++ b/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/BlobAnalyzeAction.java @@ -714,7 +714,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(blobName); out.writeVLong(targetLength); out.writeLong(seed); - out.writeList(nodes); + out.writeCollection(nodes); out.writeVInt(readNodeCount); out.writeVInt(earlyReadNodeCount); out.writeBoolean(readEarly); @@ -857,7 +857,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(writeElapsedNanos); out.writeVLong(overwriteElapsedNanos); out.writeVLong(writeThrottledNanos); - out.writeList(readDetails); + out.writeCollection(readDetails); } @Override diff --git a/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/RepositoryAnalyzeAction.java b/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/RepositoryAnalyzeAction.java index 42238350cea58..c7b32c637f6eb 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/RepositoryAnalyzeAction.java +++ b/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/RepositoryAnalyzeAction.java @@ -1102,7 +1102,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeDouble(rareActionProbability); out.writeString(blobPath); summary.writeTo(out); - out.writeList(blobResponses); + out.writeCollection(blobResponses); out.writeVLong(listingTimeNanos); out.writeVLong(deleteTimeNanos); } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsResponse.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsResponse.java index 35cb0e24faf69..20559edc78b41 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsResponse.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsResponse.java @@ -38,7 +38,7 @@ protected List readNodesFrom(StreamInput in) throws IOExcepti @Override protected void writeNodesTo(StreamOutput out, List nodes) throws IOException { - out.writeList(nodes); + out.writeCollection(nodes); } @Override diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/DefaultTransformExtension.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/DefaultTransformExtension.java new file mode 100644 index 0000000000000..9cccbade339dc --- /dev/null +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/DefaultTransformExtension.java @@ -0,0 +1,36 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.transform; + +import org.elasticsearch.cluster.metadata.IndexMetadata; +import org.elasticsearch.common.settings.Settings; + +public class DefaultTransformExtension implements TransformExtension { + + @Override + public boolean includeNodeInfo() { + return true; + } + + @Override + public Settings getTransformInternalIndexAdditionalSettings() { + return Settings.EMPTY; + } + + /** + * Provides destination index settings, hardcoded at the moment. In future this might be customizable or generation could be based on + * source settings. + */ + @Override + public Settings getTransformDestinationIndexSettings() { + return Settings.builder() + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) + .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1") + .build(); + } +} diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java index 86cdce7a92b50..6eebc97541123 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java @@ -137,6 +137,7 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa private final Settings settings; private final SetOnce transformServices = new SetOnce<>(); + private final TransformExtension transformExtension = new DefaultTransformExtension(); public static final Integer DEFAULT_INITIAL_MAX_PAGE_SEARCH_SIZE = Integer.valueOf(500); public static final TimeValue DEFAULT_TRANSFORM_FREQUENCY = TimeValue.timeValueSeconds(60); @@ -250,7 +251,12 @@ public Collection createComponents( client, xContentRegistry ); - TransformAuditor auditor = new TransformAuditor(client, clusterService.getNodeName(), clusterService, includeNodeInfo()); + TransformAuditor auditor = new TransformAuditor( + client, + clusterService.getNodeName(), + clusterService, + getTransformExtension().includeNodeInfo() + ); Clock clock = Clock.systemUTC(); TransformCheckpointService checkpointService = new TransformCheckpointService( clock, @@ -264,7 +270,11 @@ public Collection createComponents( transformServices.set(new TransformServices(configManager, checkpointService, auditor, scheduler)); - return Arrays.asList(transformServices.get(), new TransformClusterStateListener(clusterService, client)); + return Arrays.asList( + transformServices.get(), + new TransformClusterStateListener(clusterService, client), + new TransformExtensionHolder(getTransformExtension()) + ); } @Override @@ -285,7 +295,7 @@ public List> getPersistentTasksExecutor( threadPool, clusterService, settingsModule.getSettings(), - getTransformInternalIndexAdditionalSettings(), + getTransformExtension().getTransformInternalIndexAdditionalSettings(), expressionResolver ) ); @@ -354,7 +364,9 @@ public UnaryOperator> getIndexTemplateMetadat @Override public Collection getSystemIndexDescriptors(Settings settings) { try { - return List.of(TransformInternalIndex.getSystemIndexDescriptor(getTransformInternalIndexAdditionalSettings())); + return List.of( + TransformInternalIndex.getSystemIndexDescriptor(getTransformExtension().getTransformInternalIndexAdditionalSettings()) + ); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -467,11 +479,17 @@ public String getFeatureDescription() { return "Manages configuration and state for transforms"; } + public TransformExtension getTransformExtension() { + return transformExtension; + } + + @Deprecated public boolean includeNodeInfo() { - return true; + return getTransformExtension().includeNodeInfo(); } + @Deprecated public Settings getTransformInternalIndexAdditionalSettings() { - return Settings.EMPTY; + return getTransformExtension().getTransformInternalIndexAdditionalSettings(); } } diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtension.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtension.java new file mode 100644 index 0000000000000..c919f4dd4c550 --- /dev/null +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtension.java @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.transform; + +import org.elasticsearch.common.settings.Settings; + +public interface TransformExtension { + + boolean includeNodeInfo(); + + Settings getTransformInternalIndexAdditionalSettings(); + + /** + * Provides destination index settings, hardcoded at the moment. In future this might be customizable or generation could be based on + * source settings. + */ + Settings getTransformDestinationIndexSettings(); +} diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtensionHolder.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtensionHolder.java new file mode 100644 index 0000000000000..93f285f14cf69 --- /dev/null +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtensionHolder.java @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.transform; + +import org.elasticsearch.node.Node; + +import java.util.Objects; + +/** + * Wrapper for the {@link TransformExtension} interface that allows it to be used + * given the way {@link Node} does Guice bindings for plugin components. + * TODO: remove this class entirely once Guice is removed entirely. + */ +public class TransformExtensionHolder { + + private final TransformExtension transformExtension; + + /** + * Used by Guice. + */ + public TransformExtensionHolder() { + this.transformExtension = null; + } + + public TransformExtensionHolder(TransformExtension transformExtension) { + this.transformExtension = Objects.requireNonNull(transformExtension); + } + + public boolean isEmpty() { + return transformExtension == null; + } + + public TransformExtension getTransformExtension() { + return transformExtension; + } +} diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformUpdater.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformUpdater.java index 791dc75d5f0b8..98777b47543cb 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformUpdater.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformUpdater.java @@ -125,6 +125,7 @@ public static void updateTransform( final boolean dryRun, final boolean checkAccess, final TimeValue timeout, + final Settings destIndexSettings, ActionListener listener ) { // rewrite config into a new format if necessary @@ -185,6 +186,7 @@ public static void updateTransform( destIndexMappings, seqNoPrimaryTermAndIndex, clusterState, + destIndexSettings, ActionListener.wrap(r -> updateTransformListener.onResponse(null), listener::onFailure) ); }, listener::onFailure); @@ -300,6 +302,7 @@ private static void updateTransformConfiguration( Map mappings, SeqNoPrimaryTermAndIndex seqNoPrimaryTermAndIndex, ClusterState clusterState, + Settings destIndexSettings, ActionListener listener ) { // <3> Return to the listener @@ -351,6 +354,7 @@ private static void updateTransformConfiguration( indexNameExpressionResolver, clusterState, config, + destIndexSettings, mappings, createDestinationListener ); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java index cdaba16182348..a7d7851704054 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java @@ -50,6 +50,7 @@ import org.elasticsearch.xpack.core.transform.transforms.SyncConfig; import org.elasticsearch.xpack.core.transform.transforms.TransformConfig; import org.elasticsearch.xpack.core.transform.transforms.TransformDestIndexSettings; +import org.elasticsearch.xpack.transform.TransformExtensionHolder; import org.elasticsearch.xpack.transform.persistence.TransformIndex; import org.elasticsearch.xpack.transform.transforms.Function; import org.elasticsearch.xpack.transform.transforms.FunctionFactory; @@ -78,6 +79,7 @@ public class TransportPreviewTransformAction extends HandledTransportAction>> previewListener = ActionListener.wrap(docs -> { if (pipeline == null) { TransformDestIndexSettings generatedDestIndexSettings = TransformIndex.createTransformDestIndexSettings( + destIndexSettings, mappings.get(), transformId, Clock.systemUTC() diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java index d60fb4af651f9..bff969cf0b856 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportResetTransformAction.java @@ -37,6 +37,7 @@ import org.elasticsearch.xpack.core.transform.action.StopTransformAction; import org.elasticsearch.xpack.core.transform.transforms.TransformConfig; import org.elasticsearch.xpack.core.transform.transforms.TransformConfigUpdate; +import org.elasticsearch.xpack.transform.TransformExtensionHolder; import org.elasticsearch.xpack.transform.TransformServices; import org.elasticsearch.xpack.transform.notifications.TransformAuditor; import org.elasticsearch.xpack.transform.persistence.SeqNoPrimaryTermAndIndex; @@ -58,6 +59,7 @@ public class TransportResetTransformAction extends AcknowledgedTransportMasterNo private final Client client; private final SecurityContext securityContext; private final Settings settings; + private final Settings destIndexSettings; @Inject public TransportResetTransformAction( @@ -68,7 +70,8 @@ public TransportResetTransformAction( IndexNameExpressionResolver indexNameExpressionResolver, TransformServices transformServices, Client client, - Settings settings + Settings settings, + TransformExtensionHolder transformExtensionHolder ) { super( ResetTransformAction.NAME, @@ -87,6 +90,7 @@ public TransportResetTransformAction( ? new SecurityContext(settings, threadPool.getThreadContext()) : null; this.settings = settings; + this.destIndexSettings = transformExtensionHolder.getTransformExtension().getTransformDestinationIndexSettings(); } @Override @@ -131,6 +135,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A false, // dry run false, // check access request.timeout(), + destIndexSettings, updateTransformListener ); }, diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java index fa6272a30ae89..8776f112e6178 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.health.HealthStatus; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; @@ -40,6 +41,7 @@ import org.elasticsearch.xpack.core.transform.transforms.TransformState; import org.elasticsearch.xpack.core.transform.transforms.TransformTaskParams; import org.elasticsearch.xpack.core.transform.transforms.TransformTaskState; +import org.elasticsearch.xpack.transform.TransformExtensionHolder; import org.elasticsearch.xpack.transform.TransformServices; import org.elasticsearch.xpack.transform.notifications.TransformAuditor; import org.elasticsearch.xpack.transform.persistence.AuthorizationStatePersistenceUtils; @@ -62,6 +64,7 @@ public class TransportStartTransformAction extends TransportMasterNodeAction li false, // dryRun true, // checkAccess request.getTimeout(), + destIndexSettings, ActionListener.wrap(updateResult -> { TransformConfig originalConfig = configAndVersion.v1(); TransformConfig updatedConfig = updateResult.getConfig(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpgradeTransformsAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpgradeTransformsAction.java index 2e28106b77606..6b01f6d7966a0 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpgradeTransformsAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpgradeTransformsAction.java @@ -35,6 +35,7 @@ import org.elasticsearch.xpack.core.transform.action.UpgradeTransformsAction.Response; import org.elasticsearch.xpack.core.transform.transforms.TransformConfig; import org.elasticsearch.xpack.core.transform.transforms.TransformConfigUpdate; +import org.elasticsearch.xpack.transform.TransformExtensionHolder; import org.elasticsearch.xpack.transform.TransformServices; import org.elasticsearch.xpack.transform.action.TransformUpdater.UpdateResult; import org.elasticsearch.xpack.transform.notifications.TransformAuditor; @@ -56,6 +57,7 @@ public class TransportUpgradeTransformsAction extends TransportMasterNodeAction< private final Settings settings; private final Client client; private final TransformAuditor auditor; + private final Settings destIndexSettings; @Inject public TransportUpgradeTransformsAction( @@ -66,7 +68,8 @@ public TransportUpgradeTransformsAction( IndexNameExpressionResolver indexNameExpressionResolver, TransformServices transformServices, Client client, - Settings settings + Settings settings, + TransformExtensionHolder transformExtensionHolder ) { super( UpgradeTransformsAction.NAME, @@ -88,6 +91,7 @@ public TransportUpgradeTransformsAction( this.securityContext = XPackSettings.SECURITY_ENABLED.get(settings) ? new SecurityContext(settings, threadPool.getThreadContext()) : null; + this.destIndexSettings = transformExtensionHolder.getTransformExtension().getTransformDestinationIndexSettings(); } @Override @@ -163,6 +167,7 @@ private void updateOneTransform(String id, boolean dryRun, TimeValue timeout, Ac dryRun, false, // check access, timeout, + destIndexSettings, listener ); }, failure -> { diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java index e8ef290bd9db1..39183a1ca8502 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java @@ -23,7 +23,6 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.common.settings.Settings; @@ -106,6 +105,7 @@ public static void createDestinationIndex( IndexNameExpressionResolver indexNameExpressionResolver, ClusterState clusterState, TransformConfig config, + Settings destIndexSettings, Map destIndexMappings, ActionListener listener ) { @@ -137,6 +137,7 @@ public static void createDestinationIndex( if (dest.length == 0) { TransformDestIndexSettings generatedDestIndexSettings = createTransformDestIndexSettings( + destIndexSettings, destIndexMappings, config.getId(), Clock.systemUTC() @@ -248,13 +249,16 @@ static void setUpDestinationAliases(Client client, TransformConfig config, Actio ); } - public static TransformDestIndexSettings createTransformDestIndexSettings(Map mappings, String id, Clock clock) { + public static TransformDestIndexSettings createTransformDestIndexSettings( + Settings settings, + Map mappings, + String id, + Clock clock + ) { Map indexMappings = new HashMap<>(); indexMappings.put(PROPERTIES, createMappingsFromStringMap(mappings)); indexMappings.put(META, createMetadata(id, clock)); - Settings settings = createSettings(); - // transform does not create aliases, however the user might customize this in future Set aliases = null; return new TransformDestIndexSettings(indexMappings, settings, aliases); @@ -288,17 +292,6 @@ private static Map createMetadata(String id, Clock clock) { return metadata; } - /** - * creates generated index settings, hardcoded at the moment, in future this might be customizable or generation could - * be based on source settings. - */ - private static Settings createSettings() { - return Settings.builder() // <1> - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1") - .build(); - } - /** * This takes the a {@code Map} of the type "fieldname: fieldtype" and transforms it into the * typical mapping format. diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformUpdaterTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformUpdaterTests.java index 6c59f2b34f0c0..27ca18d0e1d2f 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformUpdaterTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformUpdaterTests.java @@ -43,6 +43,7 @@ import org.elasticsearch.xpack.core.transform.transforms.TransformStoredDoc; import org.elasticsearch.xpack.core.transform.transforms.TransformTaskState; import org.elasticsearch.xpack.core.transform.utils.TransformConfigVersionUtils; +import org.elasticsearch.xpack.transform.DefaultTransformExtension; import org.elasticsearch.xpack.transform.action.TransformUpdater.UpdateResult; import org.elasticsearch.xpack.transform.notifications.MockTransformAuditor; import org.elasticsearch.xpack.transform.notifications.TransformAuditor; @@ -76,6 +77,7 @@ public class TransformUpdaterTests extends ESTestCase { private ClusterService clusterService = mock(ClusterService.class); private TransformAuditor auditor = new MockTransformAuditor(clusterService); private final Settings settings = Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), true).build(); + private final Settings destIndexSettings = new DefaultTransformExtension().getTransformDestinationIndexSettings(); private static class MyMockClient extends NoOpClient { @@ -157,6 +159,7 @@ public void testTransformUpdateNoAction() throws InterruptedException { false, false, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, + destIndexSettings, listener ), updateResult -> { @@ -192,6 +195,7 @@ public void testTransformUpdateNoAction() throws InterruptedException { false, false, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, + destIndexSettings, listener ), updateResult -> { @@ -264,6 +268,7 @@ public void testTransformUpdateRewrite() throws InterruptedException { false, false, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, + destIndexSettings, listener ), updateResult -> { @@ -331,6 +336,7 @@ public void testTransformUpdateDryRun() throws InterruptedException { true, false, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, + destIndexSettings, listener ), updateResult -> { @@ -378,6 +384,7 @@ public void testTransformUpdateCheckAccessSuccess() throws InterruptedException false, true, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, + destIndexSettings, listener ), updateResult -> { @@ -420,6 +427,7 @@ public void testTransformUpdateCheckAccessFailureDeferValidation() throws Interr false, true, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, + destIndexSettings, listener ), updateResult -> { @@ -454,6 +462,7 @@ public void testTransformUpdateCheckAccessFailureNoDeferValidation() { false, true, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, + destIndexSettings, ActionListener.wrap( r -> fail("Should fail due to missing privileges"), e -> assertThat(e.getMessage(), is(equalTo("missing privileges"))) diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java index 9f704faf970c8..5afb6db1856fe 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java @@ -146,7 +146,7 @@ public void testCreateDestinationIndex() throws IOException { TransformIndex.createDestinationIndex( client, TransformConfigTests.randomTransformConfig(TRANSFORM_ID), - TransformIndex.createTransformDestIndexSettings(new HashMap<>(), TRANSFORM_ID, clock), + TransformIndex.createTransformDestIndexSettings(Settings.EMPTY, new HashMap<>(), TRANSFORM_ID, clock), ActionTestUtils.assertNoFailureListener(Assert::assertTrue) );