Skip to content

Commit b513749

Browse files
committed
Merge remote-tracking branch 'origin/main' into lucene_snapshot_10_3
2 parents f26bfde + fb76bed commit b513749

File tree

496 files changed

+6812
-2955
lines changed

Some content is hidden

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

496 files changed

+6812
-2955
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
package org.elasticsearch.benchmark.bytes;
10+
11+
import org.elasticsearch.common.bytes.BytesArray;
12+
import org.elasticsearch.common.logging.LogConfigurator;
13+
import org.openjdk.jmh.annotations.Benchmark;
14+
import org.openjdk.jmh.annotations.BenchmarkMode;
15+
import org.openjdk.jmh.annotations.Fork;
16+
import org.openjdk.jmh.annotations.Measurement;
17+
import org.openjdk.jmh.annotations.Mode;
18+
import org.openjdk.jmh.annotations.OutputTimeUnit;
19+
import org.openjdk.jmh.annotations.Param;
20+
import org.openjdk.jmh.annotations.Scope;
21+
import org.openjdk.jmh.annotations.Setup;
22+
import org.openjdk.jmh.annotations.State;
23+
import org.openjdk.jmh.annotations.Warmup;
24+
25+
import java.util.concurrent.TimeUnit;
26+
27+
@Warmup(iterations = 4, time = 1)
28+
@Measurement(iterations = 5, time = 1)
29+
@BenchmarkMode(Mode.Throughput)
30+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
31+
@State(Scope.Thread)
32+
@Fork(value = 1)
33+
public class BytesArrayIndexOfBenchmark {
34+
35+
static {
36+
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
37+
}
38+
39+
static final byte MARKER = (byte) '\n';
40+
41+
@Param(value = { "64", "127", "128", "4096", "16384", "65536", "1048576" })
42+
public int size;
43+
44+
BytesArray bytesArray;
45+
46+
@Setup
47+
public void setup() {
48+
byte[] bytes = new byte[size];
49+
bytes[bytes.length - 1] = MARKER;
50+
bytesArray = new BytesArray(bytes, 0, bytes.length);
51+
}
52+
53+
@Benchmark
54+
public int indexOf() {
55+
return bytesArray.indexOf(MARKER, 0);
56+
}
57+
58+
@Benchmark
59+
@Fork(jvmArgsPrepend = { "--add-modules=jdk.incubator.vector" })
60+
public int indexOfPanama() {
61+
return bytesArray.indexOf(MARKER, 0);
62+
}
63+
64+
@Benchmark
65+
public int withOffsetIndexOf() {
66+
return bytesArray.indexOf(MARKER, 1);
67+
}
68+
69+
@Benchmark
70+
@Fork(jvmArgsPrepend = { "--add-modules=jdk.incubator.vector" })
71+
public int withOffsetIndexPanama() {
72+
return bytesArray.indexOf(MARKER, 1);
73+
}
74+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.benchmark.bytes;
11+
12+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
13+
14+
import org.elasticsearch.test.ESTestCase;
15+
import org.openjdk.jmh.annotations.Param;
16+
17+
import java.util.Arrays;
18+
19+
public class BytesArrayIndexOfBenchmarkTests extends ESTestCase {
20+
21+
final int size;
22+
23+
public BytesArrayIndexOfBenchmarkTests(int size) {
24+
this.size = size;
25+
}
26+
27+
public void testIndexOf() {
28+
var bench = new BytesArrayIndexOfBenchmark();
29+
bench.size = size;
30+
bench.setup();
31+
assertEquals(size - 1, bench.indexOf());
32+
assertEquals(size - 1, bench.indexOfPanama());
33+
assertEquals(size - 1, bench.withOffsetIndexOf());
34+
assertEquals(size - 1, bench.withOffsetIndexPanama());
35+
}
36+
37+
@ParametersFactory
38+
public static Iterable<Object[]> parametersFactory() {
39+
try {
40+
var params = BytesArrayIndexOfBenchmark.class.getField("size").getAnnotationsByType(Param.class)[0].value();
41+
return () -> Arrays.stream(params).map(Integer::parseInt).map(i -> new Object[] { i }).iterator();
42+
} catch (NoSuchFieldException e) {
43+
throw new AssertionError(e);
44+
}
45+
}
46+
}

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/transport/AbstractTransportVersionFuncTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class AbstractTransportVersionFuncTest extends AbstractGradleFuncTest {
125125
tasks.named('generateTransportVersion') {
126126
currentUpperBoundName = '9.2'
127127
}
128+
tasks.named('validateTransportVersionResources') {
129+
currentUpperBoundName = '9.2'
130+
}
128131
"""
129132
referableAndReferencedTransportVersion("existing_91", "8012000")
130133
referableAndReferencedTransportVersion("older_92", "8122000")

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/transport/TransportVersionValidationFuncTest.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,21 @@ class TransportVersionValidationFuncTest extends AbstractTransportVersionFuncTes
277277
"[myserver/src/main/resources/transport/definitions/referable/existing_92.csv]"
278278
)
279279
}
280+
281+
def "primary id checks skipped on release branch"() {
282+
given:
283+
file("myserver/build.gradle") << """
284+
tasks.named('validateTransportVersionResources') {
285+
currentUpperBoundName = '9.1'
286+
}
287+
"""
288+
referableAndReferencedTransportVersion("some_tv", "8125000")
289+
transportVersionUpperBound("9.2", "some_tv", "8125000")
290+
291+
when:
292+
def result = gradleRunner("validateTransportVersionResources").build()
293+
294+
then:
295+
result.task(":myserver:validateTransportVersionResources").outcome == TaskOutcome.SUCCESS
296+
}
280297
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/transport/TransportVersionResourcesPlugin.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.gradle.internal.conventions.VersionPropertiesPlugin;
1515
import org.elasticsearch.gradle.internal.conventions.precommit.PrecommitPlugin;
1616
import org.elasticsearch.gradle.internal.conventions.precommit.PrecommitTaskPlugin;
17+
import org.gradle.api.Action;
1718
import org.gradle.api.Plugin;
1819
import org.gradle.api.Project;
1920
import org.gradle.api.file.Directory;
@@ -23,7 +24,6 @@
2324

2425
import java.util.Map;
2526
import java.util.Properties;
26-
import java.util.function.Consumer;
2727

2828
public class TransportVersionResourcesPlugin implements Plugin<Project> {
2929

@@ -70,6 +70,7 @@ public void apply(Project project) {
7070
t.getReferencesFiles().setFrom(tvReferencesConfig);
7171
t.getShouldValidateDensity().convention(true);
7272
t.getShouldValidatePrimaryIdNotPatch().convention(true);
73+
t.getCurrentUpperBoundName().convention(currentVersion.getMajor() + "." + currentVersion.getMinor());
7374
});
7475
project.getTasks().named(PrecommitPlugin.PRECOMMIT_TASK_NAME).configure(t -> t.dependsOn(validateTask));
7576

@@ -83,7 +84,7 @@ public void apply(Project project) {
8384
t.into(resourceRoot + "/definitions", c -> c.from(generateManifestTask));
8485
});
8586

86-
Consumer<GenerateTransportVersionDefinitionTask> generationConfiguration = t -> {
87+
Action<GenerateTransportVersionDefinitionTask> generationConfiguration = t -> {
8788
t.setGroup(taskGroup);
8889
t.getReferencesFiles().setFrom(tvReferencesConfig);
8990
t.getIncrement().convention(1000);
@@ -92,17 +93,17 @@ public void apply(Project project) {
9293

9394
var generateDefinitionsTask = project.getTasks()
9495
.register("generateTransportVersion", GenerateTransportVersionDefinitionTask.class, t -> {
95-
generationConfiguration.accept(t);
9696
t.setDescription("(Re)generates a transport version definition file");
9797
});
98+
generateDefinitionsTask.configure(generationConfiguration);
9899
validateTask.configure(t -> t.mustRunAfter(generateDefinitionsTask));
99100

100101
var resolveConflictTask = project.getTasks()
101102
.register("resolveTransportVersionConflict", GenerateTransportVersionDefinitionTask.class, t -> {
102-
generationConfiguration.accept(t);
103103
t.setDescription("Resolve merge conflicts in transport version internal state files");
104104
t.getResolveConflict().set(true);
105105
});
106+
resolveConflictTask.configure(generationConfiguration);
106107
validateTask.configure(t -> t.mustRunAfter(resolveConflictTask));
107108

108109
var generateInitialTask = project.getTasks()

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/transport/ValidateTransportVersionResourcesTask.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ public Path getResourcesDir() {
6060
@Input
6161
public abstract Property<Boolean> getShouldValidatePrimaryIdNotPatch();
6262

63+
/**
64+
* The name of the upper bounds file which will be used at runtime on the current branch. Normally
65+
* this equates to VersionProperties.getElasticsearchVersion().
66+
*/
67+
@Input
68+
public abstract Property<String> getCurrentUpperBoundName();
69+
6370
private record IdAndDefinition(TransportVersionId id, TransportVersionDefinition definition) {}
6471

6572
private static final Pattern NAME_FORMAT = Pattern.compile("[a-z0-9_]+");
@@ -76,6 +83,7 @@ public void validateTransportVersions() throws IOException {
7683
Map<String, TransportVersionDefinition> allDefinitions = collectAllDefinitions(referableDefinitions, unreferableDefinitions);
7784
Map<Integer, List<IdAndDefinition>> idsByBase = collectIdsByBase(allDefinitions.values());
7885
Map<String, TransportVersionUpperBound> upperBounds = resources.getUpperBounds();
86+
boolean onReleaseBranch = checkIfDefinitelyOnReleaseBranch(upperBounds);
7987

8088
for (var definition : referableDefinitions.values()) {
8189
validateNamedDefinition(definition, referencedNames);
@@ -93,7 +101,9 @@ public void validateTransportVersions() throws IOException {
93101
validateUpperBound(upperBound, allDefinitions, idsByBase);
94102
}
95103

96-
validatePrimaryIds(resources, upperBounds, allDefinitions);
104+
if (onReleaseBranch == false) {
105+
validatePrimaryIds(resources, upperBounds, allDefinitions);
106+
}
97107
}
98108

99109
private Map<String, TransportVersionDefinition> collectAllDefinitions(
@@ -245,7 +255,7 @@ private void validateUpperBound(
245255
}
246256

247257
TransportVersionUpperBound existingUpperBound = getResources().get().getUpperBoundFromUpstream(upperBound.name());
248-
if (existingUpperBound != null) {
258+
if (existingUpperBound != null && getShouldValidatePrimaryIdNotPatch().get()) {
249259
if (upperBound.definitionId().patch() != 0 && upperBound.definitionId().base() != existingUpperBound.definitionId().base()) {
250260
throwUpperBoundFailure(
251261
upperBound,
@@ -318,6 +328,15 @@ private void validatePrimaryIds(
318328
);
319329
}
320330

331+
private boolean checkIfDefinitelyOnReleaseBranch(Map<String, TransportVersionUpperBound> upperBounds) {
332+
// only want to look at definitions <= the current upper bound.
333+
// TODO: we should filter all of the upper bounds/definitions that are validated by this, not just in this method
334+
String currentUpperBoundName = getCurrentUpperBoundName().get();
335+
TransportVersionUpperBound currentUpperBound = upperBounds.get(currentUpperBoundName);
336+
337+
return upperBounds.values().stream().anyMatch(u -> u.definitionId().complete() > currentUpperBound.definitionId().complete());
338+
}
339+
321340
private void throwDefinitionFailure(TransportVersionDefinition definition, String message) {
322341
Path relativePath = getResources().get().getDefinitionPath(definition);
323342
throw new VerificationException("Transport version definition file [" + relativePath + "] " + message);

build-tools-internal/src/main/resources/fips_java.security

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ jdk.xml.dsig.secureValidationPolicy=\
4949
noRetrievalMethodLoops
5050
jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep;\
5151
java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!*
52+
53+
# Needed since JDK25 to match the default config in the out-of-the-box java.security
54+
jdk.includeInExceptions=hostInfoExclSocket

build-tools-internal/src/main/resources/fips_java_oracle.security

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ jdk.xml.dsig.secureValidationPolicy=\
5050
noRetrievalMethodLoops
5151
jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep;\
5252
java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!*
53+
54+
# Needed since JDK25 to match the default config in the out-of-the-box java.security
55+
jdk.includeInExceptions=hostInfoExclSocket

build-tools-internal/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ elasticsearch = 9.2.0
22
lucene = 10.3.0
33

44
bundled_jdk_vendor = openjdk
5-
bundled_jdk = 24.0.2+12@fdc5d0102fe0414db21410ad5834341f
5+
bundled_jdk = 25+36@bd75d5f9689641da8e1daabeccb5528b
66
# optional dependencies
77
spatial4j = 0.7
88
jts = 1.15.0

client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import static org.elasticsearch.client.RestClientTestUtil.randomErrorNoRetryStatusCode;
5050
import static org.elasticsearch.client.RestClientTestUtil.randomOkStatusCode;
5151
import static org.hamcrest.CoreMatchers.instanceOf;
52+
import static org.hamcrest.Matchers.startsWith;
5253
import static org.junit.Assert.assertEquals;
5354
import static org.junit.Assert.assertThat;
5455
import static org.junit.Assert.assertTrue;
@@ -314,7 +315,7 @@ public void testNodeSelector() throws Exception {
314315
} catch (ConnectException e) {
315316
// Windows isn't consistent here. Sometimes the message is even null!
316317
if (false == System.getProperty("os.name").startsWith("Windows")) {
317-
assertEquals("Connection refused", e.getMessage());
318+
assertThat(e.getMessage(), startsWith("Connection refused"));
318319
}
319320
}
320321
} else {

0 commit comments

Comments
 (0)