diff --git a/distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/APMJvmOptions.java b/distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/APMJvmOptions.java
index c3b976894676..1e57d9fab7cf 100644
--- a/distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/APMJvmOptions.java
+++ b/distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/APMJvmOptions.java
@@ -187,20 +187,12 @@ static String agentCommandLineOption(Path agentJar, Path tmpPropertiesFile) {
static void extractSecureSettings(SecureSettings secrets, Map propertiesMap) {
final Set settingNames = secrets.getSettingNames();
for (String key : List.of("api_key", "secret_token")) {
- for (String prefix : List.of("telemetry.", "tracing.apm.")) {
- if (settingNames.contains(prefix + key)) {
- if (propertiesMap.containsKey(key)) {
- throw new IllegalStateException(
- Strings.format("Duplicate telemetry setting: [telemetry.%s] and [tracing.apm.%s]", key, key)
- );
- }
-
- try (SecureString token = secrets.getString(prefix + key)) {
- propertiesMap.put(key, token.toString());
- }
+ String prefix = "telemetry.";
+ if (settingNames.contains(prefix + key)) {
+ try (SecureString token = secrets.getString(prefix + key)) {
+ propertiesMap.put(key, token.toString());
}
}
-
}
}
@@ -227,44 +219,12 @@ private static Map extractDynamicSettings(Map pr
static Map extractApmSettings(Settings settings) throws UserException {
final Map propertiesMap = new HashMap<>();
- // tracing.apm.agent. is deprecated by telemetry.agent.
final String telemetryAgentPrefix = "telemetry.agent.";
- final String deprecatedTelemetryAgentPrefix = "tracing.apm.agent.";
final Settings telemetryAgentSettings = settings.getByPrefix(telemetryAgentPrefix);
telemetryAgentSettings.keySet().forEach(key -> propertiesMap.put(key, String.valueOf(telemetryAgentSettings.get(key))));
- final Settings apmAgentSettings = settings.getByPrefix(deprecatedTelemetryAgentPrefix);
- for (String key : apmAgentSettings.keySet()) {
- if (propertiesMap.containsKey(key)) {
- throw new IllegalStateException(
- Strings.format(
- "Duplicate telemetry setting: [%s%s] and [%s%s]",
- telemetryAgentPrefix,
- key,
- deprecatedTelemetryAgentPrefix,
- key
- )
- );
- }
- propertiesMap.put(key, String.valueOf(apmAgentSettings.get(key)));
- }
-
StringJoiner globalLabels = extractGlobalLabels(telemetryAgentPrefix, propertiesMap, settings);
- if (globalLabels.length() == 0) {
- globalLabels = extractGlobalLabels(deprecatedTelemetryAgentPrefix, propertiesMap, settings);
- } else {
- StringJoiner tracingGlobalLabels = extractGlobalLabels(deprecatedTelemetryAgentPrefix, propertiesMap, settings);
- if (tracingGlobalLabels.length() != 0) {
- throw new IllegalArgumentException(
- "Cannot have global labels with tracing.agent prefix ["
- + globalLabels
- + "] and telemetry.apm.agent prefix ["
- + tracingGlobalLabels
- + "]"
- );
- }
- }
if (globalLabels.length() > 0) {
propertiesMap.put("global_labels", globalLabels.toString());
}
@@ -274,7 +234,7 @@ static Map extractApmSettings(Settings settings) throws UserExce
if (propertiesMap.containsKey(key)) {
throw new UserException(
ExitCodes.CONFIG,
- "Do not set a value for [tracing.apm.agent." + key + "], as this is configured automatically by Elasticsearch"
+ "Do not set a value for [telemetry.agent." + key + "], as this is configured automatically by Elasticsearch"
);
}
}
diff --git a/distribution/tools/server-cli/src/test/java/org/elasticsearch/server/cli/APMJvmOptionsTests.java b/distribution/tools/server-cli/src/test/java/org/elasticsearch/server/cli/APMJvmOptionsTests.java
index a7ba8eb11fbc..0e067afc1aa7 100644
--- a/distribution/tools/server-cli/src/test/java/org/elasticsearch/server/cli/APMJvmOptionsTests.java
+++ b/distribution/tools/server-cli/src/test/java/org/elasticsearch/server/cli/APMJvmOptionsTests.java
@@ -25,18 +25,15 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.function.Function;
import static org.elasticsearch.test.MapMatcher.matchesMap;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -82,109 +79,63 @@ public void testFileDeleteWorks() throws IOException {
}
public void testExtractSecureSettings() {
- MockSecureSettings duplicateSecureSettings = new MockSecureSettings();
+ MockSecureSettings secureSettings = new MockSecureSettings();
+ secureSettings.setString("telemetry.secret_token", "token");
+ secureSettings.setString("telemetry.api_key", "key");
- for (String prefix : List.of("telemetry.", "tracing.apm.")) {
- MockSecureSettings secureSettings = new MockSecureSettings();
- secureSettings.setString(prefix + "secret_token", "token");
- secureSettings.setString(prefix + "api_key", "key");
-
- duplicateSecureSettings.setString(prefix + "api_key", "secret");
-
- Map propertiesMap = new HashMap<>();
- APMJvmOptions.extractSecureSettings(secureSettings, propertiesMap);
-
- assertThat(propertiesMap, matchesMap(Map.of("secret_token", "token", "api_key", "key")));
- }
-
- Exception exception = expectThrows(
- IllegalStateException.class,
- () -> APMJvmOptions.extractSecureSettings(duplicateSecureSettings, new HashMap<>())
- );
- assertThat(exception.getMessage(), containsString("Duplicate telemetry setting"));
- assertThat(exception.getMessage(), containsString("telemetry.api_key"));
- assertThat(exception.getMessage(), containsString("tracing.apm.api_key"));
+ Map propertiesMap = new HashMap<>();
+ APMJvmOptions.extractSecureSettings(secureSettings, propertiesMap);
+ assertThat(propertiesMap, matchesMap(Map.of("secret_token", "token", "api_key", "key")));
}
public void testExtractSettings() throws UserException {
- Function buildSettings = (prefix) -> Settings.builder()
- .put(prefix + "server_url", "https://myurl:443")
- .put(prefix + "service_node_name", "instance-0000000001");
-
- for (String prefix : List.of("tracing.apm.agent.", "telemetry.agent.")) {
- var name = "APM Tracing";
- var deploy = "123";
- var org = "456";
- var extracted = APMJvmOptions.extractApmSettings(
- buildSettings.apply(prefix)
- .put(prefix + "global_labels.deployment_name", name)
- .put(prefix + "global_labels.deployment_id", deploy)
- .put(prefix + "global_labels.organization_id", org)
- .build()
- );
-
- assertThat(
- extracted,
- allOf(
- hasEntry("server_url", "https://myurl:443"),
- hasEntry("service_node_name", "instance-0000000001"),
- hasEntry(equalTo("global_labels"), not(endsWith(","))), // test that we have collapsed all global labels into one
- not(hasKey("global_labels.organization_id")) // tests that we strip out the top level label keys
- )
- );
-
- List labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
- assertThat(labels, hasSize(3));
- assertThat(labels, containsInAnyOrder("deployment_name=APM Tracing", "organization_id=" + org, "deployment_id=" + deploy));
-
- // test replacing with underscores and skipping empty
- name = "APM=Tracing";
- deploy = "";
- org = ",456";
- extracted = APMJvmOptions.extractApmSettings(
- buildSettings.apply(prefix)
- .put(prefix + "global_labels.deployment_name", name)
- .put(prefix + "global_labels.deployment_id", deploy)
- .put(prefix + "global_labels.organization_id", org)
- .build()
- );
- labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
- assertThat(labels, hasSize(2));
- assertThat(labels, containsInAnyOrder("deployment_name=APM_Tracing", "organization_id=_456"));
- }
-
- IllegalStateException err = expectThrows(
- IllegalStateException.class,
- () -> APMJvmOptions.extractApmSettings(
- Settings.builder()
- .put("tracing.apm.agent.server_url", "https://myurl:443")
- .put("telemetry.agent.server_url", "https://myurl-2:443")
- .build()
- )
- );
- assertThat(err.getMessage(), is("Duplicate telemetry setting: [telemetry.agent.server_url] and [tracing.apm.agent.server_url]"));
- }
-
- public void testNoMixedLabels() {
- String telemetryAgent = "telemetry.agent.";
- String tracingAgent = "tracing.apm.agent.";
- Settings settings = Settings.builder()
- .put("tracing.apm.enabled", true)
- .put(telemetryAgent + "server_url", "https://myurl:443")
- .put(telemetryAgent + "service_node_name", "instance-0000000001")
- .put(tracingAgent + "global_labels.deployment_id", "123")
- .put(telemetryAgent + "global_labels.organization_id", "456")
+ Settings defaults = Settings.builder()
+ .put("telemetry.agent.server_url", "https://myurl:443")
+ .put("telemetry.agent.service_node_name", "instance-0000000001")
.build();
- IllegalArgumentException err = assertThrows(IllegalArgumentException.class, () -> APMJvmOptions.extractApmSettings(settings));
+ var name = "APM Tracing";
+ var deploy = "123";
+ var org = "456";
+ var extracted = APMJvmOptions.extractApmSettings(
+ Settings.builder()
+ .put(defaults)
+ .put("telemetry.agent.global_labels.deployment_name", name)
+ .put("telemetry.agent.global_labels.deployment_id", deploy)
+ .put("telemetry.agent.global_labels.organization_id", org)
+ .build()
+ );
+
assertThat(
- err.getMessage(),
- is(
- "Cannot have global labels with tracing.agent prefix [organization_id=456] and"
- + " telemetry.apm.agent prefix [deployment_id=123]"
+ extracted,
+ allOf(
+ hasEntry("server_url", "https://myurl:443"),
+ hasEntry("service_node_name", "instance-0000000001"),
+ hasEntry(equalTo("global_labels"), not(endsWith(","))), // test that we have collapsed all global labels into one
+ not(hasKey("global_labels.organization_id")) // tests that we strip out the top level label keys
)
);
+
+ List labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
+ assertThat(labels, hasSize(3));
+ assertThat(labels, containsInAnyOrder("deployment_name=APM Tracing", "organization_id=" + org, "deployment_id=" + deploy));
+
+ // test replacing with underscores and skipping empty
+ name = "APM=Tracing";
+ deploy = "";
+ org = ",456";
+ extracted = APMJvmOptions.extractApmSettings(
+ Settings.builder()
+ .put(defaults)
+ .put("telemetry.agent.global_labels.deployment_name", name)
+ .put("telemetry.agent.global_labels.deployment_id", deploy)
+ .put("telemetry.agent.global_labels.organization_id", org)
+ .build()
+ );
+ labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
+ assertThat(labels, hasSize(2));
+ assertThat(labels, containsInAnyOrder("deployment_name=APM_Tracing", "organization_id=_456"));
}
private Path makeFakeAgentJar() throws IOException {
diff --git a/docs/changelog/119227.yaml b/docs/changelog/119227.yaml
new file mode 100644
index 000000000000..1e3d4f97a3d2
--- /dev/null
+++ b/docs/changelog/119227.yaml
@@ -0,0 +1,13 @@
+pr: 119227
+summary: Remove unfreeze REST endpoint
+area: Indices APIs
+type: breaking
+issues: []
+breaking:
+ title: Remove unfreeze REST endpoint
+ area: REST API
+ details: >-
+ The `/{index}/_unfreeze` REST endpoint is no longer supported. This API was deprecated, and the corresponding
+ `/{index}/_freeze` endpoint was removed in 8.0.
+ impact: None, since it is not possible to have a frozen index in a version which is readable by Elasticsearch 9.0
+ notable: false
diff --git a/docs/changelog/119772.yaml b/docs/changelog/119772.yaml
new file mode 100644
index 000000000000..58d483566b10
--- /dev/null
+++ b/docs/changelog/119772.yaml
@@ -0,0 +1,6 @@
+pr: 119772
+summary: ESQL Support IN operator for Date nanos
+area: ES|QL
+type: enhancement
+issues:
+ - 118578
diff --git a/docs/changelog/119831.yaml b/docs/changelog/119831.yaml
new file mode 100644
index 000000000000..61c09d7d54de
--- /dev/null
+++ b/docs/changelog/119831.yaml
@@ -0,0 +1,5 @@
+pr: 119831
+summary: Run `TransportClusterGetSettingsAction` on local node
+area: Infra/Settings
+type: enhancement
+issues: []
diff --git a/docs/changelog/119846.yaml b/docs/changelog/119846.yaml
new file mode 100644
index 000000000000..9e7d99fe1be1
--- /dev/null
+++ b/docs/changelog/119846.yaml
@@ -0,0 +1,12 @@
+pr: 119846
+summary: Drop support for brackets from METADATA syntax
+area: ES|QL
+type: deprecation
+issues:
+ - 115401
+deprecation:
+ title: Drop support for brackets from METADATA syntax
+ area: ES|QL
+ details: Please describe the details of this change for the release notes. You can
+ use asciidoc.
+ impact: Please describe the impact of this change to users
diff --git a/docs/changelog/119922.yaml b/docs/changelog/119922.yaml
new file mode 100644
index 000000000000..2fc9d9529c96
--- /dev/null
+++ b/docs/changelog/119922.yaml
@@ -0,0 +1,5 @@
+pr: 119922
+summary: "[Inference API] fix spell words: covertToString to convertToString"
+area: Machine Learning
+type: enhancement
+issues: []
diff --git a/docs/changelog/119926.yaml b/docs/changelog/119926.yaml
new file mode 100644
index 000000000000..3afafd5b2117
--- /dev/null
+++ b/docs/changelog/119926.yaml
@@ -0,0 +1,11 @@
+pr: 119926
+summary: "Deprecated tracing.apm.* settings got removed."
+area: Infra/Metrics
+type: breaking
+issues: []
+breaking:
+ title: "Deprecated tracing.apm.* settings got removed."
+ area: Cluster and node setting
+ details: Deprecated `tracing.apm.*` settings got removed, use respective `telemetry.*` / `telemetry.tracing.*` settings instead.
+ impact: 9.x nodes will refuse to start if any such setting (including secret settings) is still present.
+ notable: false
diff --git a/docs/changelog/120014.yaml b/docs/changelog/120014.yaml
new file mode 100644
index 000000000000..bef1f3ba4993
--- /dev/null
+++ b/docs/changelog/120014.yaml
@@ -0,0 +1,6 @@
+pr: 120014
+summary: Fix potential file leak in ES816BinaryQuantizedVectorsWriter
+area: Search
+type: bug
+issues:
+ - 119981
diff --git a/docs/changelog/120038.yaml b/docs/changelog/120038.yaml
new file mode 100644
index 000000000000..fe3a2ccccc09
--- /dev/null
+++ b/docs/changelog/120038.yaml
@@ -0,0 +1,5 @@
+pr: 120038
+summary: Run template simulation actions on local node
+area: Ingest Node
+type: enhancement
+issues: []
diff --git a/docs/changelog/120084.yaml b/docs/changelog/120084.yaml
new file mode 100644
index 000000000000..aafe490d79f1
--- /dev/null
+++ b/docs/changelog/120084.yaml
@@ -0,0 +1,5 @@
+pr: 120084
+summary: Improve how reindex data stream index action handles api blocks
+area: Data streams
+type: enhancement
+issues: []
diff --git a/docs/changelog/120133.yaml b/docs/changelog/120133.yaml
new file mode 100644
index 000000000000..4ec88267a1bf
--- /dev/null
+++ b/docs/changelog/120133.yaml
@@ -0,0 +1,6 @@
+pr: 120133
+summary: Use approximation to advance matched queries
+area: Search
+type: bug
+issues:
+ - 120130
diff --git a/docs/reference/esql/esql-limitations.asciidoc b/docs/reference/esql/esql-limitations.asciidoc
index 8ce8064a8161..adfd38478ab2 100644
--- a/docs/reference/esql/esql-limitations.asciidoc
+++ b/docs/reference/esql/esql-limitations.asciidoc
@@ -30,11 +30,11 @@ include::processing-commands/limit.asciidoc[tag=limitation]
** You can use `to_datetime` to cast to millisecond dates to use unsupported functions
* `double` (`float`, `half_float`, `scaled_float` are represented as `double`)
* `ip`
-* `keyword` family including `keyword`, `constant_keyword`, and `wildcard`
+* `keyword` <> including `keyword`, `constant_keyword`, and `wildcard`
* `int` (`short` and `byte` are represented as `int`)
* `long`
* `null`
-* `text`
+* `text` <> including `text`, `semantic_text` and `match_only_text`
* experimental:[] `unsigned_long`
* `version`
* Spatial types
diff --git a/docs/reference/esql/functions/description/match.asciidoc b/docs/reference/esql/functions/description/match.asciidoc
index 931fd5eb2f94..0724f0f108e3 100644
--- a/docs/reference/esql/functions/description/match.asciidoc
+++ b/docs/reference/esql/functions/description/match.asciidoc
@@ -2,4 +2,4 @@
*Description*
-Use `MATCH` to perform a <> on the specified field. Using `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL. Match can be used on text fields, as well as other field types like boolean, dates, and numeric types. For a simplified syntax, you can use the <> `:` operator instead of `MATCH`. `MATCH` returns true if the provided query matches the row.
+Use `MATCH` to perform a <> on the specified field. Using `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL. Match can be used on fields from the text family like <> and <>, as well as other field types like keyword, boolean, dates, and numeric types. For a simplified syntax, you can use the <> `:` operator instead of `MATCH`. `MATCH` returns true if the provided query matches the row.
diff --git a/docs/reference/esql/functions/kibana/definition/match.json b/docs/reference/esql/functions/kibana/definition/match.json
index d61534da81a6..eb206cb9ddf4 100644
--- a/docs/reference/esql/functions/kibana/definition/match.json
+++ b/docs/reference/esql/functions/kibana/definition/match.json
@@ -2,7 +2,7 @@
"comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.",
"type" : "eval",
"name" : "match",
- "description" : "Use `MATCH` to perform a <> on the specified field.\nUsing `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL.\n\nMatch can be used on text fields, as well as other field types like boolean, dates, and numeric types.\n\nFor a simplified syntax, you can use the <> `:` operator instead of `MATCH`.\n\n`MATCH` returns true if the provided query matches the row.",
+ "description" : "Use `MATCH` to perform a <> on the specified field.\nUsing `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL.\n\nMatch can be used on fields from the text family like <> and <>,\nas well as other field types like keyword, boolean, dates, and numeric types.\n\nFor a simplified syntax, you can use the <> `:` operator instead of `MATCH`.\n\n`MATCH` returns true if the provided query matches the row.",
"signatures" : [
{
"params" : [
diff --git a/docs/reference/esql/functions/kibana/docs/match.md b/docs/reference/esql/functions/kibana/docs/match.md
index 72258a168293..80bf84351c18 100644
--- a/docs/reference/esql/functions/kibana/docs/match.md
+++ b/docs/reference/esql/functions/kibana/docs/match.md
@@ -6,7 +6,8 @@ This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../READ
Use `MATCH` to perform a <> on the specified field.
Using `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL.
-Match can be used on text fields, as well as other field types like boolean, dates, and numeric types.
+Match can be used on fields from the text family like <> and <>,
+as well as other field types like keyword, boolean, dates, and numeric types.
For a simplified syntax, you can use the <> `:` operator instead of `MATCH`.
diff --git a/docs/reference/indices.asciidoc b/docs/reference/indices.asciidoc
index ca7de396147a..b6b82422cbb4 100644
--- a/docs/reference/indices.asciidoc
+++ b/docs/reference/indices.asciidoc
@@ -24,7 +24,6 @@ index settings, aliases, mappings, and index templates.
* <>
* <>
* <>
-* <>
* <>
* <>
* <>
@@ -143,6 +142,5 @@ include::indices/shrink-index.asciidoc[]
include::indices/simulate-index.asciidoc[]
include::indices/simulate-template.asciidoc[]
include::indices/split-index.asciidoc[]
-include::indices/apis/unfreeze.asciidoc[]
include::indices/update-settings.asciidoc[]
include::indices/put-mapping.asciidoc[]
diff --git a/docs/reference/indices/apis/unfreeze.asciidoc b/docs/reference/indices/apis/unfreeze.asciidoc
deleted file mode 100644
index 5d04d44db744..000000000000
--- a/docs/reference/indices/apis/unfreeze.asciidoc
+++ /dev/null
@@ -1,61 +0,0 @@
-[role="xpack"]
-[[unfreeze-index-api]]
-=== Unfreeze index API
-++++
-Unfreeze index
-++++
-
-[WARNING]
-.Deprecated in 7.14
-====
-In 8.0, we removed the ability to freeze an index. In previous versions,
-freezing an index reduced its memory overhead. However, frozen indices are no
-longer useful due to
-https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent
-improvements in heap memory usage].
-You can use this API to unfreeze indices that were frozen in 7.x. Frozen indices
-are not related to the frozen data tier.
-====
-
-.New API reference
-[sidebar]
---
-For the most up-to-date API details, refer to {api-es}/group/endpoint-indices[Index APIs].
---
-
-Unfreezes an index.
-
-[[unfreeze-index-api-request]]
-==== {api-request-title}
-
-`POST //_unfreeze`
-
-[[unfreeze-index-api-prereqs]]
-==== {api-prereq-title}
-
-* If the {es} {security-features} are enabled, you must have the `manage`
-<> for the target index or index alias.
-
-[[unfreeze-index-api-desc]]
-==== {api-description-title}
-
-When a frozen index is unfrozen, the index goes through the normal recovery
-process and becomes writeable again.
-
-[[unfreeze-index-api-path-parms]]
-==== {api-path-parms-title}
-
-``::
- (Required, string) Identifier for the index.
-
-[[unfreeze-index-api-examples]]
-==== {api-examples-title}
-
-The following example unfreezes an index:
-
-[source,console]
---------------------------------------------------
-POST /my-index-000001/_unfreeze
---------------------------------------------------
-// TEST[s/^/PUT my-index-000001\n/]
-// TEST[skip:unable to ignore deprecation warning]
diff --git a/docs/reference/indices/index-mgmt.asciidoc b/docs/reference/indices/index-mgmt.asciidoc
index 73643dbfd4b3..131bc79faa40 100644
--- a/docs/reference/indices/index-mgmt.asciidoc
+++ b/docs/reference/indices/index-mgmt.asciidoc
@@ -43,7 +43,7 @@ For more information on managing indices, refer to <>.
* To filter the list of indices, use the search bar or click a badge.
Badges indicate if an index is a <>, a
-<>, or <>.
+<>, or <>.
* To drill down into the index
<>, <>, and statistics,
diff --git a/docs/reference/redirects.asciidoc b/docs/reference/redirects.asciidoc
index c3bf84fa600d..9c0f0092214e 100644
--- a/docs/reference/redirects.asciidoc
+++ b/docs/reference/redirects.asciidoc
@@ -156,10 +156,16 @@ See <>.
The freeze index API was removed in 8.0.
// tag::frozen-removal-explanation[]
Frozen indices are no longer useful due to
-https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent
-improvements in heap memory usage].
+https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[improvements
+in heap memory usage].
// end::frozen-removal-explanation[]
+[role="exclude",id="unfreeze-index-api"]
+=== Unfreeze index API
+
+The unfreeze index API was removed in 9.0.
+include::redirects.asciidoc[tag=frozen-removal-explanation]
+
[role="exclude",id="ilm-freeze"]
=== Freeze {ilm-init} action
@@ -1749,8 +1755,10 @@ See <>.
=== Frozen indices
// tag::frozen-index-redirect[]
-
-For API documentation, see <>.
+Older versions of {es} provided the option to reduce the amount of data kept in memory for an index, at the expense of
+increasing search latency. This was known as 'freezing' the index.
+include::redirects.asciidoc[tag=frozen-removal-explanation]
+The freeze index API was removed in 8.0, and the unfreeze index API was removed in 9.0.
// end::frozen-index-redirect[]
[role="exclude",id="best_practices"]
diff --git a/docs/reference/sql/language/indices.asciidoc b/docs/reference/sql/language/indices.asciidoc
index 1dee7f0840ad..1912a020ab0b 100644
--- a/docs/reference/sql/language/indices.asciidoc
+++ b/docs/reference/sql/language/indices.asciidoc
@@ -100,7 +100,7 @@ requires the keyword `LIKE` for SQL `LIKE` pattern.
[[sql-index-frozen]]
=== Frozen Indices
-By default, {es-sql} doesn't search <>. To
+By default, {es-sql} doesn't search <>. To
search frozen indices, use one of the following features:
dedicated configuration parameter::
diff --git a/libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementChecker.java b/libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementChecker.java
index 3a359eb921fc..69fc57973f68 100644
--- a/libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementChecker.java
+++ b/libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementChecker.java
@@ -13,10 +13,16 @@
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.ContentHandlerFactory;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
import java.net.DatagramSocketImplFactory;
import java.net.FileNameMap;
+import java.net.InetAddress;
+import java.net.MulticastSocket;
+import java.net.NetworkInterface;
import java.net.ProxySelector;
import java.net.ResponseCache;
+import java.net.SocketAddress;
import java.net.SocketImplFactory;
import java.net.URL;
import java.net.URLStreamHandler;
@@ -189,4 +195,28 @@ public interface EntitlementChecker {
// The only implementation of SSLSession#getSessionContext(); unfortunately it's an interface, so we need to check the implementation
void check$sun_security_ssl_SSLSessionImpl$getSessionContext(Class> callerClass, SSLSession sslSession);
+
+ void check$java_net_DatagramSocket$bind(Class> callerClass, DatagramSocket that, SocketAddress addr);
+
+ void check$java_net_DatagramSocket$connect(Class> callerClass, DatagramSocket that, InetAddress addr);
+
+ void check$java_net_DatagramSocket$connect(Class> callerClass, DatagramSocket that, SocketAddress addr);
+
+ void check$java_net_DatagramSocket$send(Class> callerClass, DatagramSocket that, DatagramPacket p);
+
+ void check$java_net_DatagramSocket$receive(Class> callerClass, DatagramSocket that, DatagramPacket p);
+
+ void check$java_net_DatagramSocket$joinGroup(Class> callerClass, DatagramSocket that, SocketAddress addr, NetworkInterface ni);
+
+ void check$java_net_DatagramSocket$leaveGroup(Class> callerClass, DatagramSocket that, SocketAddress addr, NetworkInterface ni);
+
+ void check$java_net_MulticastSocket$joinGroup(Class> callerClass, MulticastSocket that, InetAddress addr);
+
+ void check$java_net_MulticastSocket$joinGroup(Class> callerClass, MulticastSocket that, SocketAddress addr, NetworkInterface ni);
+
+ void check$java_net_MulticastSocket$leaveGroup(Class> callerClass, MulticastSocket that, InetAddress addr);
+
+ void check$java_net_MulticastSocket$leaveGroup(Class> callerClass, MulticastSocket that, SocketAddress addr, NetworkInterface ni);
+
+ void check$java_net_MulticastSocket$send(Class> callerClass, MulticastSocket that, DatagramPacket p, byte ttl);
}
diff --git a/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/DummyImplementations.java b/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/DummyImplementations.java
index 6dbb684c7151..fae873123528 100644
--- a/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/DummyImplementations.java
+++ b/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/DummyImplementations.java
@@ -9,8 +9,15 @@
package org.elasticsearch.entitlement.qa.common;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.DatagramSocketImpl;
import java.net.InetAddress;
+import java.net.NetworkInterface;
import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketException;
import java.security.cert.Certificate;
import java.text.BreakIterator;
import java.text.Collator;
@@ -327,8 +334,77 @@ public Socket createSocket(Socket s, String host, int port, boolean autoClose) {
}
}
+ static class DummyDatagramSocket extends DatagramSocket {
+ DummyDatagramSocket() throws SocketException {
+ super(new DatagramSocketImpl() {
+ @Override
+ protected void create() throws SocketException {}
+
+ @Override
+ protected void bind(int lport, InetAddress laddr) throws SocketException {}
+
+ @Override
+ protected void send(DatagramPacket p) throws IOException {}
+
+ @Override
+ protected int peek(InetAddress i) throws IOException {
+ return 0;
+ }
+
+ @Override
+ protected int peekData(DatagramPacket p) throws IOException {
+ return 0;
+ }
+
+ @Override
+ protected void receive(DatagramPacket p) throws IOException {}
+
+ @Override
+ protected void setTTL(byte ttl) throws IOException {}
+
+ @Override
+ protected byte getTTL() throws IOException {
+ return 0;
+ }
+
+ @Override
+ protected void setTimeToLive(int ttl) throws IOException {}
+
+ @Override
+ protected int getTimeToLive() throws IOException {
+ return 0;
+ }
+
+ @Override
+ protected void join(InetAddress inetaddr) throws IOException {}
+
+ @Override
+ protected void leave(InetAddress inetaddr) throws IOException {}
+
+ @Override
+ protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException {}
+
+ @Override
+ protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException {}
+
+ @Override
+ protected void close() {}
+
+ @Override
+ public void setOption(int optID, Object value) throws SocketException {}
+
+ @Override
+ public Object getOption(int optID) throws SocketException {
+ return null;
+ }
+
+ @Override
+ protected void connect(InetAddress address, int port) throws SocketException {}
+ });
+ }
+ }
+
private static RuntimeException unexpected() {
return new IllegalStateException("This method isn't supposed to be called");
}
-
}
diff --git a/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/RestEntitlementsCheckAction.java b/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/RestEntitlementsCheckAction.java
index 1dd8daf55622..3a5480f46852 100644
--- a/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/RestEntitlementsCheckAction.java
+++ b/libs/entitlement/qa/common/src/main/java/org/elasticsearch/entitlement/qa/common/RestEntitlementsCheckAction.java
@@ -11,6 +11,7 @@
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.Strings;
+import org.elasticsearch.core.CheckedRunnable;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.entitlement.qa.common.DummyImplementations.DummyBreakIteratorProvider;
import org.elasticsearch.entitlement.qa.common.DummyImplementations.DummyCalendarDataProvider;
@@ -32,14 +33,18 @@
import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
-import java.io.UncheckedIOException;
+import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.HttpURLConnection;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.MalformedURLException;
+import java.net.NetworkInterface;
import java.net.ProxySelector;
import java.net.ResponseCache;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
@@ -71,20 +76,20 @@ public class RestEntitlementsCheckAction extends BaseRestHandler {
public static final Thread NO_OP_SHUTDOWN_HOOK = new Thread(() -> {}, "Shutdown hook for testing");
private final String prefix;
- record CheckAction(Runnable action, boolean isAlwaysDeniedToPlugins) {
+ record CheckAction(CheckedRunnable action, boolean isAlwaysDeniedToPlugins) {
/**
* These cannot be granted to plugins, so our test plugins cannot test the "allowed" case.
* Used both for always-denied entitlements as well as those granted only to the server itself.
*/
- static CheckAction deniedToPlugins(Runnable action) {
+ static CheckAction deniedToPlugins(CheckedRunnable action) {
return new CheckAction(action, true);
}
- static CheckAction forPlugins(Runnable action) {
+ static CheckAction forPlugins(CheckedRunnable action) {
return new CheckAction(action, false);
}
- static CheckAction alwaysDenied(Runnable action) {
+ static CheckAction alwaysDenied(CheckedRunnable action) {
return new CheckAction(action, true);
}
}
@@ -142,7 +147,13 @@ static CheckAction alwaysDenied(Runnable action) {
entry("createURLStreamHandlerProvider", alwaysDenied(RestEntitlementsCheckAction::createURLStreamHandlerProvider)),
entry("createURLWithURLStreamHandler", alwaysDenied(RestEntitlementsCheckAction::createURLWithURLStreamHandler)),
entry("createURLWithURLStreamHandler2", alwaysDenied(RestEntitlementsCheckAction::createURLWithURLStreamHandler2)),
- entry("sslSessionImpl_getSessionContext", alwaysDenied(RestEntitlementsCheckAction::sslSessionImplGetSessionContext))
+ entry("sslSessionImpl_getSessionContext", alwaysDenied(RestEntitlementsCheckAction::sslSessionImplGetSessionContext)),
+ entry("datagram_socket_bind", forPlugins(RestEntitlementsCheckAction::bindDatagramSocket)),
+ entry("datagram_socket_connect", forPlugins(RestEntitlementsCheckAction::connectDatagramSocket)),
+ entry("datagram_socket_send", forPlugins(RestEntitlementsCheckAction::sendDatagramSocket)),
+ entry("datagram_socket_receive", forPlugins(RestEntitlementsCheckAction::receiveDatagramSocket)),
+ entry("datagram_socket_join_group", forPlugins(RestEntitlementsCheckAction::joinGroupDatagramSocket)),
+ entry("datagram_socket_leave_group", forPlugins(RestEntitlementsCheckAction::leaveGroupDatagramSocket))
);
private static void createURLStreamHandlerProvider() {
@@ -154,43 +165,33 @@ public URLStreamHandler createURLStreamHandler(String protocol) {
};
}
- private static void sslSessionImplGetSessionContext() {
+ private static void sslSessionImplGetSessionContext() throws IOException {
SSLSocketFactory factory = HttpsURLConnection.getDefaultSSLSocketFactory();
try (SSLSocket socket = (SSLSocket) factory.createSocket()) {
SSLSession session = socket.getSession();
session.getSessionContext();
- } catch (IOException e) {
- throw new RuntimeException(e);
}
}
@SuppressWarnings("deprecation")
- private static void createURLWithURLStreamHandler() {
- try {
- var x = new URL("http", "host", 1234, "file", new URLStreamHandler() {
- @Override
- protected URLConnection openConnection(URL u) {
- return null;
- }
- });
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
+ private static void createURLWithURLStreamHandler() throws MalformedURLException {
+ var x = new URL("http", "host", 1234, "file", new URLStreamHandler() {
+ @Override
+ protected URLConnection openConnection(URL u) {
+ return null;
+ }
+ });
}
@SuppressWarnings("deprecation")
- private static void createURLWithURLStreamHandler2() {
- try {
- var x = new URL(null, "spec", new URLStreamHandler() {
- @Override
- protected URLConnection openConnection(URL u) {
- return null;
- }
- });
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
+ private static void createURLWithURLStreamHandler2() throws MalformedURLException {
+ var x = new URL(null, "spec", new URLStreamHandler() {
+ @Override
+ protected URLConnection openConnection(URL u) {
+ return null;
+ }
+ });
}
private static void createInetAddressResolverProvider() {
@@ -215,12 +216,8 @@ private static void setDefaultProxySelector() {
ProxySelector.setDefault(null);
}
- private static void setDefaultSSLContext() {
- try {
- SSLContext.setDefault(SSLContext.getDefault());
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
+ private static void setDefaultSSLContext() throws NoSuchAlgorithmException {
+ SSLContext.setDefault(SSLContext.getDefault());
}
private static void setDefaultHostnameVerifier() {
@@ -246,28 +243,18 @@ private static void systemExit() {
System.exit(123);
}
- private static void createClassLoader() {
+ private static void createClassLoader() throws IOException {
try (var classLoader = new URLClassLoader("test", new URL[0], RestEntitlementsCheckAction.class.getClassLoader())) {
logger.info("Created URLClassLoader [{}]", classLoader.getName());
- } catch (IOException e) {
- throw new UncheckedIOException(e);
}
}
- private static void processBuilder_start() {
- try {
- new ProcessBuilder("").start();
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ private static void processBuilder_start() throws IOException {
+ new ProcessBuilder("").start();
}
- private static void processBuilder_startPipeline() {
- try {
- ProcessBuilder.startPipeline(List.of());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ private static void processBuilder_startPipeline() throws IOException {
+ ProcessBuilder.startPipeline(List.of());
}
private static void setHttpsConnectionProperties() {
@@ -355,12 +342,8 @@ private static void setHttpsConnectionProperties() {
@SuppressWarnings("deprecation")
@SuppressForbidden(reason = "We're required to prevent calls to this forbidden API")
- private static void datagramSocket$$setDatagramSocketImplFactory() {
- try {
- DatagramSocket.setDatagramSocketImplFactory(() -> { throw new IllegalStateException(); });
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ private static void datagramSocket$$setDatagramSocketImplFactory() throws IOException {
+ DatagramSocket.setDatagramSocketImplFactory(() -> { throw new IllegalStateException(); });
}
private static void httpURLConnection$$setFollowRedirects() {
@@ -369,22 +352,14 @@ private static void setHttpsConnectionProperties() {
@SuppressWarnings("deprecation")
@SuppressForbidden(reason = "We're required to prevent calls to this forbidden API")
- private static void serverSocket$$setSocketFactory() {
- try {
- ServerSocket.setSocketFactory(() -> { throw new IllegalStateException(); });
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ private static void serverSocket$$setSocketFactory() throws IOException {
+ ServerSocket.setSocketFactory(() -> { throw new IllegalStateException(); });
}
@SuppressWarnings("deprecation")
@SuppressForbidden(reason = "We're required to prevent calls to this forbidden API")
- private static void socket$$setSocketImplFactory() {
- try {
- Socket.setSocketImplFactory(() -> { throw new IllegalStateException(); });
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
+ private static void socket$$setSocketImplFactory() throws IOException {
+ Socket.setSocketImplFactory(() -> { throw new IllegalStateException(); });
}
private static void url$$setURLStreamHandlerFactory() {
@@ -399,6 +374,51 @@ private static void setHttpsConnectionProperties() {
URLConnection.setContentHandlerFactory(__ -> { throw new IllegalStateException(); });
}
+ private static void bindDatagramSocket() throws SocketException {
+ try (var socket = new DatagramSocket(null)) {
+ socket.bind(null);
+ }
+ }
+
+ @SuppressForbidden(reason = "testing entitlements")
+ private static void connectDatagramSocket() throws SocketException {
+ try (var socket = new DummyImplementations.DummyDatagramSocket()) {
+ socket.connect(new InetSocketAddress(1234));
+ }
+ }
+
+ private static void joinGroupDatagramSocket() throws IOException {
+ try (var socket = new DummyImplementations.DummyDatagramSocket()) {
+ socket.joinGroup(
+ new InetSocketAddress(InetAddress.getByAddress(new byte[] { (byte) 230, 0, 0, 1 }), 1234),
+ NetworkInterface.getByIndex(0)
+ );
+ }
+ }
+
+ private static void leaveGroupDatagramSocket() throws IOException {
+ try (var socket = new DummyImplementations.DummyDatagramSocket()) {
+ socket.leaveGroup(
+ new InetSocketAddress(InetAddress.getByAddress(new byte[] { (byte) 230, 0, 0, 1 }), 1234),
+ NetworkInterface.getByIndex(0)
+ );
+ }
+ }
+
+ @SuppressForbidden(reason = "testing entitlements")
+ private static void sendDatagramSocket() throws IOException {
+ try (var socket = new DummyImplementations.DummyDatagramSocket()) {
+ socket.send(new DatagramPacket(new byte[] { 0 }, 1, InetAddress.getLocalHost(), 1234));
+ }
+ }
+
+ @SuppressForbidden(reason = "testing entitlements")
+ private static void receiveDatagramSocket() throws IOException {
+ try (var socket = new DummyImplementations.DummyDatagramSocket()) {
+ socket.receive(new DatagramPacket(new byte[1], 1, InetAddress.getLocalHost(), 1234));
+ }
+ }
+
public RestEntitlementsCheckAction(String prefix) {
this.prefix = prefix;
}
diff --git a/libs/entitlement/qa/entitlement-allowed-nonmodular/src/main/plugin-metadata/entitlement-policy.yaml b/libs/entitlement/qa/entitlement-allowed-nonmodular/src/main/plugin-metadata/entitlement-policy.yaml
index 30fc9f0abeec..05a94f09264a 100644
--- a/libs/entitlement/qa/entitlement-allowed-nonmodular/src/main/plugin-metadata/entitlement-policy.yaml
+++ b/libs/entitlement/qa/entitlement-allowed-nonmodular/src/main/plugin-metadata/entitlement-policy.yaml
@@ -1,3 +1,8 @@
ALL-UNNAMED:
- create_class_loader
- set_https_connection_properties
+ - network:
+ actions:
+ - listen
+ - accept
+ - connect
diff --git a/libs/entitlement/qa/entitlement-allowed/src/main/plugin-metadata/entitlement-policy.yaml b/libs/entitlement/qa/entitlement-allowed/src/main/plugin-metadata/entitlement-policy.yaml
index 0a25570a9f62..0d2c66c2daa2 100644
--- a/libs/entitlement/qa/entitlement-allowed/src/main/plugin-metadata/entitlement-policy.yaml
+++ b/libs/entitlement/qa/entitlement-allowed/src/main/plugin-metadata/entitlement-policy.yaml
@@ -1,3 +1,8 @@
org.elasticsearch.entitlement.qa.common:
- create_class_loader
- set_https_connection_properties
+ - network:
+ actions:
+ - listen
+ - accept
+ - connect
diff --git a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/api/ElasticsearchEntitlementChecker.java b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/api/ElasticsearchEntitlementChecker.java
index ca4aaceabceb..dd39ec3c5fe4 100644
--- a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/api/ElasticsearchEntitlementChecker.java
+++ b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/api/ElasticsearchEntitlementChecker.java
@@ -10,16 +10,23 @@
package org.elasticsearch.entitlement.runtime.api;
import org.elasticsearch.entitlement.bridge.EntitlementChecker;
+import org.elasticsearch.entitlement.runtime.policy.NetworkEntitlement;
import org.elasticsearch.entitlement.runtime.policy.PolicyManager;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.ContentHandlerFactory;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
import java.net.DatagramSocketImplFactory;
import java.net.FileNameMap;
+import java.net.InetAddress;
+import java.net.MulticastSocket;
+import java.net.NetworkInterface;
import java.net.ProxySelector;
import java.net.ResponseCache;
+import java.net.SocketAddress;
import java.net.SocketImplFactory;
import java.net.URL;
import java.net.URLStreamHandler;
@@ -349,4 +356,68 @@ public ElasticsearchEntitlementChecker(PolicyManager policyManager) {
public void check$sun_security_ssl_SSLSessionImpl$getSessionContext(Class> callerClass, SSLSession sslSession) {
policyManager.checkReadSensitiveNetworkInformation(callerClass);
}
+
+ @Override
+ public void check$java_net_DatagramSocket$bind(Class> callerClass, DatagramSocket that, SocketAddress addr) {
+ policyManager.checkNetworkAccess(callerClass, NetworkEntitlement.LISTEN_ACTION);
+ }
+
+ @Override
+ public void check$java_net_DatagramSocket$connect(Class> callerClass, DatagramSocket that, InetAddress addr) {
+ policyManager.checkNetworkAccess(callerClass, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_DatagramSocket$connect(Class> callerClass, DatagramSocket that, SocketAddress addr) {
+ policyManager.checkNetworkAccess(callerClass, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_DatagramSocket$send(Class> callerClass, DatagramSocket that, DatagramPacket p) {
+ var actions = NetworkEntitlement.CONNECT_ACTION;
+ if (p.getAddress().isMulticastAddress()) {
+ actions |= NetworkEntitlement.ACCEPT_ACTION;
+ }
+ policyManager.checkNetworkAccess(callerClass, actions);
+ }
+
+ @Override
+ public void check$java_net_DatagramSocket$receive(Class> callerClass, DatagramSocket that, DatagramPacket p) {
+ policyManager.checkNetworkAccess(callerClass, NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_DatagramSocket$joinGroup(Class> caller, DatagramSocket that, SocketAddress addr, NetworkInterface ni) {
+ policyManager.checkNetworkAccess(caller, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_DatagramSocket$leaveGroup(Class> caller, DatagramSocket that, SocketAddress addr, NetworkInterface ni) {
+ policyManager.checkNetworkAccess(caller, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_MulticastSocket$joinGroup(Class> callerClass, MulticastSocket that, InetAddress addr) {
+ policyManager.checkNetworkAccess(callerClass, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_MulticastSocket$joinGroup(Class> caller, MulticastSocket that, SocketAddress addr, NetworkInterface ni) {
+ policyManager.checkNetworkAccess(caller, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_MulticastSocket$leaveGroup(Class> caller, MulticastSocket that, InetAddress addr) {
+ policyManager.checkNetworkAccess(caller, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_MulticastSocket$leaveGroup(Class> caller, MulticastSocket that, SocketAddress addr, NetworkInterface ni) {
+ policyManager.checkNetworkAccess(caller, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
+
+ @Override
+ public void check$java_net_MulticastSocket$send(Class> callerClass, MulticastSocket that, DatagramPacket p, byte ttl) {
+ policyManager.checkNetworkAccess(callerClass, NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION);
+ }
}
diff --git a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/NetworkEntitlement.java b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/NetworkEntitlement.java
new file mode 100644
index 000000000000..b6c6a41d5be7
--- /dev/null
+++ b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/NetworkEntitlement.java
@@ -0,0 +1,107 @@
+/*
+ * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
+ * Public License v 1"; you may not use this file except in compliance with, at
+ * your election, the "Elastic License 2.0", the "GNU Affero General Public
+ * License v3.0 only", or the "Server Side Public License, v 1".
+ */
+
+package org.elasticsearch.entitlement.runtime.policy;
+
+import org.elasticsearch.core.Strings;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.StringJoiner;
+
+import static java.util.Map.entry;
+
+/**
+ * Describes a network entitlement (sockets) with actions.
+ */
+public class NetworkEntitlement implements Entitlement {
+
+ public static final int LISTEN_ACTION = 0x1;
+ public static final int CONNECT_ACTION = 0x2;
+ public static final int ACCEPT_ACTION = 0x4;
+
+ static final String LISTEN = "listen";
+ static final String CONNECT = "connect";
+ static final String ACCEPT = "accept";
+
+ private static final Map ACTION_MAP = Map.ofEntries(
+ entry(LISTEN, LISTEN_ACTION),
+ entry(CONNECT, CONNECT_ACTION),
+ entry(ACCEPT, ACCEPT_ACTION)
+ );
+
+ private final int actions;
+
+ @ExternalEntitlement(parameterNames = { "actions" }, esModulesOnly = false)
+ public NetworkEntitlement(List actionsList) {
+
+ int actionsInt = 0;
+
+ for (String actionString : actionsList) {
+ var action = ACTION_MAP.get(actionString);
+ if (action == null) {
+ throw new IllegalArgumentException("unknown network action [" + actionString + "]");
+ }
+ if ((actionsInt & action) == action) {
+ throw new IllegalArgumentException(Strings.format("network action [%s] specified multiple times", actionString));
+ }
+ actionsInt |= action;
+ }
+
+ this.actions = actionsInt;
+ }
+
+ public static Object printActions(int actions) {
+ var joiner = new StringJoiner(",");
+ for (var entry : ACTION_MAP.entrySet()) {
+ var action = entry.getValue();
+ if ((actions & action) == action) {
+ joiner.add(entry.getKey());
+ }
+ }
+ return joiner.toString();
+ }
+
+ /**
+ * For the actions to match, the actions present in this entitlement must be a superset
+ * of the actions required by a check.
+ * There is only one "negative" case (action required by the check but not present in the entitlement),
+ * and it can be expressed efficiently via this truth table:
+ * this.actions | requiredActions |
+ * 0 | 0 | 0
+ * 0 | 1 | 1 --> NOT this.action AND requiredActions
+ * 1 | 0 | 0
+ * 1 | 1 | 0
+ *
+ * @param requiredActions the actions required to be present for a check to pass
+ * @return true if requiredActions are present, false otherwise
+ */
+ public boolean matchActions(int requiredActions) {
+ return (~this.actions & requiredActions) == 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ NetworkEntitlement that = (NetworkEntitlement) o;
+ return actions == that.actions;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(actions);
+ }
+
+ @Override
+ public String toString() {
+ return "NetworkEntitlement{actions=" + actions + '}';
+ }
+}
diff --git a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java
index 818d61f002db..f204340ec9e2 100644
--- a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java
+++ b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java
@@ -32,24 +32,36 @@
import static java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE;
import static java.util.Objects.requireNonNull;
import static java.util.function.Predicate.not;
+import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toUnmodifiableMap;
public class PolicyManager {
private static final Logger logger = LogManager.getLogger(PolicyManager.class);
- record ModuleEntitlements(Set> flagEntitlements, FileAccessTree fileAccess) {
- public static final ModuleEntitlements NONE = new ModuleEntitlements(Set.of(), FileAccessTree.EMPTY);
+ record ModuleEntitlements(Map, List> entitlementsByType, FileAccessTree fileAccess) {
+ public static final ModuleEntitlements NONE = new ModuleEntitlements(Map.of(), FileAccessTree.EMPTY);
ModuleEntitlements {
- flagEntitlements = Set.copyOf(flagEntitlements);
+ entitlementsByType = Map.copyOf(entitlementsByType);
}
public static ModuleEntitlements from(List entitlements) {
- Set> flagEntitlements = entitlements.stream().map(Entitlement::getClass).collect(Collectors.toSet());
var fileEntitlements = entitlements.stream()
.filter(e -> e.getClass().equals(FileEntitlement.class))
.map(e -> (FileEntitlement) e).toList();
- return new ModuleEntitlements(flagEntitlements, new FileAccessTree(fileEntitlements));
+ return new ModuleEntitlements(entitlements.stream().collect(groupingBy(Entitlement::getClass)), new FileAccessTree(fileEntitlements));
+ }
+
+ public boolean hasEntitlement(Class extends Entitlement> entitlementClass) {
+ return entitlementsByType.containsKey(entitlementClass);
+ }
+
+ public Stream getEntitlements(Class entitlementClass) {
+ var entitlements = entitlementsByType.get(entitlementClass);
+ if (entitlements == null) {
+ return Stream.empty();
+ }
+ return entitlements.stream().map(entitlementClass::cast);
}
}
@@ -263,6 +275,34 @@ private String operationDescription(String methodName) {
return methodName.substring(methodName.indexOf('$'));
}
+ public void checkNetworkAccess(Class> callerClass, int actions) {
+ var requestingClass = requestingClass(callerClass);
+ if (isTriviallyAllowed(requestingClass)) {
+ return;
+ }
+
+ ModuleEntitlements entitlements = getEntitlements(requestingClass);
+ if (entitlements.getEntitlements(NetworkEntitlement.class).anyMatch(n -> n.matchActions(actions))) {
+ logger.debug(
+ () -> Strings.format(
+ "Entitled: class [%s], module [%s], entitlement [Network], actions [Ox%X]",
+ requestingClass,
+ requestingClass.getModule().getName(),
+ actions
+ )
+ );
+ return;
+ }
+ throw new NotEntitledException(
+ Strings.format(
+ "Missing entitlement: class [%s], module [%s], entitlement [Network], actions [%s]",
+ requestingClass,
+ requestingClass.getModule().getName(),
+ NetworkEntitlement.printActions(actions)
+ )
+ );
+ }
+
private void checkEntitlementPresent(Class> callerClass, Class extends Entitlement> entitlementClass) {
var requestingClass = requestingClass(callerClass);
if (isTriviallyAllowed(requestingClass)) {
@@ -270,7 +310,7 @@ private void checkEntitlementPresent(Class> callerClass, Class extends Entit
}
ModuleEntitlements entitlements = getEntitlements(requestingClass);
- if (entitlements.flagEntitlements.contains(entitlementClass)) {
+ if (entitlements.hasEntitlement(entitlementClass)) {
logger.debug(
() -> Strings.format(
"Entitled: class [%s], module [%s], entitlement [%s]",
diff --git a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyParser.java b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyParser.java
index 013acf8f22fa..ac4d4afdd97f 100644
--- a/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyParser.java
+++ b/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyParser.java
@@ -37,7 +37,8 @@ public class PolicyParser {
private static final Map> EXTERNAL_ENTITLEMENTS = Stream.of(
FileEntitlement.class,
CreateClassLoaderEntitlement.class,
- SetHttpsConnectionPropertiesEntitlement.class
+ SetHttpsConnectionPropertiesEntitlement.class,
+ NetworkEntitlement.class
).collect(Collectors.toUnmodifiableMap(PolicyParser::getEntitlementTypeName, Function.identity()));
protected final XContentParser policyParser;
diff --git a/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/NetworkEntitlementTests.java b/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/NetworkEntitlementTests.java
new file mode 100644
index 000000000000..91051d48c365
--- /dev/null
+++ b/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/NetworkEntitlementTests.java
@@ -0,0 +1,49 @@
+/*
+ * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
+ * Public License v 1"; you may not use this file except in compliance with, at
+ * your election, the "Elastic License 2.0", the "GNU Affero General Public
+ * License v3.0 only", or the "Server Side Public License, v 1".
+ */
+
+package org.elasticsearch.entitlement.runtime.policy;
+
+import org.elasticsearch.test.ESTestCase;
+
+import java.util.List;
+
+import static org.hamcrest.Matchers.is;
+
+public class NetworkEntitlementTests extends ESTestCase {
+
+ public void testMatchesActions() {
+ var listenEntitlement = new NetworkEntitlement(List.of(NetworkEntitlement.LISTEN));
+ var emptyEntitlement = new NetworkEntitlement(List.of());
+ var connectAcceptEntitlement = new NetworkEntitlement(List.of(NetworkEntitlement.CONNECT, NetworkEntitlement.ACCEPT));
+
+ assertThat(listenEntitlement.matchActions(0), is(true));
+ assertThat(listenEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION), is(true));
+ assertThat(listenEntitlement.matchActions(NetworkEntitlement.ACCEPT_ACTION), is(false));
+ assertThat(listenEntitlement.matchActions(NetworkEntitlement.CONNECT_ACTION), is(false));
+ assertThat(listenEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION | NetworkEntitlement.ACCEPT_ACTION), is(false));
+ assertThat(listenEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION | NetworkEntitlement.CONNECT_ACTION), is(false));
+ assertThat(listenEntitlement.matchActions(NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION), is(false));
+
+ assertThat(connectAcceptEntitlement.matchActions(0), is(true));
+ assertThat(connectAcceptEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION), is(false));
+ assertThat(connectAcceptEntitlement.matchActions(NetworkEntitlement.ACCEPT_ACTION), is(true));
+ assertThat(connectAcceptEntitlement.matchActions(NetworkEntitlement.CONNECT_ACTION), is(true));
+ assertThat(connectAcceptEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION | NetworkEntitlement.ACCEPT_ACTION), is(false));
+ assertThat(connectAcceptEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION | NetworkEntitlement.CONNECT_ACTION), is(false));
+ assertThat(connectAcceptEntitlement.matchActions(NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION), is(true));
+
+ assertThat(emptyEntitlement.matchActions(0), is(true));
+ assertThat(emptyEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION), is(false));
+ assertThat(emptyEntitlement.matchActions(NetworkEntitlement.ACCEPT_ACTION), is(false));
+ assertThat(emptyEntitlement.matchActions(NetworkEntitlement.CONNECT_ACTION), is(false));
+ assertThat(emptyEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION | NetworkEntitlement.ACCEPT_ACTION), is(false));
+ assertThat(emptyEntitlement.matchActions(NetworkEntitlement.LISTEN_ACTION | NetworkEntitlement.CONNECT_ACTION), is(false));
+ assertThat(emptyEntitlement.matchActions(NetworkEntitlement.CONNECT_ACTION | NetworkEntitlement.ACCEPT_ACTION), is(false));
+ }
+}
diff --git a/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyManagerTests.java b/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyManagerTests.java
index d60136d5a59b..153c96956143 100644
--- a/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyManagerTests.java
+++ b/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyManagerTests.java
@@ -113,7 +113,7 @@ public void testGetEntitlementsReturnsEntitlementsForPluginUnnamedModule() {
var callerClass = this.getClass();
var entitlements = policyManager.getEntitlements(callerClass);
- assertThat(entitlements.flagEntitlements().contains(CreateClassLoaderEntitlement.class), is(true));
+ assertThat(entitlements.hasEntitlement(CreateClassLoaderEntitlement.class), is(true));
}
public void testGetEntitlementsThrowsOnMissingPolicyForServer() throws ClassNotFoundException {
@@ -148,8 +148,8 @@ public void testGetEntitlementsReturnsEntitlementsForServerModule() throws Class
var requestingModule = mockServerClass.getModule();
var entitlements = policyManager.getEntitlements(mockServerClass);
- assertThat(entitlements.flagEntitlements().contains(CreateClassLoaderEntitlement.class), is(true));
- assertThat(entitlements.flagEntitlements().contains(ExitVMEntitlement.class), is(true));
+ assertThat(entitlements.hasEntitlement(CreateClassLoaderEntitlement.class), is(true));
+ assertThat(entitlements.hasEntitlement(ExitVMEntitlement.class), is(true));
}
public void testGetEntitlementsReturnsEntitlementsForPluginModule() throws IOException, ClassNotFoundException {
@@ -169,7 +169,7 @@ public void testGetEntitlementsReturnsEntitlementsForPluginModule() throws IOExc
var mockPluginClass = layer.findLoader("org.example.plugin").loadClass("q.B");
var entitlements = policyManager.getEntitlements(mockPluginClass);
- assertThat(entitlements.flagEntitlements().contains(CreateClassLoaderEntitlement.class), is(true));
+ assertThat(entitlements.hasEntitlement(CreateClassLoaderEntitlement.class), is(true));
// TODO: this can't work on Windows, we need to have the root be unknown
// assertThat(entitlements.fileAccess().canRead("/test/path"), is(true));
}
@@ -187,7 +187,7 @@ public void testGetEntitlementsResultIsCached() {
var callerClass = this.getClass();
var entitlements = policyManager.getEntitlements(callerClass);
- assertThat(entitlements.flagEntitlements().contains(CreateClassLoaderEntitlement.class), is(true));
+ assertThat(entitlements.hasEntitlement(CreateClassLoaderEntitlement.class), is(true));
assertThat(policyManager.moduleEntitlementsMap, aMapWithSize(1));
var cachedResult = policyManager.moduleEntitlementsMap.values().stream().findFirst().get();
var entitlementsAgain = policyManager.getEntitlements(callerClass);
diff --git a/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyParserTests.java b/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyParserTests.java
index d6925d596a34..779799ac9a32 100644
--- a/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyParserTests.java
+++ b/libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyParserTests.java
@@ -52,6 +52,22 @@ public void testPolicyBuilderOnExternalPlugin() throws IOException {
assertEquals(expected, parsedPolicy);
}
+ public void testParseNetwork() throws IOException {
+ Policy parsedPolicy = new PolicyParser(new ByteArrayInputStream("""
+ entitlement-module-name:
+ - network:
+ actions:
+ - listen
+ - accept
+ - connect
+ """.getBytes(StandardCharsets.UTF_8)), "test-policy.yaml", false).parsePolicy();
+ Policy expected = new Policy(
+ "test-policy.yaml",
+ List.of(new Scope("entitlement-module-name", List.of(new NetworkEntitlement(List.of("listen", "accept", "connect")))))
+ );
+ assertEquals(expected, parsedPolicy);
+ }
+
public void testParseCreateClassloader() throws IOException {
Policy parsedPolicy = new PolicyParser(new ByteArrayInputStream("""
entitlement-module-name:
diff --git a/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/APM.java b/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/APM.java
index 339a4ec24ca1..43447cfa21a6 100644
--- a/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/APM.java
+++ b/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/APM.java
@@ -92,14 +92,7 @@ public List> getSettings() {
APMAgentSettings.TELEMETRY_TRACING_ENABLED_SETTING,
APMAgentSettings.TELEMETRY_TRACING_NAMES_INCLUDE_SETTING,
APMAgentSettings.TELEMETRY_TRACING_NAMES_EXCLUDE_SETTING,
- APMAgentSettings.TELEMETRY_TRACING_SANITIZE_FIELD_NAMES,
- // The settings below are deprecated and are currently kept as fallback.
- APMAgentSettings.TRACING_APM_SECRET_TOKEN_SETTING,
- APMAgentSettings.TRACING_APM_API_KEY_SETTING,
- APMAgentSettings.TRACING_APM_ENABLED_SETTING,
- APMAgentSettings.TRACING_APM_NAMES_INCLUDE_SETTING,
- APMAgentSettings.TRACING_APM_NAMES_EXCLUDE_SETTING,
- APMAgentSettings.TRACING_APM_SANITIZE_FIELD_NAMES
+ APMAgentSettings.TELEMETRY_TRACING_SANITIZE_FIELD_NAMES
);
}
}
diff --git a/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettings.java b/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettings.java
index f66683a787bc..8647761e2def 100644
--- a/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettings.java
+++ b/modules/apm/src/main/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettings.java
@@ -25,9 +25,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
-import java.util.function.Function;
-import static org.elasticsearch.common.settings.Setting.Property.Deprecated;
import static org.elasticsearch.common.settings.Setting.Property.NodeScope;
import static org.elasticsearch.common.settings.Setting.Property.OperatorDynamic;
@@ -101,9 +99,6 @@ public void setAgentSetting(String key, String value) {
private static final String TELEMETRY_SETTING_PREFIX = "telemetry.";
- // The old legacy prefix
- private static final String LEGACY_TRACING_APM_SETTING_PREFIX = "tracing.apm.";
-
/**
* Allow-list of APM agent config keys users are permitted to configure.
* @see APM Java Agent Configuration
@@ -248,56 +243,24 @@ private static Setting concreteAgentSetting(String namespace, String qua
public static final Setting.AffixSetting APM_AGENT_SETTINGS = Setting.prefixKeySetting(
TELEMETRY_SETTING_PREFIX + "agent.",
- LEGACY_TRACING_APM_SETTING_PREFIX + "agent.",
- (namespace, qualifiedKey) -> qualifiedKey.startsWith(LEGACY_TRACING_APM_SETTING_PREFIX)
- ? concreteAgentSetting(namespace, qualifiedKey, NodeScope, OperatorDynamic, Deprecated)
- : concreteAgentSetting(namespace, qualifiedKey, NodeScope, OperatorDynamic)
+ null, // no fallback
+ (namespace, qualifiedKey) -> concreteAgentSetting(namespace, qualifiedKey, NodeScope, OperatorDynamic)
);
- /**
- * @deprecated in favor of TELEMETRY_TRACING_NAMES_INCLUDE_SETTING.
- */
- @Deprecated
- public static final Setting> TRACING_APM_NAMES_INCLUDE_SETTING = Setting.stringListSetting(
- LEGACY_TRACING_APM_SETTING_PREFIX + "names.include",
- OperatorDynamic,
- NodeScope,
- Deprecated
- );
-
- public static final Setting> TELEMETRY_TRACING_NAMES_INCLUDE_SETTING = Setting.listSetting(
+ public static final Setting> TELEMETRY_TRACING_NAMES_INCLUDE_SETTING = Setting.stringListSetting(
TELEMETRY_SETTING_PREFIX + "tracing.names.include",
- TRACING_APM_NAMES_INCLUDE_SETTING,
- Function.identity(),
OperatorDynamic,
NodeScope
);
- /**
- * @deprecated in favor of TELEMETRY_TRACING_NAMES_EXCLUDE_SETTING.
- */
- @Deprecated
- public static final Setting> TRACING_APM_NAMES_EXCLUDE_SETTING = Setting.stringListSetting(
- LEGACY_TRACING_APM_SETTING_PREFIX + "names.exclude",
- OperatorDynamic,
- NodeScope,
- Deprecated
- );
-
- public static final Setting> TELEMETRY_TRACING_NAMES_EXCLUDE_SETTING = Setting.listSetting(
+ public static final Setting> TELEMETRY_TRACING_NAMES_EXCLUDE_SETTING = Setting.stringListSetting(
TELEMETRY_SETTING_PREFIX + "tracing.names.exclude",
- TRACING_APM_NAMES_EXCLUDE_SETTING,
- Function.identity(),
OperatorDynamic,
NodeScope
);
- /**
- * @deprecated in favor of TELEMETRY_TRACING_SANITIZE_FIELD_NAMES.
- */
- @Deprecated
- public static final Setting> TRACING_APM_SANITIZE_FIELD_NAMES = Setting.stringListSetting(
- LEGACY_TRACING_APM_SETTING_PREFIX + "sanitize_field_names",
+ public static final Setting> TELEMETRY_TRACING_SANITIZE_FIELD_NAMES = Setting.stringListSetting(
+ TELEMETRY_SETTING_PREFIX + "tracing.sanitize_field_names",
List.of(
"password",
"passwd",
@@ -313,33 +276,12 @@ private static Setting concreteAgentSetting(String namespace, String qua
"set-cookie"
),
OperatorDynamic,
- NodeScope,
- Deprecated
- );
-
- public static final Setting> TELEMETRY_TRACING_SANITIZE_FIELD_NAMES = Setting.listSetting(
- TELEMETRY_SETTING_PREFIX + "tracing.sanitize_field_names",
- TRACING_APM_SANITIZE_FIELD_NAMES,
- Function.identity(),
- OperatorDynamic,
NodeScope
);
- /**
- * @deprecated in favor of TELEMETRY_TRACING_ENABLED_SETTING.
- */
- @Deprecated
- public static final Setting TRACING_APM_ENABLED_SETTING = Setting.boolSetting(
- LEGACY_TRACING_APM_SETTING_PREFIX + "enabled",
- false,
- OperatorDynamic,
- NodeScope,
- Deprecated
- );
-
public static final Setting TELEMETRY_TRACING_ENABLED_SETTING = Setting.boolSetting(
TELEMETRY_SETTING_PREFIX + "tracing.enabled",
- TRACING_APM_ENABLED_SETTING,
+ false,
OperatorDynamic,
NodeScope
);
@@ -351,33 +293,13 @@ private static Setting concreteAgentSetting(String namespace, String qua
NodeScope
);
- /**
- * @deprecated in favor of TELEMETRY_SECRET_TOKEN_SETTING.
- */
- @Deprecated
- public static final Setting TRACING_APM_SECRET_TOKEN_SETTING = SecureSetting.secureString(
- LEGACY_TRACING_APM_SETTING_PREFIX + "secret_token",
- null,
- Deprecated
- );
-
public static final Setting TELEMETRY_SECRET_TOKEN_SETTING = SecureSetting.secureString(
TELEMETRY_SETTING_PREFIX + "secret_token",
- TRACING_APM_SECRET_TOKEN_SETTING
- );
-
- /**
- * @deprecated in favor of TELEMETRY_API_KEY_SETTING.
- */
- @Deprecated
- public static final Setting TRACING_APM_API_KEY_SETTING = SecureSetting.secureString(
- LEGACY_TRACING_APM_SETTING_PREFIX + "api_key",
- null,
- Deprecated
+ null
);
public static final Setting TELEMETRY_API_KEY_SETTING = SecureSetting.secureString(
TELEMETRY_SETTING_PREFIX + "api_key",
- TRACING_APM_API_KEY_SETTING
+ null
);
}
diff --git a/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettingsTests.java b/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettingsTests.java
index a60048c82a3c..551667242092 100644
--- a/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettingsTests.java
+++ b/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/internal/APMAgentSettingsTests.java
@@ -11,8 +11,6 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.ClusterSettings;
-import org.elasticsearch.common.settings.MockSecureSettings;
-import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.mockito.Mockito;
@@ -21,21 +19,13 @@
import java.util.Set;
import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.APM_AGENT_SETTINGS;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TELEMETRY_API_KEY_SETTING;
import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TELEMETRY_METRICS_ENABLED_SETTING;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TELEMETRY_SECRET_TOKEN_SETTING;
import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TELEMETRY_TRACING_ENABLED_SETTING;
import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TELEMETRY_TRACING_NAMES_EXCLUDE_SETTING;
import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TELEMETRY_TRACING_NAMES_INCLUDE_SETTING;
import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TELEMETRY_TRACING_SANITIZE_FIELD_NAMES;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TRACING_APM_API_KEY_SETTING;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TRACING_APM_ENABLED_SETTING;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TRACING_APM_NAMES_EXCLUDE_SETTING;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TRACING_APM_NAMES_INCLUDE_SETTING;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TRACING_APM_SANITIZE_FIELD_NAMES;
-import static org.elasticsearch.telemetry.apm.internal.APMAgentSettings.TRACING_APM_SECRET_TOKEN_SETTING;
-import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasItem;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
@@ -70,14 +60,6 @@ public void testEnableTracing() {
}
}
- public void testEnableTracingUsingLegacySetting() {
- Settings settings = Settings.builder().put(TRACING_APM_ENABLED_SETTING.getKey(), true).build();
- apmAgentSettings.initAgentSystemProperties(settings);
-
- verify(apmAgentSettings).setAgentSetting("recording", "true");
- assertWarnings("[tracing.apm.enabled] setting was deprecated in Elasticsearch and will be removed in a future release.");
- }
-
public void testEnableMetrics() {
for (boolean tracingEnabled : List.of(true, false)) {
clearInvocations(apmAgentSettings, apmTelemetryProvider.getMeterService());
@@ -121,14 +103,6 @@ public void testDisableTracing() {
}
}
- public void testDisableTracingUsingLegacySetting() {
- Settings settings = Settings.builder().put(TRACING_APM_ENABLED_SETTING.getKey(), false).build();
- apmAgentSettings.initAgentSystemProperties(settings);
-
- verify(apmAgentSettings).setAgentSetting("recording", "false");
- assertWarnings("[tracing.apm.enabled] setting was deprecated in Elasticsearch and will be removed in a future release.");
- }
-
public void testDisableMetrics() {
for (boolean tracingEnabled : List.of(true, false)) {
clearInvocations(apmAgentSettings, apmTelemetryProvider.getMeterService());
@@ -181,70 +155,18 @@ public void testSetAgentSettings() {
verify(apmAgentSettings).setAgentSetting("span_compression_enabled", "true");
}
- public void testSetAgentsSettingsWithLegacyPrefix() {
- Settings settings = Settings.builder()
- .put(TELEMETRY_TRACING_ENABLED_SETTING.getKey(), true)
- .put("tracing.apm.agent.span_compression_enabled", "true")
- .build();
- apmAgentSettings.initAgentSystemProperties(settings);
-
- verify(apmAgentSettings).setAgentSetting("recording", "true");
- verify(apmAgentSettings).setAgentSetting("span_compression_enabled", "true");
- assertWarnings(
- "[tracing.apm.agent.span_compression_enabled] setting was deprecated in Elasticsearch and will be removed in a future release."
- );
- }
-
/**
* Check that invalid or forbidden APM agent settings are rejected.
*/
public void testRejectForbiddenOrUnknownAgentSettings() {
- List prefixes = List.of(APM_AGENT_SETTINGS.getKey(), "tracing.apm.agent.");
- for (String prefix : prefixes) {
- Settings settings = Settings.builder().put(prefix + "unknown", "true").build();
- Exception exception = expectThrows(IllegalArgumentException.class, () -> APM_AGENT_SETTINGS.getAsMap(settings));
- assertThat(exception.getMessage(), containsString("[" + prefix + "unknown]"));
- }
- // though, accept / ignore nested global_labels
- for (String prefix : prefixes) {
- Settings settings = Settings.builder().put(prefix + "global_labels.abc", "123").build();
- APMAgentSettings.APM_AGENT_SETTINGS.getAsMap(settings);
-
- if (prefix.startsWith("tracing.apm.agent.")) {
- assertWarnings(
- "[tracing.apm.agent.global_labels.abc] setting was deprecated in Elasticsearch and will be removed in a future release."
- );
- }
- }
- }
-
- public void testTelemetryTracingNamesIncludeFallback() {
- Settings settings = Settings.builder().put(TRACING_APM_NAMES_INCLUDE_SETTING.getKey(), "abc,xyz").build();
-
- List included = TELEMETRY_TRACING_NAMES_INCLUDE_SETTING.get(settings);
-
- assertThat(included, containsInAnyOrder("abc", "xyz"));
- assertWarnings("[tracing.apm.names.include] setting was deprecated in Elasticsearch and will be removed in a future release.");
- }
-
- public void testTelemetryTracingNamesExcludeFallback() {
- Settings settings = Settings.builder().put(TRACING_APM_NAMES_EXCLUDE_SETTING.getKey(), "abc,xyz").build();
-
- List included = TELEMETRY_TRACING_NAMES_EXCLUDE_SETTING.get(settings);
-
- assertThat(included, containsInAnyOrder("abc", "xyz"));
- assertWarnings("[tracing.apm.names.exclude] setting was deprecated in Elasticsearch and will be removed in a future release.");
- }
-
- public void testTelemetryTracingSanitizeFieldNamesFallback() {
- Settings settings = Settings.builder().put(TRACING_APM_SANITIZE_FIELD_NAMES.getKey(), "abc,xyz").build();
-
- List included = TELEMETRY_TRACING_SANITIZE_FIELD_NAMES.get(settings);
+ String prefix = APM_AGENT_SETTINGS.getKey();
+ Settings settings = Settings.builder().put(prefix + "unknown", "true").build();
+ Exception exception = expectThrows(IllegalArgumentException.class, () -> APM_AGENT_SETTINGS.getAsMap(settings));
+ assertThat(exception.getMessage(), containsString("[" + prefix + "unknown]"));
- assertThat(included, containsInAnyOrder("abc", "xyz"));
- assertWarnings(
- "[tracing.apm.sanitize_field_names] setting was deprecated in Elasticsearch and will be removed in a future release."
- );
+ // though, accept / ignore nested global_labels
+ var map = APMAgentSettings.APM_AGENT_SETTINGS.getAsMap(Settings.builder().put(prefix + "global_labels.abc", "123").build());
+ assertThat(map, hasEntry("global_labels.abc", "123"));
}
public void testTelemetryTracingSanitizeFieldNamesFallbackDefault() {
@@ -252,28 +174,6 @@ public void testTelemetryTracingSanitizeFieldNamesFallbackDefault() {
assertThat(included, hasItem("password")); // and more defaults
}
- public void testTelemetrySecretTokenFallback() {
- MockSecureSettings secureSettings = new MockSecureSettings();
- secureSettings.setString(TRACING_APM_SECRET_TOKEN_SETTING.getKey(), "verysecret");
- Settings settings = Settings.builder().setSecureSettings(secureSettings).build();
-
- try (SecureString secureString = TELEMETRY_SECRET_TOKEN_SETTING.get(settings)) {
- assertEquals("verysecret", secureString.toString());
- }
- assertWarnings("[tracing.apm.secret_token] setting was deprecated in Elasticsearch and will be removed in a future release.");
- }
-
- public void testTelemetryApiKeyFallback() {
- MockSecureSettings secureSettings = new MockSecureSettings();
- secureSettings.setString(TRACING_APM_API_KEY_SETTING.getKey(), "abc");
- Settings settings = Settings.builder().setSecureSettings(secureSettings).build();
-
- try (SecureString secureString = TELEMETRY_API_KEY_SETTING.get(settings)) {
- assertEquals("abc", secureString.toString());
- }
- assertWarnings("[tracing.apm.api_key] setting was deprecated in Elasticsearch and will be removed in a future release.");
- }
-
/**
* Check that invalid or forbidden APM agent settings are rejected if their last part resembles an allowed setting.
*/
diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java
index 4a3dfac36d4e..2739eb51376e 100644
--- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java
+++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java
@@ -596,7 +596,7 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception {
verifyResolvability(dataStreamName, indicesAdmin().prepareGetFieldMappings(dataStreamName), false);
verifyResolvability(dataStreamName, indicesAdmin().preparePutMapping(dataStreamName).setSource("""
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
- verifyResolvability(dataStreamName, indicesAdmin().prepareGetMappings(dataStreamName), false);
+ verifyResolvability(dataStreamName, indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, dataStreamName), false);
verifyResolvability(
dataStreamName,
indicesAdmin().prepareUpdateSettings(dataStreamName).setSettings(Settings.builder().put("index.number_of_replicas", 0)),
@@ -643,7 +643,7 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception {
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetFieldMappings(wildcardExpression), false);
verifyResolvability(wildcardExpression, indicesAdmin().preparePutMapping(wildcardExpression).setSource("""
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
- verifyResolvability(wildcardExpression, indicesAdmin().prepareGetMappings(wildcardExpression), false);
+ verifyResolvability(wildcardExpression, indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, wildcardExpression), false);
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetSettings(wildcardExpression), false);
verifyResolvability(
wildcardExpression,
@@ -1180,7 +1180,7 @@ public void testUpdateMappingViaDataStream() throws Exception {
DataStreamTimestampFieldMapper.NAME,
Map.of("enabled", true)
);
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("logs-foobar").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "logs-foobar").get();
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));
@@ -1195,7 +1195,7 @@ public void testUpdateMappingViaDataStream() throws Exception {
.setSource("{\"properties\":{\"my_field\":{\"type\":\"keyword\"}}}", XContentType.JSON)
.get();
// The mappings of all backing indices should be updated:
- getMappingsResponse = indicesAdmin().prepareGetMappings("logs-foobar").get();
+ getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "logs-foobar").get();
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));
diff --git a/modules/kibana/src/internalClusterTest/java/org/elasticsearch/kibana/KibanaThreadPoolIT.java b/modules/kibana/src/internalClusterTest/java/org/elasticsearch/kibana/KibanaThreadPoolIT.java
index 553e4696af31..a9ab0c02612f 100644
--- a/modules/kibana/src/internalClusterTest/java/org/elasticsearch/kibana/KibanaThreadPoolIT.java
+++ b/modules/kibana/src/internalClusterTest/java/org/elasticsearch/kibana/KibanaThreadPoolIT.java
@@ -16,6 +16,8 @@
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.internal.Client;
+import org.elasticsearch.cluster.metadata.IndexMetadata;
+import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
@@ -23,7 +25,6 @@
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolStats;
@@ -49,10 +50,6 @@
* threads that wait on a phaser. This lets us verify that operations on system indices
* are being directed to other thread pools.
*/
-@TestLogging(
- reason = "investigate",
- value = "org.elasticsearch.kibana.KibanaThreadPoolIT:DEBUG,org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor:TRACE"
-)
public class KibanaThreadPoolIT extends ESIntegTestCase {
private static final Logger logger = LogManager.getLogger(KibanaThreadPoolIT.class);
@@ -68,6 +65,8 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
.put("thread_pool.write.queue_size", 1)
.put("thread_pool.get.size", 1)
.put("thread_pool.get.queue_size", 1)
+ // a rejected GET may retry on an INITIALIZING shard (the target of a relocation) and unexpectedly succeed, so block rebalancing
+ .put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)
.build();
}
@@ -112,7 +111,12 @@ public void testKibanaThreadPoolByPassesBlockedThreadPools() throws Exception {
}
public void testBlockedThreadPoolsRejectUserRequests() throws Exception {
- assertAcked(client().admin().indices().prepareCreate(USER_INDEX));
+ assertAcked(
+ client().admin()
+ .indices()
+ .prepareCreate(USER_INDEX)
+ .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)) // avoid retrying rejected actions
+ );
runWithBlockedThreadPools(this::assertThreadPoolsBlocked);
diff --git a/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3MinioBasicCredentialsRestIT.java b/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3MinioBasicCredentialsRestIT.java
index 93915e8491d5..3d7c8dd15061 100644
--- a/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3MinioBasicCredentialsRestIT.java
+++ b/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3MinioBasicCredentialsRestIT.java
@@ -19,13 +19,15 @@
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
+import java.util.Locale;
+
@ThreadLeakFilters(filters = { TestContainersThreadFilter.class })
@ThreadLeakScope(ThreadLeakScope.Scope.NONE) // https://github.com/elastic/elasticsearch/issues/102482
public class RepositoryS3MinioBasicCredentialsRestIT extends AbstractRepositoryS3RestTestCase {
- private static final String PREFIX = getIdentifierPrefix("RepositoryS3MinioBasicCredentialsRestIT");
+ private static final String PREFIX = getIdentifierPrefix("RepositoryS3MinioBasicCredentialsRestIT").toLowerCase(Locale.ROOT);
private static final String BUCKET = PREFIX + "bucket";
- private static final String BASE_PATH = PREFIX + "base_path";
+ private static final String BASE_PATH = PREFIX + "base-path";
private static final String ACCESS_KEY = PREFIX + "access-key";
private static final String SECRET_KEY = PREFIX + "secret-key";
private static final String CLIENT = "minio_client";
diff --git a/muted-tests.yml b/muted-tests.yml
index 2ede31c94620..4ddc79a51ec7 100644
--- a/muted-tests.yml
+++ b/muted-tests.yml
@@ -52,9 +52,6 @@ tests:
- class: org.elasticsearch.xpack.transform.integration.TransformIT
method: testStopWaitForCheckpoint
issue: https://github.com/elastic/elasticsearch/issues/106113
-- class: org.elasticsearch.kibana.KibanaThreadPoolIT
- method: testBlockedThreadPoolsRejectUserRequests
- issue: https://github.com/elastic/elasticsearch/issues/113939
- class: org.elasticsearch.xpack.inference.TextEmbeddingCrudIT
method: testPutE5Small_withPlatformAgnosticVariant
issue: https://github.com/elastic/elasticsearch/issues/113983
@@ -230,29 +227,8 @@ tests:
- class: org.elasticsearch.xpack.inference.InferenceCrudIT
method: testGetServicesWithCompletionTaskType
issue: https://github.com/elastic/elasticsearch/issues/119959
-- class: org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCompatibilityIT
- method: testSearchableSnapshotUpgrade {p0=[9.0.0, 8.18.0, 8.18.0]}
- issue: https://github.com/elastic/elasticsearch/issues/119978
-- class: org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCompatibilityIT
- method: testSearchableSnapshotUpgrade {p0=[9.0.0, 9.0.0, 8.18.0]}
- issue: https://github.com/elastic/elasticsearch/issues/119979
-- class: org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCompatibilityIT
- method: testMountSearchableSnapshot {p0=[9.0.0, 8.18.0, 8.18.0]}
- issue: https://github.com/elastic/elasticsearch/issues/119550
-- class: org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCompatibilityIT
- method: testMountSearchableSnapshot {p0=[9.0.0, 9.0.0, 8.18.0]}
- issue: https://github.com/elastic/elasticsearch/issues/119980
-- class: org.elasticsearch.index.codec.vectors.es816.ES816HnswBinaryQuantizedVectorsFormatTests
- method: testRandomExceptions
- issue: https://github.com/elastic/elasticsearch/issues/119981
- class: org.elasticsearch.multi_cluster.MultiClusterYamlTestSuiteIT
issue: https://github.com/elastic/elasticsearch/issues/119983
-- class: org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCompatibilityIT
- method: testMountSearchableSnapshot {p0=[9.0.0, 9.0.0, 9.0.0]}
- issue: https://github.com/elastic/elasticsearch/issues/119989
-- class: org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCompatibilityIT
- method: testSearchableSnapshotUpgrade {p0=[9.0.0, 9.0.0, 9.0.0]}
- issue: https://github.com/elastic/elasticsearch/issues/119990
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
method: test {p0=transform/transforms_unattended/Test unattended put and start}
issue: https://github.com/elastic/elasticsearch/issues/120019
@@ -265,6 +241,22 @@ tests:
- class: org.elasticsearch.entitlement.qa.EntitlementsDeniedIT
method: testCheckThrows {pathPrefix=denied_nonmodular actionName=sslSessionImpl_getSessionContext}
issue: https://github.com/elastic/elasticsearch/issues/120054
+- class: org.elasticsearch.xpack.ilm.actions.SearchableSnapshotActionIT
+ method: testUpdatePolicyToAddPhasesYieldsInvalidActionsToBeSkipped
+ issue: https://github.com/elastic/elasticsearch/issues/118406
+- class: org.elasticsearch.xpack.ml.integration.DatafeedJobsIT
+ issue: https://github.com/elastic/elasticsearch/issues/120088
+- class: org.elasticsearch.xpack.searchablesnapshots.minio.MinioSearchableSnapshotsIT
+ issue: https://github.com/elastic/elasticsearch/issues/120101
+- class: org.elasticsearch.repositories.s3.S3RepositoryThirdPartyTests
+ issue: https://github.com/elastic/elasticsearch/issues/120115
+- class: org.elasticsearch.repositories.s3.RepositoryS3MinioBasicCredentialsRestIT
+ issue: https://github.com/elastic/elasticsearch/issues/120117
+- class: org.elasticsearch.repositories.blobstore.testkit.analyze.MinioRepositoryAnalysisRestIT
+ issue: https://github.com/elastic/elasticsearch/issues/118548
+- class: org.elasticsearch.xpack.security.QueryableReservedRolesIT
+ method: testConfiguredReservedRolesAfterClosingAndOpeningIndex
+ issue: https://github.com/elastic/elasticsearch/issues/120127
# Examples:
#
diff --git a/plugins/mapper-size/src/internalClusterTest/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/internalClusterTest/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java
index c2251910c312..435849821691 100644
--- a/plugins/mapper-size/src/internalClusterTest/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java
+++ b/plugins/mapper-size/src/internalClusterTest/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java
@@ -91,7 +91,7 @@ private void assertSizeMappingEnabled(String index, boolean enabled) throws IOEx
"Expected size field mapping to be " + (enabled ? "enabled" : "disabled") + " for %s",
index
);
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
Map mappingSource = getMappingsResponse.getMappings().get(index).getSourceAsMap();
assertThat(errMsg, mappingSource, hasKey("_size"));
String sizeAsString = mappingSource.get("_size").toString();
diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java
index ce514c5f1b1e..c48ae9ba1843 100644
--- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java
+++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java
@@ -12,12 +12,15 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction;
+import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsAction;
import org.elasticsearch.action.admin.cluster.state.ClusterStateAction;
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction;
import org.elasticsearch.action.admin.indices.recovery.RecoveryAction;
import org.elasticsearch.action.admin.indices.template.get.GetComponentTemplateAction;
import org.elasticsearch.action.admin.indices.template.get.GetComposableIndexTemplateAction;
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesAction;
+import org.elasticsearch.action.admin.indices.template.post.SimulateIndexTemplateAction;
+import org.elasticsearch.action.admin.indices.template.post.SimulateTemplateAction;
import org.elasticsearch.action.support.CancellableActionTestPlugin;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.action.support.RefCountingListener;
@@ -81,6 +84,25 @@ public void testGetComposableTemplateCancellation() {
runRestActionCancellationTest(new Request(HttpGet.METHOD_NAME, "/_index_template"), GetComposableIndexTemplateAction.NAME);
}
+ public void testSimulateTemplateCancellation() {
+ runRestActionCancellationTest(
+ new Request(HttpPost.METHOD_NAME, "/_index_template/_simulate/random_index_template"),
+ SimulateTemplateAction.NAME
+ );
+ }
+
+ public void testSimulateIndexTemplateCancellation() {
+ createIndex("test");
+ runRestActionCancellationTest(
+ new Request(HttpPost.METHOD_NAME, "/_index_template/_simulate_index/test"),
+ SimulateIndexTemplateAction.NAME
+ );
+ }
+
+ public void testClusterGetSettingsCancellation() {
+ runRestActionCancellationTest(new Request(HttpGet.METHOD_NAME, "/_cluster/settings"), ClusterGetSettingsAction.NAME);
+ }
+
private void runRestActionCancellationTest(Request request, String actionName) {
final var node = usually() ? internalCluster().getRandomNodeName() : internalCluster().startCoordinatingOnlyNode(Settings.EMPTY);
diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle
index 1da8e906582b..e4b46b98cedd 100644
--- a/rest-api-spec/build.gradle
+++ b/rest-api-spec/build.gradle
@@ -85,4 +85,6 @@ tasks.named("yamlRestCompatTestTransform").configure ({ task ->
task.skipTest("search.vectors/110_knn_query_with_filter/PRE_FILTER: pre-filter across multiple aliases", "waiting for #118774 backport")
task.skipTest("search.vectors/160_knn_query_missing_params/kNN search in a dis_max query - missing num_candidates", "waiting for #118774 backport")
task.skipTest("search.highlight/30_max_analyzed_offset/Plain highlighter with max_analyzed_offset < 0 should FAIL", "semantics of test has changed")
+ task.skipTest("indices.create/10_basic/Create lookup index", "default auto_expand_replicas was removed")
+ task.skipTest("indices.create/10_basic/Create lookup index with one shard", "default auto_expand_replicas was removed")
})
diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.get_settings.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.get_settings.json
index 5862804257c6..5004ab8de697 100644
--- a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.get_settings.json
+++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.get_settings.json
@@ -26,7 +26,7 @@
},
"master_timeout":{
"type":"time",
- "description":"Explicit operation timeout for connection to master node"
+ "description":"Timeout for waiting for new cluster state in case it is blocked"
},
"timeout":{
"type":"time",
diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.unfreeze.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.unfreeze.json
deleted file mode 100644
index 2327519ff281..000000000000
--- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.unfreeze.json
+++ /dev/null
@@ -1,67 +0,0 @@
-{
- "indices.unfreeze":{
- "documentation":{
- "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/unfreeze-index-api.html",
- "description":"Unfreezes an index. When a frozen index is unfrozen, the index goes through the normal recovery process and becomes writeable again."
- },
- "stability":"stable",
- "visibility":"public",
- "headers":{
- "accept": [ "application/json"]
- },
- "url":{
- "paths":[
- {
- "path":"/{index}/_unfreeze",
- "methods":[
- "POST"
- ],
- "parts":{
- "index":{
- "type":"string",
- "description":"The name of the index to unfreeze"
- }
- },
- "deprecated":{
- "version":"7.14.0",
- "description":"Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release."
- }
- }
- ]
- },
- "params":{
- "timeout":{
- "type":"time",
- "description":"Explicit operation timeout"
- },
- "master_timeout":{
- "type":"time",
- "description":"Specify timeout for connection to master"
- },
- "ignore_unavailable":{
- "type":"boolean",
- "description":"Whether specified concrete indices should be ignored when unavailable (missing or closed)"
- },
- "allow_no_indices":{
- "type":"boolean",
- "description":"Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
- },
- "expand_wildcards":{
- "type":"enum",
- "options":[
- "open",
- "closed",
- "hidden",
- "none",
- "all"
- ],
- "default":"closed",
- "description":"Whether to expand wildcard expression to concrete indices that are open, closed or both."
- },
- "wait_for_active_shards":{
- "type":"string",
- "description":"Sets the number of active shards to wait for before the operation returns."
- }
- }
- }
-}
diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.create/10_basic.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.create/10_basic.yml
index d0e1759073e1..8645c91a51ad 100644
--- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.create/10_basic.yml
+++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.create/10_basic.yml
@@ -171,7 +171,6 @@
index: test_lookup
- match: { test_lookup.settings.index.number_of_shards: "1"}
- - match: { test_lookup.settings.index.auto_expand_replicas: "0-all"}
---
"Create lookup index with one shard":
@@ -196,7 +195,6 @@
index: test_lookup
- match: { test_lookup.settings.index.number_of_shards: "1"}
- - match: { test_lookup.settings.index.auto_expand_replicas: "0-all"}
---
"Create lookup index with two shards":
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
index 420f6427a55e..68e65b16aa3a 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
@@ -519,7 +519,7 @@ public void testDeleteIndex() {
public void testGetMappings() {
interceptTransportActions(GetMappingsAction.NAME);
- GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(randomIndicesOrAliases());
+ GetMappingsRequest getMappingsRequest = new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(randomIndicesOrAliases());
internalCluster().coordOnlyNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet();
clearInterceptedActions();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
index 4c25b3262d55..b14bf38f3cbc 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
@@ -120,7 +120,7 @@ public void testNonNestedMappings() throws Exception {
)
);
- GetMappingsResponse response = indicesAdmin().prepareGetMappings("test").get();
+ GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings);
@@ -130,7 +130,7 @@ public void testNonNestedMappings() throws Exception {
public void testEmptyNestedMappings() throws Exception {
assertAcked(prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().endObject()));
- GetMappingsResponse response = indicesAdmin().prepareGetMappings("test").get();
+ GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings);
@@ -150,7 +150,7 @@ public void testEmptyMappings() throws Exception {
prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().startObject("_doc").endObject().endObject())
);
- GetMappingsResponse response = indicesAdmin().prepareGetMappings("test").get();
+ GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java
index 867ca89f9e7f..b9dadf86c334 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java
@@ -357,8 +357,9 @@ private void assertHasAliases(Set aliasNames, String name, String primar
* Fetch the mappings and settings for {@link TestSystemIndexDescriptor#INDEX_NAME} and verify that they match the expected values.
*/
private void assertMappingsAndSettings(String expectedMappings, String concreteIndex) {
- final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(INDEX_NAME))
- .actionGet();
+ final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(
+ new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(INDEX_NAME)
+ ).actionGet();
final Map mappings = getMappingsResponse.getMappings();
assertThat(
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java
index e45555b1dec1..2cd319d14832 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java
@@ -55,7 +55,7 @@ public void testBulkIndexCreatesMapping() throws Exception {
bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
bulkBuilder.get();
assertBusy(() -> {
- GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings().get();
+ GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30"));
});
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
index 7777dd778a6c..9eed1f757b5b 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
@@ -258,11 +258,14 @@ public void testLargeClusterStatePublishing() throws Exception {
.setTimeout(TimeValue.timeValueMinutes(1))
);
ensureGreen(); // wait for green state, so its both green, and there are no more pending events
- MappingMetadata masterMappingMetadata = indicesAdmin().prepareGetMappings("test").get().getMappings().get("test");
+ MappingMetadata masterMappingMetadata = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
+ .get()
+ .getMappings()
+ .get("test");
for (Client client : clients()) {
MappingMetadata mappingMetadata = client.admin()
.indices()
- .prepareGetMappings("test")
+ .prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
.setLocal(true)
.get()
.getMappings()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java
index d6ccdf3dc039..256566045c59 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java
@@ -115,7 +115,7 @@ public void testMetaWrittenWhenIndexIsClosedAndMetaUpdated() throws Exception {
)
.get();
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
assertNotNull(
((Map) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("integer_field")
);
@@ -146,7 +146,7 @@ public void testMetaWrittenWhenIndexIsClosedAndMetaUpdated() throws Exception {
)
.get();
- getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
+ getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
assertNotNull(
((Map) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("float_field")
);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java
index 802ba04375c4..24af560f608d 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java
@@ -97,7 +97,7 @@ public void testGlobalTemplatesDoNotApply() {
assertAcked(indicesAdmin().prepareCreate("a_hidden_index").setSettings(Settings.builder().put("index.hidden", true).build()));
- GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings("a_hidden_index").get();
+ GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "a_hidden_index").get();
assertThat(mappingsResponse.mappings().size(), is(1));
MappingMetadata mappingMetadata = mappingsResponse.mappings().get("a_hidden_index");
assertNotNull(mappingMetadata);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/LookupIndexModeIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/LookupIndexModeIT.java
index 960ee2fd7ca6..6bca87ebd6e3 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/LookupIndexModeIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/LookupIndexModeIT.java
@@ -49,7 +49,7 @@ public void testBasic() {
assertAcked(client().admin().indices().execute(TransportCreateIndexAction.TYPE, createRequest));
Settings settings = client().admin().indices().prepareGetSettings("hosts").get().getIndexToSettings().get("hosts");
assertThat(settings.get("index.mode"), equalTo("lookup"));
- assertThat(settings.get("index.auto_expand_replicas"), equalTo("0-all"));
+ assertNull(settings.get("index.auto_expand_replicas"));
Map allHosts = Map.of(
"192.168.1.2",
"Windows",
@@ -141,7 +141,6 @@ public void testResizeLookupIndex() {
Settings settings = client().admin().indices().prepareGetSettings("lookup-2").get().getIndexToSettings().get("lookup-2");
assertThat(settings.get("index.mode"), equalTo("lookup"));
assertThat(settings.get("index.number_of_shards"), equalTo("1"));
- assertThat(settings.get("index.auto_expand_replicas"), equalTo("0-all"));
ResizeRequest split = new ResizeRequest("lookup-3", "lookup-1");
split.setResizeType(ResizeType.SPLIT);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/DynamicMappingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/DynamicMappingIT.java
index a37fb25052ac..06561bc6d4c9 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/DynamicMappingIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/DynamicMappingIT.java
@@ -96,7 +96,11 @@ public void testSimpleDynamicMappingsSuccessful() {
client().prepareIndex("index").setId("1").setSource("a.x", 1).get();
client().prepareIndex("index").setId("2").setSource("a.y", 2).get();
- Map mappings = indicesAdmin().prepareGetMappings("index").get().mappings().get("index").sourceAsMap();
+ Map mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "index")
+ .get()
+ .mappings()
+ .get("index")
+ .sourceAsMap();
assertTrue(new WriteField("properties.a", () -> mappings).exists());
assertTrue(new WriteField("properties.a.properties.x", () -> mappings).exists());
}
@@ -183,7 +187,7 @@ private Map indexConcurrently(int numberOfFieldsToCreate, Settin
for (int i = 0; i < numberOfFieldsToCreate; ++i) {
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists());
}
- GetMappingsResponse mappings = indicesAdmin().prepareGetMappings("index").get();
+ GetMappingsResponse mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "index").get();
MappingMetadata indexMappings = mappings.getMappings().get("index");
assertNotNull(indexMappings);
Map typeMappingsMap = indexMappings.getSourceAsMap();
@@ -214,7 +218,11 @@ public void testConcurrentDynamicMappingsWithConflictingType() throws Throwable
for (int i = 0; i < numberOfDocsToCreate; ++i) {
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists());
}
- Map index = indicesAdmin().prepareGetMappings("index").get().getMappings().get("index").getSourceAsMap();
+ Map index = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "index")
+ .get()
+ .getMappings()
+ .get("index")
+ .getSourceAsMap();
for (int i = 0, j = 1; i < numberOfDocsToCreate; i++, j++) {
assertThat(new WriteField("properties.field" + i + ".type", () -> index).get(null), is(oneOf("long", "float")));
assertThat(new WriteField("properties.field" + j + ".type", () -> index).get(null), is(oneOf("long", "float")));
@@ -806,7 +814,11 @@ public void testSubobjectsFalseAtRoot() throws Exception {
assertEquals(RestStatus.CREATED, indexResponse.status());
assertBusy(() -> {
- Map mappings = indicesAdmin().prepareGetMappings("test").get().mappings().get("test").sourceAsMap();
+ Map mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
+ .get()
+ .mappings()
+ .get("test")
+ .sourceAsMap();
@SuppressWarnings("unchecked")
Map properties = (Map) mappings.get("properties");
assertEquals(4, properties.size());
@@ -851,7 +863,11 @@ public void testSubobjectsFalse() throws Exception {
assertEquals(RestStatus.CREATED, indexResponse.status());
assertBusy(() -> {
- Map mappings = indicesAdmin().prepareGetMappings("test").get().mappings().get("test").sourceAsMap();
+ Map mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
+ .get()
+ .mappings()
+ .get("test")
+ .sourceAsMap();
Map properties = (Map) mappings.get("properties");
Map foo = (Map) properties.get("foo");
properties = (Map) foo.get("properties");
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/MultiFieldsIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/MultiFieldsIntegrationIT.java
index 4a7de4b0ebc2..1a51fc12fed8 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/MultiFieldsIntegrationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/mapper/MultiFieldsIntegrationIT.java
@@ -37,7 +37,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testMultiFields() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createTypeSource()));
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map mappingSource = mappingMetadata.sourceAsMap();
@@ -53,7 +53,7 @@ public void testMultiFields() throws Exception {
assertAcked(indicesAdmin().preparePutMapping("my-index").setSource(createPutMappingSource()));
- getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
+ getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
mappingSource = mappingMetadata.sourceAsMap();
@@ -74,7 +74,7 @@ public void testMultiFields() throws Exception {
public void testGeoPointMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("geo_point")));
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map mappingSource = mappingMetadata.sourceAsMap();
@@ -102,7 +102,7 @@ public void testGeoPointMultiField() throws Exception {
public void testCompletionMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("completion")));
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map mappingSource = mappingMetadata.sourceAsMap();
@@ -123,7 +123,7 @@ public void testCompletionMultiField() throws Exception {
public void testIpMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("ip")));
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map mappingSource = mappingMetadata.sourceAsMap();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
index 652f4e02ffbc..c53cf3b56f65 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java
@@ -537,26 +537,26 @@ public void testPutMapping() throws Exception {
}
verify(indicesAdmin().preparePutMapping("foo").setSource("field", "type=text"), false);
- assertThat(indicesAdmin().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foo").get().mappings().get("foo"), notNullValue());
verify(indicesAdmin().preparePutMapping("b*").setSource("field", "type=text"), false);
- assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue());
- assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping("_all").setSource("field", "type=text"), false);
- assertThat(indicesAdmin().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue());
- assertThat(indicesAdmin().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue());
- assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue());
- assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foo").get().mappings().get("foo"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foobar").get().mappings().get("foobar"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping().setSource("field", "type=text"), false);
- assertThat(indicesAdmin().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue());
- assertThat(indicesAdmin().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue());
- assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue());
- assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foo").get().mappings().get("foo"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foobar").get().mappings().get("foobar"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping("c*").setSource("field", "type=text"), true);
assertAcked(indicesAdmin().prepareClose("barbaz").get());
verify(indicesAdmin().preparePutMapping("barbaz").setSource("field", "type=text"), false);
- assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
+ assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
}
public static final class TestPlugin extends Plugin {
@@ -664,7 +664,7 @@ static GetFieldMappingsRequestBuilder getFieldMapping(String... indices) {
}
static GetMappingsRequestBuilder getMapping(String... indices) {
- return indicesAdmin().prepareGetMappings(indices);
+ return indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, indices);
}
static GetSettingsRequestBuilder getSettings(String... indices) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceIT.java
index de565605ff58..7264585337fc 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceIT.java
@@ -123,8 +123,9 @@ private void triggerClusterStateUpdates() {
* Fetch the mappings and settings for {@link TestSystemIndexDescriptor#INDEX_NAME} and verify that they match the expected values.
*/
private void assertMappingsAndSettings(String expectedMappings) {
- final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(INDEX_NAME))
- .actionGet();
+ final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(
+ new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(INDEX_NAME)
+ ).actionGet();
final Map mappings = getMappingsResponse.getMappings();
assertThat(
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java
index 71fcb25c2e0b..e3092bda185f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java
@@ -198,7 +198,7 @@ public void testGetFieldMappingsWithBlocks() throws Exception {
try {
enableIndexBlock("test", SETTING_BLOCKS_METADATA);
- assertBlocked(indicesAdmin().prepareGetMappings(), INDEX_METADATA_BLOCK);
+ assertBlocked(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT), INDEX_METADATA_BLOCK);
} finally {
disableIndexBlock("test", SETTING_BLOCKS_METADATA);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
index 20e59fab3bd0..023aa402b733 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
@@ -42,7 +42,7 @@ protected Collection> nodePlugins() {
public void testGetMappingsWhereThereAreNone() {
createIndex("index");
- GetMappingsResponse response = indicesAdmin().prepareGetMappings().get();
+ GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertThat(response.mappings().containsKey("index"), equalTo(true));
assertEquals(MappingMetadata.EMPTY_MAPPINGS, response.mappings().get("index"));
}
@@ -70,19 +70,19 @@ public void testSimpleGetMappings() throws Exception {
assertThat(clusterHealth.isTimedOut(), equalTo(false));
// Get all mappings
- GetMappingsResponse response = indicesAdmin().prepareGetMappings().get();
+ GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa"), notNullValue());
assertThat(response.mappings().get("indexb"), notNullValue());
// Get all mappings, via wildcard support
- response = indicesAdmin().prepareGetMappings("*").get();
+ response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "*").get();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa"), notNullValue());
assertThat(response.mappings().get("indexb"), notNullValue());
// Get mappings in indexa
- response = indicesAdmin().prepareGetMappings("indexa").get();
+ response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "indexa").get();
assertThat(response.mappings().size(), equalTo(1));
assertThat(response.mappings().get("indexa"), notNullValue());
}
@@ -94,7 +94,7 @@ public void testGetMappingsWithBlocks() throws IOException {
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) {
try {
enableIndexBlock("test", block);
- GetMappingsResponse response = indicesAdmin().prepareGetMappings().get();
+ GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertThat(response.mappings().size(), equalTo(1));
assertNotNull(response.mappings().get("test"));
} finally {
@@ -104,7 +104,7 @@ public void testGetMappingsWithBlocks() throws IOException {
try {
enableIndexBlock("test", SETTING_BLOCKS_METADATA);
- assertBlocked(indicesAdmin().prepareGetMappings(), INDEX_METADATA_BLOCK);
+ assertBlocked(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT), INDEX_METADATA_BLOCK);
} finally {
disableIndexBlock("test", SETTING_BLOCKS_METADATA);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
index 6f6e488d46b2..fa2598348a1c 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
@@ -109,7 +109,7 @@ public void testUpdateMappingWithoutType() {
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("test").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertThat(getMappingsResponse.mappings().get("test").source().toString(), equalTo("""
{"_doc":{"properties":{"body":{"type":"text"},"date":{"type":"integer"}}}}"""));
}
@@ -123,7 +123,7 @@ public void testUpdateMappingWithoutTypeMultiObjects() {
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("test").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertThat(getMappingsResponse.mappings().get("test").source().toString(), equalTo("""
{"_doc":{"properties":{"date":{"type":"integer"}}}}"""));
}
@@ -215,7 +215,10 @@ public void testUpdateMappingConcurrently() throws Throwable {
.get();
assertThat(response.isAcknowledged(), equalTo(true));
- GetMappingsResponse getMappingResponse = client2.admin().indices().prepareGetMappings(indexName).get();
+ GetMappingsResponse getMappingResponse = client2.admin()
+ .indices()
+ .prepareGetMappings(TEST_REQUEST_TIMEOUT, indexName)
+ .get();
MappingMetadata mappings = getMappingResponse.getMappings().get(indexName);
@SuppressWarnings("unchecked")
Map properties = (Map) mappings.getSourceAsMap().get("properties");
@@ -284,7 +287,7 @@ private void assertConcreteMappingsOnAll(final String index, final String... fie
* Waits for the given mapping type to exists on the master node.
*/
private void assertMappingOnMaster(final String index, final String... fieldNames) {
- GetMappingsResponse response = indicesAdmin().prepareGetMappings(index).get();
+ GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
MappingMetadata mappings = response.getMappings().get(index);
assertThat(mappings, notNullValue());
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsAction.java
index 7e3c38c73509..ca02d19749ae 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsAction.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsAction.java
@@ -13,13 +13,18 @@
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
-import org.elasticsearch.action.support.master.MasterNodeReadRequest;
+import org.elasticsearch.action.support.local.LocalClusterStateRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue;
+import org.elasticsearch.core.UpdateForV10;
+import org.elasticsearch.tasks.CancellableTask;
+import org.elasticsearch.tasks.Task;
+import org.elasticsearch.tasks.TaskId;
import java.io.IOException;
+import java.util.Map;
import java.util.Objects;
public class ClusterGetSettingsAction extends ActionType {
@@ -34,25 +39,29 @@ public ClusterGetSettingsAction() {
/**
* Request to retrieve the cluster settings
*/
- public static class Request extends MasterNodeReadRequest {
+ public static class Request extends LocalClusterStateRequest {
public Request(TimeValue masterNodeTimeout) {
super(masterNodeTimeout);
}
+ /**
+ * NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to read these requests until
+ * we no longer need to support calling this action remotely.
+ */
+ @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA)
public Request(StreamInput in) throws IOException {
super(in);
assert in.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0);
}
@Override
- public void writeTo(StreamOutput out) throws IOException {
- assert out.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0);
- super.writeTo(out);
+ public ActionRequestValidationException validate() {
+ return null;
}
@Override
- public ActionRequestValidationException validate() {
- return null;
+ public Task createTask(long id, String type, String action, TaskId parentTaskId, Map headers) {
+ return new CancellableTask(id, type, action, "", parentTaskId, headers);
}
}
@@ -79,20 +88,17 @@ public int hashCode() {
return Objects.hash(persistentSettings, transientSettings, settings);
}
- public Response(StreamInput in) throws IOException {
- super(in);
- assert in.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0);
- persistentSettings = Settings.readSettingsFromStream(in);
- transientSettings = Settings.readSettingsFromStream(in);
- settings = Settings.readSettingsFromStream(in);
- }
-
public Response(Settings persistentSettings, Settings transientSettings, Settings settings) {
this.persistentSettings = Objects.requireNonNullElse(persistentSettings, Settings.EMPTY);
this.transientSettings = Objects.requireNonNullElse(transientSettings, Settings.EMPTY);
this.settings = Objects.requireNonNullElse(settings, Settings.EMPTY);
}
+ /**
+ * NB prior to 9.0 get-component was a TransportMasterNodeReadAction so for BwC we must remain able to write these responses until
+ * we no longer need to support calling this action remotely.
+ */
+ @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA)
@Override
public void writeTo(StreamOutput out) throws IOException {
assert out.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0);
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterGetSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterGetSettingsAction.java
index dce6a3800139..71b976e012aa 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterGetSettingsAction.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterGetSettingsAction.java
@@ -11,57 +11,66 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
-import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
+import org.elasticsearch.action.support.ChannelActionListener;
+import org.elasticsearch.action.support.local.TransportLocalClusterStateAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
-import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.util.concurrent.EsExecutors;
+import org.elasticsearch.core.UpdateForV10;
import org.elasticsearch.injection.guice.Inject;
+import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.Task;
-import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
-public class TransportClusterGetSettingsAction extends TransportMasterNodeReadAction<
+public class TransportClusterGetSettingsAction extends TransportLocalClusterStateAction<
ClusterGetSettingsAction.Request,
ClusterGetSettingsAction.Response> {
private final SettingsFilter settingsFilter;
+ /**
+ * NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC it must be registered with the TransportService until
+ * we no longer need to support calling this action remotely.
+ */
+ @UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA)
+ @SuppressWarnings("this-escape")
@Inject
public TransportClusterGetSettingsAction(
TransportService transportService,
ClusterService clusterService,
- ThreadPool threadPool,
SettingsFilter settingsFilter,
- ActionFilters actionFilters,
- IndexNameExpressionResolver indexNameExpressionResolver
+ ActionFilters actionFilters
) {
super(
ClusterGetSettingsAction.NAME,
- false,
- transportService,
- clusterService,
- threadPool,
actionFilters,
- ClusterGetSettingsAction.Request::new,
- indexNameExpressionResolver,
- ClusterGetSettingsAction.Response::new,
+ transportService.getTaskManager(),
+ clusterService,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
-
this.settingsFilter = settingsFilter;
+
+ transportService.registerRequestHandler(
+ actionName,
+ executor,
+ false,
+ true,
+ ClusterGetSettingsAction.Request::new,
+ (request, channel, task) -> executeDirect(task, request, new ChannelActionListener<>(channel))
+ );
}
@Override
- protected void masterOperation(
+ protected void localClusterStateOperation(
Task task,
ClusterGetSettingsAction.Request request,
ClusterState state,
ActionListener listener
) throws Exception {
+ ((CancellableTask) task).ensureNotCancelled();
Metadata metadata = state.metadata();
listener.onResponse(
new ClusterGetSettingsAction.Response(
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java
index 1bc2e1d13c86..29a124b3d0b2 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java
@@ -21,7 +21,7 @@
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.features.NodeFeature;
-import org.elasticsearch.index.mapper.SourceFieldMapper;
+import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.xcontent.ToXContentFragment;
import org.elasticsearch.xcontent.XContentBuilder;
@@ -71,7 +71,7 @@ public static MappingStats of(Metadata metadata, Runnable ensureNotCancelled) {
}
AnalysisStats.countMapping(mappingCounts, indexMetadata);
- var sourceMode = SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexMetadata.getSettings());
+ var sourceMode = IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexMetadata.getSettings());
sourceModeUsageCount.merge(sourceMode.toString().toLowerCase(Locale.ENGLISH), 1, Integer::sum);
}
final AtomicLong totalFieldCount = new AtomicLong();
diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java
index dd4114c94717..84789d8a2acf 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java
@@ -12,6 +12,7 @@
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.core.TimeValue;
import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
@@ -21,7 +22,9 @@
public class GetMappingsRequest extends ClusterInfoRequest {
- public GetMappingsRequest() {}
+ public GetMappingsRequest(TimeValue masterTimeout) {
+ super(masterTimeout);
+ }
public GetMappingsRequest(StreamInput in) throws IOException {
super(in);
diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequestBuilder.java
index 3f5413858139..a12ba4f60c26 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequestBuilder.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequestBuilder.java
@@ -11,13 +11,14 @@
import org.elasticsearch.action.support.master.info.ClusterInfoRequestBuilder;
import org.elasticsearch.client.internal.ElasticsearchClient;
+import org.elasticsearch.core.TimeValue;
public class GetMappingsRequestBuilder extends ClusterInfoRequestBuilder<
GetMappingsRequest,
GetMappingsResponse,
GetMappingsRequestBuilder> {
- public GetMappingsRequestBuilder(ElasticsearchClient client, String... indices) {
- super(client, GetMappingsAction.INSTANCE, new GetMappingsRequest().indices(indices));
+ public GetMappingsRequestBuilder(ElasticsearchClient client, TimeValue masterTimeout, String... indices) {
+ super(client, GetMappingsAction.INSTANCE, new GetMappingsRequest(masterTimeout).indices(indices));
}
}
diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequest.java
index ce29d65ececf..003be58d1955 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequest.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequest.java
@@ -12,16 +12,20 @@
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction;
-import org.elasticsearch.action.support.master.MasterNodeReadRequest;
+import org.elasticsearch.action.support.local.LocalClusterStateRequest;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.Nullable;
+import org.elasticsearch.core.TimeValue;
+import org.elasticsearch.tasks.CancellableTask;
+import org.elasticsearch.tasks.Task;
+import org.elasticsearch.tasks.TaskId;
import java.io.IOException;
+import java.util.Map;
import java.util.Objects;
-public class SimulateIndexTemplateRequest extends MasterNodeReadRequest {
+public class SimulateIndexTemplateRequest extends LocalClusterStateRequest {
private String indexName;
@@ -30,14 +34,18 @@ public class SimulateIndexTemplateRequest extends MasterNodeReadRequest headers) {
+ return new CancellableTask(id, type, action, "", parentTaskId, headers);
+ }
+
public String getIndexName() {
return indexName;
}
diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java
index a521dac60e96..1a04b6e4d763 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java
@@ -12,13 +12,11 @@
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.admin.indices.rollover.RolloverConfiguration;
-import org.elasticsearch.cluster.metadata.DataStreamGlobalRetention;
import org.elasticsearch.cluster.metadata.ResettableValue;
import org.elasticsearch.cluster.metadata.Template;
-import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.util.Maps;
import org.elasticsearch.core.Nullable;
+import org.elasticsearch.core.UpdateForV10;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
@@ -67,27 +65,11 @@ public RolloverConfiguration getRolloverConfiguration() {
return rolloverConfiguration;
}
- public SimulateIndexTemplateResponse(StreamInput in) throws IOException {
- super(in);
- resolvedTemplate = in.readOptionalWriteable(Template::new);
- if (in.readBoolean()) {
- int overlappingTemplatesCount = in.readInt();
- overlappingTemplates = Maps.newMapWithExpectedSize(overlappingTemplatesCount);
- for (int i = 0; i < overlappingTemplatesCount; i++) {
- String templateName = in.readString();
- overlappingTemplates.put(templateName, in.readStringCollectionAsList());
- }
- } else {
- this.overlappingTemplates = null;
- }
- rolloverConfiguration = in.getTransportVersion().onOrAfter(TransportVersions.V_8_9_X)
- ? in.readOptionalWriteable(RolloverConfiguration::new)
- : null;
- if (in.getTransportVersion().between(TransportVersions.V_8_14_0, TransportVersions.V_8_16_0)) {
- in.readOptionalWriteable(DataStreamGlobalRetention::read);
- }
- }
-
+ /**
+ * NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to write these responses until
+ * we no longer need to support calling this action remotely.
+ */
+ @UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(resolvedTemplate);
diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateAction.java
index 75cc72416a85..15015b910767 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateAction.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateAction.java
@@ -14,12 +14,16 @@
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.ValidateActions;
import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction;
-import org.elasticsearch.action.support.master.MasterNodeReadRequest;
+import org.elasticsearch.action.support.local.LocalClusterStateRequest;
import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.Nullable;
+import org.elasticsearch.core.TimeValue;
+import org.elasticsearch.tasks.CancellableTask;
+import org.elasticsearch.tasks.Task;
+import org.elasticsearch.tasks.TaskId;
import java.io.IOException;
+import java.util.Map;
import java.util.Objects;
/**
@@ -35,7 +39,7 @@ private SimulateTemplateAction() {
super(NAME);
}
- public static class Request extends MasterNodeReadRequest {
+ public static class Request extends LocalClusterStateRequest {
@Nullable
private String templateName;
@@ -44,26 +48,15 @@ public static class Request extends MasterNodeReadRequest {
private TransportPutComposableIndexTemplateAction.Request indexTemplateRequest;
private boolean includeDefaults = false;
- public Request() {
- super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
- }
-
- public Request(String templateName) {
- super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
- if (templateName == null) {
- throw new IllegalArgumentException("template name cannot be null");
- }
+ public Request(TimeValue masterTimeout, String templateName) {
+ super(masterTimeout);
this.templateName = templateName;
}
- public Request(TransportPutComposableIndexTemplateAction.Request indexTemplateRequest) {
- super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
- if (indexTemplateRequest == null) {
- throw new IllegalArgumentException("index template body must be present");
- }
- this.indexTemplateRequest = indexTemplateRequest;
- }
-
+ /**
+ * NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to read these requests until
+ * we no longer need to support calling this action remotely.
+ */
public Request(StreamInput in) throws IOException {
super(in);
templateName = in.readOptionalString();
@@ -73,16 +66,6 @@ public Request(StreamInput in) throws IOException {
}
}
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeOptionalString(templateName);
- out.writeOptionalWriteable(indexTemplateRequest);
- if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_9_X)) {
- out.writeBoolean(includeDefaults);
- }
- }
-
@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null;
@@ -98,6 +81,11 @@ public ActionRequestValidationException validate() {
return validationException;
}
+ @Override
+ public Task createTask(long id, String type, String action, TaskId parentTaskId, Map headers) {
+ return new CancellableTask(id, type, action, "", parentTaskId, headers);
+ }
+
@Nullable
public String getTemplateName() {
return templateName;
@@ -112,11 +100,6 @@ public TransportPutComposableIndexTemplateAction.Request getIndexTemplateRequest
return indexTemplateRequest;
}
- public Request templateName(String templateName) {
- this.templateName = templateName;
- return this;
- }
-
public Request indexTemplateRequest(TransportPutComposableIndexTemplateAction.Request indexTemplateRequest) {
this.indexTemplateRequest = indexTemplateRequest;
return this;
diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java
index d3d557b598b3..74936128caa2 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java
@@ -11,7 +11,8 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
-import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
+import org.elasticsearch.action.support.ChannelActionListener;
+import org.elasticsearch.action.support.local.TransportLocalClusterStateAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@@ -20,7 +21,6 @@
import org.elasticsearch.cluster.metadata.DataStream;
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
import org.elasticsearch.cluster.metadata.IndexMetadata;
-import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.metadata.MetadataCreateIndexService;
import org.elasticsearch.cluster.metadata.MetadataIndexTemplateService;
@@ -31,6 +31,7 @@
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsExecutors;
+import org.elasticsearch.core.UpdateForV10;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.IndexSettingProvider;
import org.elasticsearch.index.IndexSettingProviders;
@@ -42,7 +43,6 @@
import org.elasticsearch.indices.SystemIndices;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
-import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xcontent.NamedXContentRegistry;
@@ -65,7 +65,7 @@
import static org.elasticsearch.cluster.metadata.MetadataIndexTemplateService.resolveLifecycle;
import static org.elasticsearch.cluster.metadata.MetadataIndexTemplateService.resolveSettings;
-public class TransportSimulateIndexTemplateAction extends TransportMasterNodeReadAction<
+public class TransportSimulateIndexTemplateAction extends TransportLocalClusterStateAction<
SimulateIndexTemplateRequest,
SimulateIndexTemplateResponse> {
@@ -77,14 +77,18 @@ public class TransportSimulateIndexTemplateAction extends TransportMasterNodeRea
private final ClusterSettings clusterSettings;
private final boolean isDslOnlyMode;
+ /**
+ * NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC it must be registered with the TransportService until
+ * we no longer need to support calling this action remotely.
+ */
+ @UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
+ @SuppressWarnings("this-escape")
@Inject
public TransportSimulateIndexTemplateAction(
TransportService transportService,
ClusterService clusterService,
- ThreadPool threadPool,
MetadataIndexTemplateService indexTemplateService,
ActionFilters actionFilters,
- IndexNameExpressionResolver indexNameExpressionResolver,
NamedXContentRegistry xContentRegistry,
IndicesService indicesService,
SystemIndices systemIndices,
@@ -92,13 +96,9 @@ public TransportSimulateIndexTemplateAction(
) {
super(
SimulateIndexTemplateAction.NAME,
- transportService,
- clusterService,
- threadPool,
actionFilters,
- SimulateIndexTemplateRequest::new,
- indexNameExpressionResolver,
- SimulateIndexTemplateResponse::new,
+ transportService.getTaskManager(),
+ clusterService,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.indexTemplateService = indexTemplateService;
@@ -108,10 +108,19 @@ public TransportSimulateIndexTemplateAction(
this.indexSettingProviders = indexSettingProviders.getIndexSettingProviders();
this.clusterSettings = clusterService.getClusterSettings();
this.isDslOnlyMode = isDataStreamsLifecycleOnlyMode(clusterService.getSettings());
+
+ transportService.registerRequestHandler(
+ actionName,
+ executor,
+ false,
+ true,
+ SimulateIndexTemplateRequest::new,
+ (request, channel, task) -> executeDirect(task, request, new ChannelActionListener<>(channel))
+ );
}
@Override
- protected void masterOperation(
+ protected void localClusterStateOperation(
Task task,
SimulateIndexTemplateRequest request,
ClusterState state,
diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java
index 30bbad0b57df..692f027b23f9 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java
@@ -11,26 +11,26 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
-import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
+import org.elasticsearch.action.support.ChannelActionListener;
+import org.elasticsearch.action.support.local.TransportLocalClusterStateAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
-import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetadataIndexTemplateService;
import org.elasticsearch.cluster.metadata.Template;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.util.concurrent.EsExecutors;
+import org.elasticsearch.core.UpdateForV10;
import org.elasticsearch.index.IndexSettingProvider;
import org.elasticsearch.index.IndexSettingProviders;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.SystemIndices;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
-import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xcontent.NamedXContentRegistry;
@@ -48,7 +48,7 @@
* Handles simulating an index template either by name (looking it up in the
* cluster state), or by a provided template configuration
*/
-public class TransportSimulateTemplateAction extends TransportMasterNodeReadAction<
+public class TransportSimulateTemplateAction extends TransportLocalClusterStateAction<
SimulateTemplateAction.Request,
SimulateIndexTemplateResponse> {
@@ -60,14 +60,18 @@ public class TransportSimulateTemplateAction extends TransportMasterNodeReadActi
private final ClusterSettings clusterSettings;
private final boolean isDslOnlyMode;
+ /**
+ * NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC it must be registered with the TransportService until
+ * we no longer need to support calling this action remotely.
+ */
+ @UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
+ @SuppressWarnings("this-escape")
@Inject
public TransportSimulateTemplateAction(
TransportService transportService,
ClusterService clusterService,
- ThreadPool threadPool,
MetadataIndexTemplateService indexTemplateService,
ActionFilters actionFilters,
- IndexNameExpressionResolver indexNameExpressionResolver,
NamedXContentRegistry xContentRegistry,
IndicesService indicesService,
SystemIndices systemIndices,
@@ -75,13 +79,9 @@ public TransportSimulateTemplateAction(
) {
super(
SimulateTemplateAction.NAME,
- transportService,
- clusterService,
- threadPool,
actionFilters,
- SimulateTemplateAction.Request::new,
- indexNameExpressionResolver,
- SimulateIndexTemplateResponse::new,
+ transportService.getTaskManager(),
+ clusterService,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.indexTemplateService = indexTemplateService;
@@ -91,10 +91,19 @@ public TransportSimulateTemplateAction(
this.indexSettingProviders = indexSettingProviders.getIndexSettingProviders();
this.clusterSettings = clusterService.getClusterSettings();
this.isDslOnlyMode = isDataStreamsLifecycleOnlyMode(clusterService.getSettings());
+
+ transportService.registerRequestHandler(
+ actionName,
+ executor,
+ false,
+ true,
+ SimulateTemplateAction.Request::new,
+ (request, channel, task) -> executeDirect(task, request, new ChannelActionListener<>(channel))
+ );
}
@Override
- protected void masterOperation(
+ protected void localClusterStateOperation(
Task task,
SimulateTemplateAction.Request request,
ClusterState state,
diff --git a/server/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequest.java b/server/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequest.java
index 943b03588d4b..634a103e9754 100644
--- a/server/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequest.java
+++ b/server/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequest.java
@@ -16,6 +16,7 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.core.TimeValue;
import java.io.IOException;
@@ -27,11 +28,22 @@ public abstract class ClusterInfoRequest getMappings(GetMappingsRequest request)
return execute(GetMappingsAction.INSTANCE, request);
}
- public GetMappingsRequestBuilder prepareGetMappings(String... indices) {
- return new GetMappingsRequestBuilder(this, indices);
+ public GetMappingsRequestBuilder prepareGetMappings(TimeValue masterTimeout, String... indices) {
+ return new GetMappingsRequestBuilder(this, masterTimeout, indices);
}
public void getFieldMappings(GetFieldMappingsRequest request, ActionListener listener) {
diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java
index fb19a3f04fce..e24d921ba78f 100644
--- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java
+++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java
@@ -69,7 +69,6 @@
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.MapperService.MergeReason;
-import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.index.query.SearchExecutionContext;
import org.elasticsearch.indices.IndexCreationException;
import org.elasticsearch.indices.IndicesService;
@@ -1586,7 +1585,7 @@ static void validateCloneIndex(
private static final Set UNMODIFIABLE_SETTINGS_DURING_RESIZE = Set.of(
IndexSettings.MODE.getKey(),
- SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(),
+ IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(),
IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(),
IndexSortConfig.INDEX_SORT_FIELD_SETTING.getKey(),
IndexSortConfig.INDEX_SORT_ORDER_SETTING.getKey(),
diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java
index 5d1e6741c5e2..2f2fd4ef453f 100644
--- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java
+++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java
@@ -158,9 +158,7 @@ public ClusterState applyStartedShards(ClusterState clusterState, List ass
* The placeholder value for {@link DesiredBalance} when the node stands down as master.
*/
public static final DesiredBalance NOT_MASTER = new DesiredBalance(-2, Map.of());
+
/**
* The starting value for {@link DesiredBalance} when the node becomes the master.
*/
@@ -57,6 +65,10 @@ public static boolean hasChanges(DesiredBalance a, DesiredBalance b) {
return Objects.equals(a.assignments, b.assignments) == false;
}
+ /**
+ * Returns the sum of shard movements needed to reach the new desired balance. Doesn't count new shard copies as a move, nor removal or
+ * unassignment of a shard copy.
+ */
public static int shardMovements(DesiredBalance old, DesiredBalance updated) {
var intersection = Sets.intersection(old.assignments().keySet(), updated.assignments().keySet());
int movements = 0;
@@ -70,8 +82,15 @@ public static int shardMovements(DesiredBalance old, DesiredBalance updated) {
return movements;
}
+ /**
+ * Returns the number of shard movements needed to reach the new shard assignment. Doesn't count new shard copies as a move, nor removal
+ * or unassignment of a shard copy.
+ */
private static int shardMovements(ShardAssignment old, ShardAssignment updated) {
- var movements = Math.min(0, old.assigned() - updated.assigned());// compensate newly started shards
+ // A shard move should retain the same number of assigned nodes, just swap out one node for another. We will compensate for newly
+ // started shards -- adding a shard copy is not a move -- by initializing the count with a negative value so that incrementing later
+ // for a new node zeros out.
+ var movements = Math.min(0, old.assigned() - updated.assigned());
for (String nodeId : updated.nodeIds()) {
if (old.nodeIds().contains(nodeId) == false) {
movements++;
diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputer.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputer.java
index 3b22221ea7db..03630c284fa3 100644
--- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputer.java
+++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputer.java
@@ -415,11 +415,14 @@ boolean hasEnoughIterations(int currentIteration) {
}
private static Map collectShardAssignments(RoutingNodes routingNodes) {
- final var entries = routingNodes.getAssignedShards().entrySet();
- assert entries.stream().flatMap(t -> t.getValue().stream()).allMatch(ShardRouting::started) : routingNodes;
- final Map res = Maps.newHashMapWithExpectedSize(entries.size());
- for (var shardAndAssignments : entries) {
- res.put(shardAndAssignments.getKey(), ShardAssignment.ofAssignedShards(shardAndAssignments.getValue()));
+ final var allAssignedShards = routingNodes.getAssignedShards().entrySet();
+ assert allAssignedShards.stream().flatMap(t -> t.getValue().stream()).allMatch(ShardRouting::started) : routingNodes;
+ final Map res = Maps.newHashMapWithExpectedSize(allAssignedShards.size());
+ for (var shardIdAndShardRoutings : allAssignedShards) {
+ res.put(
+ shardIdAndShardRoutings.getKey(),
+ ShardAssignment.createFromAssignedShardRoutingsList(shardIdAndShardRoutings.getValue())
+ );
}
return res;
}
diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceReconciler.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceReconciler.java
index 83b370c1a792..909a7a7a99a6 100644
--- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceReconciler.java
+++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceReconciler.java
@@ -54,6 +54,10 @@ public class DesiredBalanceReconciler {
private static final Logger logger = LogManager.getLogger(DesiredBalanceReconciler.class);
+ /**
+ * The minimum interval that log messages will be written if the number of undesired shard allocations reaches the percentage of total
+ * shards set by {@link #UNDESIRED_ALLOCATIONS_LOG_THRESHOLD_SETTING}.
+ */
public static final Setting UNDESIRED_ALLOCATIONS_LOG_INTERVAL_SETTING = Setting.timeSetting(
"cluster.routing.allocation.desired_balance.undesired_allocations.log_interval",
TimeValue.timeValueHours(1),
@@ -62,6 +66,10 @@ public class DesiredBalanceReconciler {
Setting.Property.NodeScope
);
+ /**
+ * Warning log messages may be periodically written if the number of shards that are on undesired nodes reaches this percentage setting.
+ * Works together with {@link #UNDESIRED_ALLOCATIONS_LOG_INTERVAL_SETTING} to log on a periodic basis.
+ */
public static final Setting UNDESIRED_ALLOCATIONS_LOG_THRESHOLD_SETTING = Setting.doubleSetting(
"cluster.routing.allocation.desired_balance.undesired_allocations.threshold",
0.1,
@@ -96,6 +104,13 @@ public DesiredBalanceReconciler(
this.nodeAllocationStatsAndWeightsCalculator = nodeAllocationStatsAndWeightsCalculator;
}
+ /**
+ * Applies a desired shard allocation to the routing table by initializing and relocating shards in the cluster state.
+ *
+ * @param desiredBalance The new desired cluster shard allocation
+ * @param allocation Cluster state information with which to make decisions, contains routing table metadata that will be modified to
+ * reach the given desired balance.
+ */
public void reconcile(DesiredBalance desiredBalance, RoutingAllocation allocation) {
var nodeIds = allocation.routingNodes().getAllNodeIds();
allocationOrdering.retainNodes(nodeIds);
diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java
index 5be26f0b3e8c..2c73a27ad341 100644
--- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java
+++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java
@@ -17,6 +17,7 @@
import org.elasticsearch.cluster.ClusterStateTaskListener;
import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata;
import org.elasticsearch.cluster.routing.ShardRouting;
+import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.cluster.routing.allocation.AllocationService.RerouteStrategy;
import org.elasticsearch.cluster.routing.allocation.NodeAllocationStatsAndWeightsCalculator;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
@@ -56,11 +57,30 @@ public class DesiredBalanceShardsAllocator implements ShardsAllocator {
private final ShardsAllocator delegateAllocator;
private final ThreadPool threadPool;
+ /**
+ * This is a callback to run {@link AllocationService#executeWithRoutingAllocation(ClusterState, String, RerouteStrategy)}, which
+ * produces a new ClusterState with the changes made by {@link DesiredBalanceReconciler#reconcile}. The {@link RerouteStrategy} provided
+ * to the callback calls into {@link #desiredBalanceReconciler} for the changes. The {@link #masterServiceTaskQueue} will publish the
+ * new cluster state after the cluster state is constructed by the {@link ReconcileDesiredBalanceExecutor}.
+ */
private final DesiredBalanceReconcilerAction reconciler;
private final DesiredBalanceComputer desiredBalanceComputer;
+ /**
+ * Reconciliation ({@link DesiredBalanceReconciler#reconcile(DesiredBalance, RoutingAllocation)}) takes the {@link DesiredBalance}
+ * output of {@link DesiredBalanceComputer#compute} and identifies how shards need to be added, moved or removed to go from the current
+ * cluster shard allocation to the new desired allocation.
+ */
private final DesiredBalanceReconciler desiredBalanceReconciler;
private final ContinuousComputation desiredBalanceComputation;
- private final PendingListenersQueue queue;
+ /**
+ * Saves and runs listeners after DesiredBalance computations complete.
+ */
+ private final PendingListenersQueue pendingListenersQueue;
+ /**
+ * Each reroute request gets assigned a monotonically increasing sequence number. Many reroute requests may arrive before the balancer
+ * asynchronously runs a computation. The balancer will use the latest request and save this sequence number to track back to the
+ * request.
+ */
private final AtomicLong indexGenerator = new AtomicLong(-1);
private final ConcurrentLinkedQueue> pendingDesiredBalanceMoves = new ConcurrentLinkedQueue<>();
private final MasterServiceTaskQueue masterServiceTaskQueue;
@@ -199,7 +219,7 @@ public String toString() {
return "DesiredBalanceShardsAllocator#allocate";
}
};
- this.queue = new PendingListenersQueue();
+ this.pendingListenersQueue = new PendingListenersQueue();
this.masterServiceTaskQueue = clusterService.createTaskQueue(
"reconcile-desired-balance",
Priority.URGENT,
@@ -235,7 +255,7 @@ public void allocate(RoutingAllocation allocation, ActionListener listener
var index = indexGenerator.incrementAndGet();
logger.debug("Executing allocate for [{}]", index);
- queue.add(index, listener);
+ pendingListenersQueue.add(index, listener);
// This can only run on master, so unset not-master if exists
if (currentDesiredBalanceRef.compareAndSet(DesiredBalance.NOT_MASTER, DesiredBalance.BECOME_MASTER_INITIAL)) {
logger.debug("initialized desired balance for becoming master");
@@ -378,7 +398,7 @@ public DesiredBalanceStats getStats() {
private void onNoLongerMaster() {
if (indexGenerator.getAndSet(-1) != -1) {
currentDesiredBalanceRef.set(DesiredBalance.NOT_MASTER);
- queue.completeAllAsNotMaster();
+ pendingListenersQueue.completeAllAsNotMaster();
pendingDesiredBalanceMoves.clear();
desiredBalanceReconciler.clear();
desiredBalanceMetrics.zeroAllMetrics();
@@ -428,7 +448,7 @@ private ClusterState applyBalance(
batchExecutionContext.initialState(),
createReconcileAllocationAction(latest.getTask().desiredBalance)
);
- latest.success(() -> queue.complete(latest.getTask().desiredBalance.lastConvergedIndex()));
+ latest.success(() -> pendingListenersQueue.complete(latest.getTask().desiredBalance.lastConvergedIndex()));
return newState;
}
}
@@ -447,7 +467,7 @@ private static void discardSupersededTasks(
// only for tests - in production, this happens after reconciliation
protected final void completeToLastConvergedIndex() {
- queue.complete(currentDesiredBalanceRef.get().lastConvergedIndex());
+ pendingListenersQueue.complete(currentDesiredBalanceRef.get().lastConvergedIndex());
}
private void recordTime(CounterMetric metric, Runnable action) {
diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/PendingListenersQueue.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/PendingListenersQueue.java
index e1b58cf79ac0..5b14277f2c65 100644
--- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/PendingListenersQueue.java
+++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/PendingListenersQueue.java
@@ -24,6 +24,10 @@
import static org.elasticsearch.cluster.service.ClusterApplierService.CLUSTER_UPDATE_THREAD_NAME;
import static org.elasticsearch.cluster.service.MasterService.MASTER_UPDATE_THREAD_NAME;
+/**
+ * Registers listeners with an `index` number ({@link #add(long, ActionListener)}) and then completes them whenever the latest index number
+ * is greater or equal to a listener's index value ({@link #complete(long)}).
+ */
public class PendingListenersQueue {
private static final Logger logger = LogManager.getLogger(PendingListenersQueue.class);
diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardAssignment.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardAssignment.java
index 4fb9137cb454..2bd1b9bb2bb6 100644
--- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardAssignment.java
+++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardAssignment.java
@@ -17,6 +17,14 @@
import static java.util.Collections.unmodifiableSet;
+/**
+ * Simple shard assignment summary of shard copies for a particular index shard.
+ *
+ * @param nodeIds The node IDs of nodes holding a shard copy.
+ * @param total The total number of shard copies.
+ * @param unassigned The number of unassigned shard copies.
+ * @param ignored The number of ignored shard copies.
+ */
public record ShardAssignment(Set nodeIds, int total, int unassigned, int ignored) {
public ShardAssignment {
@@ -28,9 +36,13 @@ public int assigned() {
return nodeIds.size();
}
- public static ShardAssignment ofAssignedShards(List routings) {
+ /**
+ * Helper method to instantiate a new ShardAssignment from a given list of ShardRouting instances. Assumes all shards are assigned.
+ */
+ public static ShardAssignment createFromAssignedShardRoutingsList(List routings) {
var nodeIds = new LinkedHashSet();
for (ShardRouting routing : routings) {
+ assert routing.unassignedInfo() == null : "Expected assigned shard copies only, unassigned info: " + routing.unassignedInfo();
nodeIds.add(routing.currentNodeId());
}
return new ShardAssignment(unmodifiableSet(nodeIds), routings.size(), 0, 0);
diff --git a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
index afee2491672e..3c1f53ca4a2c 100644
--- a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
+++ b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
@@ -36,7 +36,6 @@
import org.elasticsearch.index.mapper.IgnoredSourceFieldMapper;
import org.elasticsearch.index.mapper.InferenceMetadataFieldsMapper;
import org.elasticsearch.index.mapper.MapperService;
-import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.index.store.FsDirectoryFactory;
import org.elasticsearch.index.store.Store;
@@ -191,7 +190,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
FieldMapper.SYNTHETIC_SOURCE_KEEP_INDEX_SETTING,
IgnoredSourceFieldMapper.SKIP_IGNORED_SOURCE_WRITE_SETTING,
IgnoredSourceFieldMapper.SKIP_IGNORED_SOURCE_READ_SETTING,
- SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING,
+ IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING,
IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING,
InferenceMetadataFieldsMapper.USE_LEGACY_SEMANTIC_TEXT_FORMAT,
diff --git a/server/src/main/java/org/elasticsearch/index/IndexMode.java b/server/src/main/java/org/elasticsearch/index/IndexMode.java
index f0814577bd20..7287a0bf307b 100644
--- a/server/src/main/java/org/elasticsearch/index/IndexMode.java
+++ b/server/src/main/java/org/elasticsearch/index/IndexMode.java
@@ -623,10 +623,7 @@ public Settings getAdditionalIndexSettings(
}
}
if (indexMode == LOOKUP) {
- return Settings.builder()
- .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
- .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-all")
- .build();
+ return Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).build();
} else {
return Settings.EMPTY;
}
diff --git a/server/src/main/java/org/elasticsearch/index/IndexSettings.java b/server/src/main/java/org/elasticsearch/index/IndexSettings.java
index 68f334b10ea5..766b6ecbc7b9 100644
--- a/server/src/main/java/org/elasticsearch/index/IndexSettings.java
+++ b/server/src/main/java/org/elasticsearch/index/IndexSettings.java
@@ -52,7 +52,6 @@
import static org.elasticsearch.index.mapper.MapperService.INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING;
import static org.elasticsearch.index.mapper.MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING;
import static org.elasticsearch.index.mapper.MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING;
-import static org.elasticsearch.index.mapper.SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING;
/**
* This class encapsulates all index level settings and handles settings updates.
@@ -655,48 +654,6 @@ public Iterator> settings() {
Property.Final
);
- public static final Setting RECOVERY_USE_SYNTHETIC_SOURCE_SETTING = Setting.boolSetting(
- "index.recovery.use_synthetic_source",
- false,
- new Setting.Validator<>() {
- @Override
- public void validate(Boolean value) {}
-
- @Override
- public void validate(Boolean enabled, Map, Object> settings) {
- if (enabled == false) {
- return;
- }
-
- // Verify if synthetic source is enabled on the index; fail if it is not
- var indexMode = (IndexMode) settings.get(MODE);
- if (indexMode.defaultSourceMode() != SourceFieldMapper.Mode.SYNTHETIC) {
- var sourceMode = (SourceFieldMapper.Mode) settings.get(INDEX_MAPPER_SOURCE_MODE_SETTING);
- if (sourceMode != SourceFieldMapper.Mode.SYNTHETIC) {
- throw new IllegalArgumentException(
- String.format(
- Locale.ROOT,
- "The setting [%s] is only permitted when [%s] is set to [%s]. Current mode: [%s].",
- RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(),
- INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(),
- SourceFieldMapper.Mode.SYNTHETIC.name(),
- sourceMode.name()
- )
- );
- }
- }
- }
-
- @Override
- public Iterator> settings() {
- List> res = List.of(INDEX_MAPPER_SOURCE_MODE_SETTING, MODE);
- return res.iterator();
- }
- },
- Property.IndexScope,
- Property.Final
- );
-
/**
* Returns true
if TSDB encoding is enabled. The default is true
*/
@@ -753,6 +710,60 @@ public Iterator> settings() {
Property.ServerlessPublic
);
+ public static final Setting INDEX_MAPPER_SOURCE_MODE_SETTING = Setting.enumSetting(
+ SourceFieldMapper.Mode.class,
+ settings -> {
+ final IndexMode indexMode = IndexSettings.MODE.get(settings);
+ return indexMode.defaultSourceMode().name();
+ },
+ "index.mapping.source.mode",
+ value -> {},
+ Setting.Property.Final,
+ Setting.Property.IndexScope
+ );
+
+ public static final Setting RECOVERY_USE_SYNTHETIC_SOURCE_SETTING = Setting.boolSetting(
+ "index.recovery.use_synthetic_source",
+ false,
+ new Setting.Validator<>() {
+ @Override
+ public void validate(Boolean value) {}
+
+ @Override
+ public void validate(Boolean enabled, Map, Object> settings) {
+ if (enabled == false) {
+ return;
+ }
+
+ // Verify if synthetic source is enabled on the index; fail if it is not
+ var indexMode = (IndexMode) settings.get(MODE);
+ if (indexMode.defaultSourceMode() != SourceFieldMapper.Mode.SYNTHETIC) {
+ var sourceMode = (SourceFieldMapper.Mode) settings.get(INDEX_MAPPER_SOURCE_MODE_SETTING);
+ if (sourceMode != SourceFieldMapper.Mode.SYNTHETIC) {
+ throw new IllegalArgumentException(
+ String.format(
+ Locale.ROOT,
+ "The setting [%s] is only permitted when [%s] is set to [%s]. Current mode: [%s].",
+ RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(),
+ INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(),
+ SourceFieldMapper.Mode.SYNTHETIC.name(),
+ sourceMode.name()
+ )
+ );
+ }
+ }
+ }
+
+ @Override
+ public Iterator> settings() {
+ List> res = List.of(INDEX_MAPPER_SOURCE_MODE_SETTING, MODE);
+ return res.iterator();
+ }
+ },
+ Property.IndexScope,
+ Property.Final
+ );
+
/**
* Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use.
* TODO: Remove in 9.0
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java
index 29acdf200692..36335be58ce9 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java
@@ -18,7 +18,6 @@
import org.elasticsearch.common.Explicit;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
-import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.core.Nullable;
@@ -70,11 +69,6 @@ public class SourceFieldMapper extends MetadataFieldMapper {
public static final String LOSSY_PARAMETERS_ALLOWED_SETTING_NAME = "index.lossy.source-mapping-parameters";
- public static final Setting INDEX_MAPPER_SOURCE_MODE_SETTING = Setting.enumSetting(SourceFieldMapper.Mode.class, settings -> {
- final IndexMode indexMode = IndexSettings.MODE.get(settings);
- return indexMode.defaultSourceMode().name();
- }, "index.mapping.source.mode", value -> {}, Setting.Property.Final, Setting.Property.IndexScope);
-
public static final String DEPRECATION_WARNING = "Configuring source mode in mappings is deprecated and will be removed "
+ "in future versions. Use [index.mapping.source.mode] index setting instead.";
@@ -264,8 +258,8 @@ public SourceFieldMapper build() {
private Mode resolveSourceMode() {
// If the `index.mapping.source.mode` exists it takes precedence to determine the source mode for `_source`
// otherwise the mode is determined according to `_source.mode`.
- if (INDEX_MAPPER_SOURCE_MODE_SETTING.exists(settings)) {
- return INDEX_MAPPER_SOURCE_MODE_SETTING.get(settings);
+ if (IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.exists(settings)) {
+ return IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.get(settings);
}
// If `_source.mode` is not set we need to apply a default according to index mode.
@@ -297,7 +291,7 @@ private static SourceFieldMapper resolveStaticInstance(final Mode sourceMode) {
return DEFAULT;
}
- final Mode settingSourceMode = INDEX_MAPPER_SOURCE_MODE_SETTING.get(c.getSettings());
+ final Mode settingSourceMode = IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.get(c.getSettings());
// Needed for bwc so that "mode" is not serialized in case of standard index with stored source.
if (indexMode == IndexMode.STANDARD && settingSourceMode == Mode.STORED) {
return DEFAULT;
@@ -482,11 +476,11 @@ public boolean isSynthetic() {
}
public static boolean isSynthetic(IndexSettings indexSettings) {
- return INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == SourceFieldMapper.Mode.SYNTHETIC;
+ return IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == SourceFieldMapper.Mode.SYNTHETIC;
}
public static boolean isStored(IndexSettings indexSettings) {
- return INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == Mode.STORED;
+ return IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == Mode.STORED;
}
public boolean isDisabled() {
diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java
index ca9e4abcaeec..477cc1acb831 100644
--- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java
+++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java
@@ -11,15 +11,16 @@
import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsAction;
import org.elasticsearch.action.admin.cluster.settings.RestClusterGetSettingsResponse;
-import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
+import org.elasticsearch.rest.RestUtils;
import org.elasticsearch.rest.Scope;
import org.elasticsearch.rest.ServerlessScope;
+import org.elasticsearch.rest.action.RestCancellableNodeClient;
import org.elasticsearch.rest.action.RestToXContentListener;
import java.io.IOException;
@@ -52,19 +53,14 @@ public String getName() {
return "cluster_get_settings_action";
}
- private static void setUpRequestParams(MasterNodeReadRequest> clusterRequest, RestRequest request) {
- clusterRequest.local(request.paramAsBoolean("local", clusterRequest.local()));
- }
-
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final boolean renderDefaults = request.paramAsBoolean("include_defaults", false);
ClusterGetSettingsAction.Request clusterSettingsRequest = new ClusterGetSettingsAction.Request(getMasterNodeTimeout(request));
+ RestUtils.consumeDeprecatedLocalParameter(request);
- setUpRequestParams(clusterSettingsRequest, request);
-
- return channel -> client.execute(
+ return channel -> new RestCancellableNodeClient(client, request.getHttpChannel()).execute(
ClusterGetSettingsAction.INSTANCE,
clusterSettingsRequest,
new RestToXContentListener(channel).map(
diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java
index 27620fa750ea..f9e02646041a 100644
--- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java
+++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java
@@ -13,7 +13,6 @@
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.Strings;
-import org.elasticsearch.core.TimeValue;
import org.elasticsearch.http.HttpChannel;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
@@ -51,11 +50,9 @@ public String getName() {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
- final GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
+ final GetMappingsRequest getMappingsRequest = new GetMappingsRequest(getMasterNodeTimeout(request));
getMappingsRequest.indices(indices);
getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
- final TimeValue timeout = getMasterNodeTimeout(request);
- getMappingsRequest.masterNodeTimeout(timeout);
getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
final HttpChannel httpChannel = request.getHttpChannel();
return channel -> new RestCancellableNodeClient(client, httpChannel).admin()
diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java
index 4cc010c15ffb..1689d234387c 100644
--- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java
+++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java
@@ -18,6 +18,7 @@
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.Scope;
import org.elasticsearch.rest.ServerlessScope;
+import org.elasticsearch.rest.action.RestCancellableNodeClient;
import org.elasticsearch.rest.action.RestToXContentListener;
import java.io.IOException;
@@ -41,8 +42,10 @@ public String getName() {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
- SimulateIndexTemplateRequest simulateIndexTemplateRequest = new SimulateIndexTemplateRequest(request.param("name"));
- simulateIndexTemplateRequest.masterNodeTimeout(getMasterNodeTimeout(request));
+ SimulateIndexTemplateRequest simulateIndexTemplateRequest = new SimulateIndexTemplateRequest(
+ getMasterNodeTimeout(request),
+ request.param("name")
+ );
simulateIndexTemplateRequest.includeDefaults(request.paramAsBoolean("include_defaults", false));
if (request.hasContent()) {
TransportPutComposableIndexTemplateAction.Request indexTemplateRequest = new TransportPutComposableIndexTemplateAction.Request(
@@ -57,7 +60,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
simulateIndexTemplateRequest.indexTemplateRequest(indexTemplateRequest);
}
- return channel -> client.execute(
+ return channel -> new RestCancellableNodeClient(client, request.getHttpChannel()).execute(
SimulateIndexTemplateAction.INSTANCE,
simulateIndexTemplateRequest,
new RestToXContentListener<>(channel)
diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateTemplateAction.java
index cc2e3136a416..47b68e24a9ed 100644
--- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateTemplateAction.java
+++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSimulateTemplateAction.java
@@ -17,6 +17,7 @@
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.Scope;
import org.elasticsearch.rest.ServerlessScope;
+import org.elasticsearch.rest.action.RestCancellableNodeClient;
import org.elasticsearch.rest.action.RestToXContentListener;
import java.io.IOException;
@@ -39,8 +40,10 @@ public String getName() {
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
- SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request();
- simulateRequest.templateName(request.param("name"));
+ SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request(
+ getMasterNodeTimeout(request),
+ request.param("name")
+ );
simulateRequest.includeDefaults(request.paramAsBoolean("include_defaults", false));
if (request.hasContent()) {
TransportPutComposableIndexTemplateAction.Request indexTemplateRequest = new TransportPutComposableIndexTemplateAction.Request(
@@ -54,8 +57,11 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
simulateRequest.indexTemplateRequest(indexTemplateRequest);
}
- simulateRequest.masterNodeTimeout(getMasterNodeTimeout(request));
- return channel -> client.execute(SimulateTemplateAction.INSTANCE, simulateRequest, new RestToXContentListener<>(channel));
+ return channel -> new RestCancellableNodeClient(client, request.getHttpChannel()).execute(
+ SimulateTemplateAction.INSTANCE,
+ simulateRequest,
+ new RestToXContentListener<>(channel)
+ );
}
}
diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/MatchedQueriesPhase.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/MatchedQueriesPhase.java
index 5220dadec7a1..53116ff8f6eb 100644
--- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/MatchedQueriesPhase.java
+++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/MatchedQueriesPhase.java
@@ -9,10 +9,12 @@
package org.elasticsearch.search.fetch.subphase;
import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.ScorerSupplier;
+import org.apache.lucene.search.TwoPhaseIterator;
import org.apache.lucene.search.Weight;
import org.elasticsearch.index.query.ParsedQuery;
import org.elasticsearch.search.fetch.FetchContext;
@@ -52,8 +54,9 @@ public FetchSubPhaseProcessor getProcessor(FetchContext context) throws IOExcept
);
}
return new FetchSubPhaseProcessor() {
+ record ScorerAndIterator(Scorer scorer, DocIdSetIterator approximation, TwoPhaseIterator twoPhase) {}
- final Map matchingIterators = new HashMap<>();
+ final Map matchingIterators = new HashMap<>();
@Override
public void setNextReader(LeafReaderContext readerContext) throws IOException {
@@ -63,7 +66,14 @@ public void setNextReader(LeafReaderContext readerContext) throws IOException {
if (ss != null) {
Scorer scorer = ss.get(0L);
if (scorer != null) {
- matchingIterators.put(entry.getKey(), scorer);
+ final TwoPhaseIterator twoPhase = scorer.twoPhaseIterator();
+ final DocIdSetIterator iterator;
+ if (twoPhase == null) {
+ iterator = scorer.iterator();
+ } else {
+ iterator = twoPhase.approximation();
+ }
+ matchingIterators.put(entry.getKey(), new ScorerAndIterator(scorer, iterator, twoPhase));
}
}
}
@@ -73,13 +83,13 @@ public void setNextReader(LeafReaderContext readerContext) throws IOException {
public void process(HitContext hitContext) throws IOException {
Map matches = new LinkedHashMap<>();
int doc = hitContext.docId();
- for (Map.Entry entry : matchingIterators.entrySet()) {
- Scorer scorer = entry.getValue();
- if (scorer.iterator().docID() < doc) {
- scorer.iterator().advance(doc);
+ for (Map.Entry entry : matchingIterators.entrySet()) {
+ ScorerAndIterator query = entry.getValue();
+ if (query.approximation.docID() < doc) {
+ query.approximation.advance(doc);
}
- if (scorer.iterator().docID() == doc) {
- matches.put(entry.getKey(), scorer.score());
+ if (query.approximation.docID() == doc && (query.twoPhase == null || query.twoPhase.matches())) {
+ matches.put(entry.getKey(), query.scorer.score());
}
}
hitContext.hit().matchedQueries(matches);
diff --git a/server/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java b/server/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java
index 9eb0170af5ef..d899a390d8be 100644
--- a/server/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java
+++ b/server/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java
@@ -102,14 +102,6 @@ private SearchLookup(SearchLookup searchLookup, Set fieldChain) {
this.fieldLookupProvider = searchLookup.fieldLookupProvider;
}
- private SearchLookup(SearchLookup searchLookup, SourceProvider sourceProvider, Set fieldChain) {
- this.fieldChain = Collections.unmodifiableSet(fieldChain);
- this.sourceProvider = sourceProvider;
- this.fieldTypeLookup = searchLookup.fieldTypeLookup;
- this.fieldDataLookup = searchLookup.fieldDataLookup;
- this.fieldLookupProvider = searchLookup.fieldLookupProvider;
- }
-
/**
* Creates a copy of the current {@link SearchLookup} that looks fields up in the same way, but also tracks field references
* in order to detect cycles and prevent resolving fields that depend on more than {@link #MAX_FIELD_CHAIN_DEPTH} other fields.
@@ -153,7 +145,4 @@ public Source getSource(LeafReaderContext ctx, int doc) throws IOException {
return sourceProvider.getSource(ctx, doc);
}
- public SearchLookup swapSourceProvider(SourceProvider sourceProvider) {
- return new SearchLookup(this, sourceProvider, fieldChain);
- }
}
diff --git a/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java b/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
index f260c7aad30e..debe3d6e6bd9 100644
--- a/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
+++ b/server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
@@ -70,7 +70,6 @@
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.Mapping;
-import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.index.shard.IndexLongFieldRange;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardId;
@@ -158,7 +157,7 @@ public final class RestoreService implements ClusterStateApplier {
SETTING_CREATION_DATE,
SETTING_HISTORY_UUID,
IndexSettings.MODE.getKey(),
- SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(),
+ IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(),
IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(),
IndexSortConfig.INDEX_SORT_FIELD_SETTING.getKey(),
IndexSortConfig.INDEX_SORT_ORDER_SETTING.getKey(),
diff --git a/server/src/main/java/org/elasticsearch/transport/TransportHandshaker.java b/server/src/main/java/org/elasticsearch/transport/TransportHandshaker.java
index a43b1e7440bd..ec9b30e71e62 100644
--- a/server/src/main/java/org/elasticsearch/transport/TransportHandshaker.java
+++ b/server/src/main/java/org/elasticsearch/transport/TransportHandshaker.java
@@ -41,9 +41,14 @@ final class TransportHandshaker {
* ignores the body of the request. After the handshake, the OutboundHandler uses the min(local,remote) protocol version for all later
* messages.
*
- * This version supports two handshake protocols, v6080099 and v7170099, which respectively have the same message structure as the
- * transport protocols of v6.8.0 and v7.17.0. This node only sends v7170099 requests, but it can send a valid response to any v6080099
- * requests that it receives.
+ * This version supports three handshake protocols, v6080099, v7170099 and v8800000, which respectively have the same message structure
+ * as the transport protocols of v6.8.0, v7.17.0, and v8.18.0. This node only sends v7170099 requests, but it can send a valid response
+ * to any v6080099 or v8800000 requests that it receives.
+ *
+ * Note that these are not really TransportVersion constants as used elsewhere in ES, they're independent things that just happen to be
+ * stored in the same location in the message header and which roughly match the same ID numbering scheme. Older versions of ES did
+ * rely on them matching the real transport protocol (which itself matched the release version numbers), but these days that's no longer
+ * true.
*
* Here are some example messages, broken down to show their structure:
*
@@ -79,7 +84,7 @@ final class TransportHandshaker {
* c3 f9 eb 03 -- max acceptable protocol version (vInt: 00000011 11101011 11111001 11000011 == 8060099)
*
*
- * ## v7170099 Request:
+ * ## v7170099 and v8800000 Requests:
*
* 45 53 -- 'ES' marker
* 00 00 00 31 -- total message length
@@ -98,7 +103,7 @@ final class TransportHandshaker {
* 04 -- payload length
* c3 f9 eb 03 -- max acceptable protocol version (vInt: 00000011 11101011 11111001 11000011 == 8060099)
*
- * ## v7170099 Response:
+ * ## v7170099 and v8800000 Responses:
*
* 45 53 -- 'ES' marker
* 00 00 00 17 -- total message length
@@ -118,7 +123,12 @@ final class TransportHandshaker {
static final TransportVersion EARLIEST_HANDSHAKE_VERSION = TransportVersion.fromId(6080099);
static final TransportVersion REQUEST_HANDSHAKE_VERSION = TransportVersions.MINIMUM_COMPATIBLE;
- static final Set ALLOWED_HANDSHAKE_VERSIONS = Set.of(EARLIEST_HANDSHAKE_VERSION, REQUEST_HANDSHAKE_VERSION);
+ static final TransportVersion V9_HANDSHAKE_VERSION = TransportVersion.fromId(8_800_00_0);
+ static final Set ALLOWED_HANDSHAKE_VERSIONS = Set.of(
+ EARLIEST_HANDSHAKE_VERSION,
+ REQUEST_HANDSHAKE_VERSION,
+ V9_HANDSHAKE_VERSION
+ );
static final String HANDSHAKE_ACTION_NAME = "internal:tcp/handshake";
private final ConcurrentMap pendingHandshakes = new ConcurrentHashMap<>();
diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsSerializationTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsSerializationTests.java
deleted file mode 100644
index 5954de058698..000000000000
--- a/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsSerializationTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
- * Public License v 1"; you may not use this file except in compliance with, at
- * your election, the "Elastic License 2.0", the "GNU Affero General Public
- * License v3.0 only", or the "Server Side Public License, v 1".
- */
-
-package org.elasticsearch.action.admin.cluster.settings;
-
-import org.elasticsearch.common.io.stream.Writeable;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.test.AbstractWireSerializingTestCase;
-
-public class ClusterGetSettingsSerializationTests extends AbstractWireSerializingTestCase {
- @Override
- protected Writeable.Reader instanceReader() {
- return ClusterGetSettingsAction.Response::new;
- }
-
- @Override
- protected ClusterGetSettingsAction.Response createTestInstance() {
- final Settings persistentSettings = Settings.builder()
- .put("persistent.foo.filtered", "bar")
- .put("persistent.foo.non_filtered", "baz")
- .build();
-
- final Settings transientSettings = Settings.builder()
- .put("transient.foo.filtered", "bar")
- .put("transient.foo.non_filtered", "baz")
- .build();
-
- final Settings allSettings = Settings.builder().put(persistentSettings).put(transientSettings).build();
-
- return new ClusterGetSettingsAction.Response(persistentSettings, transientSettings, allSettings);
- }
-
- @Override
- protected ClusterGetSettingsAction.Response mutateInstance(ClusterGetSettingsAction.Response instance) {
- final Settings otherSettings = Settings.builder().put("random.setting", randomAlphaOfLength(randomIntBetween(1, 12))).build();
- return switch (between(0, 2)) {
- case 0 -> new ClusterGetSettingsAction.Response(otherSettings, instance.transientSettings(), instance.settings());
- case 1 -> new ClusterGetSettingsAction.Response(instance.persistentSettings(), otherSettings, instance.settings());
- case 2 -> new ClusterGetSettingsAction.Response(instance.persistentSettings(), instance.transientSettings(), otherSettings);
- default -> throw new IllegalStateException("Unexpected switch value");
- };
- }
-}
diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsTests.java
index 47f3f71bcc11..58341b7d7fb9 100644
--- a/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsTests.java
+++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterGetSettingsTests.java
@@ -12,17 +12,18 @@
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.cluster.ClusterState;
-import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
+import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.MockUtils;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.List;
+import java.util.Map;
import static org.mockito.Mockito.mock;
@@ -54,10 +55,8 @@ public void testTransportFilters() throws Exception {
TransportClusterGetSettingsAction action = new TransportClusterGetSettingsAction(
transportService,
mock(ClusterService.class),
- threadPool,
filter,
- mock(ActionFilters.class),
- mock(IndexNameExpressionResolver.class)
+ mock(ActionFilters.class)
);
final Settings persistentSettings = Settings.builder()
@@ -74,7 +73,8 @@ public void testTransportFilters() throws Exception {
final ClusterState clusterState = ClusterState.builder(ClusterState.EMPTY_STATE).metadata(metadata).build();
final PlainActionFuture future = new PlainActionFuture<>();
- action.masterOperation(null, null, clusterState, future);
+ final var task = new CancellableTask(1, "test", ClusterGetSettingsAction.NAME, "", null, Map.of());
+ action.localClusterStateOperation(task, null, clusterState, future);
assertTrue(future.isDone());
final ClusterGetSettingsAction.Response response = future.get();
diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java
index 96954458c18c..0617053769da 100644
--- a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java
+++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java
@@ -17,8 +17,8 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
-import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.script.Script;
import org.elasticsearch.tasks.TaskCancelledException;
import org.elasticsearch.test.AbstractWireSerializingTestCase;
@@ -586,7 +586,7 @@ public void testSourceModes() {
int numDisabledIndices = randomIntBetween(1, 5);
for (int i = 0; i < numSyntheticIndices; i++) {
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo-synthetic-" + i).settings(
- indexSettings(IndexVersion.current(), 4, 1).put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "synthetic")
+ indexSettings(IndexVersion.current(), 4, 1).put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "synthetic")
);
builder.put(indexMetadata);
}
@@ -594,7 +594,7 @@ public void testSourceModes() {
IndexMetadata.Builder indexMetadata;
if (randomBoolean()) {
indexMetadata = new IndexMetadata.Builder("foo-stored-" + i).settings(
- indexSettings(IndexVersion.current(), 4, 1).put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "stored")
+ indexSettings(IndexVersion.current(), 4, 1).put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "stored")
);
} else {
indexMetadata = new IndexMetadata.Builder("foo-stored-" + i).settings(indexSettings(IndexVersion.current(), 4, 1));
@@ -603,7 +603,7 @@ public void testSourceModes() {
}
for (int i = 0; i < numDisabledIndices; i++) {
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo-disabled-" + i).settings(
- indexSettings(IndexVersion.current(), 4, 1).put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "disabled")
+ indexSettings(IndexVersion.current(), 4, 1).put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "disabled")
);
builder.put(indexMetadata);
}
diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequestTests.java
index 02a4c134ccd1..1d861b340543 100644
--- a/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequestTests.java
+++ b/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateRequestTests.java
@@ -12,45 +12,21 @@
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction;
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
-import org.elasticsearch.cluster.metadata.ComposableIndexTemplateTests;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.Template;
-import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.test.AbstractWireSerializingTestCase;
+import org.elasticsearch.test.ESTestCase;
import java.util.List;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
-public class SimulateIndexTemplateRequestTests extends AbstractWireSerializingTestCase {
-
- @Override
- protected Writeable.Reader instanceReader() {
- return SimulateIndexTemplateRequest::new;
- }
-
- @Override
- protected SimulateIndexTemplateRequest createTestInstance() {
- SimulateIndexTemplateRequest req = new SimulateIndexTemplateRequest(randomAlphaOfLength(10));
- TransportPutComposableIndexTemplateAction.Request newTemplateRequest = new TransportPutComposableIndexTemplateAction.Request(
- randomAlphaOfLength(4)
- );
- newTemplateRequest.indexTemplate(ComposableIndexTemplateTests.randomInstance());
- req.indexTemplateRequest(newTemplateRequest);
- req.includeDefaults(randomBoolean());
- return req;
- }
-
- @Override
- protected SimulateIndexTemplateRequest mutateInstance(SimulateIndexTemplateRequest instance) {
- return randomValueOtherThan(instance, this::createTestInstance);
- }
+public class SimulateIndexTemplateRequestTests extends ESTestCase {
public void testIndexNameCannotBeNullOrEmpty() {
- expectThrows(IllegalArgumentException.class, () -> new SimulateIndexTemplateRequest((String) null));
- expectThrows(IllegalArgumentException.class, () -> new SimulateIndexTemplateRequest(""));
+ expectThrows(IllegalArgumentException.class, () -> new SimulateIndexTemplateRequest(TEST_REQUEST_TIMEOUT, null));
+ expectThrows(IllegalArgumentException.class, () -> new SimulateIndexTemplateRequest(TEST_REQUEST_TIMEOUT, ""));
}
public void testAddingGlobalTemplateWithHiddenIndexSettingIsIllegal() {
@@ -60,7 +36,7 @@ public void testAddingGlobalTemplateWithHiddenIndexSettingIsIllegal() {
TransportPutComposableIndexTemplateAction.Request request = new TransportPutComposableIndexTemplateAction.Request("test");
request.indexTemplate(globalTemplate);
- SimulateIndexTemplateRequest simulateRequest = new SimulateIndexTemplateRequest("testing");
+ SimulateIndexTemplateRequest simulateRequest = new SimulateIndexTemplateRequest(TEST_REQUEST_TIMEOUT, "testing");
simulateRequest.indexTemplateRequest(request);
ActionRequestValidationException validationException = simulateRequest.validate();
diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateRequestTests.java
index 14ebf260d3bf..6163566a5e59 100644
--- a/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateRequestTests.java
+++ b/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/SimulateTemplateRequestTests.java
@@ -12,49 +12,17 @@
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction;
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
-import org.elasticsearch.cluster.metadata.ComposableIndexTemplateTests;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.Template;
-import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.test.AbstractWireSerializingTestCase;
+import org.elasticsearch.test.ESTestCase;
import java.util.List;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
-public class SimulateTemplateRequestTests extends AbstractWireSerializingTestCase {
-
- @Override
- protected Writeable.Reader instanceReader() {
- return SimulateTemplateAction.Request::new;
- }
-
- @Override
- protected SimulateTemplateAction.Request createTestInstance() {
- SimulateTemplateAction.Request req = new SimulateTemplateAction.Request(randomAlphaOfLength(10));
- TransportPutComposableIndexTemplateAction.Request newTemplateRequest = new TransportPutComposableIndexTemplateAction.Request(
- randomAlphaOfLength(4)
- );
- newTemplateRequest.indexTemplate(ComposableIndexTemplateTests.randomInstance());
- req.indexTemplateRequest(newTemplateRequest);
- req.includeDefaults(randomBoolean());
- return req;
- }
-
- @Override
- protected SimulateTemplateAction.Request mutateInstance(SimulateTemplateAction.Request instance) {
- return randomValueOtherThan(instance, this::createTestInstance);
- }
-
- public void testIndexNameCannotBeNullOrEmpty() {
- expectThrows(IllegalArgumentException.class, () -> new SimulateTemplateAction.Request((String) null));
- expectThrows(
- IllegalArgumentException.class,
- () -> new SimulateTemplateAction.Request((TransportPutComposableIndexTemplateAction.Request) null)
- );
- }
+public class SimulateTemplateRequestTests extends ESTestCase {
public void testAddingGlobalTemplateWithHiddenIndexSettingIsIllegal() {
Template template = new Template(Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, true).build(), null, null);
@@ -63,7 +31,7 @@ public void testAddingGlobalTemplateWithHiddenIndexSettingIsIllegal() {
TransportPutComposableIndexTemplateAction.Request request = new TransportPutComposableIndexTemplateAction.Request("test");
request.indexTemplate(globalTemplate);
- SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request("testing");
+ SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request(TEST_REQUEST_TIMEOUT, "testing");
simulateRequest.indexTemplateRequest(request);
ActionRequestValidationException validationException = simulateRequest.validate();
diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceTests.java
index 760900817780..2c15addfe217 100644
--- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceTests.java
+++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceTests.java
@@ -46,19 +46,19 @@ public void testShardMovements() {
);
assertThat(
- "1 shard movements when existing shard is moved and new shard copy is unassigned",
+ "1 shard movements when an existing shard copy is moved and new shard copy is unassigned",
shardMovements(new ShardAssignment(Set.of("a", "b"), 2, 0, 0), new ShardAssignment(Set.of("a", "c"), 3, 1, 0)),
equalTo(1)
);
assertThat(
- "1 shard movement",
+ "1 shard movement when an existing shard copy is moved",
shardMovements(new ShardAssignment(Set.of("a", "b"), 2, 0, 0), new ShardAssignment(Set.of("a", "c"), 2, 0, 0)),
equalTo(1)
);
assertThat(
- "2 shard movement",
+ "2 shard movements when both shard copies are move to new nodes",
shardMovements(new ShardAssignment(Set.of("a", "b"), 2, 0, 0), new ShardAssignment(Set.of("c", "d"), 2, 0, 0)),
equalTo(2)
);
@@ -77,10 +77,10 @@ public void testShardMovements() {
}
private static int shardMovements(ShardAssignment old, ShardAssignment updated) {
- return DesiredBalance.shardMovements(of(old), of(updated));
+ return DesiredBalance.shardMovements(createDesiredBalanceWith(old), createDesiredBalanceWith(updated));
}
- private static DesiredBalance of(ShardAssignment assignment) {
+ private static DesiredBalance createDesiredBalanceWith(ShardAssignment assignment) {
return new DesiredBalance(1, Map.of(new ShardId("index", "_na_", 0), assignment));
}
}
diff --git a/server/src/test/java/org/elasticsearch/index/codec/vectors/es816/ES816BinaryQuantizedVectorsWriter.java b/server/src/test/java/org/elasticsearch/index/codec/vectors/es816/ES816BinaryQuantizedVectorsWriter.java
index 4d97235c5fae..61bd5323b5b4 100644
--- a/server/src/test/java/org/elasticsearch/index/codec/vectors/es816/ES816BinaryQuantizedVectorsWriter.java
+++ b/server/src/test/java/org/elasticsearch/index/codec/vectors/es816/ES816BinaryQuantizedVectorsWriter.java
@@ -437,32 +437,35 @@ private CloseableRandomVectorScorerSupplier mergeOneFieldToIndex(
float[] centroid,
float cDotC
) throws IOException {
- long vectorDataOffset = binarizedVectorData.alignFilePointer(Float.BYTES);
- final IndexOutput tempQuantizedVectorData = segmentWriteState.directory.createTempOutput(
- binarizedVectorData.getName(),
- "temp",
- segmentWriteState.context
- );
- final IndexOutput tempScoreQuantizedVectorData = segmentWriteState.directory.createTempOutput(
- binarizedVectorData.getName(),
- "score_temp",
- segmentWriteState.context
- );
- IndexInput binarizedDataInput = null;
- IndexInput binarizedScoreDataInput = null;
- boolean success = false;
- int descritizedDimension = BQVectorUtils.discretize(fieldInfo.getVectorDimension(), 64);
- BinaryQuantizer quantizer = new BinaryQuantizer(
+ final long vectorDataOffset = binarizedVectorData.alignFilePointer(Float.BYTES);
+ final int descritizedDimension = BQVectorUtils.discretize(fieldInfo.getVectorDimension(), 64);
+ final BinaryQuantizer quantizer = new BinaryQuantizer(
fieldInfo.getVectorDimension(),
descritizedDimension,
fieldInfo.getVectorSimilarityFunction()
);
+
+ IndexOutput tempQuantizedVectorData = null;
+ IndexOutput tempScoreQuantizedVectorData = null;
+ final DocsWithFieldSet docsWithField;
+ boolean success = false;
+
try {
+ tempQuantizedVectorData = segmentWriteState.directory.createTempOutput(
+ binarizedVectorData.getName(),
+ "temp",
+ segmentWriteState.context
+ );
+ tempScoreQuantizedVectorData = segmentWriteState.directory.createTempOutput(
+ binarizedVectorData.getName(),
+ "score_temp",
+ segmentWriteState.context
+ );
FloatVectorValues floatVectorValues = KnnVectorsWriter.MergedVectorValues.mergeFloatVectorValues(fieldInfo, mergeState);
if (fieldInfo.getVectorSimilarityFunction() == COSINE) {
floatVectorValues = new NormalizedFloatVectorValues(floatVectorValues);
}
- DocsWithFieldSet docsWithField = writeBinarizedVectorAndQueryData(
+ docsWithField = writeBinarizedVectorAndQueryData(
tempQuantizedVectorData,
tempScoreQuantizedVectorData,
floatVectorValues,
@@ -470,13 +473,30 @@ private CloseableRandomVectorScorerSupplier mergeOneFieldToIndex(
quantizer
);
CodecUtil.writeFooter(tempQuantizedVectorData);
- IOUtils.close(tempQuantizedVectorData);
+ CodecUtil.writeFooter(tempScoreQuantizedVectorData);
+ success = true;
+ } finally {
+ if (success) {
+ IOUtils.close(tempQuantizedVectorData, tempScoreQuantizedVectorData);
+ } else {
+ IOUtils.closeWhileHandlingException(tempQuantizedVectorData, tempScoreQuantizedVectorData);
+ if (tempQuantizedVectorData != null) {
+ IOUtils.deleteFilesIgnoringExceptions(segmentWriteState.directory, tempQuantizedVectorData.getName());
+ }
+ if (tempScoreQuantizedVectorData != null) {
+ IOUtils.deleteFilesIgnoringExceptions(segmentWriteState.directory, tempScoreQuantizedVectorData.getName());
+ }
+ }
+ }
+
+ IndexInput binarizedDataInput = null;
+ IndexInput binarizedScoreDataInput = null;
+ success = false;
+ try {
binarizedDataInput = segmentWriteState.directory.openInput(tempQuantizedVectorData.getName(), segmentWriteState.context);
binarizedVectorData.copyBytes(binarizedDataInput, binarizedDataInput.length() - CodecUtil.footerLength());
- long vectorDataLength = binarizedVectorData.getFilePointer() - vectorDataOffset;
+ final long vectorDataLength = binarizedVectorData.getFilePointer() - vectorDataOffset;
CodecUtil.retrieveChecksum(binarizedDataInput);
- CodecUtil.writeFooter(tempScoreQuantizedVectorData);
- IOUtils.close(tempScoreQuantizedVectorData);
binarizedScoreDataInput = segmentWriteState.directory.openInput(
tempScoreQuantizedVectorData.getName(),
segmentWriteState.context
@@ -490,10 +510,9 @@ private CloseableRandomVectorScorerSupplier mergeOneFieldToIndex(
cDotC,
docsWithField
);
- success = true;
final IndexInput finalBinarizedDataInput = binarizedDataInput;
final IndexInput finalBinarizedScoreDataInput = binarizedScoreDataInput;
- OffHeapBinarizedVectorValues vectorValues = new OffHeapBinarizedVectorValues.DenseOffHeapVectorValues(
+ final OffHeapBinarizedVectorValues vectorValues = new OffHeapBinarizedVectorValues.DenseOffHeapVectorValues(
fieldInfo.getVectorDimension(),
docsWithField.cardinality(),
centroid,
@@ -503,7 +522,7 @@ private CloseableRandomVectorScorerSupplier mergeOneFieldToIndex(
vectorsScorer,
finalBinarizedDataInput
);
- RandomVectorScorerSupplier scorerSupplier = vectorsScorer.getRandomVectorScorerSupplier(
+ final RandomVectorScorerSupplier scorerSupplier = vectorsScorer.getRandomVectorScorerSupplier(
fieldInfo.getVectorSimilarityFunction(),
new OffHeapBinarizedQueryVectorValues(
finalBinarizedScoreDataInput,
@@ -513,22 +532,20 @@ private CloseableRandomVectorScorerSupplier mergeOneFieldToIndex(
),
vectorValues
);
+ final String tempQuantizedVectorDataName = tempQuantizedVectorData.getName();
+ final String tempScoreQuantizedVectorDataName = tempScoreQuantizedVectorData.getName();
+ success = true;
return new BinarizedCloseableRandomVectorScorerSupplier(scorerSupplier, vectorValues, () -> {
IOUtils.close(finalBinarizedDataInput, finalBinarizedScoreDataInput);
IOUtils.deleteFilesIgnoringExceptions(
segmentWriteState.directory,
- tempQuantizedVectorData.getName(),
- tempScoreQuantizedVectorData.getName()
+ tempQuantizedVectorDataName,
+ tempScoreQuantizedVectorDataName
);
});
} finally {
if (success == false) {
- IOUtils.closeWhileHandlingException(
- tempQuantizedVectorData,
- tempScoreQuantizedVectorData,
- binarizedDataInput,
- binarizedScoreDataInput
- );
+ IOUtils.closeWhileHandlingException(binarizedDataInput, binarizedScoreDataInput);
IOUtils.deleteFilesIgnoringExceptions(
segmentWriteState.directory,
tempQuantizedVectorData.getName(),
diff --git a/server/src/test/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshotTests.java b/server/src/test/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshotTests.java
index 2a6c3428d6d4..a5d5d9b210e3 100644
--- a/server/src/test/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshotTests.java
+++ b/server/src/test/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshotTests.java
@@ -19,14 +19,12 @@
import java.io.IOException;
-import static org.elasticsearch.index.mapper.SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING;
-
public class LuceneSyntheticSourceChangesSnapshotTests extends SearchBasedChangesSnapshotTests {
@Override
protected Settings indexSettings() {
return Settings.builder()
.put(super.indexSettings())
- .put(INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.name())
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.name())
.put(IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(), true)
.build();
}
diff --git a/server/src/test/java/org/elasticsearch/index/engine/TranslogOperationAsserterTests.java b/server/src/test/java/org/elasticsearch/index/engine/TranslogOperationAsserterTests.java
index b764bce464d1..d0455c14bd78 100644
--- a/server/src/test/java/org/elasticsearch/index/engine/TranslogOperationAsserterTests.java
+++ b/server/src/test/java/org/elasticsearch/index/engine/TranslogOperationAsserterTests.java
@@ -24,8 +24,6 @@
import java.io.IOException;
-import static org.elasticsearch.index.mapper.SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING;
-
public class TranslogOperationAsserterTests extends EngineTestCase {
@Override
@@ -33,7 +31,7 @@ protected Settings indexSettings() {
return Settings.builder()
.put(super.indexSettings())
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
- .put(INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.name())
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.name())
.put(IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(), true)
.build();
}
@@ -57,10 +55,10 @@ EngineConfig engineConfig(boolean useSyntheticSource) {
EngineConfig config = engine.config();
Settings.Builder settings = Settings.builder().put(config.getIndexSettings().getSettings());
if (useSyntheticSource) {
- settings.put(INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.name());
+ settings.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.name());
settings.put(IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(), true);
} else {
- settings.put(INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED.name());
+ settings.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED.name());
settings.put(IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(), false);
}
IndexMetadata imd = IndexMetadata.builder(config.getIndexSettings().getIndexMetadata()).settings(settings).build();
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java
index 907a1a15721d..4b0fac2cf2e0 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java
@@ -54,7 +54,7 @@ public void putMappings() {
}
public void testGetMappings() {
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings().get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertExpectedMappings(getMappingsResponse.mappings());
}
@@ -71,7 +71,7 @@ public void testGetFieldMappings() {
assertFieldMappings(mappings.get("filtered"), FILTERED_FLAT_FIELDS);
// double check that submitting the filtered mappings to an unfiltered index leads to the same get field mappings output
// as the one coming from a filtered index with same mappings
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("filtered").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "filtered").get();
MappingMetadata filtered = getMappingsResponse.getMappings().get("filtered");
assertAcked(indicesAdmin().prepareCreate("test").setMapping(filtered.getSourceAsMap()));
GetFieldMappingsResponse response = indicesAdmin().prepareGetFieldMappings("test").setFields("*").get();
@@ -98,7 +98,7 @@ public void testFieldCapabilities() {
assertFieldCaps(filtered, filteredFields);
// double check that submitting the filtered mappings to an unfiltered index leads to the same field_caps output
// as the one coming from a filtered index with same mappings
- GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("filtered").get();
+ GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "filtered").get();
MappingMetadata filteredMapping = getMappingsResponse.getMappings().get("filtered");
assertAcked(indicesAdmin().prepareCreate("test").setMapping(filteredMapping.getSourceAsMap()));
FieldCapabilitiesResponse test = client().fieldCaps(new FieldCapabilitiesRequest().fields("*").indices("test")).actionGet();
@@ -155,7 +155,7 @@ private void assertExpectedMappings(Map mappings) {
private void assertMappingsAreValid(Map sourceAsMap) {
// check that the returned filtered mappings are still valid mappings by submitting them and retrieving them back
assertAcked(indicesAdmin().prepareCreate("test").setMapping(sourceAsMap));
- GetMappingsResponse testMappingsResponse = indicesAdmin().prepareGetMappings("test").get();
+ GetMappingsResponse testMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertEquals(1, testMappingsResponse.getMappings().size());
// the mappings are returned unfiltered for this index, yet they are the same as the previous ones that were returned filtered
assertFiltered(testMappingsResponse.getMappings().get("test"));
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IgnoredSourceFieldMapperConfigurationTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IgnoredSourceFieldMapperConfigurationTests.java
index 8646e1b66dcb..1ba5f423d4b0 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/IgnoredSourceFieldMapperConfigurationTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/IgnoredSourceFieldMapperConfigurationTests.java
@@ -12,6 +12,7 @@
import org.apache.lucene.index.DirectoryReader;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.CheckedConsumer;
+import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.xcontent.XContentBuilder;
import java.io.IOException;
@@ -130,7 +131,7 @@ private MapperService mapperServiceWithCustomSettings(
for (var entry : customSettings.entrySet()) {
settings.put(entry.getKey(), entry.getValue());
}
- settings.put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC);
+ settings.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC);
return createMapperService(settings.build(), mapping(mapping));
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/NonDynamicFieldMapperTestCase.java b/server/src/test/java/org/elasticsearch/index/mapper/NonDynamicFieldMapperTestCase.java
index 6ea41763cbcc..b669c717719b 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/NonDynamicFieldMapperTestCase.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/NonDynamicFieldMapperTestCase.java
@@ -43,7 +43,7 @@ public void testCreateExplicitMappingSucceeds() throws Exception {
""", getMapping());
var resp = client().admin().indices().prepareCreate("test").setMapping(mapping).get();
assertTrue(resp.isAcknowledged());
- var mappingsResp = client().admin().indices().prepareGetMappings("test").get();
+ var mappingsResp = client().admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
var mappingMetadata = mappingsResp.getMappings().get("test");
var fieldType = XContentMapValues.extractValue("properties.field.type", mappingMetadata.getSourceAsMap());
assertThat(fieldType, equalTo(getTypeName()));
@@ -149,7 +149,7 @@ public void testCreateExplicitMappingInIndexTemplateSucceeds() throws Exception
var resp = client().prepareIndex("test1").setSource("field", "hello world").get();
assertThat(resp.status(), equalTo(RestStatus.CREATED));
- var mappingsResp = client().admin().indices().prepareGetMappings("test1").get();
+ var mappingsResp = client().admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test1").get();
var mappingMetadata = mappingsResp.getMappings().get("test1");
var fieldType = XContentMapValues.extractValue("properties.field.type", mappingMetadata.getSourceAsMap());
assertThat(fieldType, equalTo(getTypeName()));
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java
index b7693513a434..bc560d94b8f5 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java
@@ -427,7 +427,7 @@ public void testRecoverySourceWitInvalidSettings() {
{
Settings settings = Settings.builder()
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED.toString())
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED.toString())
.put(IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(), true)
.build();
IllegalArgumentException exc = expectThrows(
@@ -470,7 +470,7 @@ public void testRecoverySourceWitInvalidSettings() {
public void testRecoverySourceWithSyntheticSource() throws IOException {
{
Settings settings = Settings.builder()
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.toString())
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.toString())
.build();
MapperService mapperService = createMapperService(settings, topMapping(b -> {}));
DocumentMapper docMapper = mapperService.documentMapper();
@@ -480,7 +480,7 @@ public void testRecoverySourceWithSyntheticSource() throws IOException {
}
{
Settings settings = Settings.builder()
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.toString())
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.toString())
.put(IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(), true)
.build();
MapperService mapperService = createMapperService(settings, topMapping(b -> {}));
@@ -539,7 +539,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.STANDARD.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
DocumentMapper docMapper = mapperService.documentMapper();
@@ -549,7 +549,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.STANDARD.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
final DocumentMapper docMapper = mapperService.documentMapper();
@@ -559,7 +559,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.STANDARD.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
final DocumentMapper docMapper = mapperService.documentMapper();
@@ -571,7 +571,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.LOGSDB.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
DocumentMapper docMapper = mapperService.documentMapper();
@@ -581,7 +581,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.LOGSDB.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
final DocumentMapper docMapper = mapperService.documentMapper();
@@ -591,7 +591,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.LOGSDB.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
.build();
var ex = expectThrows(MapperParsingException.class, () -> createMapperService(settings, mappings));
assertEquals("Failed to parse mapping: _source can not be disabled in index using [logsdb] index mode", ex.getMessage());
@@ -613,7 +613,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
""";
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
.put(IndexMetadata.INDEX_ROUTING_PATH.getKey(), "routing_field")
.build();
final MapperService mapperService = createMapperService(settings, mappings);
@@ -635,7 +635,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
""";
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
.put(IndexMetadata.INDEX_ROUTING_PATH.getKey(), "routing_field")
.build();
final MapperService mapperService = createMapperService(settings, mappings);
@@ -657,7 +657,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
""";
final Settings settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES.name())
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
.put(IndexMetadata.INDEX_ROUTING_PATH.getKey(), "routing_field")
.build();
var ex = expectThrows(MapperParsingException.class, () -> createMapperService(settings, mappings));
@@ -668,7 +668,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
{
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
DocumentMapper docMapper = mapperService.documentMapper();
@@ -677,7 +677,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
{
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.STORED)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
final DocumentMapper docMapper = mapperService.documentMapper();
@@ -686,7 +686,7 @@ public void testStandardIndexModeWithSourceModeSetting() throws IOException {
{
final XContentBuilder mappings = topMapping(b -> {});
final Settings settings = Settings.builder()
- .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
+ .put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.DISABLED)
.build();
final MapperService mapperService = createMapperService(settings, mappings);
final DocumentMapper docMapper = mapperService.documentMapper();
diff --git a/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java b/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java
index 889afab00e83..c0185832d612 100644
--- a/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java
+++ b/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java
@@ -27,6 +27,7 @@
import static org.elasticsearch.common.bytes.ReleasableBytesReferenceStreamInputTests.wrapAsReleasable;
import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.instanceOf;
@@ -182,7 +183,7 @@ public void testDecodePreHeaderSizeVariableInt() throws IOException {
}
}
- public void testDecodeHandshakeCompatibility() throws IOException {
+ public void testDecodeHandshakeV7Compatibility() throws IOException {
String action = "test-request";
long requestId = randomNonNegativeLong();
final String headerKey = randomAlphaOfLength(10);
@@ -223,6 +224,55 @@ public void testDecodeHandshakeCompatibility() throws IOException {
}
+ public void testDecodeHandshakeV8Compatibility() throws IOException {
+ doHandshakeCompatibilityTest(TransportHandshaker.REQUEST_HANDSHAKE_VERSION, null);
+ doHandshakeCompatibilityTest(TransportHandshaker.REQUEST_HANDSHAKE_VERSION, Compression.Scheme.DEFLATE);
+ }
+
+ public void testDecodeHandshakeV9Compatibility() throws IOException {
+ doHandshakeCompatibilityTest(TransportHandshaker.V9_HANDSHAKE_VERSION, null);
+ doHandshakeCompatibilityTest(TransportHandshaker.V9_HANDSHAKE_VERSION, Compression.Scheme.DEFLATE);
+ }
+
+ private void doHandshakeCompatibilityTest(TransportVersion transportVersion, Compression.Scheme compressionScheme) throws IOException {
+ String action = "test-request";
+ long requestId = randomNonNegativeLong();
+ final String headerKey = randomAlphaOfLength(10);
+ final String headerValue = randomAlphaOfLength(20);
+ threadContext.putHeader(headerKey, headerValue);
+ OutboundMessage message = new OutboundMessage.Request(
+ threadContext,
+ new TestRequest(randomAlphaOfLength(100)),
+ transportVersion,
+ action,
+ requestId,
+ true,
+ compressionScheme
+ );
+
+ try (RecyclerBytesStreamOutput os = new RecyclerBytesStreamOutput(recycler)) {
+ final BytesReference bytes = message.serialize(os);
+ int totalHeaderSize = TcpHeader.headerSize(transportVersion);
+
+ InboundDecoder decoder = new InboundDecoder(recycler);
+ final ArrayList