Skip to content

Commit 9677d53

Browse files
committed
Merge branch 'geogrid_tech_preview' of github.com:craigtaverner/elasticsearch into geogrid_tech_preview
2 parents 2fff33a + c6d1435 commit 9677d53

File tree

86 files changed

+2321
-1059
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2321
-1059
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
steps:
2+
- command: .buildkite/scripts/trigger-if-java-ea-new-build.sh
3+
env:
4+
RECENT_TIME_WINDOW: "24" # time window to consider a build as new in hours
5+
agents:
6+
image: "docker.elastic.co/ci-agent-images/eck-region/buildkite-agent:1.5"
7+
memory: "4G"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
steps: []
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#
2+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
# or more contributor license agreements. Licensed under the "Elastic License
4+
# 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
# Public License v 1"; you may not use this file except in compliance with, at
6+
# your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
# License v3.0 only", or the "Server Side Public License, v 1".
8+
#
9+
10+
#!/bin/bash
11+
12+
# Allow overriding the time window (in hours) to check for new builds, defaults to 24
13+
RECENT_TIME_WINDOW=${RECENT_TIME_WINDOW:-24}
14+
15+
# Extract current JDK major version from bundled_jdk in version.properties
16+
CURRENT_JDK=$(grep "^bundled_jdk =" build-tools-internal/version.properties | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)
17+
TARGET_JDK=$((CURRENT_JDK + 1))
18+
19+
echo "Current JDK major version: $CURRENT_JDK"
20+
echo "Target JDK major version: $TARGET_JDK"
21+
22+
# Query Elasticsearch JDK archive for available JDKs
23+
JDK_ARCHIVE_URL="https://builds.es-jdk-archive.com/jdks/openjdk/recent.json"
24+
echo "Querying JDK archive: $JDK_ARCHIVE_URL"
25+
26+
# Fetch JDK info and filter for target major version
27+
JDK_DATA=$(curl -s "$JDK_ARCHIVE_URL")
28+
29+
if [[ -z "$JDK_DATA" ]]; then
30+
echo "Failed to fetch JDK data from archive"
31+
exit 1
32+
fi
33+
34+
# Find the latest build for the target JDK version
35+
LATEST_BUILD=$(echo "$JDK_DATA" | jq -r --arg target "$TARGET_JDK" '
36+
.majors[$target].builds |
37+
sort_by(.archived_at) |
38+
last'
39+
)
40+
41+
if [[ "$LATEST_BUILD" == "null" || -z "$LATEST_BUILD" ]]; then
42+
echo "No builds found for JDK $TARGET_JDK"
43+
exit 1
44+
fi
45+
46+
# Extract timestamp and JDK identifier
47+
TIMESTAMP=$(echo "$LATEST_BUILD" | jq -r '.archived_at')
48+
JDK_IDENTIFIER=$(echo "$LATEST_BUILD" | jq -r '.id')
49+
50+
echo "Latest JDK ${TARGET_JDK} build from ES archive:"
51+
echo " Timestamp: $TIMESTAMP"
52+
echo " JDK Identifier: $JDK_IDENTIFIER"
53+
54+
# Set variables for use in the pipeline trigger
55+
jdkbuild="$JDK_IDENTIFIER"
56+
jdk_timestamp="$TIMESTAMP"
57+
58+
# Check if timestamp is within last 24 hours
59+
CURRENT_TIME=$(date +%s)
60+
BUILD_TIME=$(date -d "$TIMESTAMP" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S" "${TIMESTAMP%Z}" +%s 2>/dev/null || echo "0")
61+
62+
if [[ "$BUILD_TIME" == "0" ]]; then
63+
echo "Failed to parse timestamp: $TIMESTAMP"
64+
SHOULD_TRIGGER="false"
65+
else
66+
TIME_DIFF=$((CURRENT_TIME - BUILD_TIME))
67+
TIME_WINDOW=$((RECENT_TIME_WINDOW * 60 * 60))
68+
69+
if [[ $TIME_DIFF -lt $TIME_WINDOW ]]; then
70+
echo "Build is recent (less than ${RECENT_TIME_WINDOW}h old)"
71+
SHOULD_TRIGGER="true"
72+
else
73+
echo "Build is older than ${RECENT_TIME_WINDOW} hours"
74+
SHOULD_TRIGGER="false"
75+
fi
76+
fi
77+
78+
echo "SHOULD_TRIGGER: $SHOULD_TRIGGER"
79+
80+
81+
if [[ "$SHOULD_TRIGGER" == "true" ]]; then
82+
EFFECTIVE_START_DATE=$(date -u -d "@$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -r "$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo "")
83+
echo "Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER"
84+
cat << EOF | buildkite-agent pipeline upload
85+
steps:
86+
- trigger: elasticsearch-performance-esbench-jdk
87+
label: Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER
88+
async: true
89+
build:
90+
branch: "$BUILDKITE_BRANCH"
91+
env:
92+
EFFECTIVE_START_DATE: "$EFFECTIVE_START_DATE"
93+
EXECUTION_MODE: "start-run"
94+
EOF
95+
fi

catalog-info.yaml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,45 @@ spec:
138138
cronline: "0 4 * * * America/New_York"
139139
message: "Run java EA tests 1x per day"
140140
---
141-
141+
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
142+
apiVersion: backstage.io/v1alpha1
143+
kind: Resource
144+
metadata:
145+
name: buildkite-pipeline-elasticsearch-java-ea-check-new-build
146+
description: Check for new jdk ea build and trigger downstream jobs
147+
links:
148+
- title: Pipeline
149+
url: https://buildkite.com/elastic/elasticsearch-java-ea-check-new-build
150+
spec:
151+
type: buildkite-pipeline
152+
system: buildkite
153+
owner: group:elasticsearch-team
154+
implementation:
155+
apiVersion: buildkite.elastic.dev/v1
156+
kind: Pipeline
157+
metadata:
158+
description: ":java: Check for new pre release jdk build and trigger downstream jobs"
159+
name: elasticsearch / java-ea / check-new-build
160+
spec:
161+
repository: elastic/elasticsearch
162+
pipeline_file: .buildkite/pipelines/java-ea-check-new-build.yml
163+
branch_configuration: main
164+
teams:
165+
elasticsearch-team: {}
166+
ml-core: {}
167+
everyone:
168+
access_level: BUILD_AND_READ
169+
provider_settings:
170+
build_branches: false
171+
build_pull_requests: false
172+
publish_commit_status: false
173+
trigger_mode: none
174+
schedules:
175+
Periodically on main:
176+
branch: main
177+
cronline: "0 6 * * * UTC"
178+
message: "Check for new java pre release build 1x per day"
179+
---
142180
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
143181
apiVersion: backstage.io/v1alpha1
144182
kind: Resource

libs/logstash-bridge/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ other Elasticsearch internals.
66

77
If a change is introduced in a separate Elasticsearch project that causes this project to fail,
88
please consult with members of @elastic/logstash to chart a path forward.
9+
10+
## How to build the module?
11+
```shell
12+
./gradlew :lib:logstash-bridge:build
13+
```

libs/logstash-bridge/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ dependencies {
2424
compileOnly project(':x-pack:plugin:redact')
2525
compileOnly project(':x-pack:plugin:spatial')
2626
compileOnly project(':x-pack:plugin:wildcard')
27+
28+
compileOnly('com.maxmind.db:maxmind-db:3.1.1')
2729
}
2830

2931
tasks.named('forbiddenApisMain').configure {

libs/logstash-bridge/src/main/java/module-info.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
requires org.elasticsearch.redact;
2424
requires org.elasticsearch.spatial;
2525
requires org.elasticsearch.wildcard;
26+
requires org.elasticsearch.ingest.geoip;
27+
requires com.maxmind.db;
2628

2729
exports org.elasticsearch.logstashbridge;
2830
exports org.elasticsearch.logstashbridge.common;

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/StableBridgeAPI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ static <T, B extends StableBridgeAPI<T>> B fromInternal(final T delegate, final
5050
* An {@code ProxyInternal<INTERNAL>} is an implementation of {@code StableBridgeAPI<INTERNAL>} that
5151
* proxies calls to a delegate that is an actual {@code INTERNAL}.
5252
*
53+
* <p>
54+
* implementations are intended to be <em>opaque</em> to consumers of this library,
55+
* and should <em>NOT</em> have public constructors.
56+
* </p>
57+
*
5358
* @param <INTERNAL>
5459
*/
5560
abstract class ProxyInternal<INTERNAL> implements StableBridgeAPI<INTERNAL> {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.logstashbridge.common;
11+
12+
import org.elasticsearch.cluster.metadata.ProjectId;
13+
import org.elasticsearch.logstashbridge.StableBridgeAPI;
14+
15+
/**
16+
* A {@link StableBridgeAPI} for {@link ProjectId}
17+
*/
18+
public interface ProjectIdBridge extends StableBridgeAPI<ProjectId> {
19+
String id();
20+
21+
static ProjectIdBridge fromInternal(final ProjectId projectId) {
22+
return new ProxyInternal(projectId);
23+
}
24+
25+
static ProjectIdBridge fromId(final String id) {
26+
final ProjectId internal = ProjectId.fromId(id);
27+
return new ProxyInternal(internal);
28+
}
29+
30+
static ProjectIdBridge getDefault() {
31+
return ProxyInternal.DEFAULT;
32+
}
33+
34+
/**
35+
* An implementation of {@link ProjectIdBridge} that proxies calls to
36+
* an internal {@link ProjectId} instance.
37+
*
38+
* @see StableBridgeAPI.ProxyInternal
39+
*/
40+
final class ProxyInternal extends StableBridgeAPI.ProxyInternal<ProjectId> implements ProjectIdBridge {
41+
private static final ProjectIdBridge.ProxyInternal DEFAULT = new ProjectIdBridge.ProxyInternal(ProjectId.DEFAULT);
42+
43+
ProxyInternal(ProjectId internalDelegate) {
44+
super(internalDelegate);
45+
}
46+
47+
@Override
48+
public String id() {
49+
return this.internalDelegate.id();
50+
}
51+
52+
@Override
53+
public ProjectId toInternal() {
54+
return this.internalDelegate;
55+
}
56+
}
57+
}

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/common/SettingsBridge.java

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,27 @@
1212
import org.elasticsearch.logstashbridge.StableBridgeAPI;
1313

1414
/**
15-
* An external bridge for {@link Settings}
15+
* A {@link StableBridgeAPI} for {@link Settings}
1616
*/
17-
public class SettingsBridge extends StableBridgeAPI.ProxyInternal<Settings> {
17+
public interface SettingsBridge extends StableBridgeAPI<Settings> {
1818

19-
public static SettingsBridge fromInternal(final Settings delegate) {
20-
return new SettingsBridge(delegate);
19+
static SettingsBridge fromInternal(final Settings delegate) {
20+
return new ProxyInternal(delegate);
2121
}
2222

23-
public static Builder builder() {
24-
return Builder.fromInternal(Settings.builder());
25-
}
26-
27-
public SettingsBridge(final Settings delegate) {
28-
super(delegate);
29-
}
30-
31-
@Override
32-
public Settings toInternal() {
33-
return this.internalDelegate;
23+
static SettingsBuilderBridge builder() {
24+
return SettingsBuilderBridge.fromInternal(Settings.builder());
3425
}
3526

3627
/**
37-
* An external bridge for {@link Settings.Builder} that proxies calls to a real {@link Settings.Builder}
28+
* An implementation of {@link SettingsBridge} that proxies calls to
29+
* an internal {@link Settings} instance.
30+
*
31+
* @see StableBridgeAPI.ProxyInternal
3832
*/
39-
public static class Builder extends StableBridgeAPI.ProxyInternal<Settings.Builder> {
40-
static Builder fromInternal(final Settings.Builder delegate) {
41-
return new Builder(delegate);
42-
}
43-
44-
private Builder(final Settings.Builder delegate) {
45-
super(delegate);
46-
}
47-
48-
public Builder put(final String key, final String value) {
49-
this.internalDelegate.put(key, value);
50-
return this;
51-
}
52-
53-
public SettingsBridge build() {
54-
return new SettingsBridge(this.internalDelegate.build());
33+
final class ProxyInternal extends StableBridgeAPI.ProxyInternal<Settings> implements SettingsBridge {
34+
ProxyInternal(Settings internalDelegate) {
35+
super(internalDelegate);
5536
}
5637
}
5738
}

0 commit comments

Comments
 (0)