Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions docs/reference/setup/install/check-running.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ GET /
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,
"lucene_version" : "{lucene_version}",
"index_version" : "67890",
"minimum_wire_compatibility_version" : "1.2.3",
"minimum_index_compatibility_version" : "1.2.3",
"transport_version" : "12345"
"minimum_index_compatibility_version" : "1.2.3"
},
"tagline" : "You Know, for Search"
}
Expand All @@ -56,6 +54,4 @@ GET /
// TESTRESPONSE[s/"build_snapshot" : false,/"build_snapshot" : $body.version.build_snapshot,/]
// TESTRESPONSE[s/"minimum_wire_compatibility_version" : "1.2.3"/"minimum_wire_compatibility_version" : $body.version.minimum_wire_compatibility_version/]
// TESTRESPONSE[s/"minimum_index_compatibility_version" : "1.2.3"/"minimum_index_compatibility_version" : $body.version.minimum_index_compatibility_version/]
// TESTRESPONSE[s/"transport_version" : "12345"/"transport_version" : $body.version.transport_version/]
// TESTRESPONSE[s/"index_version" : "67890"/"index_version" : $body.version.index_version/]
// So much s/// but at least we test that the layout is close to matching....
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class MainResponse extends ActionResponse implements ToXContentObject {

private String nodeName;
private Version version;
private IndexVersion indexVersion;
private TransportVersion transportVersion;
private String luceneVersion;
private ClusterName clusterName;
private String clusterUuid;
private Build build;
Expand All @@ -41,26 +40,35 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
super(in);
nodeName = in.readString();
version = Version.readVersion(in);
indexVersion = in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031) ? IndexVersion.readVersion(in) : null;
transportVersion = in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019) ? TransportVersion.readVersion(in) : null;

// Index version and transport version were briefly included in the main response, but
// removed before the 8.9.0 release. Reading code remains here (throwing away the values)
// for those versions until the new format has propagated through serverless. Additionally,
// the lucene version was previously read by inferring from either Version or IndexVersion.
// Now the lucene version is read explicitly.
if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_037)) {
luceneVersion = in.readString();
} else {
if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031)) {
luceneVersion = IndexVersion.readVersion(in).luceneVersion().toString();
} else if (version.before(Version.V_8_10_0)) {
luceneVersion = IndexVersion.fromId(version.id).luceneVersion().toString();
} else {
luceneVersion = "unknown";
}
if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019)) {
TransportVersion.readVersion(in);
}
}
clusterName = new ClusterName(in);
clusterUuid = in.readString();
build = Build.readBuild(in);
}

public MainResponse(
String nodeName,
Version version,
IndexVersion indexVersion,
TransportVersion transportVersion,
ClusterName clusterName,
String clusterUuid,
Build build
) {
public MainResponse(String nodeName, Version version, String luceneVersion, ClusterName clusterName, String clusterUuid, Build build) {
this.nodeName = nodeName;
this.version = version;
this.indexVersion = indexVersion;
this.transportVersion = transportVersion;
this.luceneVersion = luceneVersion;
this.clusterName = clusterName;
this.clusterUuid = clusterUuid;
this.build = build;
Expand All @@ -74,12 +82,8 @@ public Version getVersion() {
return version;
}

public IndexVersion getIndexVersion() {
return indexVersion;
}

public TransportVersion getTransportVersion() {
return transportVersion;
public String getLuceneVersion() {
return luceneVersion;
}

public ClusterName getClusterName() {
Expand All @@ -98,27 +102,27 @@ public Build getBuild() {
public void writeTo(StreamOutput out) throws IOException {
out.writeString(nodeName);
Version.writeVersion(version, out);
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031)) {
IndexVersion.writeVersion(indexVersion, out);
}
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019)) {
TransportVersion.writeVersion(transportVersion, out);

// Index version and transport version were briefly included in the main response, but
// removed before the 8.9.0 release. Writing code remains here (writing the latest versions)
// for those versions until the new format has propagated through serverless. Additionally,
// the lucene version was previously inferred from either Version or IndexVersion.
// Now the lucene version is written explicitly.
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_037)) {
out.writeString(luceneVersion);
} else {
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031)) {
IndexVersion.writeVersion(IndexVersion.current(), out);
}
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019)) {
TransportVersion.writeVersion(TransportVersion.current(), out);
}
}
clusterName.writeTo(out);
out.writeString(clusterUuid);
Build.writeBuild(build, out);
}

