From 27e7fc734c74207f1a2b0df9965f1ef21d2c7492 Mon Sep 17 00:00:00 2001 From: javanna Date: Thu, 1 Sep 2016 17:21:53 +0200 Subject: [PATCH] HttpInfo to implement Writeable rather than Streamable --- .../admin/cluster/node/info/NodeInfo.java | 2 +- .../java/org/elasticsearch/http/HttpInfo.java | 39 +++++++------------ 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java index 93141b74f9f..68ec0f39e6d 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java @@ -217,7 +217,7 @@ public class NodeInfo extends BaseNodeResponse { transport = TransportInfo.readTransportInfo(in); } if (in.readBoolean()) { - http = HttpInfo.readHttpInfo(in); + http = new HttpInfo(in); } if (in.readBoolean()) { plugins = new PluginsAndModules(); diff --git a/core/src/main/java/org/elasticsearch/http/HttpInfo.java b/core/src/main/java/org/elasticsearch/http/HttpInfo.java index 0f285974e8a..e8f3985a23a 100644 --- a/core/src/main/java/org/elasticsearch/http/HttpInfo.java +++ b/core/src/main/java/org/elasticsearch/http/HttpInfo.java @@ -21,7 +21,7 @@ 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.transport.BoundTransportAddress; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.ToXContent; @@ -29,15 +29,20 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -/** - * - */ -public class HttpInfo implements Streamable, ToXContent { +public class HttpInfo implements Writeable, ToXContent { - private BoundTransportAddress address; - private long maxContentLength; + private final BoundTransportAddress address; + private final long maxContentLength; - HttpInfo() { + public HttpInfo(StreamInput in) throws IOException { + address = BoundTransportAddress.readBoundTransportAddress(in); + maxContentLength = in.readLong(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + address.writeTo(out); + out.writeLong(maxContentLength); } public HttpInfo(BoundTransportAddress address, long maxContentLength) { @@ -63,24 +68,6 @@ public class HttpInfo implements Streamable, ToXContent { return builder; } - public static HttpInfo readHttpInfo(StreamInput in) throws IOException { - HttpInfo info = new HttpInfo(); - info.readFrom(in); - return info; - } - - @Override - public void readFrom(StreamInput in) throws IOException { - address = BoundTransportAddress.readBoundTransportAddress(in); - maxContentLength = in.readLong(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - address.writeTo(out); - out.writeLong(maxContentLength); - } - public BoundTransportAddress address() { return address; }