diff --git a/src/main/java/org/elasticsearch/Build.java b/src/main/java/org/elasticsearch/Build.java index 3b8493a60bb..7d68ec13ffa 100644 --- a/src/main/java/org/elasticsearch/Build.java +++ b/src/main/java/org/elasticsearch/Build.java @@ -21,9 +21,12 @@ package org.elasticsearch; import org.elasticsearch.common.io.FastStringReader; import org.elasticsearch.common.io.Streams; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; import org.joda.time.DateTimeZone; import org.joda.time.format.ISODateTimeFormat; +import java.io.IOException; import java.util.Properties; /** @@ -77,4 +80,17 @@ public class Build { public String timestamp() { return timestamp; } + + public static Build readBuild(StreamInput in) throws IOException { + String hash = in.readString(); + String hashShort = in.readString(); + String timestamp = in.readString(); + return new Build(hash, hashShort, timestamp); + } + + public static void writeBuild(Build build, StreamOutput out) throws IOException { + out.writeString(build.hash()); + out.writeString(build.hashShort()); + out.writeString(build.timestamp()); + } } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java index 2fe5676234d..dce4b9237f0 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.cluster.node.info; import com.google.common.collect.ImmutableMap; +import org.elasticsearch.Build; import org.elasticsearch.Version; import org.elasticsearch.action.support.nodes.NodeOperationResponse; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -51,6 +52,7 @@ public class NodeInfo extends NodeOperationResponse { private String hostname; private Version version; + private Build build; @Nullable private Settings settings; @@ -82,12 +84,13 @@ public class NodeInfo extends NodeOperationResponse { NodeInfo() { } - public NodeInfo(@Nullable String hostname, Version version, DiscoveryNode node, @Nullable ImmutableMap serviceAttributes, @Nullable Settings settings, + public NodeInfo(@Nullable String hostname, Version version, Build build, DiscoveryNode node, @Nullable ImmutableMap serviceAttributes, @Nullable Settings settings, @Nullable OsInfo os, @Nullable ProcessInfo process, @Nullable JvmInfo jvm, @Nullable ThreadPoolInfo threadPool, @Nullable NetworkInfo network, @Nullable TransportInfo transport, @Nullable HttpInfo http, @Nullable PluginsInfo plugins) { super(node); this.hostname = hostname; this.version = version; + this.build = build; this.serviceAttributes = serviceAttributes; this.settings = settings; this.os = os; @@ -115,6 +118,13 @@ public class NodeInfo extends NodeOperationResponse { return version; } + /** + * The build version of the node. + */ + public Build getBuild() { + return this.build; + } + /** * The service attributes of the node. */ @@ -196,6 +206,7 @@ public class NodeInfo extends NodeOperationResponse { hostname = in.readString(); } version = Version.readVersion(in); + build = Build.readBuild(in); if (in.readBoolean()) { ImmutableMap.Builder builder = ImmutableMap.builder(); int size = in.readVInt(); @@ -243,6 +254,7 @@ public class NodeInfo extends NodeOperationResponse { out.writeString(hostname); } out.writeVInt(version.id); + Build.writeBuild(build, out); if (getServiceAttributes() == null) { out.writeBoolean(false); } else { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index a081e7c2be0..11680283220 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -84,9 +84,8 @@ public class NodesInfoResponse extends NodesOperationResponse implemen builder.field("hostname", nodeInfo.getHostname(), XContentBuilder.FieldCaseConversion.NONE); } - if (nodeInfo.getVersion() != null) { - builder.field("version", nodeInfo.getVersion()); - } + builder.field("version", nodeInfo.getVersion()); + builder.field("build", nodeInfo.getBuild().hashShort()); if (nodeInfo.getServiceAttributes() != null) { for (Map.Entry nodeAttribute : nodeInfo.getServiceAttributes().entrySet()) { diff --git a/src/main/java/org/elasticsearch/node/service/NodeService.java b/src/main/java/org/elasticsearch/node/service/NodeService.java index ad0f35ee3c6..b0e95a5cbb4 100644 --- a/src/main/java/org/elasticsearch/node/service/NodeService.java +++ b/src/main/java/org/elasticsearch/node/service/NodeService.java @@ -20,6 +20,7 @@ package org.elasticsearch.node.service; import com.google.common.collect.ImmutableMap; +import org.elasticsearch.Build; import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; @@ -115,7 +116,7 @@ public class NodeService extends AbstractComponent { } public NodeInfo info() { - return new NodeInfo(hostname, version, disovery.localNode(), serviceAttributes, + return new NodeInfo(hostname, version, Build.CURRENT, disovery.localNode(), serviceAttributes, settings, monitorService.osService().info(), monitorService.processService().info(), @@ -130,7 +131,7 @@ public class NodeService extends AbstractComponent { public NodeInfo info(boolean settings, boolean os, boolean process, boolean jvm, boolean threadPool, boolean network, boolean transport, boolean http, boolean plugin) { - return new NodeInfo(hostname, version, disovery.localNode(), serviceAttributes, + return new NodeInfo(hostname, version, Build.CURRENT, disovery.localNode(), serviceAttributes, settings ? this.settings : null, os ? monitorService.osService().info() : null, process ? monitorService.processService().info() : null, diff --git a/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index dff8f665f04..6a4a8dde302 100644 --- a/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -127,7 +127,8 @@ public class RestNodesAction extends AbstractCatAction { table.addCell("ip", "desc:ip address"); table.addCell("port", "desc:bound transport port"); - table.addCell("es", "default:false;desc:es version"); + table.addCell("version", "default:false;desc:es version"); + table.addCell("build", "default:false;desc:es build hash"); table.addCell("jdk", "default:false;desc:jdk version"); table.addCell("diskAvail", "default:false;text-align:right;desc:available disk space"); table.addCell("heapPercent", "text-align:right;desc:used heap ratio"); @@ -162,6 +163,7 @@ public class RestNodesAction extends AbstractCatAction { table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); table.addCell(info == null ? null : info.getVersion().number()); + table.addCell(info == null ? null : info.getBuild().hashShort()); table.addCell(info == null ? null : info.getJvm().version()); table.addCell(stats == null ? null : stats.getFs() == null ? null : stats.getFs().total().getAvailable()); table.addCell(stats == null ? null : stats.getJvm().getMem().getHeapUsedPrecent());