Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix_swallow_send_request
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed May 15, 2024
2 parents 1fa129e + 6922441 commit b2847b3
Show file tree
Hide file tree
Showing 189 changed files with 12,494 additions and 563 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.apache.commons.compress.utils.Lists;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.jvm.toolchain.JavaToolchainDownload;
import org.gradle.jvm.toolchain.JavaToolchainRequest;
Expand All @@ -21,25 +20,25 @@
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Comparator;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.StreamSupport;

import static org.gradle.jvm.toolchain.JavaToolchainDownload.fromUri;

public abstract class AdoptiumJdkToolchainResolver extends AbstractCustomJavaToolchainResolver {

// package protected for better testing
final Map<AdoptiumVersionRequest, Optional<AdoptiumVersionInfo>> CACHED_SEMVERS = new ConcurrentHashMap<>();
final Map<AdoptiumVersionRequest, Optional<String>> CACHED_RELEASES = new ConcurrentHashMap<>();

@Override
public Optional<JavaToolchainDownload> resolve(JavaToolchainRequest request) {
if (requestIsSupported(request) == false) {
return Optional.empty();
}
AdoptiumVersionRequest versionRequestKey = toVersionRequest(request);
Optional<AdoptiumVersionInfo> versionInfo = CACHED_SEMVERS.computeIfAbsent(
Optional<String> versionInfo = CACHED_RELEASES.computeIfAbsent(
versionRequestKey,
(r) -> resolveAvailableVersion(versionRequestKey)
);
Expand All @@ -54,12 +53,12 @@ private AdoptiumVersionRequest toVersionRequest(JavaToolchainRequest request) {
return new AdoptiumVersionRequest(platform, arch, javaLanguageVersion);
}

private Optional<AdoptiumVersionInfo> resolveAvailableVersion(AdoptiumVersionRequest requestKey) {
private Optional<String> resolveAvailableVersion(AdoptiumVersionRequest requestKey) {
ObjectMapper mapper = new ObjectMapper();
try {
int languageVersion = requestKey.languageVersion.asInt();
URL source = new URL(
"https://api.adoptium.net/v3/info/release_versions?architecture="
"https://api.adoptium.net/v3/info/release_names?architecture="
+ requestKey.arch
+ "&image_type=jdk&os="
+ requestKey.platform
Expand All @@ -71,14 +70,8 @@ private Optional<AdoptiumVersionInfo> resolveAvailableVersion(AdoptiumVersionReq
+ ")"
);
JsonNode jsonNode = mapper.readTree(source);
JsonNode versionsNode = jsonNode.get("versions");
return Optional.of(
Lists.newArrayList(versionsNode.iterator())
.stream()
.map(this::toVersionInfo)
.max(Comparator.comparing(AdoptiumVersionInfo::semver))
.get()
);
JsonNode versionsNode = jsonNode.get("releases");
return StreamSupport.stream(versionsNode.spliterator(), false).map(JsonNode::textValue).findFirst();
} catch (FileNotFoundException e) {
// request combo not supported (e.g. aarch64 + windows
return Optional.empty();
Expand All @@ -87,21 +80,10 @@ private Optional<AdoptiumVersionInfo> resolveAvailableVersion(AdoptiumVersionReq
}
}

private AdoptiumVersionInfo toVersionInfo(JsonNode node) {
return new AdoptiumVersionInfo(
node.get("build").asInt(),
node.get("major").asInt(),
node.get("minor").asInt(),
node.get("openjdk_version").asText(),
node.get("security").asInt(),
node.get("semver").asText()
);
}

private URI resolveDownloadURI(AdoptiumVersionRequest request, AdoptiumVersionInfo versionInfo) {
private URI resolveDownloadURI(AdoptiumVersionRequest request, String version) {
return URI.create(
"https://api.adoptium.net/v3/binary/version/jdk-"
+ versionInfo.semver
"https://api.adoptium.net/v3/binary/version/"
+ version
+ "/"
+ request.platform
+ "/"
Expand All @@ -118,7 +100,5 @@ private boolean requestIsSupported(JavaToolchainRequest request) {
return anyVendorOr(request.getJavaToolchainSpec().getVendor().get(), JvmVendorSpec.ADOPTIUM);
}

record AdoptiumVersionInfo(int build, int major, int minor, String openjdkVersion, int security, String semver) {}

record AdoptiumVersionRequest(String platform, String arch, JavaLanguageVersion languageVersion) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ record JdkBuild(JavaLanguageVersion languageVersion, String version, String buil
);

// package private so it can be replaced by tests
List<JdkBuild> builds = List.of(
getBundledJdkBuild(),
// 22 release candidate
new JdkBuild(JavaLanguageVersion.of(22), "22", "36", "830ec9fcccef480bb3e73fb7ecafe059")
);
List<JdkBuild> builds = List.of(getBundledJdkBuild());

private JdkBuild getBundledJdkBuild() {
String bundledJdkVersion = VersionProperties.getBundledJdkVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package org.elasticsearch.gradle.internal.toolchain
import org.gradle.api.services.BuildServiceParameters
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.toolchain.JavaToolchainResolver
import org.gradle.platform.OperatingSystem

import static org.elasticsearch.gradle.internal.toolchain.AbstractCustomJavaToolchainResolver.toArchString
import static org.elasticsearch.gradle.internal.toolchain.AbstractCustomJavaToolchainResolver.toOsString
Expand All @@ -38,12 +37,7 @@ class AdoptiumJdkToolchainResolverSpec extends AbstractToolchainResolverSpec {
toOsString(it[2], it[1]),
toArchString(it[3]),
languageVersion);
resolver.CACHED_SEMVERS.put(request, Optional.of(new AdoptiumJdkToolchainResolver.AdoptiumVersionInfo(languageVersion.asInt(),
1,
1,
"" + languageVersion.asInt() + ".1.1.1+37",
0, "" + languageVersion.asInt() + ".1.1.1+37.1"
)))
resolver.CACHED_RELEASES.put(request, Optional.of('jdk-' + languageVersion.asInt() + '.1.1.1+37.1'))

}
return resolver
Expand Down
2 changes: 1 addition & 1 deletion build-tools-internal/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ elasticsearch = 8.15.0
lucene = 9.10.0

bundled_jdk_vendor = openjdk
bundled_jdk = 21.0.2+13@f2283984656d49d69e91c558476027ac
bundled_jdk = 22.0.1+8@c7ec1332f7bb44aeba2eb341ae18aca4
# optional dependencies
spatial4j = 0.7
jts = 1.15.0
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog/108409.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 108409
summary: Support multiple associated groups for TopN
area: Application
type: enhancement
issues:
- 108018
5 changes: 5 additions & 0 deletions docs/changelog/108574.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 108574
summary: "[ESQL] CBRT function"
area: ES|QL
type: enhancement
issues: []
15 changes: 15 additions & 0 deletions docs/changelog/108600.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pr: 108600
summary: "Prevent DLS/FLS if `replication` is assigned"
area: Security
type: breaking
issues: [ ]
breaking:
title: "Prevent DLS/FLS if `replication` is assigned"
area: REST API
details: For cross-cluster API keys, {es} no longer allows specifying document-level security (DLS)
or field-level security (FLS) in the `search` field, if `replication` is also specified.
{es} likewise blocks the use of any existing cross-cluster API keys that meet this condition.
impact: Remove any document-level security (DLS) or field-level security (FLS) definitions from the `search` field
for cross-cluster API keys that also have a `replication` field, or create two separate cross-cluster API keys,
one for search and one for replication.
notable: false
5 changes: 5 additions & 0 deletions docs/changelog/108602.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 108602
summary: "[Inference API] Extract optional long instead of integer in `RateLimitSettings#of`"
area: Machine Learning
type: bug
issues: []
6 changes: 6 additions & 0 deletions docs/changelog/108643.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 108643
summary: Use `scheduleUnlessShuttingDown` in `LeaderChecker`
area: Cluster Coordination
type: bug
issues:
- 108642
29 changes: 29 additions & 0 deletions docs/changelog/108651.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pr: 108651
summary: Add support for the 'ISP' database to the geoip processor
area: Ingest Node
type: enhancement
issues: []
highlight:
title: Add support for the 'ISP' database to the geoip processor
body: |-
Follow on to https://github.com/elastic/elasticsearch/pull/107287,
https://github.com/elastic/elasticsearch/pull/107377, and
https://github.com/elastic/elasticsearch/pull/108639
Adds support for the ['GeoIP2
ISP'](https://dev.maxmind.com/geoip/docs/databases/isp) database from
MaxMind to the geoip processor.
The geoip processor will automatically download the [various 'GeoLite2'
databases](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data),
but the 'GeoIP2 ISP' database is not a 'GeoLite2' database -- it's a
commercial database available to those with a suitable license from
MaxMind.
The support that is being added for it in this PR is in line with the
support that we already have for MaxMind's 'GeoIP2 City' and 'GeoIP2
Country' databases -- that is, one would need to arrange their own
download management via some custom endpoint or otherwise arrange for
the relevant file(s) to be in the $ES_CONFIG/ingest-geoip directory on
the nodes of the cluster.
notable: true
5 changes: 5 additions & 0 deletions docs/changelog/108654.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 108654
summary: Update bundled JDK to Java 22 (again)
area: Packaging
type: upgrade
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/108672.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 108672
summary: Add bounds checking to parsing ISO8601 timezone offset values
area: Infra/Core
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

beta::[]

Updates the draft `filtering` configuration of a connector and marks the draft validation state as `edited`. The filtering configuration can be activated once validated by the Elastic connector service.
Updates the draft `filtering` configuration of a connector and marks the draft validation state as `edited`. The filtering draft is activated once validated by the running Elastic connector service.

The filtering property is used to configure sync rules (both basic and advanced) for a connector. Learn more in the {enterprise-search-ref}/sync-rules.html[sync rules documentation].

Expand All @@ -15,14 +15,13 @@ The filtering property is used to configure sync rules (both basic and advanced)

`PUT _connector/<connector_id>/_filtering`

`PUT _connector/<connector_id>/_filtering/_activate`

[[update-connector-filtering-api-prereq]]
==== {api-prereq-title}

* To sync data using self-managed connectors, you need to deploy the {enterprise-search-ref}/build-connector.html[Elastic connector service] on your own infrastructure. This service runs automatically on Elastic Cloud for native connectors.
* The `connector_id` parameter should reference an existing connector.
* To activate filtering rules, the `draft.validation.state` must be `valid`.
* Filtering draft is activated once validated by the running Elastic connector service, the `draft.validation.state` must be `valid`.
* If, after a validation attempt, the `draft.validation.state` equals to `invalid`, inspect `draft.validation.errors` and fix any issues.

[[update-connector-filtering-api-path-params]]
==== {api-path-parms-title}
Expand Down Expand Up @@ -185,20 +184,4 @@ PUT _connector/my-sql-connector/_filtering/_validation

Note, you can also update draft `rules` and `advanced_snippet` in a single request.

Once the draft is updated, its validation state is set to `edited`. The connector service will then validate the rules and report the validation state as either `invalid` or `valid`. If the state is `valid`, the draft filtering can be activated with:


[source,console]
----
PUT _connector/my-sql-connector/_filtering/_activate
----
// TEST[continued]

[source,console-result]
----
{
"result": "updated"
}
----

Once filtering rules are activated, they will be applied to all subsequent full or incremental syncs.
Once the draft is updated, its validation state is set to `edited`. The connector service will then validate the rules and report the validation state as either `invalid` or `valid`. If the state is `valid`, the draft filtering will be activated by the running Elastic connector service.
2 changes: 2 additions & 0 deletions docs/reference/esql/esql-language.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Detailed reference documentation for the {esql} language:
* <<esql-multivalued-fields>>
* <<esql-enrich-data>>
* <<esql-process-data-with-dissect-and-grok>>
* <<esql-implicit-casting>>

include::esql-syntax.asciidoc[]
include::esql-commands.asciidoc[]
Expand All @@ -23,3 +24,4 @@ include::esql-index-options.asciidoc[]
include::multivalued-fields.asciidoc[]
include::esql-process-data-with-dissect-grok.asciidoc[]
include::esql-enrich-data.asciidoc[]
include::implicit-casting.asciidoc[]
5 changes: 5 additions & 0 deletions docs/reference/esql/functions/description/cbrt.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.

*Description*

Returns the cube root of a number. The input can be any numeric value, the return value is always a double. Cube roots of infinities are null.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/description/sqrt.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

*Description*

Returns the square root of a number. The input can be any numeric value, the return value is always a double. Square roots of negative numbers and infinites are null.
Returns the square root of a number. The input can be any numeric value, the return value is always a double. Square roots of negative numbers and infinities are null.
13 changes: 13 additions & 0 deletions docs/reference/esql/functions/examples/cbrt.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.

*Example*

[source.merge.styled,esql]
----
include::{esql-specs}/math.csv-spec[tag=cbrt]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/math.csv-spec[tag=cbrt-result]
|===

59 changes: 59 additions & 0 deletions docs/reference/esql/functions/kibana/definition/cbrt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.",
"type" : "eval",
"name" : "cbrt",
"description" : "Returns the cube root of a number. The input can be any numeric value, the return value is always a double.\nCube roots of infinities are null.",
"signatures" : [
{
"params" : [
{
"name" : "number",
"type" : "double",
"optional" : false,
"description" : "Numeric expression. If `null`, the function returns `null`."
}
],
"variadic" : false,
"returnType" : "double"
},
{
"params" : [
{
"name" : "number",
"type" : "integer",
"optional" : false,
"description" : "Numeric expression. If `null`, the function returns `null`."
}
],
"variadic" : false,
"returnType" : "double"
},
{
"params" : [
{
"name" : "number",
"type" : "long",
"optional" : false,
"description" : "Numeric expression. If `null`, the function returns `null`."
}
],
"variadic" : false,
"returnType" : "double"
},
{
"params" : [
{
"name" : "number",
"type" : "unsigned_long",
"optional" : false,
"description" : "Numeric expression. If `null`, the function returns `null`."
}
],
"variadic" : false,
"returnType" : "double"
}
],
"examples" : [
"ROW d = 1000.0\n| EVAL c = cbrt(d)"
]
}
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/definition/sqrt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.",
"type" : "eval",
"name" : "sqrt",
"description" : "Returns the square root of a number. The input can be any numeric value, the return value is always a double.\nSquare roots of negative numbers and infinites are null.",
"description" : "Returns the square root of a number. The input can be any numeric value, the return value is always a double.\nSquare roots of negative numbers and infinities are null.",
"signatures" : [
{
"params" : [
Expand Down
12 changes: 12 additions & 0 deletions docs/reference/esql/functions/kibana/docs/cbrt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--
This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
-->

### CBRT
Returns the cube root of a number. The input can be any numeric value, the return value is always a double.
Cube roots of infinities are null.

```
ROW d = 1000.0
| EVAL c = cbrt(d)
```
Loading

0 comments on commit b2847b3

Please sign in to comment.