Add build hash to nodes info API
also, add it to the cat nodes api
This commit is contained in:
parent
96cca039e9
commit
e67cad3127
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, String> serviceAttributes, @Nullable Settings settings,
|
||||
public NodeInfo(@Nullable String hostname, Version version, Build build, DiscoveryNode node, @Nullable ImmutableMap<String, String> 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<String, String> 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 {
|
||||
|
|
|
@ -84,9 +84,8 @@ public class NodesInfoResponse extends NodesOperationResponse<NodeInfo> 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<String, String> nodeAttribute : nodeInfo.getServiceAttributes().entrySet()) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue