HttpStats to implement Writeable rather than Streamable
This commit is contained in:
parent
e263c64072
commit
3521e2e1a9
|
@ -217,9 +217,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||
threadPool = in.readOptionalWriteable(ThreadPoolStats::new);
|
||||
fs = in.readOptionalWriteable(FsInfo::new);
|
||||
transport = in.readOptionalWriteable(TransportStats::new);
|
||||
if (in.readBoolean()) {
|
||||
http = HttpStats.readHttpStats(in);
|
||||
}
|
||||
http = in.readOptionalWriteable(HttpStats::new);
|
||||
breaker = AllCircuitBreakerStats.readOptionalAllCircuitBreakerStats(in);
|
||||
scriptStats = in.readOptionalStreamable(ScriptStats::new);
|
||||
discoveryStats = in.readOptionalStreamable(() -> new DiscoveryStats(null));
|
||||
|
@ -242,12 +240,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||
out.writeOptionalWriteable(threadPool);
|
||||
out.writeOptionalWriteable(fs);
|
||||
out.writeOptionalWriteable(transport);
|
||||
if (http == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
http.writeTo(out);
|
||||
}
|
||||
out.writeOptionalWriteable(http);
|
||||
out.writeOptionalStreamable(breaker);
|
||||
out.writeOptionalStreamable(scriptStats);
|
||||
out.writeOptionalStreamable(discoveryStats);
|
||||
|
|
|
@ -21,42 +21,23 @@ package org.elasticsearch.http;
|
|||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpStats implements Streamable, ToXContent {
|
||||
public class HttpStats implements Writeable, ToXContent {
|
||||
|
||||
private long serverOpen;
|
||||
private long totalOpen;
|
||||
|
||||
HttpStats() {
|
||||
|
||||
}
|
||||
private final long serverOpen;
|
||||
private final long totalOpen;
|
||||
|
||||
public HttpStats(long serverOpen, long totalOpen) {
|
||||
this.serverOpen = serverOpen;
|
||||
this.totalOpen = totalOpen;
|
||||
}
|
||||
|
||||
public long getServerOpen() {
|
||||
return this.serverOpen;
|
||||
}
|
||||
|
||||
public long getTotalOpen() {
|
||||
return this.totalOpen;
|
||||
}
|
||||
|
||||
public static HttpStats readHttpStats(StreamInput in) throws IOException {
|
||||
HttpStats stats = new HttpStats();
|
||||
stats.readFrom(in);
|
||||
return stats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
public HttpStats(StreamInput in) throws IOException {
|
||||
serverOpen = in.readVLong();
|
||||
totalOpen = in.readVLong();
|
||||
}
|
||||
|
@ -67,6 +48,14 @@ public class HttpStats implements Streamable, ToXContent {
|
|||
out.writeVLong(totalOpen);
|
||||
}
|
||||
|
||||
public long getServerOpen() {
|
||||
return this.serverOpen;
|
||||
}
|
||||
|
||||
public long getTotalOpen() {
|
||||
return this.totalOpen;
|
||||
}
|
||||
|
||||
static final class Fields {
|
||||
static final String HTTP = "http";
|
||||
static final String CURRENT_OPEN = "current_open";
|
||||
|
|
Loading…
Reference in New Issue