Node Stats: Add timestamp per node stats element, closes #1851.
This commit is contained in:
parent
dd60187735
commit
1f050435b2
|
@ -41,6 +41,8 @@ import java.io.IOException;
|
|||
*/
|
||||
public class NodeStats extends NodeOperationResponse {
|
||||
|
||||
private long timestamp;
|
||||
|
||||
@Nullable
|
||||
private String hostname;
|
||||
|
||||
|
@ -74,10 +76,11 @@ public class NodeStats extends NodeOperationResponse {
|
|||
NodeStats() {
|
||||
}
|
||||
|
||||
public NodeStats(DiscoveryNode node, @Nullable String hostname, @Nullable NodeIndicesStats indices,
|
||||
public NodeStats(DiscoveryNode node, long timestamp, @Nullable String hostname, @Nullable NodeIndicesStats indices,
|
||||
@Nullable OsStats os, @Nullable ProcessStats process, @Nullable JvmStats jvm, @Nullable ThreadPoolStats threadPool, @Nullable NetworkStats network,
|
||||
@Nullable FsStats fs, @Nullable TransportStats transport, @Nullable HttpStats http) {
|
||||
super(node);
|
||||
this.timestamp = timestamp;
|
||||
this.hostname = hostname;
|
||||
this.indices = indices;
|
||||
this.os = os;
|
||||
|
@ -90,6 +93,14 @@ public class NodeStats extends NodeOperationResponse {
|
|||
this.http = http;
|
||||
}
|
||||
|
||||
public long timestamp() {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String hostname() {
|
||||
return this.hostname;
|
||||
|
@ -241,6 +252,7 @@ public class NodeStats extends NodeOperationResponse {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
timestamp = in.readVLong();
|
||||
if (in.readBoolean()) {
|
||||
hostname = in.readUTF();
|
||||
}
|
||||
|
@ -276,6 +288,7 @@ public class NodeStats extends NodeOperationResponse {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVLong(timestamp);
|
||||
if (hostname == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
|
|
|
@ -67,6 +67,7 @@ public class NodesStatsResponse extends NodesOperationResponse<NodeStats> implem
|
|||
for (NodeStats nodeStats : this) {
|
||||
builder.startObject(nodeStats.node().id(), XContentBuilder.FieldCaseConversion.NONE);
|
||||
|
||||
builder.field("timestamp", nodeStats.timestamp());
|
||||
builder.field("name", nodeStats.node().name(), XContentBuilder.FieldCaseConversion.NONE);
|
||||
builder.field("transport_address", nodeStats.node().address().toString());
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class NodeService extends AbstractComponent {
|
|||
public NodeStats stats() {
|
||||
// for indices stats we want to include previous allocated shards stats as well (it will
|
||||
// only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats)
|
||||
return new NodeStats(clusterService.state().nodes().localNode(), hostname,
|
||||
return new NodeStats(clusterService.state().nodes().localNode(), System.currentTimeMillis(), hostname,
|
||||
indicesService.stats(true),
|
||||
monitorService.osService().stats(),
|
||||
monitorService.processService().stats(),
|
||||
|
@ -149,7 +149,7 @@ public class NodeService extends AbstractComponent {
|
|||
public NodeStats stats(boolean indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean network, boolean fs, boolean transport, boolean http) {
|
||||
// for indices stats we want to include previous allocated shards stats as well (it will
|
||||
// only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats)
|
||||
return new NodeStats(clusterService.state().nodes().localNode(), hostname,
|
||||
return new NodeStats(clusterService.state().nodes().localNode(), System.currentTimeMillis(), hostname,
|
||||
indices ? indicesService.stats(true) : null,
|
||||
os ? monitorService.osService().stats() : null,
|
||||
process ? monitorService.processService().stats() : null,
|
||||
|
|
Loading…
Reference in New Issue