Skip to content

Commit

Permalink
Merge branch 'main' into esql-remove-is-nan-and-friends
Browse files Browse the repository at this point in the history
 Conflicts:
	docs/reference/esql/esql-functions.asciidoc
	x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec
  • Loading branch information
not-napoleon committed Jan 9, 2024
2 parents f34a38a + e93892c commit 1e36455
Show file tree
Hide file tree
Showing 323 changed files with 6,930 additions and 2,153 deletions.
10 changes: 10 additions & 0 deletions .buildkite/pipelines/dra-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ steps:
image: family/elasticsearch-ubuntu-2204
machineType: custom-32-98304
buildDirectory: /dev/shm/bk
- wait
# The hadoop build depends on the ES artifact
# So let's trigger the hadoop build any time we build a new staging artifact
- trigger: elasticsearch-hadoop-dra-workflow
async: true
build:
branch: "${BUILDKITE_BRANCH}"
env:
DRA_WORKFLOW: staging
if: build.env('DRA_WORKFLOW') == 'staging'
2 changes: 1 addition & 1 deletion build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ dependencies {
// ensuring brought asm version brought in by spock is up-to-date
testImplementation buildLibs.asm
integTestImplementation buildLibs.asm
integTestImplementation('org.ow2.asm:asm:9.5')
integTestImplementation('org.ow2.asm:asm:9.6')
api("org.yaml:snakeyaml") {
version { strictly(versions.snakeyaml) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.util.Locale;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;

import javax.net.ssl.SSLContext;

Expand All @@ -51,6 +53,9 @@ public final class RestClientBuilder {
public static final int DEFAULT_MAX_CONN_PER_ROUTE = 10;
public static final int DEFAULT_MAX_CONN_TOTAL = 30;

static final String THREAD_NAME_PREFIX = "elasticsearch-rest-client-";
private static final String THREAD_NAME_FORMAT = THREAD_NAME_PREFIX + "%d-thread-%d";

public static final String VERSION;
static final String META_HEADER_NAME = "X-Elastic-Client-Meta";
static final String META_HEADER_VALUE;
Expand Down Expand Up @@ -298,6 +303,24 @@ public RestClient build() {
return restClient;
}

/**
* Similar to {@code org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.DefaultThreadFactory} but with better thread names.
*/
private static class RestClientThreadFactory implements ThreadFactory {
private static final AtomicLong CLIENT_THREAD_POOL_ID_GENERATOR = new AtomicLong();

private final long clientThreadPoolId = CLIENT_THREAD_POOL_ID_GENERATOR.getAndIncrement(); // 0-based
private final AtomicLong clientThreadId = new AtomicLong();

@Override
public Thread newThread(Runnable runnable) {
return new Thread(
runnable,
String.format(Locale.ROOT, THREAD_NAME_FORMAT, clientThreadPoolId, clientThreadId.incrementAndGet()) // 1-based
);
}
}

private CloseableHttpAsyncClient createHttpClient() {
// default timeouts are all infinite
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom()
Expand All @@ -315,7 +338,8 @@ private CloseableHttpAsyncClient createHttpClient() {
.setMaxConnTotal(DEFAULT_MAX_CONN_TOTAL)
.setSSLContext(SSLContext.getDefault())
.setUserAgent(USER_AGENT_HEADER_VALUE)
.setTargetAuthenticationStrategy(new PersistentCredentialsAuthenticationStrategy());
.setTargetAuthenticationStrategy(new PersistentCredentialsAuthenticationStrategy())
.setThreadFactory(new RestClientThreadFactory());
if (httpClientConfigCallback != null) {
httpClientBuilder = httpClientConfigCallback.customizeHttpClient(httpClientBuilder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.TrustManagerFactory;

import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
Expand Down Expand Up @@ -105,6 +111,40 @@ public void testBuilderUsesDefaultSSLContext() throws Exception {
}
}

public void testBuilderSetsThreadName() throws Exception {
assumeFalse("https://github.com/elastic/elasticsearch/issues/49094", inFipsJvm());
final SSLContext defaultSSLContext = SSLContext.getDefault();
try {
SSLContext.setDefault(getSslContext());
try (RestClient client = buildRestClient()) {
final CountDownLatch latch = new CountDownLatch(1);
client.performRequestAsync(new Request("GET", "/"), new ResponseListener() {
@Override
public void onSuccess(Response response) {
assertThat(
Thread.currentThread().getName(),
allOf(
startsWith(RestClientBuilder.THREAD_NAME_PREFIX),
containsString("elasticsearch"),
containsString("rest-client")
)
);
assertEquals(200, response.getStatusLine().getStatusCode());
latch.countDown();
}

@Override
public void onFailure(Exception exception) {
throw new AssertionError("unexpected", exception);
}
});
assertTrue(latch.await(10, TimeUnit.SECONDS));
}
} finally {
SSLContext.setDefault(defaultSSLContext);
}
}

private RestClient buildRestClient() {
InetSocketAddress address = httpsServer.getAddress();
return RestClient.builder(new HttpHost(address.getHostString(), address.getPort(), "https")).build();
Expand Down
4 changes: 2 additions & 2 deletions distribution/tools/plugin-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ dependencies {
compileOnly project(":libs:elasticsearch-cli")
implementation project(":libs:elasticsearch-plugin-api")
implementation project(":libs:elasticsearch-plugin-scanner")
implementation 'org.ow2.asm:asm:9.5'
implementation 'org.ow2.asm:asm-tree:9.5'
implementation 'org.ow2.asm:asm:9.6'
implementation 'org.ow2.asm:asm-tree:9.6'

api "org.bouncycastle:bcpg-fips:1.0.7.1"
api "org.bouncycastle:bc-fips:1.0.2.4"
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/103160.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 103160
summary: Set thread name used by REST client
area: Java Low Level REST Client
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/103178.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 103178
summary: Expose API key authentication metrics
area: Authentication
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/103903.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 103903
summary: Account for reserved disk size
area: Allocation
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/103928.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 103928
summary: "ESQL: `MV_FIRST` and `MV_LAST`"
area: ES|QL
type: enhancement
issues: []
6 changes: 6 additions & 0 deletions docs/changelog/103948.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 103948
summary: '''elasticsearch-certutil cert'' now verifies the issuing chain of the generated
certificate'
area: TLS
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/103996.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 103996
summary: Ensure unique IDs between inference models and trained model deployments
area: Machine Learning
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/104029.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 104029
summary: '`AsyncOperator#isFinished` must never return true on failure'
area: ES|QL
type: bug
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/104046.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 104046
summary: "ESQL: Update the use of some user-caused exceptions"
area: ES|QL
type: bug
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/104063.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 104063
summary: Add serverless scopes for Connector APIs
area: Application
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/104077.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 104077
summary: Retry updates to model snapshot ID on job config
area: Machine Learning
type: bug
issues: []
6 changes: 6 additions & 0 deletions docs/changelog/104118.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 104118
summary: "ESQL: add `date_diff` function"
area: ES|QL
type: enhancement
issues:
- 101942
20 changes: 20 additions & 0 deletions docs/reference/esql/esql-apis.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[esql-apis]]
== {esql} APIs

The {es} Query Language ({esql}) provides a powerful way to filter, transform,
and analyze data stored in {es}, and in the future in other runtimes. For an
overview of {esql} and related tutorials, see <<esql>>.

* <<esql-query-api>>
* <<esql-async-query-api>>
* <<esql-async-query-get-api>>
* <<esql-async-query-delete-api>>


include::esql-query-api.asciidoc[]

include::esql-async-query-api.asciidoc[]

include::esql-async-query-get-api.asciidoc[]

include::esql-async-query-delete-api.asciidoc[]
Loading

0 comments on commit 1e36455

Please sign in to comment.