diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/search/aggregations/AggConstructionContentionBenchmark.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/search/aggregations/AggConstructionContentionBenchmark.java index 26a4a8c92f181..357c6a66a1ae1 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/search/aggregations/AggConstructionContentionBenchmark.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/search/aggregations/AggConstructionContentionBenchmark.java @@ -43,7 +43,6 @@ import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; -import org.elasticsearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder; import org.elasticsearch.search.aggregations.support.AggregationContext; @@ -152,7 +151,6 @@ private class DummyAggregationContext extends AggregationContext { private final CircuitBreaker breaker; private final PreallocatedCircuitBreakerService preallocated; - private final MultiBucketConsumer multiBucketConsumer; DummyAggregationContext(long bytesToPreallocate) { CircuitBreakerService breakerService; @@ -168,7 +166,6 @@ private class DummyAggregationContext extends AggregationContext { preallocated = null; } breaker = breakerService.getBreaker(CircuitBreaker.REQUEST); - multiBucketConsumer = new MultiBucketConsumer(Integer.MAX_VALUE, breaker); } @Override @@ -298,8 +295,8 @@ public void addReleasable(Aggregator aggregator) { } @Override - public MultiBucketConsumer multiBucketConsumer() { - return multiBucketConsumer; + public int maxBuckets() { + return Integer.MAX_VALUE; } @Override diff --git a/docs/changelog/95107.yaml b/docs/changelog/95107.yaml new file mode 100644 index 0000000000000..9b757e0d68042 --- /dev/null +++ b/docs/changelog/95107.yaml @@ -0,0 +1,5 @@ +pr: 95107 +summary: Cache modification time of translog writer file +area: Engine +type: enhancement +issues: [] diff --git a/docs/changelog/95665.yaml b/docs/changelog/95665.yaml new file mode 100644 index 0000000000000..59e99db23b51b --- /dev/null +++ b/docs/changelog/95665.yaml @@ -0,0 +1,5 @@ +pr: 95665 +summary: "[DLM] Fix the new endpoint rest-api specification" +area: DLM +type: bug +issues: [] diff --git a/docs/reference/ingest/processors/geoip.asciidoc b/docs/reference/ingest/processors/geoip.asciidoc index c9ee4f0c74ccd..fac1c943b8a7d 100644 --- a/docs/reference/ingest/processors/geoip.asciidoc +++ b/docs/reference/ingest/processors/geoip.asciidoc @@ -9,13 +9,13 @@ IPv4 or IPv6 address. [[geoip-automatic-updates]] By default, the processor uses the GeoLite2 City, GeoLite2 Country, and GeoLite2 -ASN GeoIP2 databases from -http://dev.maxmind.com/geoip/geoip2/geolite2/[MaxMind], shared under the -CC BY-SA 4.0 license. It automatically downloads these databases if either -`ingest.geoip.downloader.eager.download` is set to true, or your cluster -has at least one pipeline with a `geoip` processor. {es} -automatically downloads updates for -these databases from the Elastic GeoIP endpoint: +ASN GeoIP2 databases from http://dev.maxmind.com/geoip/geoip2/geolite2/[MaxMind], shared under the +CC BY-SA 4.0 license. It automatically downloads these databases if your nodes can connect to `storage.googleapis.com` domain and either: + +* `ingest.geoip.downloader.eager.download` is set to true +* your cluster has at least one pipeline with a `geoip` processor + +{es} automatically downloads updates for these databases from the Elastic GeoIP endpoint: https://geoip.elastic.co/v1/database. To get download statistics for these updates, use the <>. diff --git a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ParsedMediaType.java b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ParsedMediaType.java index bbbaf22e6c95a..ecc82f293cb4c 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/xcontent/ParsedMediaType.java +++ b/libs/x-content/src/main/java/org/elasticsearch/xcontent/ParsedMediaType.java @@ -62,7 +62,7 @@ public static ParsedMediaType parseMediaType(String headerValue) { if (isMediaRange(headerValue) || "*/*".equals(headerValue)) { return null; } - final String[] elements = headerValue.toLowerCase(Locale.ROOT).split("[\\s\\t]*;"); + final String[] elements = headerValue.toLowerCase(Locale.ROOT).split(";"); final String[] splitMediaType = elements[0].split("/"); if ((splitMediaType.length == 2 diff --git a/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/SearchCancellationIT.java b/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/SearchCancellationIT.java index 48f4bcf800d61..8363aa310a451 100644 --- a/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/SearchCancellationIT.java +++ b/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/SearchCancellationIT.java @@ -19,7 +19,6 @@ import org.elasticsearch.aggregations.AggregationsPlugin; import org.elasticsearch.aggregations.bucket.timeseries.TimeSeriesAggregationBuilder; import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexMode; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.plugins.Plugin; @@ -62,14 +61,10 @@ public void testCancellationDuringTimeSeriesAggregation() throws Exception { int numberOfDocsPerRefresh = numberOfShards * between(3000, 3500) / numberOfRefreshes; assertAcked( prepareCreate("test").setSettings( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES.name()) + indexSettings(numberOfShards, 0).put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES.name()) .put(IndexMetadata.INDEX_ROUTING_PATH.getKey(), "dim") .put(TIME_SERIES_START_TIME.getKey(), now) .put(TIME_SERIES_END_TIME.getKey(), now + (long) numberOfRefreshes * numberOfDocsPerRefresh + 1) - .build() ).setMapping(""" { "properties": { 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 03667088b5775..f680c4640d70c 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 @@ -1569,10 +1569,7 @@ public void testMultiThreadedRollover() throws Exception { // Test that datastream's segments by default are sorted on @timestamp desc public void testSegmentsSortedOnTimestampDesc() throws Exception { - Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .build(); + Settings settings = indexSettings(1, 0).build(); putComposableIndexTemplate("template_for_foo", null, List.of("metrics-foo*"), settings, null); CreateDataStreamAction.Request createDataStreamRequest = new CreateDataStreamAction.Request("metrics-foo"); client().execute(CreateDataStreamAction.INSTANCE, createDataStreamRequest).get(); @@ -2047,10 +2044,7 @@ public void testWriteIndexWriteLoadAndAvgShardSizeIsStoredAfterRollover() throws final String dataStreamName = "logs-es"; final int numberOfShards = randomIntBetween(1, 5); final int numberOfReplicas = randomIntBetween(0, 1); - final var indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numberOfReplicas) - .build(); + final var indexSettings = indexSettings(numberOfShards, numberOfReplicas).build(); DataStreamIT.putComposableIndexTemplate("my-template", null, List.of("logs-*"), indexSettings, null); final var request = new CreateDataStreamAction.Request(dataStreamName); assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet()); @@ -2097,10 +2091,7 @@ public void testWriteLoadAndAvgShardSizeIsStoredInABestEffort() throws Exception final List dataOnlyNodes = internalCluster().startDataOnlyNodes(4); final String dataStreamName = "logs-es"; - final var indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put("index.routing.allocation.include._name", String.join(",", dataOnlyNodes)) + final var indexSettings = indexSettings(2, 1).put("index.routing.allocation.include._name", String.join(",", dataOnlyNodes)) .build(); DataStreamIT.putComposableIndexTemplate("my-template", null, List.of("logs-*"), indexSettings, null); final var createDataStreamRequest = new CreateDataStreamAction.Request(dataStreamName); @@ -2172,11 +2163,7 @@ public void testNoShardSizeIsForecastedWhenAllShardStatRequestsFail() throws Exc final String dataOnlyNode = internalCluster().startDataOnlyNode(); final String dataStreamName = "logs-es"; - final var indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put("index.routing.allocation.require._name", dataOnlyNode) - .build(); + final var indexSettings = indexSettings(1, 0).put("index.routing.allocation.require._name", dataOnlyNode).build(); DataStreamIT.putComposableIndexTemplate("my-template", null, List.of("logs-*"), indexSettings, null); final var createDataStreamRequest = new CreateDataStreamAction.Request(dataStreamName); assertAcked(client().execute(CreateDataStreamAction.INSTANCE, createDataStreamRequest).actionGet()); @@ -2217,10 +2204,7 @@ public void testShardSizeIsForecastedDuringRollover() throws Exception { final String dataStreamName = "logs-es"; final int numberOfShards = randomIntBetween(1, 5); final int numberOfReplicas = randomIntBetween(0, 1); - final var indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numberOfReplicas) - .build(); + final var indexSettings = indexSettings(numberOfShards, numberOfReplicas).build(); DataStreamIT.putComposableIndexTemplate("my-template", null, List.of("logs-*"), indexSettings, null); final var request = new CreateDataStreamAction.Request(dataStreamName); assertAcked(client().execute(CreateDataStreamAction.INSTANCE, request).actionGet()); diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/mapper/MetadataCreateDataStreamServiceTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/mapper/MetadataCreateDataStreamServiceTests.java index 9e006034b5808..09a684f7fe480 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/mapper/MetadataCreateDataStreamServiceTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/mapper/MetadataCreateDataStreamServiceTests.java @@ -68,12 +68,7 @@ public void testValidateTimestampFieldMappingInvalidFieldType() { MappingLookup createMappingLookup(String mapping) throws IOException { String indexName = "test"; IndexMetadata indexMetadata = IndexMetadata.builder(indexName) - .settings( - Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - ) + .settings(indexSettings(Version.CURRENT, 1, 1)) .putMapping(mapping) .build(); IndicesModule indicesModule = new IndicesModule(List.of()); diff --git a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java index 2d6038a4d7d9c..5e0f4f29163d7 100644 --- a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java +++ b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java @@ -10,14 +10,11 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.Version; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.geo.GeoUtils; import org.elasticsearch.common.geo.GeometryNormalizer; import org.elasticsearch.common.geo.GeometryParser; import org.elasticsearch.common.geo.Orientation; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.geometry.Geometry; import org.elasticsearch.geometry.GeometryCollection; import org.elasticsearch.geometry.Line; @@ -385,13 +382,6 @@ public void testParse3DPolygon() throws IOException, ParseException { Coordinate[] coordinates = shellCoordinates.toArray(new Coordinate[shellCoordinates.size()]); Version randomVersion = VersionUtils.randomIndexCompatibleVersion(random()); - Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, randomVersion) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) - .build(); - LinearRing shell = GEOMETRY_FACTORY.createLinearRing(shellCoordinates.toArray(new Coordinate[shellCoordinates.size()])); Polygon expected = GEOMETRY_FACTORY.createPolygon(shell, null); final Version version = VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0); diff --git a/modules/parent-join/src/internalClusterTest/java/org/elasticsearch/join/aggregations/ChildrenIT.java b/modules/parent-join/src/internalClusterTest/java/org/elasticsearch/join/aggregations/ChildrenIT.java index 7d295049c6b84..afb7ad702de9c 100644 --- a/modules/parent-join/src/internalClusterTest/java/org/elasticsearch/join/aggregations/ChildrenIT.java +++ b/modules/parent-join/src/internalClusterTest/java/org/elasticsearch/join/aggregations/ChildrenIT.java @@ -12,8 +12,6 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.internal.Requests; -import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.InternalAggregation; @@ -206,9 +204,7 @@ public void testPostCollection() throws Exception { String masterType = "masterprod"; String childType = "variantsku"; assertAcked( - prepareCreate(indexName).setSettings( - Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - ) + prepareCreate(indexName).setSettings(indexSettings(1, 0)) .setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, masterType, childType), diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/index/reindex/BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/index/reindex/BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests.java index e9292bb9bbabb..47f0bc01aa9f5 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/index/reindex/BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/index/reindex/BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests.java @@ -16,7 +16,6 @@ import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; @@ -269,10 +268,7 @@ public void testDeleteByQuery() throws Exception { } private void createIndexWithSingleShard(String index) throws Exception { - final Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .build(); + final Settings indexSettings = indexSettings(1, 0).build(); final XContentBuilder mappings = jsonBuilder(); { mappings.startObject(); diff --git a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/AnalysisPolishFactoryTests.java b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/AnalysisPolishFactoryTests.java index 62925f7d53cc4..c203f8e297982 100644 --- a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/AnalysisPolishFactoryTests.java +++ b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/AnalysisPolishFactoryTests.java @@ -41,12 +41,7 @@ protected Map> getTokenFilters() { public void testThreadSafety() throws IOException { // TODO: is this the right boilerplate? I forked this out of TransportAnalyzeAction.java: - Settings settings = Settings.builder() - // for _na_ - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) + Settings settings = indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .build(); Environment environment = TestEnvironment.newEnvironment(settings); diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index 3f9a007e6bf4e..e8f5240e31abd 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -1501,9 +1501,7 @@ public void testPeerRecoveryRetentionLeases() throws Exception { */ public void testOperationBasedRecovery() throws Exception { if (isRunningAgainstOldCluster()) { - Settings.Builder settings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1); + Settings.Builder settings = indexSettings(1, 1); if (minimumNodeVersion().before(Version.V_8_0_0) && randomBoolean()) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); } @@ -1741,9 +1739,7 @@ public void testEnableSoftDeletesOnRestore() throws Exception { assumeTrue("soft deletes must be enabled on 8.0+", getOldClusterVersion().before(Version.V_8_0_0)); final String snapshot = "snapshot-" + index; if (isRunningAgainstOldCluster()) { - final Settings.Builder settings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1); + final Settings.Builder settings = indexSettings(1, 1); settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false); createIndex(index, settings.build()); ensureGreen(index); @@ -1801,10 +1797,7 @@ public void testEnableSoftDeletesOnRestore() throws Exception { public void testForbidDisableSoftDeletesOnRestore() throws Exception { final String snapshot = "snapshot-" + index; if (isRunningAgainstOldCluster()) { - final Settings.Builder settings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true); + final Settings.Builder settings = indexSettings(1, 1).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true); createIndex(index, settings.build()); ensureGreen(index); int numDocs = randomIntBetween(0, 100); diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java index 5e0137e143080..dc92685595c67 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java @@ -716,14 +716,7 @@ public void testAutoExpandIndicesDuringRollingUpgrade() throws Exception { List nodes = new ArrayList<>(nodeMap.keySet()); if (CLUSTER_TYPE == ClusterType.OLD) { - createIndex( - indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomInt(2)) - .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-all") - .build() - ); + createIndex(indexName, indexSettings(1, randomInt(2)).put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-all").build()); ensureGreen(indexName); updateIndexSettings( indexName, diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete_data_lifecycle.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete_data_lifecycle.json index f20e54ff74117..96aa5d21e62c8 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete_data_lifecycle.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete_data_lifecycle.json @@ -4,19 +4,13 @@ "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/dlm-delete-lifecycle.html", "description":"Deletes the data lifecycle of the selected data streams." }, - "stability":"stable", + "stability":"experimental", "visibility":"public", "headers":{ "accept": [ "application/json"] }, "url":{ "paths":[ - { - "path":"/_data_stream/_lifecycle", - "methods":[ - "DELETE" - ] - }, { "path":"/_data_stream/{name}/_lifecycle", "methods":[ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_data_lifecycle.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_data_lifecycle.json index 8f21bcf2c7a46..7cbfbfb9e5008 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_data_lifecycle.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_data_lifecycle.json @@ -4,19 +4,13 @@ "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/dlm-get-lifecycle.html", "description":"Returns the data lifecycle of the selected data streams." }, - "stability":"stable", + "stability":"experimental", "visibility":"public", "headers":{ "accept": [ "application/json"] }, "url":{ "paths":[ - { - "path":"/_data_stream/_lifecycle", - "methods":[ - "GET" - ] - }, { "path":"/_data_stream/{name}/_lifecycle", "methods":[ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_data_lifecycle.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_data_lifecycle.json index 61d8180cdd193..63cf5addd3bb7 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_data_lifecycle.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_data_lifecycle.json @@ -4,19 +4,13 @@ "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/dlm-put-lifecycle.html", "description":"Updates the data lifecycle of the selected data streams." }, - "stability":"stable", + "stability":"experimental", "visibility":"public", "headers":{ "accept": [ "application/json"] }, - "url":{ - "paths":[ - { - "path":"/_data_stream/_lifecycle", - "methods":[ - "PUT" - ] - }, + "url": { + "paths": [ { "path":"/_data_stream/{name}/_lifecycle", "methods":[ diff --git a/server/build.gradle b/server/build.gradle index 43c6903f4e316..1a58732a9b9da 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -81,12 +81,6 @@ dependencies { } -spotless { - java { - targetExclude "src/main/java/org/elasticsearch/Version.java" - } -} - tasks.named("forbiddenPatterns").configure { exclude '**/*.json' exclude '**/*.jmx' diff --git a/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java index 1f22a933ffa07..2eb7828f1c2d9 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java @@ -225,14 +225,7 @@ public void testVerifyApiBlocksDuringPartition() throws Exception { public void testMappingTimeout() throws Exception { startCluster(3); - createIndex( - "test", - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 1) - .put("index.routing.allocation.exclude._name", internalCluster().getMasterName()) - .build() - ); + createIndex("test", indexSettings(1, 1).put("index.routing.allocation.exclude._name", internalCluster().getMasterName()).build()); // create one field index("test", "1", "{ \"f\": 1 }"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java b/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java index 7d9ef2a105e1e..ade27a844e7df 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java @@ -54,7 +54,7 @@ public void testStartFailureOnDataForNonDataNode() throws Exception { Settings dataPathSettings = internalCluster().dataPathSettings(node); logger.info("--> creating index"); - prepareCreate(indexName, Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)).get(); + prepareCreate(indexName, indexSettings(1, 0)).get(); final String indexUUID = resolveIndex(indexName).getUUID(); if (writeDanglingIndices) { assertBusy( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/env/NodeRepurposeCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/env/NodeRepurposeCommandIT.java index 1be7fc125d648..06bb86b8e072d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/env/NodeRepurposeCommandIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/env/NodeRepurposeCommandIT.java @@ -32,7 +32,7 @@ public void testRepurpose() throws Exception { ); logger.info("--> creating index"); - prepareCreate(indexName, Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)).get(); + prepareCreate(indexName, indexSettings(1, 0)).get(); logger.info("--> indexing a simple document"); client().prepareIndex(indexName).setId("1").setSource("field1", "value1").get(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java index 9bf6f24a9015d..292cda335b921 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java @@ -255,11 +255,10 @@ public void testPersistGlobalCheckpoint() throws Exception { public void testPersistLocalCheckpoint() { internalCluster().ensureAtLeastNumDataNodes(2); - Settings.Builder indexSettings = Settings.builder() - .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "10m") - .put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.REQUEST) - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", randomIntBetween(0, 1)); + Settings.Builder indexSettings = indexSettings(1, randomIntBetween(0, 1)).put( + IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), + "10m" + ).put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.REQUEST); prepareCreate("test", indexSettings).get(); ensureGreen("test"); int numDocs = randomIntBetween(1, 20); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java index 4047cfdfa7c80..6968d9bb0c4b9 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java @@ -76,11 +76,7 @@ protected Collection> nodePlugins() { public void testRetentionLeasesSyncedOnAdd() throws Exception { final int numberOfReplicas = 2 - scaledRandomIntBetween(0, 2); internalCluster().ensureAtLeastNumDataNodes(1 + numberOfReplicas); - final Settings settings = Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", numberOfReplicas) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .build(); + final Settings settings = indexSettings(1, numberOfReplicas).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build(); createIndex("index", settings); ensureGreen("index"); final String primaryShardNodeId = clusterService().state().routingTable().index("index").shard(0).primaryShard().currentNodeId(); @@ -195,11 +191,10 @@ public void testRetentionLeasesSyncOnExpiration() throws Exception { final TimeValue retentionLeaseTimeToLive = TimeValue.timeValueMillis( randomLongBetween(estimatedTimeIntervalMillis, 2 * estimatedTimeIntervalMillis) ); - final Settings settings = Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", numberOfReplicas) - .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(1)) - .build(); + final Settings settings = indexSettings(1, numberOfReplicas).put( + IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), + TimeValue.timeValueSeconds(1) + ).build(); createIndex("index", settings); ensureGreen("index"); final String primaryShardNodeId = clusterService().state().routingTable().index("index").shard(0).primaryShard().currentNodeId(); @@ -270,11 +265,10 @@ public void testRetentionLeasesSyncOnExpiration() throws Exception { public void testBackgroundRetentionLeaseSync() throws Exception { final int numberOfReplicas = 2 - scaledRandomIntBetween(0, 2); internalCluster().ensureAtLeastNumDataNodes(1 + numberOfReplicas); - final Settings settings = Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", numberOfReplicas) - .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(1)) - .build(); + final Settings settings = indexSettings(1, numberOfReplicas).put( + IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), + TimeValue.timeValueSeconds(1) + ).build(); createIndex("index", settings); ensureGreen("index"); final String primaryShardNodeId = clusterService().state().routingTable().index("index").shard(0).primaryShard().currentNodeId(); @@ -328,10 +322,7 @@ public void testRetentionLeasesSyncOnRecovery() throws Exception { * We effectively disable the background sync to ensure that the retention leases are not synced in the background so that the only * source of retention leases on the replicas would be from recovery. */ - final Settings.Builder settings = Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 0) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) + final Settings.Builder settings = indexSettings(1, 0).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueHours(24)); // when we increase the number of replicas below we want to exclude the replicas from being allocated so that they do not recover assertAcked(prepareCreate("index", 1, settings)); @@ -462,10 +453,7 @@ private void runUnderBlockTest( final BiConsumer> primaryConsumer, final Consumer afterSync ) throws InterruptedException { - final Settings settings = Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 0) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) + final Settings settings = indexSettings(1, 0).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(1)) .build(); assertAcked(prepareCreate("index").setSettings(settings)); @@ -567,10 +555,7 @@ private void runWaitForShardsTest( final Consumer afterSync ) throws InterruptedException { final int numDataNodes = internalCluster().numDataNodes(); - final Settings settings = Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", numDataNodes) - .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) + final Settings settings = indexSettings(1, numDataNodes).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(1)) .build(); assertAcked(prepareCreate("index").setSettings(settings)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/GlobalCheckpointListenersIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/GlobalCheckpointListenersIT.java index 2c25e2648123f..70adc75574437 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/GlobalCheckpointListenersIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/GlobalCheckpointListenersIT.java @@ -8,7 +8,6 @@ package org.elasticsearch.index.shard; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.IndexService; import org.elasticsearch.indices.IndicesService; @@ -40,7 +39,7 @@ public void shutdownExecutor() { } public void testGlobalCheckpointListeners() throws Exception { - createIndex("test", Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).build()); + createIndex("test", indexSettings(1, 0).build()); ensureGreen(); final IndicesService indicesService = getInstanceFromNode(IndicesService.class); final IndexService test = indicesService.indexService(resolveIndex("test")); @@ -107,7 +106,7 @@ public void accept(final long g, final Exception e) { } public void testGlobalCheckpointListenerTimeout() throws InterruptedException { - createIndex("test", Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).build()); + createIndex("test", indexSettings(1, 0).build()); ensureGreen(); final IndicesService indicesService = getInstanceFromNode(IndicesService.class); final IndexService test = indicesService.indexService(resolveIndex("test")); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java index 65bb53787ce15..59ab1eb5c09d1 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java @@ -675,10 +675,7 @@ private static ShardRouting getInitializingShardRouting(ShardRouting existingSha } public void testInvalidateIndicesRequestCacheWhenRollbackEngine() throws Exception { - createIndex( - "test", - Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).put("index.refresh_interval", -1).build() - ); + createIndex("test", indexSettings(1, 0).put("index.refresh_interval", -1).build()); ensureGreen(); final IndicesService indicesService = getInstanceFromNode(IndicesService.class); final IndexShard shard = indicesService.getShardOrNull(new ShardId(resolveIndex("test"), 0)); @@ -728,10 +725,7 @@ public void testInvalidateIndicesRequestCacheWhenRollbackEngine() throws Excepti } public void testShardChangesWithDefaultDocType() throws Exception { - Settings settings = Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 0) - .put("index.translog.flush_threshold_size", "512mb") // do not flush + Settings settings = indexSettings(1, 0).put("index.translog.flush_threshold_size", "512mb") // do not flush .put("index.soft_deletes.enabled", true) .build(); IndexService indexService = createIndex("index", settings, "user_doc", "title", "type=keyword"); @@ -760,7 +754,7 @@ public void testShardChangesWithDefaultDocType() throws Exception { */ public void testNoOpEngineFactoryTakesPrecedence() { final String indexName = "closed-index"; - createIndex(indexName, Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).build()); + createIndex(indexName, indexSettings(1, 0).build()); ensureGreen(); assertAcked(client().admin().indices().prepareClose(indexName)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java index 4b46857775f6d..d122a10783e93 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java @@ -19,7 +19,6 @@ import org.elasticsearch.action.bulk.TransportShardBulkAction; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.internal.Client; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.engine.SegmentsStats; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.SearchHit; @@ -70,12 +69,7 @@ public void testRetryDueToExceptionOnNetworkLayer() throws ExecutionException, I Client client = internalCluster().coordOnlyNodeClient(); NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().get(); NodeStats unluckyNode = randomFrom(nodeStats.getNodes().stream().filter((s) -> s.getNode().canContainData()).toList()); - assertAcked( - client().admin() - .indices() - .prepareCreate("index") - .setSettings(Settings.builder().put("index.number_of_replicas", 1).put("index.number_of_shards", 5)) - ); + assertAcked(client().admin().indices().prepareCreate("index").setSettings(indexSettings(5, 1))); ensureGreen("index"); logger.info("unlucky node: {}", unluckyNode.getNode()); // create a transport service that throws a ConnectTransportException for one bulk request and therefore triggers a retry. diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndexingMemoryControllerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndexingMemoryControllerIT.java index feb2356b31a41..8f2341ecded95 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndexingMemoryControllerIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndexingMemoryControllerIT.java @@ -92,10 +92,7 @@ public Optional getEngineFactory(IndexSettings indexSettings) { // #10312 public void testDeletesAloneCanTriggerRefresh() throws Exception { - IndexService indexService = createIndex( - "index", - Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).put("index.refresh_interval", -1).build() - ); + IndexService indexService = createIndex("index", indexSettings(1, 0).put("index.refresh_interval", -1).build()); IndexShard shard = indexService.getShard(0); for (int i = 0; i < 100; i++) { client().prepareIndex("index").setId(Integer.toString(i)).setSource("field", "value").get(); 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 54fff949bc42d..b7c6d8b74d33e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java @@ -63,12 +63,7 @@ public void testDynamicUpdates() throws Exception { client().admin() .indices() .prepareCreate("test") - .setSettings( - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 0) - .put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), Long.MAX_VALUE) - ) + .setSettings(indexSettings(1, 0).put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), Long.MAX_VALUE)) .execute() .actionGet(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); @@ -108,15 +103,9 @@ public void testDynamicUpdates() throws Exception { } public void testUpdateMappingWithoutType() { - client().admin() - .indices() - .prepareCreate("test") - .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) - .setMapping(""" - {"properties":{"body":{"type":"text"}}} - """) - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping(""" + {"properties":{"body":{"type":"text"}}} + """).execute().actionGet(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setSource(""" @@ -145,15 +134,9 @@ public void testUpdateMappingWithoutTypeMultiObjects() { } public void testUpdateMappingWithConflicts() { - client().admin() - .indices() - .prepareCreate("test") - .setSettings(Settings.builder().put("index.number_of_shards", 2).put("index.number_of_replicas", 0)) - .setMapping(""" - {"properties":{"body":{"type":"text"}}} - """) - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setSettings(indexSettings(2, 0)).setMapping(""" + {"properties":{"body":{"type":"text"}}} + """).execute().actionGet(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); try { @@ -184,14 +167,8 @@ public void testUpdateMappingWithNormsConflicts() { Second regression test for https://github.com/elastic/elasticsearch/issues/3381 */ public void testUpdateMappingNoChanges() { - client().admin() - .indices() - .prepareCreate("test") - .setSettings(Settings.builder().put("index.number_of_shards", 2).put("index.number_of_replicas", 0)) - .setMapping(""" - {"properties":{"body":{"type":"text"}}}""") - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setSettings(indexSettings(2, 0)).setMapping(""" + {"properties":{"body":{"type":"text"}}}""").execute().actionGet(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setSource(""" diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java index f795460c9b1f5..50e26cd29354c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -17,7 +17,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand; import org.elasticsearch.common.Priority; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.test.ESIntegTestCase; @@ -34,12 +33,7 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase { public void testPrimaryRelocationWhileIndexing() throws Exception { internalCluster().ensureAtLeastNumDataNodes(randomIntBetween(2, 3)); - client().admin() - .indices() - .prepareCreate("test") - .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) - .setMapping("field", "type=text") - .get(); + client().admin().indices().prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping("field", "type=text").get(); ensureGreen("test"); AtomicInteger numAutoGenDocs = new AtomicInteger(); final AtomicBoolean finished = new AtomicBoolean(false); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index fba99709a0403..26cdc459044fa 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -852,12 +852,9 @@ public void testDoNotInfinitelyWaitForMapping() { internalCluster().ensureAtLeastNumDataNodes(3); createIndex( "test", - Settings.builder() - .put("index.analysis.analyzer.test_analyzer.type", "custom") + indexSettings(1, 0).put("index.analysis.analyzer.test_analyzer.type", "custom") .put("index.analysis.analyzer.test_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.test_analyzer.filter", "test_token_filter") - .put("index.number_of_replicas", 0) - .put("index.number_of_shards", 1) .build() ); client().admin().indices().preparePutMapping("test").setSource("test_field", "type=text,analyzer=test_analyzer").get(); @@ -967,9 +964,7 @@ public void testRecoverLocallyUpToGlobalCheckpoint() throws Exception { String indexName = "test-index"; createIndex( indexName, - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 1) + indexSettings(1, 1) // disable global checkpoint background sync so we can verify the start recovery request .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "12h") .put("index.routing.allocation.include._name", String.join(",", nodes)) @@ -1488,12 +1483,7 @@ public void testAllocateEmptyPrimaryResetsGlobalCheckpoint() throws Exception { client().admin() .indices() .prepareCreate(indexName) - .setSettings( - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 1) - .put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), randomBoolean()) - ) + .setSettings(indexSettings(1, 1).put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), randomBoolean())) .get() ); final List indexRequests = IntStream.range(0, between(10, 500)) @@ -1524,14 +1514,7 @@ public void testPeerRecoveryTrimsLocalTranslog() throws Exception { internalCluster().startNode(); List dataNodes = internalCluster().startDataOnlyNodes(2); String indexName = "test-index"; - createIndex( - indexName, - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 1) - .put("index.routing.allocation.include._name", String.join(",", dataNodes)) - .build() - ); + createIndex(indexName, indexSettings(1, 1).put("index.routing.allocation.include._name", String.join(",", dataNodes)).build()); ensureGreen(indexName); ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); DiscoveryNode nodeWithOldPrimary = clusterState.nodes() @@ -1603,14 +1586,7 @@ public void testReservesBytesDuringPeerRecoveryPhaseOne() throws Exception { internalCluster().startNode(); List dataNodes = internalCluster().startDataOnlyNodes(2); String indexName = "test-index"; - createIndex( - indexName, - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 0) - .put("index.routing.allocation.include._name", String.join(",", dataNodes)) - .build() - ); + createIndex(indexName, indexSettings(1, 0).put("index.routing.allocation.include._name", String.join(",", dataNodes)).build()); ensureGreen(indexName); final List indexRequests = IntStream.range(0, between(10, 500)) .mapToObj(n -> client().prepareIndex(indexName).setSource("foo", "bar")) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java index e1b02f4e93d50..4dd135efaf639 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java @@ -117,7 +117,7 @@ public void testSimpleRelocationNoIndexing() { final String node_1 = internalCluster().startNode(); logger.info("--> creating test index ..."); - prepareCreate("test", Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)).get(); + prepareCreate("test", indexSettings(1, 0)).get(); logger.info("--> index 10 docs"); for (int i = 0; i < 10; i++) { @@ -180,7 +180,7 @@ public void testRelocationWhileIndexingRandom() throws Exception { nodes[0] = internalCluster().startNode(); logger.info("--> creating test index ..."); - prepareCreate("test", Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", numberOfReplicas)).get(); + prepareCreate("test", indexSettings(1, numberOfReplicas)).get(); for (int i = 2; i <= numberOfNodes; i++) { logger.info("--> starting [node{}] ...", i); @@ -295,10 +295,7 @@ public void testRelocationWhileRefreshing() throws Exception { prepareCreate( "test", // set refresh_interval because we want to control refreshes - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", numberOfReplicas) - .put("index.refresh_interval", -1) + indexSettings(1, numberOfReplicas).put("index.refresh_interval", -1) ).get(); for (int i = 1; i < numberOfNodes; i++) { @@ -555,9 +552,7 @@ public void testRelocateWhileWaitingForRefresh() { logger.info("--> creating test index ..."); prepareCreate( "test", - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 0) + indexSettings(1, 0) // we want to control refreshes .put("index.refresh_interval", -1) ).get(); @@ -614,7 +609,7 @@ public void testRelocateWhileContinuouslyIndexingAndWaitingForRefresh() throws E prepareCreate( "test", // we want to control refreshes - Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).put("index.refresh_interval", -1) + indexSettings(1, 0).put("index.refresh_interval", -1) ).get(); logger.info("--> index 10 docs"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java index 19f4c391760a5..2aeaae77b8c93 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java @@ -69,10 +69,7 @@ public void testShrinking() throws Exception { .indices() .prepareCreate(index) .setSettings( - Settings.builder() - .put("index.number_of_shards", currentShards) - .put("index.number_of_routing_shards", currentShards) - .put("index.number_of_replicas", numberOfReplicas()) + indexSettings(currentShards, numberOfReplicas()).put("index.number_of_routing_shards", currentShards) .put("index.routing_partition_size", partitionSize) ) .setMapping("{\"_routing\":{\"required\":true}}") @@ -130,13 +127,7 @@ public void testShrinking() throws Exception { client().admin() .indices() .prepareResizeIndex(previousIndex, index) - .setSettings( - Settings.builder() - .put("index.number_of_shards", currentShards) - .put("index.number_of_replicas", numberOfReplicas()) - .putNull("index.routing.allocation.require._name") - .build() - ) + .setSettings(indexSettings(currentShards, numberOfReplicas()).putNull("index.routing.allocation.require._name").build()) .get(); ensureGreen(); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java index 5404433c72913..79161d8897610 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java @@ -111,11 +111,7 @@ private void setClusterDefaultAllowPartialResults(boolean allowPartialResults) { } private void buildRedIndex(int numShards) throws Exception { - assertAcked( - prepareCreate("test").setSettings( - Settings.builder().put("index.number_of_shards", numShards).put("index.number_of_replicas", 0) - ) - ); + assertAcked(prepareCreate("test").setSettings(indexSettings(numShards, 0))); ensureGreen(); for (int i = 0; i < 10; i++) { client().prepareIndex("test").setId("" + i).setSource("field1", "value1").get(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java index 51d7dd9725a5d..4db777b02756d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java @@ -14,7 +14,6 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.Priority; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.search.SearchHits; import org.elasticsearch.test.ESIntegTestCase; @@ -42,7 +41,7 @@ private void testSearchAndRelocateConcurrently(final int numberOfReplicas) throw client().admin() .indices() .prepareCreate("test") - .setSettings(Settings.builder().put("index.number_of_shards", numShards).put("index.number_of_replicas", numberOfReplicas)) + .setSettings(indexSettings(numShards, numberOfReplicas)) .setMapping("loc", "type=geo_point", "test", "type=text") .get(); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java index 412657b37d8dc..cf345e9afdd91 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java @@ -3329,7 +3329,7 @@ public void testHighlightQueryRewriteDatesWithNow() throws Exception { .indices() .prepareCreate("index-1") .setMapping("d", "type=date", "field", "type=text,store=true,term_vector=with_positions_offsets") - .setSettings(Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) + .setSettings(indexSettings(2, 0)) .get() ); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java index c22f414b7c0da..cc8e7899550ce 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java @@ -52,11 +52,7 @@ public Settings nodeSettings(int nodeOrdinal, Settings otherSettings) { // see #2896 public void testStopOneNodePreferenceWithRedState() throws IOException { - assertAcked( - prepareCreate("test").setSettings( - Settings.builder().put("index.number_of_shards", cluster().numDataNodes() + 2).put("index.number_of_replicas", 0) - ) - ); + assertAcked(prepareCreate("test").setSettings(indexSettings(cluster().numDataNodes() + 2, 0))); ensureGreen(); for (int i = 0; i < 10; i++) { client().prepareIndex("test").setId("" + i).setSource("field1", "value1").get(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java index 18fc34d11bc0c..0f3a269d8c111 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java @@ -934,11 +934,7 @@ public void testThatFuzzySuggesterIsUnicodeAware() throws Exception { public void testThatStatsAreWorking() throws Exception { String otherField = "testOtherField"; - client().admin() - .indices() - .prepareCreate(INDEX) - .setSettings(Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) - .get(); + client().admin().indices().prepareCreate(INDEX).setSettings(indexSettings(2, 0)).get(); ensureGreen(); AcknowledgedResponse putMappingResponse = client().admin() .indices() diff --git a/server/src/internalClusterTest/java/org/elasticsearch/similarity/SimilarityIT.java b/server/src/internalClusterTest/java/org/elasticsearch/similarity/SimilarityIT.java index d75f1e7249c06..e2327b3c2e5d2 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/similarity/SimilarityIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/similarity/SimilarityIT.java @@ -9,7 +9,6 @@ package org.elasticsearch.similarity; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESIntegTestCase; import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; @@ -46,12 +45,7 @@ public void testCustomBM25Similarity() throws Exception { .endObject() ) .setSettings( - Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 0) - .put("similarity.custom.type", "BM25") - .put("similarity.custom.k1", 2.0f) - .put("similarity.custom.b", 0.5f) + indexSettings(1, 0).put("similarity.custom.type", "BM25").put("similarity.custom.k1", 2.0f).put("similarity.custom.b", 0.5f) ) .execute() .actionGet(); diff --git a/server/src/main/java/org/elasticsearch/TransportVersion.java b/server/src/main/java/org/elasticsearch/TransportVersion.java index 56930e45b9eda..c07e476772ba1 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersion.java +++ b/server/src/main/java/org/elasticsearch/TransportVersion.java @@ -11,9 +11,11 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.core.Assertions; import java.io.IOException; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -21,28 +23,42 @@ import java.util.NavigableMap; import java.util.Set; import java.util.TreeMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Represents the version of the wire protocol used to communicate between ES nodes. *

- * Prior to 8.7.0, the node {@link Version} was used everywhere. This class separates the wire protocol version - * from the running node version. Each node version has a reference to a specific transport version used by that node. + * Prior to 8.8.0, the release {@link Version} was used everywhere. This class separates the wire protocol version + * from the release version. *

- * Each transport version constant has an id number, which for versions prior to 8.7.0 is the same as the node version - * for backwards compatibility. - * There is also a unique id string. This is not actually used in the protocol, but is there to ensure each protocol version - * is only added to the source file once. This string needs to be unique (here, a UUID, but can be any other unique nonempty string). - * If two concurrent PRs added the same protocol version, the unique string causes a git conflict, ensuring the second PR to be merged - * must be updated with the next free version. Without the unique id string, git will happily merge the two versions together, - * causing problems when you try to upgrade between those two PRs. + * Each transport version constant has an id number, which for versions prior to 8.9.0 is the same as the release version + * for backwards compatibility. In 8.9.0 this is changed to an incrementing number, disconnected from the release version. *

- * When adding new transport versions, it is recommended to leave a gap in the id number (say, 100) - * to leave space for any intermediate fixes that may be needed in the future. - *

- * The earliest compatible version is hardcoded at {@link #MINIMUM_COMPATIBLE}. Previously, this was dynamically calculated + * Each version constant has a unique id string. This is not actually used in the binary protocol, but is there to ensure + * each protocol version is only added to the source file once. This string needs to be unique (normally a UUID, + * but can be any other unique nonempty string). + * If two concurrent PRs add the same transport version, the different unique ids cause a git conflict, ensuring the second PR to be merged + * must be updated with the next free version first. Without the unique id string, git will happily merge the two versions together, + * resulting in the same transport version being used across multiple commits, + * causing problems when you try to upgrade between those two merged commits. + *

Version compatibility

+ * The earliest compatible version is hardcoded in the {@link #MINIMUM_COMPATIBLE} field. Previously, this was dynamically calculated * from the major/minor versions of {@link Version}, but {@code TransportVersion} does not have separate major/minor version numbers. - * So the minimum compatible version needs to be hard-coded as the transport version of the minimum compatible node version. - * That variable should be updated appropriately whenever we do a major version release. + * So the minimum compatible version is hard-coded as the transport version used by the highest minor release of the previous major version. + * {@link #MINIMUM_COMPATIBLE} should be updated appropriately whenever a major release happens. + *

+ * The earliest CCS compatible version is hardcoded at {@link #MINIMUM_CCS_VERSION}, as the transport version used by the + * previous minor release. This should be updated appropriately whenever a minor release happens. + *

Adding a new version

+ * A new transport version should be added every time a change is made to the serialization protocol of one or more classes. + * Each transport version should only be used in a single merged commit (apart from BwC versions copied from {@link Version}). + *

+ * To add a new transport version, add a new constant at the bottom of the list that is one greater than the current highest version, + * ensure it has a unique id, and update the {@link #CURRENT} constant to point to the new version. + *

Reverting a transport version

+ * If you revert a commit with a transport version change, you must ensure there is a new transport version + * representing the reverted change. Do not let the transport version go backwards, it must always be incremented. */ public class TransportVersion implements Comparable { public static final TransportVersion ZERO = new TransportVersion(0, "00000000-0000-0000-0000-000000000000"); @@ -138,23 +154,19 @@ public class TransportVersion implements Comparable { public static final TransportVersion V_8_9_0 = new TransportVersion(8_09_00_99, "13c1c2cb-d975-461f-ab98-309ebc1c01bc"); /* * READ THE JAVADOC ABOVE BEFORE ADDING NEW TRANSPORT VERSIONS - * Detached transport versions added below here. Starts at ES major version 10 equivalent. - */ - // NOTE: DO NOT UNCOMMENT until all transport code uses TransportVersion - // public static final TransportVersion V_10_000_000 = new TransportVersion(10_000_000, "dc3cbf06-3ed5-4e1b-9978-ee1d04d235bc"); - /* - * When adding a new transport version, ensure there is a gap (say, 100) between versions - * This is to make it possible to add intermediate versions for any bug fixes that may be required. - * - * When adding versions for patch fixes, add numbers in the middle of the gap. This is to ensure there is always some space - * for patch fixes between any two versions. + * Detached transport versions added below here. */ - /** Reference to the current transport version */ + /** + * Reference to the most recent transport version. + * This should be the transport version with the highest id. + */ public static final TransportVersion CURRENT = V_8_9_0; - /** Reference to the earliest compatible transport version to this version of the codebase */ - // TODO: can we programmatically calculate or check this? Don't want to introduce circular ref between Version/TransportVersion + /** + * Reference to the earliest compatible transport version to this version of the codebase. + * This should be the transport version used by the highest minor version of the previous major. + */ public static final TransportVersion MINIMUM_COMPATIBLE = V_7_17_0; /** @@ -164,32 +176,78 @@ public class TransportVersion implements Comparable { public static final TransportVersion MINIMUM_CCS_VERSION = V_8_7_0; static NavigableMap getAllVersionIds(Class cls) { + Map versionIdFields = new HashMap<>(); + Map uniqueIdFields = new HashMap<>(); NavigableMap builder = new TreeMap<>(); - Map uniqueIds = new HashMap<>(); Set ignore = Set.of("ZERO", "CURRENT", "MINIMUM_COMPATIBLE", "MINIMUM_CCS_VERSION"); + Pattern bwcVersionField = Pattern.compile("^V_(\\d_\\d{1,2}_\\d{1,2})$"); + Pattern transportVersionField = Pattern.compile("^V_(\\d+_\\d{3}_\\d{3})$"); + for (Field declaredField : cls.getFields()) { if (declaredField.getType().equals(TransportVersion.class)) { String fieldName = declaredField.getName(); if (ignore.contains(fieldName)) { continue; } - try { - TransportVersion version = (TransportVersion) declaredField.get(null); - TransportVersion maybePrevious = builder.put(version.id, version); - assert maybePrevious == null - : "expected [" + version.id + "] to be uniquely mapped but saw [" + maybePrevious + "] and [" + version + "]"; + // check the field modifiers + if (declaredField.getModifiers() != (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL)) { + assert false : "Version field [" + fieldName + "] should be public static final"; + continue; + } - TransportVersion sameUniqueId = uniqueIds.put(version.uniqueId, version); + TransportVersion version; + try { + version = (TransportVersion) declaredField.get(null); + } catch (IllegalAccessException e) { + // should not happen, checked above + throw new AssertionError(e); + } + builder.put(version.id, version); + + if (Assertions.ENABLED) { + // check the version number is unique + var sameVersionNumber = versionIdFields.put(version.id, fieldName); + assert sameVersionNumber == null + : "Versions [" + + sameVersionNumber + + "] and [" + + fieldName + + "] have the same version number [" + + version.id + + "]. Each TransportVersion should have a different version number"; + + // check the name matches the version number + try { + int fieldNumber; + int idNumber = version.id; + Matcher matcher = bwcVersionField.matcher(fieldName); + if (matcher.matches()) { + // match single digits _\d_ or _\d$ to put a 0 in front, but do not actually capture the _ or $ + fieldNumber = Integer.parseInt(matcher.group(1).replaceAll("_(\\d)(?=_|$)", "_0$1").replace("_", "")); + idNumber /= 100; // remove the extra '99' + } else if ((matcher = transportVersionField.matcher(fieldName)).matches()) { + fieldNumber = Integer.parseInt(matcher.group(1).replace("_", "")); + } else { + assert false : "Version [" + fieldName + "] does not have the correct name format"; + continue; + } + + assert fieldNumber == idNumber : "Version [" + fieldName + "] does not match its version number [" + idNumber + "]"; + } catch (NumberFormatException e) { + assert false : "Version [" + fieldName + "] does not have the correct name format"; + continue; + } + + // check the id is unique + var sameUniqueId = uniqueIdFields.put(version.uniqueId, fieldName); assert sameUniqueId == null - : "Versions " - + version - + " and " + : "Versions [" + + fieldName + + "] and [" + sameUniqueId - + " have the same unique id. Each TransportVersion should have a different unique id"; - } catch (IllegalAccessException e) { - assert false : "Version field [" + fieldName + "] should be public"; + + "] have the same unique id. Each TransportVersion should have a different unique id"; } } } @@ -197,11 +255,7 @@ static NavigableMap getAllVersionIds(Class cls) { return Collections.unmodifiableNavigableMap(builder); } - private static final NavigableMap VERSION_IDS; - - static { - VERSION_IDS = getAllVersionIds(TransportVersion.class); - } + private static final NavigableMap VERSION_IDS = getAllVersionIds(TransportVersion.class); static Collection getAllVersions() { return VERSION_IDS.values(); diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index 2f7f9331d4428..7b2d4a8ed40b2 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -31,7 +31,6 @@ import java.util.Objects; import java.util.TreeMap; -@SuppressWarnings("checkstyle:linelength") public class Version implements Comparable, ToXContentFragment { /* * The logic for ID is: XXYYZZAA, where XX is major version, YY is minor version, ZZ is revision, and AA is alpha/beta/rc indicator AA @@ -50,97 +49,97 @@ public class Version implements Comparable, ToXContentFragment { */ public static final int V_EMPTY_ID = 0; - public static final Version V_EMPTY = new Version(V_EMPTY_ID, TransportVersion.ZERO, org.apache.lucene.util.Version.LATEST); - public static final Version V_7_0_0 = new Version(7_00_00_99, TransportVersion.V_7_0_0, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_0_1 = new Version(7_00_01_99, TransportVersion.V_7_0_1, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_1_0 = new Version(7_01_00_99, TransportVersion.V_7_1_0, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_1_1 = new Version(7_01_01_99, TransportVersion.V_7_1_1, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_2_0 = new Version(7_02_00_99, TransportVersion.V_7_2_0, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_2_1 = new Version(7_02_01_99, TransportVersion.V_7_2_1, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_3_0 = new Version(7_03_00_99, TransportVersion.V_7_3_0, org.apache.lucene.util.Version.LUCENE_8_1_0); - public static final Version V_7_3_1 = new Version(7_03_01_99, TransportVersion.V_7_3_1, org.apache.lucene.util.Version.LUCENE_8_1_0); - public static final Version V_7_3_2 = new Version(7_03_02_99, TransportVersion.V_7_3_2, org.apache.lucene.util.Version.LUCENE_8_1_0); - public static final Version V_7_4_0 = new Version(7_04_00_99, TransportVersion.V_7_4_0, org.apache.lucene.util.Version.LUCENE_8_2_0); - public static final Version V_7_4_1 = new Version(7_04_01_99, TransportVersion.V_7_4_1, org.apache.lucene.util.Version.LUCENE_8_2_0); - public static final Version V_7_4_2 = new Version(7_04_02_99, TransportVersion.V_7_4_2, org.apache.lucene.util.Version.LUCENE_8_2_0); - public static final Version V_7_5_0 = new Version(7_05_00_99, TransportVersion.V_7_5_0, org.apache.lucene.util.Version.LUCENE_8_3_0); - public static final Version V_7_5_1 = new Version(7_05_01_99, TransportVersion.V_7_5_1, org.apache.lucene.util.Version.LUCENE_8_3_0); - public static final Version V_7_5_2 = new Version(7_05_02_99, TransportVersion.V_7_5_2, org.apache.lucene.util.Version.LUCENE_8_3_0); - public static final Version V_7_6_0 = new Version(7_06_00_99, TransportVersion.V_7_6_0, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final Version V_7_6_1 = new Version(7_06_01_99, TransportVersion.V_7_6_1, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final Version V_7_6_2 = new Version(7_06_02_99, TransportVersion.V_7_6_2, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final Version V_7_7_0 = new Version(7_07_00_99, TransportVersion.V_7_7_0, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_7_1 = new Version(7_07_01_99, TransportVersion.V_7_7_1, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_8_0 = new Version(7_08_00_99, TransportVersion.V_7_8_0, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_8_1 = new Version(7_08_01_99, TransportVersion.V_7_8_1, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_9_0 = new Version(7_09_00_99, TransportVersion.V_7_9_0, org.apache.lucene.util.Version.LUCENE_8_6_0); - public static final Version V_7_9_1 = new Version(7_09_01_99, TransportVersion.V_7_9_1, org.apache.lucene.util.Version.LUCENE_8_6_2); - public static final Version V_7_9_2 = new Version(7_09_02_99, TransportVersion.V_7_9_2, org.apache.lucene.util.Version.LUCENE_8_6_2); - public static final Version V_7_9_3 = new Version(7_09_03_99, TransportVersion.V_7_9_3, org.apache.lucene.util.Version.LUCENE_8_6_2); - public static final Version V_7_10_0 = new Version(7_10_00_99, TransportVersion.V_7_10_0, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_10_1 = new Version(7_10_01_99, TransportVersion.V_7_10_1, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_10_2 = new Version(7_10_02_99, TransportVersion.V_7_10_2, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_11_0 = new Version(7_11_00_99, TransportVersion.V_7_11_0, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_11_1 = new Version(7_11_01_99, TransportVersion.V_7_11_1, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_11_2 = new Version(7_11_02_99, TransportVersion.V_7_11_2, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_12_0 = new Version(7_12_00_99, TransportVersion.V_7_12_0, org.apache.lucene.util.Version.LUCENE_8_8_0); - public static final Version V_7_12_1 = new Version(7_12_01_99, TransportVersion.V_7_12_1, org.apache.lucene.util.Version.LUCENE_8_8_0); - public static final Version V_7_13_0 = new Version(7_13_00_99, TransportVersion.V_7_13_0, org.apache.lucene.util.Version.LUCENE_8_8_2); - public static final Version V_7_13_1 = new Version(7_13_01_99, TransportVersion.V_7_13_1, org.apache.lucene.util.Version.LUCENE_8_8_2); - public static final Version V_7_13_2 = new Version(7_13_02_99, TransportVersion.V_7_13_2, org.apache.lucene.util.Version.LUCENE_8_8_2); - public static final Version V_7_13_3 = new Version(7_13_03_99, TransportVersion.V_7_13_3, org.apache.lucene.util.Version.LUCENE_8_8_2); - public static final Version V_7_13_4 = new Version(7_13_04_99, TransportVersion.V_7_13_4, org.apache.lucene.util.Version.LUCENE_8_8_2); - public static final Version V_7_14_0 = new Version(7_14_00_99, TransportVersion.V_7_14_0, org.apache.lucene.util.Version.LUCENE_8_9_0); - public static final Version V_7_14_1 = new Version(7_14_01_99, TransportVersion.V_7_14_1, org.apache.lucene.util.Version.LUCENE_8_9_0); - public static final Version V_7_14_2 = new Version(7_14_02_99, TransportVersion.V_7_14_2, org.apache.lucene.util.Version.LUCENE_8_9_0); - public static final Version V_7_15_0 = new Version(7_15_00_99, TransportVersion.V_7_15_0, org.apache.lucene.util.Version.LUCENE_8_9_0); - public static final Version V_7_15_1 = new Version(7_15_01_99, TransportVersion.V_7_15_1, org.apache.lucene.util.Version.LUCENE_8_9_0); - public static final Version V_7_15_2 = new Version(7_15_02_99, TransportVersion.V_7_15_2, org.apache.lucene.util.Version.LUCENE_8_9_0); - public static final Version V_7_16_0 = new Version(7_16_00_99, TransportVersion.V_7_16_0, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_7_16_1 = new Version(7_16_01_99, TransportVersion.V_7_16_1, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_7_16_2 = new Version(7_16_02_99, TransportVersion.V_7_16_2, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_7_16_3 = new Version(7_16_03_99, TransportVersion.V_7_16_3, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_7_17_0 = new Version(7_17_00_99, TransportVersion.V_7_17_0, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_1 = new Version(7_17_01_99, TransportVersion.V_7_17_1, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_2 = new Version(7_17_02_99, TransportVersion.V_7_17_2, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_3 = new Version(7_17_03_99, TransportVersion.V_7_17_3, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_4 = new Version(7_17_04_99, TransportVersion.V_7_17_4, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_5 = new Version(7_17_05_99, TransportVersion.V_7_17_5, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_6 = new Version(7_17_06_99, TransportVersion.V_7_17_6, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_7 = new Version(7_17_07_99, TransportVersion.V_7_17_7, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_8 = new Version(7_17_08_99, TransportVersion.V_7_17_8, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_9 = new Version(7_17_09_99, TransportVersion.V_7_17_9, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_7_17_10 = new Version(7_17_10_99, TransportVersion.V_7_17_10, org.apache.lucene.util.Version.LUCENE_8_11_1); - public static final Version V_8_0_0 = new Version(8_00_00_99, TransportVersion.V_8_0_0, org.apache.lucene.util.Version.LUCENE_9_0_0); - public static final Version V_8_0_1 = new Version(8_00_01_99, TransportVersion.V_8_0_1, org.apache.lucene.util.Version.LUCENE_9_0_0); - public static final Version V_8_1_0 = new Version(8_01_00_99, TransportVersion.V_8_1_0, org.apache.lucene.util.Version.LUCENE_9_0_0); - public static final Version V_8_1_1 = new Version(8_01_01_99, TransportVersion.V_8_1_1, org.apache.lucene.util.Version.LUCENE_9_0_0); - public static final Version V_8_1_2 = new Version(8_01_02_99, TransportVersion.V_8_1_2, org.apache.lucene.util.Version.LUCENE_9_0_0); - public static final Version V_8_1_3 = new Version(8_01_03_99, TransportVersion.V_8_1_3, org.apache.lucene.util.Version.LUCENE_9_0_0); - public static final Version V_8_2_0 = new Version(8_02_00_99, TransportVersion.V_8_2_0, org.apache.lucene.util.Version.LUCENE_9_1_0); - public static final Version V_8_2_1 = new Version(8_02_01_99, TransportVersion.V_8_2_1, org.apache.lucene.util.Version.LUCENE_9_1_0); - public static final Version V_8_2_2 = new Version(8_02_02_99, TransportVersion.V_8_2_2, org.apache.lucene.util.Version.LUCENE_9_1_0); - public static final Version V_8_2_3 = new Version(8_02_03_99, TransportVersion.V_8_2_3, org.apache.lucene.util.Version.LUCENE_9_1_0); - public static final Version V_8_3_0 = new Version(8_03_00_99, TransportVersion.V_8_3_0, org.apache.lucene.util.Version.LUCENE_9_2_0); - public static final Version V_8_3_1 = new Version(8_03_01_99, TransportVersion.V_8_3_1, org.apache.lucene.util.Version.LUCENE_9_2_0); - public static final Version V_8_3_2 = new Version(8_03_02_99, TransportVersion.V_8_3_2, org.apache.lucene.util.Version.LUCENE_9_2_0); - public static final Version V_8_3_3 = new Version(8_03_03_99, TransportVersion.V_8_3_3, org.apache.lucene.util.Version.LUCENE_9_2_0); - public static final Version V_8_4_0 = new Version(8_04_00_99, TransportVersion.V_8_4_0, org.apache.lucene.util.Version.LUCENE_9_3_0); - public static final Version V_8_4_1 = new Version(8_04_01_99, TransportVersion.V_8_4_1, org.apache.lucene.util.Version.LUCENE_9_3_0); - public static final Version V_8_4_2 = new Version(8_04_02_99, TransportVersion.V_8_4_2, org.apache.lucene.util.Version.LUCENE_9_3_0); - public static final Version V_8_4_3 = new Version(8_04_03_99, TransportVersion.V_8_4_3, org.apache.lucene.util.Version.LUCENE_9_3_0); - public static final Version V_8_5_0 = new Version(8_05_00_99, TransportVersion.V_8_5_0, org.apache.lucene.util.Version.LUCENE_9_4_1); - public static final Version V_8_5_1 = new Version(8_05_01_99, TransportVersion.V_8_5_1, org.apache.lucene.util.Version.LUCENE_9_4_1); - public static final Version V_8_5_2 = new Version(8_05_02_99, TransportVersion.V_8_5_2, org.apache.lucene.util.Version.LUCENE_9_4_1); - public static final Version V_8_5_3 = new Version(8_05_03_99, TransportVersion.V_8_5_3, org.apache.lucene.util.Version.LUCENE_9_4_2); - public static final Version V_8_6_0 = new Version(8_06_00_99, TransportVersion.V_8_6_0, org.apache.lucene.util.Version.LUCENE_9_4_2); - public static final Version V_8_6_1 = new Version(8_06_01_99, TransportVersion.V_8_6_1, org.apache.lucene.util.Version.LUCENE_9_4_2); - public static final Version V_8_6_2 = new Version(8_06_02_99, TransportVersion.V_8_6_2, org.apache.lucene.util.Version.LUCENE_9_4_2); - public static final Version V_8_7_0 = new Version(8_07_00_99, TransportVersion.V_8_7_0, org.apache.lucene.util.Version.LUCENE_9_5_0); - public static final Version V_8_7_1 = new Version(8_07_01_99, TransportVersion.V_8_7_1, org.apache.lucene.util.Version.LUCENE_9_5_0); - - public static final Version V_8_8_0 = new Version(8_08_00_99, TransportVersion.V_8_8_0, org.apache.lucene.util.Version.LUCENE_9_6_0); - public static final Version V_8_9_0 = new Version(8_09_00_99, TransportVersion.V_8_9_0, org.apache.lucene.util.Version.LUCENE_9_6_0); + public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST); + public static final Version V_7_0_0 = new Version(7_00_00_99, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final Version V_7_0_1 = new Version(7_00_01_99, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final Version V_7_1_0 = new Version(7_01_00_99, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final Version V_7_1_1 = new Version(7_01_01_99, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final Version V_7_2_0 = new Version(7_02_00_99, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final Version V_7_2_1 = new Version(7_02_01_99, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final Version V_7_3_0 = new Version(7_03_00_99, org.apache.lucene.util.Version.LUCENE_8_1_0); + public static final Version V_7_3_1 = new Version(7_03_01_99, org.apache.lucene.util.Version.LUCENE_8_1_0); + public static final Version V_7_3_2 = new Version(7_03_02_99, org.apache.lucene.util.Version.LUCENE_8_1_0); + public static final Version V_7_4_0 = new Version(7_04_00_99, org.apache.lucene.util.Version.LUCENE_8_2_0); + public static final Version V_7_4_1 = new Version(7_04_01_99, org.apache.lucene.util.Version.LUCENE_8_2_0); + public static final Version V_7_4_2 = new Version(7_04_02_99, org.apache.lucene.util.Version.LUCENE_8_2_0); + public static final Version V_7_5_0 = new Version(7_05_00_99, org.apache.lucene.util.Version.LUCENE_8_3_0); + public static final Version V_7_5_1 = new Version(7_05_01_99, org.apache.lucene.util.Version.LUCENE_8_3_0); + public static final Version V_7_5_2 = new Version(7_05_02_99, org.apache.lucene.util.Version.LUCENE_8_3_0); + public static final Version V_7_6_0 = new Version(7_06_00_99, org.apache.lucene.util.Version.LUCENE_8_4_0); + public static final Version V_7_6_1 = new Version(7_06_01_99, org.apache.lucene.util.Version.LUCENE_8_4_0); + public static final Version V_7_6_2 = new Version(7_06_02_99, org.apache.lucene.util.Version.LUCENE_8_4_0); + public static final Version V_7_7_0 = new Version(7_07_00_99, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final Version V_7_7_1 = new Version(7_07_01_99, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final Version V_7_8_0 = new Version(7_08_00_99, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final Version V_7_8_1 = new Version(7_08_01_99, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final Version V_7_9_0 = new Version(7_09_00_99, org.apache.lucene.util.Version.LUCENE_8_6_0); + public static final Version V_7_9_1 = new Version(7_09_01_99, org.apache.lucene.util.Version.LUCENE_8_6_2); + public static final Version V_7_9_2 = new Version(7_09_02_99, org.apache.lucene.util.Version.LUCENE_8_6_2); + public static final Version V_7_9_3 = new Version(7_09_03_99, org.apache.lucene.util.Version.LUCENE_8_6_2); + public static final Version V_7_10_0 = new Version(7_10_00_99, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final Version V_7_10_1 = new Version(7_10_01_99, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final Version V_7_10_2 = new Version(7_10_02_99, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final Version V_7_11_0 = new Version(7_11_00_99, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final Version V_7_11_1 = new Version(7_11_01_99, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final Version V_7_11_2 = new Version(7_11_02_99, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final Version V_7_12_0 = new Version(7_12_00_99, org.apache.lucene.util.Version.LUCENE_8_8_0); + public static final Version V_7_12_1 = new Version(7_12_01_99, org.apache.lucene.util.Version.LUCENE_8_8_0); + public static final Version V_7_13_0 = new Version(7_13_00_99, org.apache.lucene.util.Version.LUCENE_8_8_2); + public static final Version V_7_13_1 = new Version(7_13_01_99, org.apache.lucene.util.Version.LUCENE_8_8_2); + public static final Version V_7_13_2 = new Version(7_13_02_99, org.apache.lucene.util.Version.LUCENE_8_8_2); + public static final Version V_7_13_3 = new Version(7_13_03_99, org.apache.lucene.util.Version.LUCENE_8_8_2); + public static final Version V_7_13_4 = new Version(7_13_04_99, org.apache.lucene.util.Version.LUCENE_8_8_2); + public static final Version V_7_14_0 = new Version(7_14_00_99, org.apache.lucene.util.Version.LUCENE_8_9_0); + public static final Version V_7_14_1 = new Version(7_14_01_99, org.apache.lucene.util.Version.LUCENE_8_9_0); + public static final Version V_7_14_2 = new Version(7_14_02_99, org.apache.lucene.util.Version.LUCENE_8_9_0); + public static final Version V_7_15_0 = new Version(7_15_00_99, org.apache.lucene.util.Version.LUCENE_8_9_0); + public static final Version V_7_15_1 = new Version(7_15_01_99, org.apache.lucene.util.Version.LUCENE_8_9_0); + public static final Version V_7_15_2 = new Version(7_15_02_99, org.apache.lucene.util.Version.LUCENE_8_9_0); + public static final Version V_7_16_0 = new Version(7_16_00_99, org.apache.lucene.util.Version.LUCENE_8_10_1); + public static final Version V_7_16_1 = new Version(7_16_01_99, org.apache.lucene.util.Version.LUCENE_8_10_1); + public static final Version V_7_16_2 = new Version(7_16_02_99, org.apache.lucene.util.Version.LUCENE_8_10_1); + public static final Version V_7_16_3 = new Version(7_16_03_99, org.apache.lucene.util.Version.LUCENE_8_10_1); + public static final Version V_7_17_0 = new Version(7_17_00_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_1 = new Version(7_17_01_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_2 = new Version(7_17_02_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_3 = new Version(7_17_03_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_4 = new Version(7_17_04_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_5 = new Version(7_17_05_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_6 = new Version(7_17_06_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_7 = new Version(7_17_07_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_8 = new Version(7_17_08_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_9 = new Version(7_17_09_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_7_17_10 = new Version(7_17_10_99, org.apache.lucene.util.Version.LUCENE_8_11_1); + public static final Version V_8_0_0 = new Version(8_00_00_99, org.apache.lucene.util.Version.LUCENE_9_0_0); + public static final Version V_8_0_1 = new Version(8_00_01_99, org.apache.lucene.util.Version.LUCENE_9_0_0); + public static final Version V_8_1_0 = new Version(8_01_00_99, org.apache.lucene.util.Version.LUCENE_9_0_0); + public static final Version V_8_1_1 = new Version(8_01_01_99, org.apache.lucene.util.Version.LUCENE_9_0_0); + public static final Version V_8_1_2 = new Version(8_01_02_99, org.apache.lucene.util.Version.LUCENE_9_0_0); + public static final Version V_8_1_3 = new Version(8_01_03_99, org.apache.lucene.util.Version.LUCENE_9_0_0); + public static final Version V_8_2_0 = new Version(8_02_00_99, org.apache.lucene.util.Version.LUCENE_9_1_0); + public static final Version V_8_2_1 = new Version(8_02_01_99, org.apache.lucene.util.Version.LUCENE_9_1_0); + public static final Version V_8_2_2 = new Version(8_02_02_99, org.apache.lucene.util.Version.LUCENE_9_1_0); + public static final Version V_8_2_3 = new Version(8_02_03_99, org.apache.lucene.util.Version.LUCENE_9_1_0); + public static final Version V_8_3_0 = new Version(8_03_00_99, org.apache.lucene.util.Version.LUCENE_9_2_0); + public static final Version V_8_3_1 = new Version(8_03_01_99, org.apache.lucene.util.Version.LUCENE_9_2_0); + public static final Version V_8_3_2 = new Version(8_03_02_99, org.apache.lucene.util.Version.LUCENE_9_2_0); + public static final Version V_8_3_3 = new Version(8_03_03_99, org.apache.lucene.util.Version.LUCENE_9_2_0); + public static final Version V_8_4_0 = new Version(8_04_00_99, org.apache.lucene.util.Version.LUCENE_9_3_0); + public static final Version V_8_4_1 = new Version(8_04_01_99, org.apache.lucene.util.Version.LUCENE_9_3_0); + public static final Version V_8_4_2 = new Version(8_04_02_99, org.apache.lucene.util.Version.LUCENE_9_3_0); + public static final Version V_8_4_3 = new Version(8_04_03_99, org.apache.lucene.util.Version.LUCENE_9_3_0); + public static final Version V_8_5_0 = new Version(8_05_00_99, org.apache.lucene.util.Version.LUCENE_9_4_1); + public static final Version V_8_5_1 = new Version(8_05_01_99, org.apache.lucene.util.Version.LUCENE_9_4_1); + public static final Version V_8_5_2 = new Version(8_05_02_99, org.apache.lucene.util.Version.LUCENE_9_4_1); + public static final Version V_8_5_3 = new Version(8_05_03_99, org.apache.lucene.util.Version.LUCENE_9_4_2); + public static final Version V_8_6_0 = new Version(8_06_00_99, org.apache.lucene.util.Version.LUCENE_9_4_2); + public static final Version V_8_6_1 = new Version(8_06_01_99, org.apache.lucene.util.Version.LUCENE_9_4_2); + public static final Version V_8_6_2 = new Version(8_06_02_99, org.apache.lucene.util.Version.LUCENE_9_4_2); + public static final Version V_8_7_0 = new Version(8_07_00_99, org.apache.lucene.util.Version.LUCENE_9_5_0); + public static final Version V_8_7_1 = new Version(8_07_01_99, org.apache.lucene.util.Version.LUCENE_9_5_0); + + public static final Version V_8_8_0 = new Version(8_08_00_99, org.apache.lucene.util.Version.LUCENE_9_6_0); + public static final Version V_8_9_0 = new Version(8_09_00_99, org.apache.lucene.util.Version.LUCENE_9_6_0); public static final Version CURRENT = V_8_9_0; private static final NavigableMap VERSION_IDS; @@ -211,7 +210,7 @@ private static Version fromIdSlow(int id) { // Our best guess is to use the same Lucene version as the previous // version in the list, assuming that it didn't change. List versions = DeclaredVersionsHolder.DECLARED_VERSIONS; - Version tmp = new Version(id, TransportVersion.CURRENT, org.apache.lucene.util.Version.LATEST); + Version tmp = new Version(id, org.apache.lucene.util.Version.LATEST); int index = Collections.binarySearch(versions, tmp); if (index < 0) { index = -2 - index; @@ -227,8 +226,7 @@ private static Version fromIdSlow(int id) { } else { luceneVersion = versions.get(index).luceneVersion; } - // TODO: assume this is an old version that has transport version == release version - return new Version(id, TransportVersion.fromId(id), luceneVersion); + return new Version(id, luceneVersion); } public static void writeVersion(Version version, StreamOutput out) throws IOException { @@ -311,18 +309,16 @@ private static Version fromStringSlow(String version) { public final byte minor; public final byte revision; public final byte build; - public final TransportVersion transportVersion; public final org.apache.lucene.util.Version luceneVersion; private final String toString; private final int previousMajorId; - Version(int id, TransportVersion transportVersion, org.apache.lucene.util.Version luceneVersion) { + Version(int id, org.apache.lucene.util.Version luceneVersion) { this.id = id; this.major = (byte) ((id / 1000000) % 100); this.minor = (byte) ((id / 10000) % 100); this.revision = (byte) ((id / 100) % 100); this.build = (byte) (id % 100); - this.transportVersion = Objects.requireNonNull(transportVersion); this.luceneVersion = Objects.requireNonNull(luceneVersion); this.toString = major + "." + minor + "." + revision; this.previousMajorId = major > 0 ? (major - 1) * 1000000 + 99 : major; diff --git a/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java b/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java index a8e1103245e24..f3b9e21569ed4 100644 --- a/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java +++ b/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java @@ -16,10 +16,12 @@ import org.elasticsearch.action.admin.indices.refresh.UnpromotableShardRefreshRequest; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.core.Nullable; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportService; public class PostWriteRefresh { @@ -35,15 +37,16 @@ public void refreshShard( WriteRequest.RefreshPolicy policy, IndexShard indexShard, @Nullable Translog.Location location, - ActionListener listener + ActionListener listener, + @Nullable TimeValue postWriteRefreshTimeout ) { switch (policy) { case NONE -> listener.onResponse(false); case WAIT_UNTIL -> waitUntil(indexShard, location, new ActionListener<>() { @Override public void onResponse(Boolean forced) { - if (indexShard.getReplicationGroup().getRoutingTable().unpromotableShards().size() > 0 && location != null) { - refreshUnpromotables(indexShard, location, listener, forced); + if (indexShard.routingEntry().isSearchable() == false && location != null) { + refreshUnpromotables(indexShard, location, listener, forced, postWriteRefreshTimeout); } else { listener.onResponse(forced); } @@ -58,7 +61,7 @@ public void onFailure(Exception e) { @Override public void onResponse(Engine.RefreshResult refreshResult) { if (indexShard.getReplicationGroup().getRoutingTable().unpromotableShards().size() > 0) { - sendUnpromotableRequests(indexShard, refreshResult.generation(), true, listener); + sendUnpromotableRequests(indexShard, refreshResult.generation(), true, listener, postWriteRefreshTimeout); } else { listener.onResponse(true); } @@ -100,27 +103,49 @@ private static void waitUntil(IndexShard indexShard, Translog.Location location, } } - private void refreshUnpromotables(IndexShard indexShard, Translog.Location location, ActionListener listener, boolean forced) { + private void refreshUnpromotables( + IndexShard indexShard, + Translog.Location location, + ActionListener listener, + boolean forced, + @Nullable TimeValue postWriteRefreshTimeout + ) { Engine engineOrNull = indexShard.getEngineOrNull(); if (engineOrNull == null) { listener.onFailure(new AlreadyClosedException("Engine closed during refresh.")); return; } - engineOrNull.addFlushListener(location, new ActionListener<>() { + engineOrNull.addFlushListener(location, ActionListener.wrap(new ActionListener<>() { @Override public void onResponse(Long generation) { - sendUnpromotableRequests(indexShard, generation, forced, listener); + engineOrNull.addFlushDurabilityListener(generation, ActionListener.wrap(new ActionListener<>() { + @Override + public void onResponse(Void unused) { + sendUnpromotableRequests(indexShard, generation, forced, listener, postWriteRefreshTimeout); + } + + @Override + public void onFailure(Exception e) { + listener.onFailure(e); + } + })); } @Override public void onFailure(Exception e) { listener.onFailure(e); } - }); + })); } - private void sendUnpromotableRequests(IndexShard indexShard, long generation, boolean wasForced, ActionListener listener) { + private void sendUnpromotableRequests( + IndexShard indexShard, + long generation, + boolean wasForced, + ActionListener listener, + @Nullable TimeValue postWriteRefreshTimeout + ) { UnpromotableShardRefreshRequest unpromotableReplicaRequest = new UnpromotableShardRefreshRequest( indexShard.getReplicationGroup().getRoutingTable(), generation @@ -129,6 +154,7 @@ private void sendUnpromotableRequests(IndexShard indexShard, long generation, bo transportService.getLocalNode(), TransportUnpromotableShardRefreshAction.NAME, unpromotableReplicaRequest, + TransportRequestOptions.timeout(postWriteRefreshTimeout), new ActionListenerResponseHandler<>( listener.delegateFailure((l, r) -> l.onResponse(wasForced)), (in) -> ActionResponse.Empty.INSTANCE, diff --git a/server/src/main/java/org/elasticsearch/action/support/replication/TransportWriteAction.java b/server/src/main/java/org/elasticsearch/action/support/replication/TransportWriteAction.java index 9bba8e25aba7d..a158a240031cf 100644 --- a/server/src/main/java/org/elasticsearch/action/support/replication/TransportWriteAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/replication/TransportWriteAction.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.Releasable; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.IndexingPressure; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.mapper.MapperParsingException; @@ -421,10 +422,11 @@ static final class AsyncAfterWriteAction { private final Logger logger; private final PostWriteRefresh postWriteRefresh; private final Consumer postWriteAction; + private final TimeValue postWriteRefreshTimeout; AsyncAfterWriteAction( final IndexShard indexShard, - final WriteRequest request, + final ReplicatedWriteRequest request, @Nullable final Translog.Location location, final RespondingWriteResult respond, final Logger logger, @@ -448,6 +450,7 @@ static final class AsyncAfterWriteAction { pendingOps.incrementAndGet(); } this.logger = logger; + this.postWriteRefreshTimeout = request.timeout(); assert pendingOps.get() >= 0 && pendingOps.get() <= 3 : "pendingOps was: " + pendingOps.get(); } @@ -499,7 +502,13 @@ public void onFailure(Exception e) { }; // If the post refresh action is null, this is just the replica and we only call the static method if (postWriteRefresh != null) { - postWriteRefresh.refreshShard(request.getRefreshPolicy(), indexShard, location, refreshListener); + postWriteRefresh.refreshShard( + request.getRefreshPolicy(), + indexShard, + location, + refreshListener, + postWriteRefreshTimeout + ); } else { PostWriteRefresh.refreshReplicaShard(request.getRefreshPolicy(), indexShard, location, refreshListener); } diff --git a/server/src/main/java/org/elasticsearch/index/engine/Engine.java b/server/src/main/java/org/elasticsearch/index/engine/Engine.java index b30aa5472a546..69171f63dcba8 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/Engine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/Engine.java @@ -1985,6 +1985,15 @@ public void addFlushListener(Translog.Location location, ActionListener li listener.onFailure(new UnsupportedOperationException("Engine type " + this.getClass() + " does not support flush listeners.")); } + /** + * Adds a listener which will be executed once the request generation has been durably persisted. + */ + public void addFlushDurabilityListener(long generation, ActionListener listener) { + listener.onFailure( + new UnsupportedOperationException("Engine type " + this.getClass() + " does not support generation durability listeners.") + ); + } + /** * Captures the result of a refresh operation on the index shard. *

diff --git a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 7b57b43a25ec8..1d497ab7ca292 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -3161,4 +3161,13 @@ public void onFailure(Exception e) { protected void waitForCommitDurability(long generation, ActionListener listener) { listener.onResponse(null); } + + @Override + public void addFlushDurabilityListener(long generation, ActionListener listener) { + ensureOpen(); + if (lastCommittedSegmentInfos.getGeneration() < generation) { + listener.onFailure(new IllegalStateException("Cannot wait on generation which has not been committed")); + } + listener.onResponse(null); + } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java index f422714f058f2..545f5d6ba850e 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java @@ -866,6 +866,10 @@ private void indexValue(DocumentParserContext context, String value) { if (value == null) { return; } + // if field is disabled, skip indexing + if ((fieldType.indexOptions() == IndexOptions.NONE) && (fieldType.stored() == false) && (fieldType().hasDocValues() == false)) { + return; + } if (value.length() > fieldType().ignoreAbove()) { context.addIgnoredField(name()); @@ -885,35 +889,31 @@ private void indexValue(DocumentParserContext context, String value) { context.getDimensions().addString(fieldType().name(), binaryValue); } - if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored() || fieldType().hasDocValues()) { - // If the UTF8 encoding of the field value is bigger than the max length 32766, Lucene fill fail the indexing request and, to - // roll back the changes, will mark the (possibly partially indexed) document as deleted. This results in deletes, even in an - // append-only workload, which in turn leads to slower merges, as these will potentially have to fall back to MergeStrategy.DOC - // instead of MergeStrategy.BULK. To avoid this, we do a preflight check here before indexing the document into Lucene. - if (binaryValue.length > MAX_TERM_LENGTH) { - byte[] prefix = new byte[30]; - System.arraycopy(binaryValue.bytes, binaryValue.offset, prefix, 0, 30); - String msg = "Document contains at least one immense term in field=\"" - + fieldType().name() - + "\" (whose " - + "UTF8 encoding is longer than the max length " - + MAX_TERM_LENGTH - + "), all of which were " - + "skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense " - + "term is: '" - + Arrays.toString(prefix) - + "...'"; - throw new IllegalArgumentException(msg); - } + // If the UTF8 encoding of the field value is bigger than the max length 32766, Lucene fill fail the indexing request and, to + // roll back the changes, will mark the (possibly partially indexed) document as deleted. This results in deletes, even in an + // append-only workload, which in turn leads to slower merges, as these will potentially have to fall back to MergeStrategy.DOC + // instead of MergeStrategy.BULK. To avoid this, we do a preflight check here before indexing the document into Lucene. + if (binaryValue.length > MAX_TERM_LENGTH) { + byte[] prefix = new byte[30]; + System.arraycopy(binaryValue.bytes, binaryValue.offset, prefix, 0, 30); + String msg = "Document contains at least one immense term in field=\"" + + fieldType().name() + + "\" (whose " + + "UTF8 encoding is longer than the max length " + + MAX_TERM_LENGTH + + "), all of which were " + + "skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense " + + "term is: '" + + Arrays.toString(prefix) + + "...'"; + throw new IllegalArgumentException(msg); + } - if (fieldType.indexOptions() != IndexOptions.NONE || fieldType().hasDocValues() || fieldType.stored()) { - Field field = new KeywordField(fieldType().name(), binaryValue, fieldType); - context.doc().add(field); + Field field = new KeywordField(fieldType().name(), binaryValue, fieldType); + context.doc().add(field); - if (fieldType().hasDocValues() == false && fieldType.omitNorms()) { - context.addToFieldNames(fieldType().name()); - } - } + if (fieldType().hasDocValues() == false && fieldType.omitNorms()) { + context.addToFieldNames(fieldType().name()); } } diff --git a/server/src/main/java/org/elasticsearch/index/translog/TranslogWriter.java b/server/src/main/java/org/elasticsearch/index/translog/TranslogWriter.java index 9550de70eb64f..c390ace777d3b 100644 --- a/server/src/main/java/org/elasticsearch/index/translog/TranslogWriter.java +++ b/server/src/main/java/org/elasticsearch/index/translog/TranslogWriter.java @@ -84,6 +84,12 @@ public class TranslogWriter extends BaseTranslogReader implements Closeable { private final DiskIoBufferPool diskIoBufferPool; + // package private for testing + LastModifiedTimeCache lastModifiedTimeCache; + + // package private for testing + record LastModifiedTimeCache(long lastModifiedTime, long totalOffset, long syncedOffset) {} + private TranslogWriter( final ShardId shardId, final Checkpoint initialCheckpoint, @@ -127,6 +133,7 @@ private TranslogWriter( this.seenSequenceNumbers = Assertions.ENABLED ? new HashMap<>() : null; this.tragedy = tragedy; this.operationListener = operationListener; + this.lastModifiedTimeCache = new LastModifiedTimeCache(-1, -1, -1); } public static TranslogWriter create( @@ -642,4 +649,13 @@ public final void close() throws IOException { protected final boolean isClosed() { return closed.get(); } + + @Override + public long getLastModifiedTime() throws IOException { + if (lastModifiedTimeCache.totalOffset() != totalOffset || lastModifiedTimeCache.syncedOffset() != lastSyncedCheckpoint.offset) { + long mtime = super.getLastModifiedTime(); + lastModifiedTimeCache = new LastModifiedTimeCache(mtime, totalOffset, lastSyncedCheckpoint.offset); + } + return lastModifiedTimeCache.lastModifiedTime(); + } } diff --git a/server/src/main/java/org/elasticsearch/search/SearchService.java b/server/src/main/java/org/elasticsearch/search/SearchService.java index bd041b6ad05f5..1d349a6940cff 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchService.java +++ b/server/src/main/java/org/elasticsearch/search/SearchService.java @@ -1255,7 +1255,7 @@ private void parseSource(DefaultSearchContext context, SearchSourceBuilder sourc */ () -> context.rewrittenQuery() == null ? new MatchAllDocsQuery() : context.rewrittenQuery(), context.getProfilers() == null ? null : context.getProfilers().getAggregationProfiler(), - multiBucketConsumerService.create(), + multiBucketConsumerService.getLimit(), () -> new SubSearchContext(context).parsedQuery(context.parsedQuery()).fetchFieldsContext(context.fetchFieldsContext()), context.bitsetFilterCache(), context.indexShard().shardId().hashCode(), diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java b/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java index 77794c5701092..b0c1a95cdc67b 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java @@ -107,10 +107,6 @@ public static void execute(SearchContext context) { Aggregator[] aggregators = context.aggregations().aggregators(); List aggregations = new ArrayList<>(aggregators.length); - if (context.aggregations().factories().context() != null) { - // Rollup can end up here with a null context but not null factories..... - context.aggregations().factories().context().multiBucketConsumer().reset(); - } for (Aggregator aggregator : context.aggregations().aggregators()) { try { aggregator.postCollection(); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketConsumerService.java b/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketConsumerService.java index 85747ce9e379e..5d29a7104c0b9 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketConsumerService.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketConsumerService.java @@ -125,20 +125,16 @@ public void accept(int value) { } } - public void reset() { - this.count = 0; - } - public int getCount() { return count; } - - public int getLimit() { - return limit; - } } public MultiBucketConsumer create() { return new MultiBucketConsumer(maxBucket, breaker); } + + public int getLimit() { + return maxBucket; + } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java index 3eac58db2d0df..6997d1f96c907 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java @@ -8,6 +8,7 @@ package org.elasticsearch.search.aggregations.bucket; import org.apache.lucene.index.LeafReaderContext; +import org.elasticsearch.common.breaker.CircuitBreaker; import org.elasticsearch.common.util.LongArray; import org.elasticsearch.core.Releasable; import org.elasticsearch.search.aggregations.AggregationExecutionException; @@ -34,14 +35,14 @@ import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Function; -import java.util.function.IntConsumer; import java.util.function.LongUnaryOperator; import java.util.function.ToLongFunction; public abstract class BucketsAggregator extends AggregatorBase { - private final IntConsumer multiBucketConsumer; + private final CircuitBreaker breaker; private LongArray docCounts; protected final DocCountProvider docCountProvider; + private int callCount; public BucketsAggregator( String name, @@ -52,7 +53,7 @@ public BucketsAggregator( Map metadata ) throws IOException { super(name, factories, aggCtx, parent, bucketCardinality, metadata); - multiBucketConsumer = aggCtx.multiBucketConsumer(); + breaker = aggCtx.breaker(); docCounts = bigArrays().newLongArray(1, true); docCountProvider = new DocCountProvider(); } @@ -85,10 +86,12 @@ public final void collectBucket(LeafBucketCollector subCollector, int doc, long public final void collectExistingBucket(LeafBucketCollector subCollector, int doc, long bucketOrd) throws IOException { int docCount = docCountProvider.getDocCount(doc); if (docCounts.increment(bucketOrd, docCount) == docCount) { - // We calculate the final number of buckets only during the reduce phase. But we still need to - // trigger bucket consumer from time to time in order to give it a chance to check available memory and break - // the execution if we are running out. To achieve that we are passing 0 as a bucket count. - multiBucketConsumer.accept(0); + // We call the circuit breaker the time to time in order to give it a chance to check available + // memory in the parent breaker and break the execution if we are running out. To achieve that we + // are passing 0 as the estimated bytes every 1024 calls + if ((++callCount & 0x3FF) == 0) { + breaker.addEstimateBytesAndMaybeBreak(0, "allocated_buckets"); + } } subCollector.collect(doc, bucketOrd); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java index 3d99d6fe1f265..3dcc48c8f69d2 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java @@ -105,7 +105,7 @@ public final class CompositeAggregator extends BucketsAggregator implements Size this.formats = Arrays.stream(sourceConfigs).map(CompositeValuesSourceConfig::format).toList(); this.sources = new SingleDimensionValuesSource[sourceConfigs.length]; // check that the provided size is not greater than the search.max_buckets setting - int bucketLimit = aggCtx.multiBucketConsumer().getLimit(); + int bucketLimit = aggCtx.maxBuckets(); if (size > bucketLimit) { throw new MultiBucketConsumerService.TooManyBucketsException( "Trying to create too many buckets. Must be less than or equal" diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationContext.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationContext.java index df5ede180ad30..30ecd980609ac 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationContext.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationContext.java @@ -37,7 +37,6 @@ import org.elasticsearch.search.aggregations.AggregationExecutionContext; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.BucketCollector; -import org.elasticsearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer; import org.elasticsearch.search.aggregations.bucket.filter.FilterByFilterAggregator; import org.elasticsearch.search.internal.SubSearchContext; import org.elasticsearch.search.lookup.SearchLookup; @@ -230,7 +229,10 @@ public final AggregationUsageService getUsageService() { */ public abstract void addReleasable(Aggregator aggregator); - public abstract MultiBucketConsumer multiBucketConsumer(); + /** + * Max buckets provided by the search.max_buckets setting + */ + public abstract int maxBuckets(); /** * Get the filter cache. @@ -330,7 +332,7 @@ public static class ProductionAggregationContext extends AggregationContext { private final BigArrays bigArrays; private final Supplier topLevelQuery; private final AggregationProfiler profiler; - private final MultiBucketConsumer multiBucketConsumer; + private final int maxBuckets; private final Supplier subSearchContextBuilder; private final BitsetFilterCache bitsetFilterCache; private final int randomSeed; @@ -350,7 +352,7 @@ public ProductionAggregationContext( long bytesToPreallocate, Supplier topLevelQuery, @Nullable AggregationProfiler profiler, - MultiBucketConsumer multiBucketConsumer, + int maxBuckets, Supplier subSearchContextBuilder, BitsetFilterCache bitsetFilterCache, int randomSeed, @@ -383,7 +385,7 @@ public ProductionAggregationContext( } this.topLevelQuery = topLevelQuery; this.profiler = profiler; - this.multiBucketConsumer = multiBucketConsumer; + this.maxBuckets = maxBuckets; this.subSearchContextBuilder = subSearchContextBuilder; this.bitsetFilterCache = bitsetFilterCache; this.randomSeed = randomSeed; @@ -519,8 +521,8 @@ public void addReleasable(Aggregator aggregator) { } @Override - public MultiBucketConsumer multiBucketConsumer() { - return multiBucketConsumer; + public int maxBuckets() { + return maxBuckets; } @Override diff --git a/server/src/test/java/org/elasticsearch/TransportVersionTests.java b/server/src/test/java/org/elasticsearch/TransportVersionTests.java index d4530717afdf2..91b37cc47e679 100644 --- a/server/src/test/java/org/elasticsearch/TransportVersionTests.java +++ b/server/src/test/java/org/elasticsearch/TransportVersionTests.java @@ -12,11 +12,13 @@ import org.elasticsearch.test.TransportVersionUtils; import java.lang.reflect.Modifier; +import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; @@ -54,30 +56,50 @@ private static String padNumber(String number) { } public static class CorrectFakeVersion { - public static final TransportVersion V1 = new TransportVersion(1, "1"); - public static final TransportVersion V2 = new TransportVersion(2, "2"); - public static final TransportVersion V3 = new TransportVersion(3, "3"); + public static final TransportVersion V_0_00_01 = new TransportVersion(199, "1"); + public static final TransportVersion V_0_000_002 = new TransportVersion(2, "2"); + public static final TransportVersion V_0_000_003 = new TransportVersion(3, "3"); + public static final TransportVersion V_0_000_004 = new TransportVersion(4, "4"); + } + + public static class IncorrectFormatVersion { + public static final TransportVersion V_1 = new TransportVersion(1, "1"); } public static class DuplicatedIdFakeVersion { - public static final TransportVersion V1 = new TransportVersion(1, "1"); - public static final TransportVersion V2 = new TransportVersion(2, "2"); - public static final TransportVersion V3 = new TransportVersion(2, "3"); + public static final TransportVersion V_0_000_001 = new TransportVersion(1, "1"); + public static final TransportVersion V_0_000_002 = new TransportVersion(2, "2"); + public static final TransportVersion V_0_000_003 = new TransportVersion(2, "3"); } public static class DuplicatedStringIdFakeVersion { - public static final TransportVersion V1 = new TransportVersion(1, "1"); - public static final TransportVersion V2 = new TransportVersion(2, "2"); - public static final TransportVersion V3 = new TransportVersion(3, "2"); + public static final TransportVersion V_0_000_001 = new TransportVersion(1, "1"); + public static final TransportVersion V_0_000_002 = new TransportVersion(2, "2"); + public static final TransportVersion V_0_000_003 = new TransportVersion(3, "2"); } public void testStaticTransportVersionChecks() { assertThat( TransportVersion.getAllVersionIds(CorrectFakeVersion.class), - equalTo(Map.of(1, CorrectFakeVersion.V1, 2, CorrectFakeVersion.V2, 3, CorrectFakeVersion.V3)) + equalTo( + Map.of( + 199, + CorrectFakeVersion.V_0_00_01, + 2, + CorrectFakeVersion.V_0_000_002, + 3, + CorrectFakeVersion.V_0_000_003, + 4, + CorrectFakeVersion.V_0_000_004 + ) + ) ); - expectThrows(AssertionError.class, () -> TransportVersion.getAllVersionIds(DuplicatedIdFakeVersion.class)); - expectThrows(AssertionError.class, () -> TransportVersion.getAllVersionIds(DuplicatedStringIdFakeVersion.class)); + AssertionError e = expectThrows(AssertionError.class, () -> TransportVersion.getAllVersionIds(IncorrectFormatVersion.class)); + assertThat(e.getMessage(), containsString("does not have the correct name format")); + e = expectThrows(AssertionError.class, () -> TransportVersion.getAllVersionIds(DuplicatedIdFakeVersion.class)); + assertThat(e.getMessage(), containsString("have the same version number")); + e = expectThrows(AssertionError.class, () -> TransportVersion.getAllVersionIds(DuplicatedStringIdFakeVersion.class)); + assertThat(e.getMessage(), containsString("have the same unique id")); } public void testDefinedConstants() throws IllegalAccessException { @@ -144,7 +166,6 @@ public void testMax() { } public void testVersionConstantPresent() { - // TODO those versions are not cached at the moment, perhaps we should add them to idToVersion set too? Set ignore = Set.of(TransportVersion.ZERO, TransportVersion.CURRENT, TransportVersion.MINIMUM_COMPATIBLE); assertThat(TransportVersion.CURRENT, sameInstance(TransportVersion.fromId(TransportVersion.CURRENT.id))); final int iters = scaledRandomIntBetween(20, 100); @@ -156,17 +177,7 @@ public void testVersionConstantPresent() { } public void testCURRENTIsLatest() { - final int iters = scaledRandomIntBetween(100, 1000); - for (int i = 0; i < iters; i++) { - TransportVersion version = TransportVersionUtils.randomVersion(); - if (version != TransportVersion.CURRENT) { - assertThat( - "Version: " + version + " should be before: " + Version.CURRENT + " but wasn't", - version.before(TransportVersion.CURRENT), - is(true) - ); - } - } + assertThat(Collections.max(TransportVersion.getAllVersions()), is(TransportVersion.CURRENT)); } public void testToString() { diff --git a/server/src/test/java/org/elasticsearch/VersionTests.java b/server/src/test/java/org/elasticsearch/VersionTests.java index 26a5415473d07..a2635dd95f14b 100644 --- a/server/src/test/java/org/elasticsearch/VersionTests.java +++ b/server/src/test/java/org/elasticsearch/VersionTests.java @@ -178,7 +178,7 @@ public void testParseVersion() { for (int i = 0; i < iters; i++) { Version version = randomVersion(random()); if (random().nextBoolean()) { - version = new Version(version.id, version.transportVersion, version.luceneVersion); + version = new Version(version.id, version.luceneVersion); } Version parsedVersion = Version.fromString(version.toString()); assertEquals(version, parsedVersion); diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java index a0f7bb1a054b2..d00dd007db57d 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java @@ -22,12 +22,14 @@ import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Releasable; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.engine.DocIdSeqNoAndSource; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.engine.EngineTestCase; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.IndexShardTestCase; import org.elasticsearch.index.shard.ReplicationGroup; +import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -48,6 +50,7 @@ public class PostWriteRefreshTests extends IndexShardTestCase { + private final TimeValue postWriteRefreshTimeout = TimeValue.timeValueSeconds(30); private final AtomicBoolean unpromotableRefreshRequestReceived = new AtomicBoolean(false); private TransportService transportService; @@ -83,7 +86,13 @@ public void testWaitUntilRefreshPrimaryShard() throws IOException { Engine.IndexResult result = indexDoc(primary, "_doc", id); PlainActionFuture f = PlainActionFuture.newFuture(); PostWriteRefresh postWriteRefresh = new PostWriteRefresh(transportService); - postWriteRefresh.refreshShard(WriteRequest.RefreshPolicy.WAIT_UNTIL, primary, result.getTranslogLocation(), f); + postWriteRefresh.refreshShard( + WriteRequest.RefreshPolicy.WAIT_UNTIL, + primary, + result.getTranslogLocation(), + f, + postWriteRefreshTimeout + ); Releasable releasable = simulateScheduledRefresh(primary, false); f.actionGet(); assertFalse(unpromotableRefreshRequestReceived.get()); @@ -102,7 +111,13 @@ public void testImmediateRefreshPrimaryShard() throws IOException { Engine.IndexResult result = indexDoc(primary, "_doc", id); PlainActionFuture f = PlainActionFuture.newFuture(); PostWriteRefresh postWriteRefresh = new PostWriteRefresh(transportService); - postWriteRefresh.refreshShard(WriteRequest.RefreshPolicy.IMMEDIATE, primary, result.getTranslogLocation(), f); + postWriteRefresh.refreshShard( + WriteRequest.RefreshPolicy.IMMEDIATE, + primary, + result.getTranslogLocation(), + f, + postWriteRefreshTimeout + ); f.actionGet(); assertFalse(unpromotableRefreshRequestReceived.get()); assertEngineContainsIdNoRefresh(primary, id); @@ -123,18 +138,28 @@ public void testPrimaryWithUnpromotables() throws IOException { ReplicationGroup replicationGroup = mock(ReplicationGroup.class); IndexShardRoutingTable routingTable = mock(IndexShardRoutingTable.class); + ShardId shardId = primary.shardId(); + ShardRouting routing = ShardRouting.newUnassigned( + shardId, + true, + RecoverySource.EmptyStoreRecoverySource.INSTANCE, + new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, ""), + ShardRouting.Role.INDEX_ONLY + ); + when(primary.routingEntry()).thenReturn(routing); when(primary.getReplicationGroup()).thenReturn(replicationGroup).thenReturn(realReplicationGroup); when(replicationGroup.getRoutingTable()).thenReturn(routingTable); ShardRouting shardRouting = ShardRouting.newUnassigned( - primary.shardId(), + shardId, false, RecoverySource.PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "message"), ShardRouting.Role.SEARCH_ONLY ); when(routingTable.unpromotableShards()).thenReturn(List.of(shardRouting)); + when(routingTable.shardId()).thenReturn(shardId); WriteRequest.RefreshPolicy policy = randomFrom(WriteRequest.RefreshPolicy.IMMEDIATE, WriteRequest.RefreshPolicy.WAIT_UNTIL); - postWriteRefresh.refreshShard(policy, primary, result.getTranslogLocation(), f); + postWriteRefresh.refreshShard(policy, primary, result.getTranslogLocation(), f, postWriteRefreshTimeout); final Releasable releasable; if (policy == WriteRequest.RefreshPolicy.WAIT_UNTIL) { releasable = simulateScheduledRefresh(primary, true); @@ -212,7 +237,7 @@ public void testWaitForWithNullLocationCompletedImmediately() throws IOException when(routingTable.unpromotableShards()).thenReturn(List.of(shardRouting)); } WriteRequest.RefreshPolicy policy = WriteRequest.RefreshPolicy.WAIT_UNTIL; - postWriteRefresh.refreshShard(policy, primary, null, f); + postWriteRefresh.refreshShard(policy, primary, null, f, postWriteRefreshTimeout); f.actionGet(); } finally { closeShards(primary, primary); diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java index ff480b9979a83..06265204a8a8d 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java @@ -169,7 +169,13 @@ public void testPrimaryImmediateRefresh() throws Exception { @SuppressWarnings({ "unchecked", "rawtypes" }) ArgumentCaptor> refreshListener = ArgumentCaptor.forClass((Class) ActionListener.class); - verify(testAction.postWriteRefresh).refreshShard(eq(RefreshPolicy.IMMEDIATE), eq(indexShard), any(), refreshListener.capture()); + verify(testAction.postWriteRefresh).refreshShard( + eq(RefreshPolicy.IMMEDIATE), + eq(indexShard), + any(), + refreshListener.capture(), + eq(request.timeout()) + ); // Now we can fire the listener manually and we'll get a response refreshListener.getValue().onResponse(true); @@ -208,7 +214,8 @@ public void testPrimaryWaitForRefresh() throws Exception { eq(RefreshPolicy.WAIT_UNTIL), eq(indexShard), any(), - refreshListener.capture() + refreshListener.capture(), + eq(request.timeout()) ); // Now we can fire the listener manually and we'll get a response diff --git a/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldMapperTests.java index a43440cf5df8c..34a57b1d33ff7 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldMapperTests.java @@ -627,7 +627,7 @@ public void testKeywordFieldUtf8LongerThan32766() throws Exception { } /** - * Test that we don't error on exceeding field size if field is neither indexed nor has doc values + * Test that we don't error on exceeding field size if field is neither indexed nor has doc values nor stored */ public void testKeywordFieldUtf8LongerThan32766SourceOnly() throws Exception { DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> { diff --git a/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java index a57d85be976c9..790fed4621683 100644 --- a/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java +++ b/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java @@ -1586,6 +1586,40 @@ ChannelFactory getChannelFactory() { } } + public void testTranslogWriterLastModifiedTime() throws IOException { + Path tempDir = createTempDir(); + try (Translog translog = create(tempDir)) { + long mtime = translog.getCurrent().getLastModifiedTime(); + TranslogWriter.LastModifiedTimeCache mtimeCache = translog.getCurrent().lastModifiedTimeCache; + // no ops + long lastMtime = translog.getCurrent().getLastModifiedTime(); + TranslogWriter.LastModifiedTimeCache lastMtimeCache = translog.getCurrent().lastModifiedTimeCache; + assertThat(lastMtime, equalTo(mtime)); + assertEquals(lastMtimeCache, mtimeCache); + + mtime = lastMtime; + mtimeCache = lastMtimeCache; + // add ops + int count = randomIntBetween(1, 100); + for (int i = 0; i < count; i++) { + translog.add(indexOp(randomAlphaOfLength(128), i, primaryTerm.get())); + } + lastMtime = translog.getCurrent().getLastModifiedTime(); + lastMtimeCache = translog.getCurrent().lastModifiedTimeCache; + assertThat(lastMtime, greaterThanOrEqualTo(mtime)); + assertThat(lastMtimeCache.totalOffset(), greaterThan(mtimeCache.totalOffset())); + + mtime = lastMtime; + mtimeCache = lastMtimeCache; + // sync ops + translog.sync(); + lastMtime = translog.getCurrent().getLastModifiedTime(); + lastMtimeCache = translog.getCurrent().lastModifiedTimeCache; + assertThat(lastMtime, greaterThanOrEqualTo(mtime)); + assertThat(lastMtimeCache.syncedOffset(), greaterThan(mtimeCache.syncedOffset())); + } + } + public void testTranslogOperationListener() throws IOException { Path tempDir = createTempDir(); final Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT).build(); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java index fdd7855adadbe..17d635b90d57e 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java @@ -34,6 +34,7 @@ import org.elasticsearch.search.aggregations.AggregationReduceContext; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.BucketOrder; +import org.elasticsearch.search.aggregations.MultiBucketConsumerService; import org.elasticsearch.search.aggregations.bucket.DateHistogramAggregatorTestCase; import org.elasticsearch.search.aggregations.bucket.range.RangeAggregator; import org.elasticsearch.search.aggregations.bucket.terms.StringTerms; @@ -1069,7 +1070,7 @@ private void aggregationImplementationChoiceTestCase( null, () -> false, builder, - context.multiBucketConsumer(), + new MultiBucketConsumerService.MultiBucketConsumer(context.maxBuckets(), context.breaker()), PipelineTree.EMPTY ) ); diff --git a/test/framework/src/main/java/org/elasticsearch/action/support/replication/TransportWriteActionTestHelper.java b/test/framework/src/main/java/org/elasticsearch/action/support/replication/TransportWriteActionTestHelper.java index 9e2816b9ab3df..64f372d41079d 100644 --- a/test/framework/src/main/java/org/elasticsearch/action/support/replication/TransportWriteActionTestHelper.java +++ b/test/framework/src/main/java/org/elasticsearch/action/support/replication/TransportWriteActionTestHelper.java @@ -8,7 +8,6 @@ package org.elasticsearch.action.support.replication; import org.apache.logging.log4j.Logger; -import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.core.Nullable; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.translog.Translog; @@ -22,7 +21,7 @@ public abstract class TransportWriteActionTestHelper { public static void performPostWriteActions( final IndexShard indexShard, - final WriteRequest request, + final ReplicatedWriteRequest request, @Nullable final Translog.Location location, final Logger logger ) { diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java index 5a8b9c598713c..09f51944e83c4 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java @@ -58,7 +58,6 @@ import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.search.aggregations.Aggregator; -import org.elasticsearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry; import org.elasticsearch.search.internal.SubSearchContext; @@ -366,7 +365,6 @@ private AggregationContext aggregationContext( ) { return new AggregationContext() { private final CircuitBreaker breaker = mock(CircuitBreaker.class); - private final MultiBucketConsumer multiBucketConsumer = new MultiBucketConsumer(Integer.MAX_VALUE, breaker); @Override public IndexSearcher searcher() { @@ -492,8 +490,8 @@ public void addReleasable(Aggregator aggregator) { } @Override - public MultiBucketConsumer multiBucketConsumer() { - return multiBucketConsumer; + public int maxBuckets() { + return Integer.MAX_VALUE; } @Override diff --git a/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java index 32fe62b922b06..2d9d0039822ce 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java @@ -345,7 +345,6 @@ public void onCache(ShardId shardId, Accountable accountable) {} emptyMap() ); - MultiBucketConsumer consumer = new MultiBucketConsumer(maxBucket, breakerService.getBreaker(CircuitBreaker.REQUEST)); AggregationContext context = new ProductionAggregationContext( Optional.ofNullable(analysisModule).map(AnalysisModule::getAnalysisRegistry).orElse(null), searchExecutionContext, @@ -353,7 +352,7 @@ public void onCache(ShardId shardId, Accountable accountable) {} bytesToPreallocate, () -> query, null, - consumer, + maxBucket, () -> buildSubSearchContext(indexSettings, searchExecutionContext, bitsetFilterCache), bitsetFilterCache, randomInt(), @@ -792,7 +791,7 @@ protected void debugTestCase( getMockScriptService(), () -> false, builder, - context.multiBucketConsumer(), + new MultiBucketConsumer(context.maxBuckets(), context.breaker()), builder.buildPipelineTree() ) ); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 24dd8fe4d7a9a..c1f22875b55c3 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -713,11 +713,11 @@ public Settings indexSettings() { Settings.Builder builder = Settings.builder(); int numberOfShards = numberOfShards(); if (numberOfShards > 0) { - builder.put(SETTING_NUMBER_OF_SHARDS, numberOfShards).build(); + builder.put(SETTING_NUMBER_OF_SHARDS, numberOfShards); } int numberOfReplicas = numberOfReplicas(); if (numberOfReplicas >= 0) { - builder.put(SETTING_NUMBER_OF_REPLICAS, numberOfReplicas).build(); + builder.put(SETTING_NUMBER_OF_REPLICAS, numberOfReplicas); } // 30% of the time if (randomInt(9) < 3) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java index ff4c8d2e393f4..17a59fd1042c8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java @@ -832,14 +832,30 @@ public Builder validate(boolean forCreation) { ); } } - if (modelId != null && packagedModel - ? MlStrings.isValidId(modelId.substring(1)) // packaged models - : MlStrings.isValidId(modelId) == false) { - validationException = addValidationError( - Messages.getMessage(Messages.INVALID_ID, TrainedModelConfig.MODEL_ID.getPreferredName(), modelId), - validationException - ); + + if (modelId != null) { + if (packagedModel) { + String idToValidate = modelId.substring(1); + if (idToValidate.endsWith("_SNAPSHOT")) { + idToValidate = idToValidate.substring(0, idToValidate.length() - 9); + } + + if (MlStrings.isValidId(idToValidate) == false) { + validationException = addValidationError( + Messages.getMessage(Messages.INVALID_MODEL_PACKAGE_ID, TrainedModelConfig.MODEL_ID.getPreferredName(), modelId), + validationException + ); + } + } else { + if (MlStrings.isValidId(modelId) == false) { + validationException = addValidationError( + Messages.getMessage(Messages.INVALID_ID, TrainedModelConfig.MODEL_ID.getPreferredName(), modelId), + validationException + ); + } + } } + if (modelId != null && MlStrings.hasValidLengthForId(modelId) == false) { validationException = addValidationError( Messages.getMessage( diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java index e80cac65f871b..77b4dcaaac83f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java @@ -96,6 +96,7 @@ public final class Messages { "Inconsistent {0}; ''{1}'' specified in the body differs from ''{2}'' specified as a URL argument"; public static final String INVALID_ID = "Invalid {0}; ''{1}'' can contain lowercase alphanumeric (a-z and 0-9), hyphens or " + "underscores; must start and end with alphanumeric"; + public static final String INVALID_MODEL_PACKAGE_ID = "Invalid {0}; ''{1}'' is not a valid model package id"; public static final String ID_TOO_LONG = "Invalid {0}; ''{1}'' cannot contain more than {2} characters."; public static final String INVALID_GROUP = "Invalid group id ''{0}''; must be non-empty string and may contain lowercase alphanumeric" + " (a-z and 0-9), hyphens or underscores; must start and end with alphanumeric"; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java index 54f26be69ac2b..a94236a0b3543 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java @@ -49,6 +49,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; @@ -400,7 +401,7 @@ public void testSerializationWithCompressedLazyDefinition() throws IOException { } public void testValidatePackagedModelRequiredFields() { - String modelId = "." + randomAlphaOfLength(20); + String modelId = "." + randomAlphaOfLength(20).toLowerCase(Locale.ROOT); TrainedModelConfig.Builder builder = TrainedModelConfig.builder().setModelId(modelId); diff --git a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/60_behavioral_analytics_list.yml b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/60_behavioral_analytics_list.yml index e5a55a5f81d08..ccedfd773c8a6 100644 --- a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/60_behavioral_analytics_list.yml +++ b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/60_behavioral_analytics_list.yml @@ -14,6 +14,11 @@ teardown: name: my-test-analytics-collection ignore: 404 + - do: + search_application.delete_behavioral_analytics: + name: my-test-analytics-collection2 + ignore: 404 + --- "Get Analytics Collection for a particular collection": - do: diff --git a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/80_behavioral_analytics_delete.yml b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/80_behavioral_analytics_delete.yml index 035f8cadd16df..d6b158cd4a52c 100644 --- a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/80_behavioral_analytics_delete.yml +++ b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/80_behavioral_analytics_delete.yml @@ -7,7 +7,7 @@ setup: teardown: - do: search_application.delete_behavioral_analytics: - name: test-analytics-collection-to-delete + name: my-test-analytics-collection ignore: 404 --- diff --git a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml index 1e7a31a7e5ee5..a3e5d4aa81b37 100644 --- a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml +++ b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml @@ -2,6 +2,7 @@ setup: - do: search_application.put_behavioral_analytics: name: my-test-analytics-collection + ignore: 400 # Sometimes teardown does not delete the collection and tests get flaky - this fixes it --- teardown: diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java index 6ff4542825a73..8706a54a0d893 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java @@ -306,7 +306,7 @@ public void testIndexTemplatesMigration() throws Exception { String composableTemplate = "no_need_to_migrate_composable_template"; { Request composableTemplateRequest = new Request("PUT", "/_index_template/" + composableTemplate); - Settings indexSettings = Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).build(); + Settings indexSettings = indexSettings(1, 0).build(); composableTemplateRequest.setJsonEntity( "{\"index_patterns\": [\"1notreallyimportant-*\"], \"template\":{\"settings\": " + Strings.toString(indexSettings) + "}}" ); diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java index e31a64962e74f..dc47708fa8817 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java @@ -175,10 +175,7 @@ public void setup() throws IOException { * check that the value of the label (last value) matches the value * of the corresponding metric which uses a last_value metric type. */ - Settings.Builder settings = Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numOfShards) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) - .put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES) + Settings.Builder settings = indexSettings(numOfShards, numOfReplicas).put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES) .putList(IndexMetadata.INDEX_ROUTING_PATH.getKey(), List.of(FIELD_DIMENSION_1)) .put( IndexSettings.TIME_SERIES_START_TIME.getKey(), @@ -1088,10 +1085,7 @@ public interface SourceSupplier { private String createDataStream() throws Exception { String dataStreamName = randomAlphaOfLength(10).toLowerCase(Locale.getDefault()); Template indexTemplate = new Template( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numOfShards) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) - .put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES) + indexSettings(numOfShards, numOfReplicas).put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES) .putList(IndexMetadata.INDEX_ROUTING_PATH.getKey(), List.of(FIELD_DIMENSION_1)) .build(), new CompressedXContent(""" diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java index e81cf9c6d4acd..3ac770c965913 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java @@ -186,10 +186,7 @@ public void testDataStreamDownsample() throws ExecutionException, InterruptedExc private void putComposableIndexTemplate(final String id, final List patterns) throws IOException { final PutComposableIndexTemplateAction.Request request = new PutComposableIndexTemplateAction.Request(id); final Template template = new Template( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES) + indexSettings(1, 0).put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES) .putList(IndexMetadata.INDEX_ROUTING_PATH.getKey(), List.of("routing_field")) .build(), new CompressedXContent(""" diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java index 21b4f8e2ed393..a4607cdd8b6c1 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java @@ -449,12 +449,7 @@ public void testRequestCacheOnFrozen() throws Exception { .indices() .prepareCreate("test-index") .setMapping("f", "type=date") - .setSettings( - Settings.builder() - .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - ) + .setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)) .get() ); indexRandom( diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java index e2ca6fdd069f4..ab6ef9e114611 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.cluster.ClusterInfoServiceUtils; import org.elasticsearch.cluster.DiskUsageIntegTestCase; import org.elasticsearch.cluster.InternalClusterInfoService; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.RepositoryMetadata; import org.elasticsearch.cluster.node.DiscoveryNodeRole; import org.elasticsearch.cluster.routing.ShardRoutingState; @@ -109,10 +108,7 @@ private int createIndices() throws InterruptedException { try { createIndex( index, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) + indexSettings(1, 0).put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .put(INDEX_SOFT_DELETES_SETTING.getKey(), true) .put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms") .put(DataTier.TIER_PREFERENCE_SETTING.getKey(), DataTier.DATA_HOT) diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java index ffe7547c1cf3a..2e21895515958 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; @@ -110,13 +109,7 @@ public void testConcurrentPrewarming() throws Exception { for (int index = 0; index < nbIndices; index++) { final String indexName = "index-" + index; final int nbShards = randomIntBetween(1, 5); - createIndex( - indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, nbShards) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .build() - ); + createIndex(indexName, indexSettings(nbShards, 0).build()); shardsPerIndex.put(indexName, nbShards); } diff --git a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java index 3d3da1fd8fd7d..469bc33fcade5 100644 --- a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java +++ b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java @@ -118,30 +118,21 @@ private void runSearchableSnapshotsTest( final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); logger.info("creating index [{}]", indexName); - createIndex( - indexName, - indexSettings != null - ? indexSettings - : Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 5)) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .build(), - """ - "properties": { - "field": { - "type": "integer" - }, - "text": { - "type": "text", - "fields": { - "raw": { - "type": "keyword" - } + createIndex(indexName, indexSettings != null ? indexSettings : indexSettings(randomIntBetween(1, 5), 0).build(), """ + "properties": { + "field": { + "type": "integer" + }, + "text": { + "type": "text", + "fields": { + "raw": { + "type": "keyword" } } } - """ - ); + } + """); ensureGreen(indexName); logger.info("indexing [{}] documents", numDocs); @@ -476,12 +467,9 @@ public void testQueryScript() throws Exception { }, false, 10_000, - Settings.builder() - .put(SearchableSnapshots.SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING.getKey(), true) + indexSettings(1, 0).put(SearchableSnapshots.SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING.getKey(), true) .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build() ); } diff --git a/x-pack/plugin/security/cli/build.gradle b/x-pack/plugin/security/cli/build.gradle index 2849f3198ba96..e4dccea9593bd 100644 --- a/x-pack/plugin/security/cli/build.gradle +++ b/x-pack/plugin/security/cli/build.gradle @@ -10,7 +10,6 @@ dependencies { compileOnly project(path: xpackModule('core')) api "org.bouncycastle:bcpkix-jdk15on:${versions.bouncycastle}" api "org.bouncycastle:bcprov-jdk15on:${versions.bouncycastle}" - api "commons-io:commons-io:2.5" testImplementation("com.google.jimfs:jimfs:${versions.jimfs}") { // this is provided by the runtime classpath, from the security project exclude group: "com.google.guava", module: "guava" diff --git a/x-pack/plugin/security/cli/licenses/commons-io-LICENSE.txt b/x-pack/plugin/security/cli/licenses/commons-io-LICENSE.txt deleted file mode 100644 index d645695673349..0000000000000 --- a/x-pack/plugin/security/cli/licenses/commons-io-LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/x-pack/plugin/security/cli/licenses/commons-io-NOTICE.txt b/x-pack/plugin/security/cli/licenses/commons-io-NOTICE.txt deleted file mode 100644 index a6b77d1eb6089..0000000000000 --- a/x-pack/plugin/security/cli/licenses/commons-io-NOTICE.txt +++ /dev/null @@ -1,5 +0,0 @@ -Apache Commons IO -Copyright 2002-2014 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). diff --git a/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/AutoConfigureNode.java b/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/AutoConfigureNode.java index cd56a3829643e..46ecfb0c33ea7 100644 --- a/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/AutoConfigureNode.java +++ b/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/AutoConfigureNode.java @@ -10,7 +10,6 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; -import org.apache.commons.io.FileUtils; import org.apache.lucene.util.SetOnce; import org.bouncycastle.asn1.x509.ExtendedKeyUsage; import org.bouncycastle.asn1.x509.GeneralName; @@ -36,9 +35,9 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.CheckedConsumer; +import org.elasticsearch.core.IOUtils; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.PathUtils; -import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.discovery.SettingsBasedSeedHostsProvider; import org.elasticsearch.env.Environment; @@ -62,6 +61,7 @@ import java.net.URL; import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; +import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; @@ -942,14 +942,16 @@ private void notifyOfFailure(boolean inEnrollmentMode, Terminal terminal, Termin } } - @SuppressForbidden(reason = "Commons IO lib uses the File API") private void deleteDirectory(Path directory) throws IOException { - FileUtils.deleteDirectory(directory.toFile()); + IOUtils.rm(directory); } - @SuppressForbidden(reason = "Commons IO lib uses the File API") private void moveDirectory(Path srcDir, Path dstDir) throws IOException { - FileUtils.moveDirectory(srcDir.toFile(), dstDir.toFile()); + try { + Files.move(srcDir, dstDir, StandardCopyOption.ATOMIC_MOVE); + } catch (AtomicMoveNotSupportedException e) { + Files.move(srcDir, dstDir); + } } private GeneralNames getSubjectAltNames(Settings settings) throws IOException { diff --git a/x-pack/plugin/security/cli/src/test/java/org/elasticsearch/xpack/security/cli/AutoConfigureNodeTests.java b/x-pack/plugin/security/cli/src/test/java/org/elasticsearch/xpack/security/cli/AutoConfigureNodeTests.java index 623bb4a8e54a3..d1dbe9d037756 100644 --- a/x-pack/plugin/security/cli/src/test/java/org/elasticsearch/xpack/security/cli/AutoConfigureNodeTests.java +++ b/x-pack/plugin/security/cli/src/test/java/org/elasticsearch/xpack/security/cli/AutoConfigureNodeTests.java @@ -9,7 +9,6 @@ import joptsimple.OptionParser; -import org.apache.commons.io.FileUtils; import org.bouncycastle.asn1.x509.GeneralName; import org.bouncycastle.asn1.x509.KeyPurposeId; import org.elasticsearch.cli.MockTerminal; @@ -18,7 +17,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.ssl.KeyStoreUtil; -import org.elasticsearch.core.SuppressForbidden; +import org.elasticsearch.core.IOUtils; import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.http.HttpTransportSettings; @@ -291,8 +290,7 @@ private X509Certificate runAutoConfigAndReturnHTTPCertificate(Path configDir, Se return (X509Certificate) httpKeystore.getCertificate("http"); } - @SuppressForbidden(reason = "Uses File API because the commons io library does, which is useful for file manipulation") private void deleteDirectory(Path directory) throws IOException { - FileUtils.deleteDirectory(directory.toFile()); + IOUtils.rm(directory); } } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java index caa23c0377cfd..db7f18a4773da 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java @@ -150,7 +150,7 @@ public void testUpdatesAreRejected() { .indices() .prepareCreate(indexName) .setMapping("id", "type=keyword", "field1", "type=text", "field2", "type=text") - .setSettings(Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 1)) + .setSettings(indexSettings(1, 0)) ); client().prepareIndex(indexName).setId("1").setSource("id", "1", "field1", "value1").setRefreshPolicy(IMMEDIATE).get(); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java index 111b5f3265c8a..f38c5368e5bf8 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java @@ -1339,7 +1339,7 @@ public void testSuggesters() throws Exception { client().admin() .indices() .prepareCreate("test") - .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) + .setSettings(indexSettings(1, 0)) .setMapping("field1", "type=text", "suggest_field1", "type=text", "suggest_field2", "type=completion") ); @@ -1366,7 +1366,7 @@ public void testSuggesters() throws Exception { client().admin() .indices() .prepareCreate("fls-index") - .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) + .setSettings(indexSettings(1, 0)) .setMapping( "field1", "type=text", @@ -1454,7 +1454,7 @@ public void testProfile() throws Exception { client().admin() .indices() .prepareCreate("test") - .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) + .setSettings(indexSettings(1, 0)) .setMapping("field1", "type=text", "other_field", "type=text") ); @@ -1473,7 +1473,7 @@ public void testProfile() throws Exception { client().admin() .indices() .prepareCreate("fls-index") - .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) + .setSettings(indexSettings(1, 0)) .setMapping("field1", "type=text", "other_field", "type=text", "yet_another", "type=text") ); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java index ac24ba40496f0..e22cd73abed9a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java @@ -2307,8 +2307,7 @@ private AuthorizedIndices buildAuthorizedIndices(User user, String action, Trans } public static IndexMetadata.Builder indexBuilder(String index) { - return IndexMetadata.builder(index) - .settings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)); + return IndexMetadata.builder(index).settings(indexSettings(1, 0)); } private ResolvedIndices resolveIndices(TransportRequest request, AuthorizedIndices authorizedIndices) { diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/DesiredBalanceShutdownIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/DesiredBalanceShutdownIT.java index e1f2d068a3933..4c957094148da 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/DesiredBalanceShutdownIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/DesiredBalanceShutdownIT.java @@ -40,11 +40,7 @@ public void testDesiredBalanceWithShutdown() throws Exception { createIndex( INDEX, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5)) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._name", oldNodeName) - .build() + indexSettings(between(1, 5), 0).put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._name", oldNodeName).build() ); ensureGreen(INDEX); diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java index 937b67c8d787b..aec74e2c6f739 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java @@ -10,7 +10,6 @@ import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; import org.elasticsearch.cluster.routing.RoutingNodesHelper; import org.elasticsearch.cluster.routing.ShardRouting; @@ -39,10 +38,8 @@ protected Collection> nodePlugins() { public void testShardAllocationIsDelayedForRestartingNode() throws Exception { internalCluster().startNodes(3); prepareCreate("test").setSettings( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) // Disable "normal" delayed allocation + // Disable "normal" delayed allocation + indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) ).get(); ensureGreen("test"); indexRandomData(); @@ -78,10 +75,8 @@ public Settings onNodeStopped(String nodeName) throws Exception { public void testShardAllocationWillProceedAfterTimeout() throws Exception { internalCluster().startNodes(3); prepareCreate("test").setSettings( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) // Disable "normal" delayed allocation + // Disable "normal" delayed allocation + indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) ).get(); ensureGreen("test"); indexRandomData(); @@ -110,10 +105,8 @@ public void testShardAllocationWillProceedAfterTimeout() throws Exception { public void testIndexLevelAllocationDelayWillBeUsedIfLongerThanShutdownDelay() throws Exception { internalCluster().startNodes(3); prepareCreate("test").setSettings( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "3h") // Use a long timeout we definitely won't hit + // Use a long timeout we definitely won't hit + indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "3h") ).get(); ensureGreen("test"); indexRandomData(); @@ -184,10 +177,8 @@ public void testShardAllocationStartsImmediatelyIfShutdownDeleted() throws Excep private String setupLongTimeoutTestCase() throws Exception { internalCluster().startNodes(3); prepareCreate("test").setSettings( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) // Disable "normal" delayed allocation + // Disable "normal" delayed allocation + indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) ).get(); ensureGreen("test"); indexRandomData(); diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index 5af0f6b3c6efa..b55f59aff903b 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -14,7 +14,6 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.RoutingNodesHelper; @@ -120,10 +119,8 @@ public void testNotStalledIfAllShardsHaveACopyOnAnotherNode() throws Exception { final String indexName = "test"; prepareCreate(indexName).setSettings( - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) // <- Ensure we have a copy of the shard on both nodes - .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) // Disable "normal" delayed allocation + // Ensure we have a copy of the shard on both nodes and disable "normal" delayed allocation + indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0) ).get(); ensureGreen(indexName); indexRandomData(indexName); @@ -400,14 +397,7 @@ public void testNodeShutdownWithUnassignedShards() throws Exception { final String nodeA = internalCluster().startNode(); final String nodeAId = getNodeId(nodeA); - createIndex( - "index", - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put("index.routing.allocation.include._name", nodeA) - .build() - ); + createIndex("index", indexSettings(1, 0).put("index.routing.allocation.include._name", nodeA).build()); ensureYellow("index"); diff --git a/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java b/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java index 1d0587e8c504d..00efa6d60a684 100644 --- a/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java +++ b/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java @@ -296,10 +296,7 @@ public void testPeerRecoveryUsesSnapshots() throws Exception { String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.require._name", sourceNode) .build() @@ -366,10 +363,7 @@ public void testFallbacksToSourceNodeWhenSnapshotDownloadFails() throws Exceptio String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.require._name", sourceNode) .build() @@ -422,10 +416,7 @@ public void testRateLimitingIsEnforced() throws Exception { String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.require._name", sourceNode) .build() @@ -478,10 +469,7 @@ public void testPeerRecoveryTriesToUseMostOfTheDataFromAnAvailableSnapshot() thr String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.require._name", sourceNode) .build() @@ -520,10 +508,7 @@ public void testPeerRecoveryDoNotUseSnapshotsWhenSegmentsAreNotSharedAndSeqNosAr String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") + indexSettings(1, 0).put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.require._name", sourceNode) .build() ); @@ -681,10 +666,7 @@ public void testRecoveryAfterRestoreUsesSnapshots() throws Exception { String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .build() ); @@ -742,10 +724,7 @@ public void testReplicaRecoveryUsesSnapshots() throws Exception { String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.include._name", String.join(",", dataNodes)) .build() @@ -807,10 +786,7 @@ public void testRecoveryConcurrentlyWithIndexing() throws Exception { String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .build() ); @@ -861,10 +837,7 @@ public void testSeqNoBasedRecoveryIsUsedAfterPrimaryFailOver() throws Exception String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 1).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.include._name", String.join(",", dataNodes)) .build() @@ -1179,10 +1152,7 @@ public void testNodeDisconnectsDoNotOverAccountRecoveredBytes() throws Exception String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 1).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.include._name", String.join(",", dataNodes)) .build() @@ -1315,10 +1285,7 @@ private void executeRecoveryWithSnapshotFileDownloadThrottled(SnapshotBasedRecov String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .put("index.routing.allocation.require._name", dataNodes.get(0)) .put(SETTING_ALLOCATION_MAX_RETRY.getKey(), 0) @@ -1381,10 +1348,7 @@ private void checkRecoveryIsPerformedFromSourceNode() throws Exception { String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); createIndex( indexName, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) + indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") .build() ); diff --git a/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/AbstractSnapshotBasedRecoveryRestTestCase.java b/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/AbstractSnapshotBasedRecoveryRestTestCase.java index 2e104d5035005..3aba0994ee369 100644 --- a/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/AbstractSnapshotBasedRecoveryRestTestCase.java +++ b/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/AbstractSnapshotBasedRecoveryRestTestCase.java @@ -52,10 +52,7 @@ public void testRecoveryUsingSnapshots() throws Exception { final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); - createIndex( - indexName, - Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).build() - ); + createIndex(indexName, indexSettings(1, 0).build()); ensureGreen(indexName); final int numDocs = randomIntBetween(500, 1000); diff --git a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ParsedMediaType.java b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ParsedMediaType.java index 7738e14cacf05..e1a100d3e7023 100644 --- a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ParsedMediaType.java +++ b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/content/ParsedMediaType.java @@ -59,7 +59,7 @@ public static ParsedMediaType parseMediaType(String headerValue) { if (isMediaRange(headerValue) || "*/*".equals(headerValue)) { return null; } - final String[] elements = headerValue.toLowerCase(Locale.ROOT).split("[\\s\\t]*;"); + final String[] elements = headerValue.toLowerCase(Locale.ROOT).split(";"); final String[] splitMediaType = elements[0].split("/"); if ((splitMediaType.length == 2 diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java index 4f8e373142298..815f07bf64751 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.xpack.core.watcher.condition.Condition; import org.elasticsearch.xpack.core.watcher.condition.ExecutableCondition; import org.elasticsearch.xpack.core.watcher.execution.ExecutionState; +import org.elasticsearch.xpack.core.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.core.watcher.input.Input; import org.elasticsearch.xpack.core.watcher.transport.actions.put.PutWatchRequestBuilder; import org.elasticsearch.xpack.watcher.condition.CompareCondition; @@ -92,7 +93,6 @@ protected Map, Object>> pluginScripts() { /** * A hard failure is where an exception is thrown by the script condition. */ - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/94836") @SuppressWarnings("unchecked") public void testActionConditionWithHardFailures() throws Exception { final String id = "testActionConditionWithHardFailures"; @@ -115,9 +115,14 @@ public void testActionConditionWithHardFailures() throws Exception { assertWatchWithMinimumActionsCount(id, ExecutionState.EXECUTED, 1); // only one action should have failed via condition - final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); - assertThat(response.getHits().getTotalHits().value, is(oneOf(1L, 2L))); + assertBusy(() -> { + // Watcher history is now written asynchronously, so we check this in an assertBusy + ensureGreen(HistoryStoreField.DATA_STREAM); + final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); + assertThat(response.getHits().getTotalHits().value, is(oneOf(1L, 2L))); + }); + final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); final SearchHit hit = response.getHits().getAt(0); final List actions = getActionsFromHit(hit.getSourceAsMap()); @@ -144,7 +149,6 @@ public void testActionConditionWithHardFailures() throws Exception { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/94836") @SuppressWarnings("unchecked") public void testActionConditionWithFailures() throws Exception { final String id = "testActionConditionWithFailures"; @@ -160,9 +164,14 @@ public void testActionConditionWithFailures() throws Exception { assertWatchWithMinimumActionsCount(id, ExecutionState.EXECUTED, 1); // only one action should have failed via condition - final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); - assertThat(response.getHits().getTotalHits().value, is(oneOf(1L, 2L))); + assertBusy(() -> { + // Watcher history is now written asynchronously, so we check this in an assertBusy + ensureGreen(HistoryStoreField.DATA_STREAM); + final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); + assertThat(response.getHits().getTotalHits().value, is(oneOf(1L, 2L))); + }); + final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); final SearchHit hit = response.getHits().getAt(0); final List actions = getActionsFromHit(hit.getSourceAsMap()); @@ -189,7 +198,6 @@ public void testActionConditionWithFailures() throws Exception { } @SuppressWarnings("unchecked") - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/65064") public void testActionCondition() throws Exception { final String id = "testActionCondition"; final List actionConditions = new ArrayList<>(); @@ -211,8 +219,14 @@ public void testActionCondition() throws Exception { assertWatchWithMinimumActionsCount(id, ExecutionState.EXECUTED, 1); // all actions should be successful + assertBusy(() -> { + // Watcher history is now written asynchronously, so we check this in an assertBusy + ensureGreen(HistoryStoreField.DATA_STREAM); + final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); + assertThat(response.getHits().getTotalHits().value, is(oneOf(1L, 2L))); + }); + final SearchResponse response = searchHistory(SearchSourceBuilder.searchSource().query(termQuery("watch_id", id))); - assertThat(response.getHits().getTotalHits().value, is(oneOf(1L, 2L))); final SearchHit hit = response.getHits().getAt(0); final List actions = getActionsFromHit(hit.getSourceAsMap()); diff --git a/x-pack/qa/mixed-tier-cluster/src/javaRestTest/java/org/elasticsearch/mixed/DataTierMixedIT.java b/x-pack/qa/mixed-tier-cluster/src/javaRestTest/java/org/elasticsearch/mixed/DataTierMixedIT.java index 129838b767c08..74df6cf0ab3f9 100644 --- a/x-pack/qa/mixed-tier-cluster/src/javaRestTest/java/org/elasticsearch/mixed/DataTierMixedIT.java +++ b/x-pack/qa/mixed-tier-cluster/src/javaRestTest/java/org/elasticsearch/mixed/DataTierMixedIT.java @@ -7,17 +7,12 @@ package org.elasticsearch.mixed; -import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.rest.ESRestTestCase; public class DataTierMixedIT extends ESRestTestCase { public void testMixedTierCompatibility() throws Exception { - createIndex( - "test-index", - Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).build() - ); + createIndex("test-index", indexSettings(1, 0).build()); ensureGreen("test-index"); } } diff --git a/x-pack/qa/rolling-upgrade-multi-cluster/src/test/java/org/elasticsearch/upgrades/CcrRollingUpgradeIT.java b/x-pack/qa/rolling-upgrade-multi-cluster/src/test/java/org/elasticsearch/upgrades/CcrRollingUpgradeIT.java index c51814cd19356..f1d77955351f9 100644 --- a/x-pack/qa/rolling-upgrade-multi-cluster/src/test/java/org/elasticsearch/upgrades/CcrRollingUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade-multi-cluster/src/test/java/org/elasticsearch/upgrades/CcrRollingUpgradeIT.java @@ -285,7 +285,7 @@ public void testBiDirectionalIndexFollowing() throws Exception { } private static void createLeaderIndex(RestClient client, String indexName) throws IOException { - Settings.Builder indexSettings = Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0); + Settings.Builder indexSettings = indexSettings(1, 0); if (randomBoolean()) { indexSettings.put("index.soft_deletes.enabled", true); } diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SearchableSnapshotsRollingUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SearchableSnapshotsRollingUpgradeIT.java index 025136c418b3b..9225fbfaa6642 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SearchableSnapshotsRollingUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SearchableSnapshotsRollingUpgradeIT.java @@ -14,7 +14,6 @@ import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.Maps; @@ -89,13 +88,7 @@ private void executeMountAndRecoversCorrectlyTestCase(Storage storage, long numb registerRepository(repository, FsRepository.TYPE, true, repositorySettings(repository)); final String originalIndex = "logs_" + suffix; - createIndex( - originalIndex, - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 3)) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .build() - ); + createIndex(originalIndex, indexSettings(randomIntBetween(1, 3), 0).build()); indexDocs(originalIndex, numberOfDocs); createSnapshot(repository, snapshot, originalIndex); deleteIndex(originalIndex); @@ -159,13 +152,7 @@ private void executeBlobCacheCreationTestCase(Storage storage, long numberOfDocs // snapshots must be created from indices on the lowest version, otherwise we won't be able // to mount them again in the mixed version cluster (and we'll have IndexFormatTooNewException) for (int i = 0; i < numberOfSnapshots; i++) { - createIndex( - indices[i], - Settings.builder() - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 3)) - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .build() - ); + createIndex(indices[i], indexSettings(randomIntBetween(1, 3), 0).build()); indexDocs(indices[i], numberOfDocs * (i + 1L)); createSnapshot(repository, snapshots[i], indices[i]);