private String getLuceneVersion() {
if (indexVersion != null) {
return indexVersion.luceneVersion().toString();
} else if (version.before(Version.V_8_10_0)) {
return IndexVersion.fromId(version.id).luceneVersion().toString();
} else {
return "unknown";
}
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
Expand All @@ -132,11 +136,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
.field("build_hash", build.hash())
.field("build_date", build.date())
.field("build_snapshot", build.isSnapshot())
.field("lucene_version", getLuceneVersion())
.field("index_version", indexVersion != null ? indexVersion.toString() : "unknown")
.field("lucene_version", luceneVersion)
.field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString())
.field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString())
.field("transport_version", transportVersion != null ? transportVersion.toString() : "unknown")
.endObject();
builder.field("tagline", "You Know, for Search");
builder.endObject();
Expand Down Expand Up @@ -170,16 +172,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
response.version = Version.fromString(
((String) value.get("number")).replace("-SNAPSHOT", "").replaceFirst("-(alpha\\d+|beta\\d+|rc\\d+)", "")
);

String indexVersion = (String) value.get("index_version");
response.indexVersion = indexVersion != null && indexVersion.equals("unknown") == false
? IndexVersion.fromId(Integer.parseInt(indexVersion))
: null;

String transportVersion = (String) value.get("transport_version");
response.transportVersion = transportVersion != null && transportVersion.equals("unknown") == false
? TransportVersion.fromString(transportVersion)
: null;
response.luceneVersion = ((String) value.get("lucene_version"));
}, (parser, context) -> parser.map(), new ParseField("version"));
}

Expand All @@ -198,16 +191,15 @@ public boolean equals(Object o) {
MainResponse other = (MainResponse) o;
return Objects.equals(nodeName, other.nodeName)
&& Objects.equals(version, other.version)
&& Objects.equals(indexVersion, other.indexVersion)
&& Objects.equals(transportVersion, other.transportVersion)
&& Objects.equals(luceneVersion, other.luceneVersion)
&& Objects.equals(clusterUuid, other.clusterUuid)
&& Objects.equals(build, other.build)
&& Objects.equals(clusterName, other.clusterName);
}

@Override
public int hashCode() {
return Objects.hash(nodeName, version, indexVersion, transportVersion, clusterUuid, build, clusterName);
return Objects.hash(nodeName, version, luceneVersion, clusterUuid, build, clusterName);
}

