Skip to content

Commit 822c6e3

Browse files
authored
Merge branch 'main' into mp-downsample
2 parents 493288f + cfa98f3 commit 822c6e3

File tree

78 files changed

+309
-337
lines changed

Some content is hidden

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

78 files changed

+309
-337
lines changed

build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ develocity {
133133
}
134134
} else {
135135
tag 'LOCAL'
136-
if (providers.systemProperty('idea.active').present) {
136+
if (System.getProperty('idea.active') == 'true') {
137137
tag 'IDEA'
138138
}
139139
}

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Docs live in **three places**:
1717

1818
1. **Reference content** lives in this repo. This covers low-level stuff like settings and configuration information that is tightly coupled to code.
1919
- 👩🏽‍💻 **Engineers** own the bulk of this content.
20-
2. **API reference docs** live in the [Elasticsearch specification](https://github.com/elastic/elasticsearch-specification)
20+
2. **API reference docs** live in the [Elasticsearch specification](https://github.com/elastic/elasticsearch-specification/blob/main/README.md#how-to-generate-the-openapi-representation)
2121
- This is where you need to update API docs published in the [new API docs system](https://www.elastic.co/docs/api/doc/elasticsearch/v8/)
2222
- 👩🏽‍💻 **Engineers** own this content.
2323
3. **Narrative, overview, and conceptual content** mostly lives in the [`docs-content`](https://github.com/elastic/docs-content/) repo.
@@ -106,4 +106,4 @@ This allows slightly more expressive testing of the snippets. Since that syntax
106106
% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: thai_example, first: thai, second: rebuilt_thai}\nendyaml\n/]
107107
```
108108

109-
Any place you can use json you can use elements like `$body.path.to.thing` which is replaced on the fly with the contents of the thing at `path.to.thing` in the last response.
109+
Any place you can use json you can use elements like `$body.path.to.thing` which is replaced on the fly with the contents of the thing at `path.to.thing` in the last response.

plugins/discovery-ec2/build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ esplugin.bundleSpec.from('config/discovery-ec2') {
4646
}
4747

4848
tasks.register("writeTestJavaPolicy") {
49+
boolean inFips = buildParams.inFipsJvm
50+
inputs.property("inFipsJvm", inFips)
51+
final File javaPolicy = new File(layout.buildDirectory.asFile.get(), "tmp/java.policy")
52+
outputs.file(javaPolicy)
4953
doLast {
50-
final File tmp = file("${buildDir}/tmp")
51-
if (tmp.exists() == false && tmp.mkdirs() == false) {
52-
throw new GradleException("failed to create temporary directory [${tmp}]")
53-
}
54-
final File javaPolicy = file("${tmp}/java.policy")
55-
if (buildParams.inFipsJvm) {
54+
if (inFips) {
5655
javaPolicy.write(
5756
[
5857
"grant {",
@@ -95,9 +94,9 @@ tasks.withType(Test).configureEach {
9594
// this is needed to manipulate com.amazonaws.sdk.ec2MetadataServiceEndpointOverride system property
9695
// it is better rather disable security manager at all with `systemProperty 'tests.security.manager', 'false'`
9796
if (buildParams.inFipsJvm){
98-
nonInputProperties.systemProperty 'java.security.policy', "=file://${buildDir}/tmp/java.policy"
97+
nonInputProperties.systemProperty 'java.security.policy', "=file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
9998
} else {
100-
nonInputProperties.systemProperty 'java.security.policy', "file://${buildDir}/tmp/java.policy"
99+
nonInputProperties.systemProperty 'java.security.policy', "file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
101100
}
102101
}
103102

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ static TransportVersion def(int id) {
5757
public static final TransportVersion V_7_3_0 = def(7_03_00_99);
5858
public static final TransportVersion V_7_3_2 = def(7_03_02_99);
5959
public static final TransportVersion V_7_4_0 = def(7_04_00_99);
60-
public static final TransportVersion V_7_6_0 = def(7_06_00_99);
6160
public static final TransportVersion V_7_8_0 = def(7_08_00_99);
6261
public static final TransportVersion V_7_8_1 = def(7_08_01_99);
6362
public static final TransportVersion V_7_9_0 = def(7_09_00_99);

server/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ private static void writeBlockSet(Set<ClusterBlock> blocks, StreamOutput out) th
438438
public static ClusterBlocks readFrom(StreamInput in) throws IOException {
439439
if (in.getTransportVersion().onOrAfter(TransportVersions.MULTI_PROJECT)) {
440440
final Set<ClusterBlock> global = readBlockSet(in);
441-
final Map<ProjectId, ProjectBlocks> projectBlocksMap = in.readImmutableMap(ProjectId::new, ProjectBlocks::readFrom);
441+
final Map<ProjectId, ProjectBlocks> projectBlocksMap = in.readImmutableMap(ProjectId::readFrom, ProjectBlocks::readFrom);
442442
if (global.isEmpty()
443443
&& noProjectOrDefaultProjectOnly(projectBlocksMap)
444444
&& projectBlocksMap.getOrDefault(Metadata.DEFAULT_PROJECT_ID, ProjectBlocks.EMPTY).indices().isEmpty()) {

server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class Metadata implements Diffable<Metadata>, ChunkedToXContent {
8888
public static final String UNKNOWN_CLUSTER_UUID = "_na_";
8989
// TODO multi-project: verify that usages are really expected to work on the default project only,
9090
// and that they are not a stop-gap solution to make the tests pass
91-
public static final ProjectId DEFAULT_PROJECT_ID = new ProjectId("default");
91+
public static final ProjectId DEFAULT_PROJECT_ID = ProjectId.DEFAULT;
9292

9393
public enum XContentContext {
9494
/* Custom metadata should be returned as part of API call */
@@ -1154,7 +1154,7 @@ public static Metadata readFrom(StreamInput in) throws IOException {
11541154
builder.put(ReservedStateMetadata.readFrom(in));
11551155
}
11561156

1157-
builder.projectMetadata(in.readMap(ProjectId::new, ProjectMetadata::readFrom));
1157+
builder.projectMetadata(in.readMap(ProjectId::readFrom, ProjectMetadata::readFrom));
11581158
}
11591159
return builder.build();
11601160
}

server/src/main/java/org/elasticsearch/cluster/metadata/ProjectId.java

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,39 @@
1919
import org.elasticsearch.xcontent.XContentParser;
2020

2121
import java.io.IOException;
22+
import java.util.Objects;
2223

23-
public record ProjectId(String id) implements Writeable, ToXContent {
24+
public class ProjectId implements Writeable, ToXContent {
2425

25-
public static final Reader<ProjectId> READER = ProjectId::new;
26+
private static final String DEFAULT_STRING = "default";
27+
public static final ProjectId DEFAULT = new ProjectId(DEFAULT_STRING);
28+
public static final Reader<ProjectId> READER = ProjectId::readFrom;
2629
private static final int MAX_LENGTH = 128;
2730

28-
public ProjectId {
31+
private final String id;
32+
33+
private ProjectId(String id) {
2934
if (Strings.isNullOrBlank(id)) {
3035
throw new IllegalArgumentException("project-id cannot be empty");
3136
}
32-
assert isValidFormatId(id) : "project-id [" + id + "] must be alphanumeric ASCII with up to " + MAX_LENGTH + " chars";
37+
if (isValidFormatId(id) == false) {
38+
final var message = "project-id [" + id + "] must be alphanumeric ASCII with up to " + MAX_LENGTH + " chars";
39+
assert false : message;
40+
throw new IllegalArgumentException(message);
41+
}
42+
this.id = id;
43+
}
44+
45+
public String id() {
46+
return id;
47+
}
48+
49+
public static ProjectId fromId(String id) {
50+
if (DEFAULT_STRING.equals(id)) {
51+
return DEFAULT;
52+
} else {
53+
return new ProjectId(id);
54+
}
3355
}
3456

3557
static boolean isValidFormatId(String id) {
@@ -53,8 +75,8 @@ private static boolean isValidIdChar(char c) {
5375
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || c == '-';
5476
}
5577

56-
public ProjectId(StreamInput in) throws IOException {
57-
this(in.readString());
78+
public static ProjectId readFrom(StreamInput in) throws IOException {
79+
return fromId(in.readString());
5880
}
5981

6082
@Override
@@ -79,4 +101,16 @@ public static ProjectId ofNullable(@Nullable String id, @Nullable ProjectId fall
79101
public String toString() {
80102
return this.id;
81103
}
104+
105+
@Override
106+
public boolean equals(Object o) {
107+
if (o == null || getClass() != o.getClass()) return false;
108+
ProjectId projectId = (ProjectId) o;
109+
return Objects.equals(id, projectId.id);
110+
}
111+
112+
@Override
113+
public int hashCode() {
114+
return Objects.hashCode(id);
115+
}
82116
}

server/src/main/java/org/elasticsearch/cluster/metadata/ProjectMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params p) {
21362136
}
21372137

21382138
public static ProjectMetadata readFrom(StreamInput in) throws IOException {
2139-
ProjectId id = new ProjectId(in);
2139+
ProjectId id = ProjectId.readFrom(in);
21402140
Builder builder = builder(id);
21412141
Function<String, MappingMetadata> mappingLookup;
21422142
Map<String, MappingMetadata> mappingMetadataMap = in.readMapValues(MappingMetadata::new, MappingMetadata::getSha256);

server/src/main/java/org/elasticsearch/cluster/project/AbstractProjectResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ProjectId getProjectId() {
5050
if (headerValue == null) {
5151
return getFallbackProjectId();
5252
}
53-
return new ProjectId(headerValue);
53+
return ProjectId.fromId(headerValue);
5454
}
5555

5656
@Override
@@ -89,7 +89,7 @@ public boolean supportsMultipleProjects() {
8989
}
9090

9191
protected static ProjectMetadata findProject(Metadata metadata, String headerValue) {
92-
var project = metadata.projects().get(new ProjectId(headerValue));
92+
var project = metadata.projects().get(ProjectId.fromId(headerValue));
9393
if (project == null) {
9494
throw new IllegalArgumentException("Could not find project with id [" + headerValue + "]");
9595
}

server/src/main/java/org/elasticsearch/cluster/routing/GlobalRoutingTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static Diff<GlobalRoutingTable> readDiffFrom(StreamInput in) throws IOExc
179179
}
180180

181181
public static GlobalRoutingTable readFrom(StreamInput in) throws IOException {
182-
final var table = in.readImmutableOpenMap(ProjectId::new, RoutingTable::readFrom);
182+
final var table = in.readImmutableOpenMap(ProjectId::readFrom, RoutingTable::readFrom);
183183
return new GlobalRoutingTable(table);
184184
}
185185

0 commit comments

Comments
 (0)