HttpInfo to implement Writeable rather than Streamable

This commit is contained in:
javanna 2016-09-01 17:21:53 +02:00 committed by Luca Cavanna
parent 279f8b27e3
commit 27e7fc734c
2 changed files with 14 additions and 27 deletions

View File

@ -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();

View File

@ -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;
}