@Override
Expand All @@ -218,10 +210,8 @@ public String toString() {
+ '\''
+ ", version="
+ version
+ ", indexVersion="
+ indexVersion
+ ", transportVersion="
+ transportVersion
+ ", luceneVersion="
+ luceneVersion
+ ", clusterName="
+ clusterName
+ ", clusterUuid='"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package org.elasticsearch.rest.root;

import org.elasticsearch.Build;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
Expand Down Expand Up @@ -47,8 +46,7 @@ protected void doExecute(Task task, MainRequest request, ActionListener<MainResp
new MainResponse(
nodeName,
Version.CURRENT,
IndexVersion.current(),
TransportVersion.current(),
IndexVersion.current().luceneVersion().toString(),
clusterState.getClusterName(),
clusterState.metadata().clusterUUID(),
Build.current()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected MainResponse createTestInstance() {
IndexVersion indexVersion = IndexVersionUtils.randomVersion();
TransportVersion transportVersion = TransportVersionUtils.randomVersion();
Build build = new Build(Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(), version.toString());
return new MainResponse(nodeName, version, indexVersion, transportVersion, clusterName, clusterUuid, build);
return new MainResponse(nodeName, version, indexVersion.luceneVersion().toString(), clusterName, clusterUuid, build);
}

@Override
Expand All @@ -59,12 +59,10 @@ public void testToXContent() throws IOException {
Build build = new Build(current.type(), current.hash(), current.date(), current.isSnapshot(), current.qualifiedVersion());
Version version = Version.CURRENT;
IndexVersion indexVersion = IndexVersion.current();
TransportVersion transportVersion = TransportVersion.current();
MainResponse response = new MainResponse(
"nodeName",
version,
indexVersion,
transportVersion,
indexVersion.luceneVersion().toString(),
new ClusterName("clusterName"),
clusterUUID,
build
Expand All @@ -87,10 +85,8 @@ public void testToXContent() throws IOException {
"build_date": "%s",
"build_snapshot": %s,
"lucene_version": "%s",
"index_version": "%s",
"minimum_wire_compatibility_version": "%s",
"minimum_index_compatibility_version": "%s",
"transport_version": "%s"
"minimum_index_compatibility_version": "%s"
},
"tagline": "You Know, for Search"
}
Expand All @@ -102,10 +98,8 @@ public void testToXContent() throws IOException {
current.date(),
current.isSnapshot(),
indexVersion.luceneVersion().toString(),
indexVersion.toString(),
version.minimumCompatibilityVersion().toString(),
version.minimumIndexCompatibilityVersion().toString(),
transportVersion.toString()
version.minimumIndexCompatibilityVersion().toString()
)
),
Strings.toString(builder)
Expand All @@ -117,21 +111,22 @@ protected MainResponse mutateInstance(MainResponse mutateInstance) {
String clusterUuid = mutateInstance.getClusterUuid();
Build build = mutateInstance.getBuild();
Version version = mutateInstance.getVersion();
IndexVersion indexVersion = mutateInstance.getIndexVersion();
TransportVersion transportVersion = mutateInstance.getTransportVersion();
String luceneVersion = mutateInstance.getLuceneVersion();
String nodeName = mutateInstance.getNodeName();
ClusterName clusterName = mutateInstance.getClusterName();
switch (randomIntBetween(0, 6)) {
switch (randomIntBetween(0, 5)) {
case 0 -> clusterUuid = clusterUuid + randomAlphaOfLength(5);
case 1 -> nodeName = nodeName + randomAlphaOfLength(5);
case 2 ->
// toggle the snapshot flag of the original Build parameter
build = new Build(Build.Type.UNKNOWN, build.hash(), build.date(), build.isSnapshot() == false, build.qualifiedVersion());
case 3 -> version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random()));
case 4 -> clusterName = new ClusterName(clusterName + randomAlphaOfLength(5));
case 5 -> transportVersion = randomValueOtherThan(transportVersion, () -> TransportVersionUtils.randomVersion(random()));
case 6 -> indexVersion = randomValueOtherThan(indexVersion, () -> IndexVersionUtils.randomVersion(random()));
case 5 -> luceneVersion = randomValueOtherThan(
luceneVersion,
() -> IndexVersionUtils.randomVersion(random()).luceneVersion().toString()
);
}
return new MainResponse(nodeName, version, indexVersion, transportVersion, clusterName, clusterUuid, build);
return new MainResponse(nodeName, version, luceneVersion, clusterName, clusterUuid, build);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ public void testHeadResponse() throws Exception {
final String clusterUUID = randomAlphaOfLengthBetween(10, 20);
final Version version = Version.CURRENT;
final IndexVersion indexVersion = IndexVersion.current();
final TransportVersion transportVersion = TransportVersion.current();
final Build build = Build.current();

final MainResponse mainResponse = new MainResponse(
nodeName,
version,
indexVersion,
transportVersion,
indexVersion.luceneVersion().toString(),
clusterName,
clusterUUID,
build
Expand Down Expand Up @@ -78,8 +76,7 @@ public void testGetResponse() throws Exception {
final MainResponse mainResponse = new MainResponse(
nodeName,
version,
indexVersion,
transportVersion,
indexVersion.luceneVersion().toString(),
clusterName,
clusterUUID,
build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.qa.verify_version_constants;

import org.apache.lucene.tests.util.LuceneTestCase;
import org.elasticsearch.Version;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
Expand All @@ -24,6 +25,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.lessThan;

@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/97736")
public class VerifyVersionConstantsIT extends ESRestTestCase {

public void testLuceneVersionConstant() throws IOException, ParseException {
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/org/elasticsearch/TransportVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ private static TransportVersion registerTransportVersion(int id, String uniqueId
public static final TransportVersion V_8_500_033 = registerTransportVersion(8_500_033, "193ab7c4-a751-4cbd-a66a-2d7d56ccbc10");
public static final TransportVersion V_8_500_034 = registerTransportVersion(8_500_034, "16871c8b-88ba-4432-980a-10fd9ecad2dc");
public static final TransportVersion V_8_500_035 = registerTransportVersion(8_500_035, "664dd6ce-3487-4fbd-81a9-af778b28be45");

// Introduced for stateless plugin
public static final TransportVersion V_8_500_036 = registerTransportVersion(8_500_036, "3343c64f-d7ac-4f02-9262-3e1acfc56f89");
public static final TransportVersion V_8_500_037 = registerTransportVersion(8_500_037, "d76a4f22-8878-43e0-acfa-15e452195fa7");

private static class CurrentHolder {
private static final TransportVersion CURRENT = findCurrent(V_8_500_036);
private static final TransportVersion CURRENT = findCurrent(V_8_500_037);

// finds the pluggable current version, or uses the given fallback
private static TransportVersion findCurrent(TransportVersion fallback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package org.elasticsearch.xpack.sql.jdbc;

import org.elasticsearch.Build;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.index.IndexVersion;
Expand Down Expand Up @@ -54,8 +53,7 @@ MainResponse createMainResponse(Version version) {
final String date = new Date(randomNonNegativeLong()).toString();
Build build = new Build(Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(), version.toString());
IndexVersion indexVersion = IndexVersion.current();
TransportVersion transportVersion = TransportVersion.current();
return new MainResponse(nodeName, version, indexVersion, transportVersion, clusterName, clusterUuid, build);
return new MainResponse(nodeName, version, indexVersion.luceneVersion().toString(), clusterName, clusterUuid, build);
}

String webServerAddress() {
Expand Down