parent
f72d5c1907
commit
22f99e848f
|
@ -49,6 +49,8 @@ public class NodeInfo extends NodeOperationResponse {
|
|||
@Nullable
|
||||
private String hostname;
|
||||
|
||||
private String version;
|
||||
|
||||
@Nullable
|
||||
private Settings settings;
|
||||
|
||||
|
@ -76,11 +78,12 @@ public class NodeInfo extends NodeOperationResponse {
|
|||
NodeInfo() {
|
||||
}
|
||||
|
||||
public NodeInfo(@Nullable String hostname, DiscoveryNode node, @Nullable ImmutableMap<String, String> serviceAttributes, @Nullable Settings settings,
|
||||
public NodeInfo(@Nullable String hostname, String version, 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) {
|
||||
super(node);
|
||||
this.hostname = hostname;
|
||||
this.version = version;
|
||||
this.serviceAttributes = serviceAttributes;
|
||||
this.settings = settings;
|
||||
this.os = os;
|
||||
|
@ -108,6 +111,20 @@ public class NodeInfo extends NodeOperationResponse {
|
|||
return hostname();
|
||||
}
|
||||
|
||||
/**
|
||||
* The current ES version
|
||||
*/
|
||||
public String version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* The current ES version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version();
|
||||
}
|
||||
|
||||
/**
|
||||
* The service attributes of the node.
|
||||
*/
|
||||
|
@ -246,6 +263,7 @@ public class NodeInfo extends NodeOperationResponse {
|
|||
if (in.readBoolean()) {
|
||||
hostname = in.readUTF();
|
||||
}
|
||||
version = in.readOptionalString();
|
||||
if (in.readBoolean()) {
|
||||
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
|
||||
int size = in.readVInt();
|
||||
|
@ -289,6 +307,7 @@ public class NodeInfo extends NodeOperationResponse {
|
|||
out.writeBoolean(true);
|
||||
out.writeUTF(hostname);
|
||||
}
|
||||
out.writeOptionalString(version);
|
||||
if (serviceAttributes() == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
|
|
|
@ -83,6 +83,10 @@ public class NodesInfoResponse extends NodesOperationResponse<NodeInfo> implemen
|
|||
builder.field("hostname", nodeInfo.hostname(), XContentBuilder.FieldCaseConversion.NONE);
|
||||
}
|
||||
|
||||
if (nodeInfo.version() != null) {
|
||||
builder.field("version", nodeInfo.version());
|
||||
}
|
||||
|
||||
if (nodeInfo.serviceAttributes() != null) {
|
||||
for (Map.Entry<String, String> nodeAttribute : nodeInfo.serviceAttributes().entrySet()) {
|
||||
builder.field(nodeAttribute.getKey(), nodeAttribute.getValue());
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.node.service;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
|
@ -60,6 +61,8 @@ public class NodeService extends AbstractComponent {
|
|||
@Nullable
|
||||
private String hostname;
|
||||
|
||||
private final String version;
|
||||
|
||||
@Inject
|
||||
public NodeService(Settings settings, ThreadPool threadPool, MonitorService monitorService, Discovery discovery, ClusterService clusterService, TransportService transportService, IndicesService indicesService) {
|
||||
super(settings);
|
||||
|
@ -73,6 +76,7 @@ public class NodeService extends AbstractComponent {
|
|||
if (address != null) {
|
||||
this.hostname = address.getHostName();
|
||||
}
|
||||
this.version = Version.CURRENT.toString();
|
||||
}
|
||||
|
||||
public void setHttpServer(@Nullable HttpServer httpServer) {
|
||||
|
@ -105,7 +109,7 @@ public class NodeService extends AbstractComponent {
|
|||
}
|
||||
|
||||
public NodeInfo info() {
|
||||
return new NodeInfo(hostname, clusterService.state().nodes().localNode(), serviceAttributes,
|
||||
return new NodeInfo(hostname, version, clusterService.state().nodes().localNode(), serviceAttributes,
|
||||
settings,
|
||||
monitorService.osService().info(),
|
||||
monitorService.processService().info(),
|
||||
|
@ -118,7 +122,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) {
|
||||
return new NodeInfo(hostname, clusterService.state().nodes().localNode(), serviceAttributes,
|
||||
return new NodeInfo(hostname, version, clusterService.state().nodes().localNode(), serviceAttributes,
|
||||
settings ? this.settings : null,
|
||||
os ? monitorService.osService().info() : null,
|
||||
process ? monitorService.processService().info() : null,
|
||||
|
|
Loading…
Reference in New Issue