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: 4 additions & 2 deletions docs/reference/setup/install/check-running.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ 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" : "123456"
"transport_version" : "12345"
},
"tagline" : "You Know, for Search"
}
Expand All @@ -55,5 +56,6 @@ 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" : "123456"/"transport_version" : $body.version.transport_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 @@ -15,6 +15,7 @@
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.xcontent.ObjectParser;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.ToXContentObject;
Expand All @@ -28,6 +29,7 @@ public class MainResponse extends ActionResponse implements ToXContentObject {

private String nodeName;
private Version version;
private IndexVersion indexVersion;
private TransportVersion transportVersion;
private ClusterName clusterName;
private String clusterUuid;
Expand All @@ -39,7 +41,8 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
super(in);
nodeName = in.readString();
version = Version.readVersion(in);
transportVersion = in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_014) ? TransportVersion.readVersion(in) : null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been 19 (was already fixed in serialization)

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;
clusterName = new ClusterName(in);
clusterUuid = in.readString();
build = Build.readBuild(in);
Expand All @@ -48,13 +51,15 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
public MainResponse(
String nodeName,
Version version,
IndexVersion indexVersion,
TransportVersion transportVersion,
ClusterName clusterName,
String clusterUuid,
Build build
) {
this.nodeName = nodeName;
this.version = version;
this.indexVersion = indexVersion;
this.transportVersion = transportVersion;
this.clusterName = clusterName;
this.clusterUuid = clusterUuid;
Expand All @@ -69,6 +74,10 @@ public Version getVersion() {
return version;
}

public IndexVersion getIndexVersion() {
return indexVersion;
}

public TransportVersion getTransportVersion() {
return transportVersion;
}
Expand All @@ -89,6 +98,9 @@ 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);
}
Expand All @@ -97,6 +109,16 @@ public void writeTo(StreamOutput out) throws IOException {
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 @@ -110,7 +132,8 @@ 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", version.luceneVersion().toString())
.field("lucene_version", getLuceneVersion())
.field("index_version", indexVersion != null ? indexVersion.toString() : "unknown")
.field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString())
.field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString())
.field("transport_version", transportVersion != null ? transportVersion.toString() : "unknown")
Expand Down Expand Up @@ -147,7 +170,16 @@ 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+)", "")
);
response.transportVersion = TransportVersion.fromString(((String) value.get("transport_version")));

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;
}, (parser, context) -> parser.map(), new ParseField("version"));
}

Expand All @@ -166,6 +198,7 @@ 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(clusterUuid, other.clusterUuid)
&& Objects.equals(build, other.build)
Expand All @@ -174,7 +207,7 @@ public boolean equals(Object o) {

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

@Override
Expand All @@ -185,6 +218,8 @@ public String toString() {
+ '\''
+ ", version="
+ version
+ ", indexVersion="
+ indexVersion
+ ", transportVersion="
+ transportVersion
+ ", clusterName="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.node.Node;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;
Expand Down Expand Up @@ -46,6 +47,7 @@ protected void doExecute(Task task, MainRequest request, ActionListener<MainResp
new MainResponse(
nodeName,
Version.CURRENT,
IndexVersion.current(),
TransportVersion.current(),
clusterState.getClusterName(),
clusterState.metadata().clusterUUID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.test.AbstractXContentSerializingTestCase;
import org.elasticsearch.test.TransportVersionUtils;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.index.IndexVersionUtils;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
Expand All @@ -35,9 +37,10 @@ protected MainResponse createTestInstance() {
String nodeName = randomAlphaOfLength(10);
final String date = new Date(randomNonNegativeLong()).toString();
Version version = VersionUtils.randomIndexCompatibleVersion(random());
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, transportVersion, clusterName, clusterUuid, build);
return new MainResponse(nodeName, version, indexVersion, transportVersion, clusterName, clusterUuid, build);
}

@Override
Expand All @@ -55,8 +58,17 @@ public void testToXContent() throws IOException {
final Build current = Build.current();
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, transportVersion, new ClusterName("clusterName"), clusterUUID, build);
MainResponse response = new MainResponse(
"nodeName",
version,
indexVersion,
transportVersion,
new ClusterName("clusterName"),
clusterUUID,
build
);
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertEquals(
Expand All @@ -75,6 +87,7 @@ 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"
Expand All @@ -88,7 +101,8 @@ public void testToXContent() throws IOException {
current.hash(),
current.date(),
current.isSnapshot(),
version.luceneVersion().toString(),
indexVersion.luceneVersion().toString(),
indexVersion.toString(),
version.minimumCompatibilityVersion().toString(),
version.minimumIndexCompatibilityVersion().toString(),
transportVersion.toString()
Expand All @@ -103,10 +117,11 @@ 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 nodeName = mutateInstance.getNodeName();
ClusterName clusterName = mutateInstance.getClusterName();
switch (randomIntBetween(0, 5)) {
switch (randomIntBetween(0, 6)) {
case 0 -> clusterUuid = clusterUuid + randomAlphaOfLength(5);
case 1 -> nodeName = nodeName + randomAlphaOfLength(5);
case 2 ->
Expand All @@ -115,7 +130,8 @@ protected MainResponse mutateInstance(MainResponse mutateInstance) {
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()));
}
return new MainResponse(nodeName, version, transportVersion, clusterName, clusterUuid, build);
return new MainResponse(nodeName, version, indexVersion, transportVersion, clusterName, clusterUuid, build);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
Expand All @@ -35,10 +36,19 @@ public void testHeadResponse() throws Exception {
final ClusterName clusterName = new ClusterName("cluster1");
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, transportVersion, clusterName, clusterUUID, build);
final MainResponse mainResponse = new MainResponse(
nodeName,
version,
indexVersion,
transportVersion,
clusterName,
clusterUUID,
build
);
XContentBuilder builder = JsonXContent.contentBuilder();
RestRequest restRequest = new FakeRestRequest() {
@Override
Expand All @@ -60,11 +70,20 @@ public void testGetResponse() throws Exception {
final ClusterName clusterName = new ClusterName("cluster1");
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 boolean prettyPrint = randomBoolean();

final MainResponse mainResponse = new MainResponse(nodeName, version, transportVersion, clusterName, clusterUUID, build);
final MainResponse mainResponse = new MainResponse(
nodeName,
version,
indexVersion,
transportVersion,
clusterName,
clusterUUID,
build
);
XContentBuilder builder = JsonXContent.contentBuilder();

Map<String, String> params = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,38 @@
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;

import java.io.IOException;
import java.text.ParseException;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.lessThan;

public class VerifyVersionConstantsIT extends ESRestTestCase {

public void testLuceneVersionConstant() throws IOException, ParseException {
final Response response = client().performRequest(new Request("GET", "/"));
Response response = client().performRequest(new Request("GET", "/"));
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
final ObjectPath objectPath = ObjectPath.createFromResponse(response);
final String elasticsearchVersionString = objectPath.evaluate("version.number").toString();
final Version elasticsearchVersion = Version.fromString(elasticsearchVersionString.replace("-SNAPSHOT", ""));
final String luceneVersionString = objectPath.evaluate("version.lucene_version").toString();
final org.apache.lucene.util.Version luceneVersion = org.apache.lucene.util.Version.parse(luceneVersionString);
assertThat(elasticsearchVersion.luceneVersion(), equalTo(luceneVersion));
ObjectPath objectPath = ObjectPath.createFromResponse(response);

String luceneVersionString = objectPath.evaluate("version.lucene_version").toString();
org.apache.lucene.util.Version luceneVersion = org.apache.lucene.util.Version.parse(luceneVersionString);

IndexVersion indexVersion;
Object indexVersionString = objectPath.evaluate("version.index_version");
if (indexVersionString != null) {
indexVersion = IndexVersion.fromId(Integer.parseInt(indexVersionString.toString()));
} else {
String elasticsearchVersionString = objectPath.evaluate("version.number").toString();
Version elasticsearchVersion = Version.fromString(elasticsearchVersionString.replace("-SNAPSHOT", ""));
assertThat(elasticsearchVersion, lessThan(Version.V_8_10_0));
indexVersion = IndexVersion.fromId(elasticsearchVersion.id);
}

assertThat(indexVersion.luceneVersion(), equalTo(luceneVersion));
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/org/elasticsearch/TransportVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ private static TransportVersion registerTransportVersion(int id, String uniqueId
public static final TransportVersion V_8_500_028 = registerTransportVersion(8_500_028, "a6592d08-15cb-4e1a-b9b4-b2ba24058444");
public static final TransportVersion V_8_500_029 = registerTransportVersion(8_500_029, "f3bd98af-6187-e161-e315-718a2fecc2db");
public static final TransportVersion V_8_500_030 = registerTransportVersion(8_500_030, "b72d7f12-8ed3-4a5b-8e6a-4910ea10e0d7");
public static final TransportVersion V_8_500_031 = registerTransportVersion(8_500_031, "e7aa7e95-37e7-46a3-aad1-90a21c0769e7");

private static class CurrentHolder {
private static final TransportVersion CURRENT = findCurrent(V_8_500_030);
private static final TransportVersion CURRENT = findCurrent(V_8_500_031);

// finds the pluggable current version, or uses the given fallback
private static TransportVersion findCurrent(TransportVersion fallback) {
Expand Down
Loading