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 ef229bb34bd..9e198cc6296 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 @@ -214,7 +214,7 @@ public class NodeInfo extends BaseNodeResponse { threadPool = new ThreadPoolInfo(in); } if (in.readBoolean()) { - transport = TransportInfo.readTransportInfo(in); + transport = new TransportInfo(in); } if (in.readBoolean()) { http = new HttpInfo(in); diff --git a/core/src/main/java/org/elasticsearch/transport/TransportInfo.java b/core/src/main/java/org/elasticsearch/transport/TransportInfo.java index 236c0d50a98..fbabf49b65d 100644 --- a/core/src/main/java/org/elasticsearch/transport/TransportInfo.java +++ b/core/src/main/java/org/elasticsearch/transport/TransportInfo.java @@ -22,7 +22,7 @@ package org.elasticsearch.transport; import org.elasticsearch.common.Nullable; 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.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -31,56 +31,17 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; -/** - * - */ -public class TransportInfo implements Streamable, ToXContent { +public class TransportInfo implements Writeable, ToXContent { private BoundTransportAddress address; private Map profileAddresses; - TransportInfo() { - } - public TransportInfo(BoundTransportAddress address, @Nullable Map profileAddresses) { this.address = address; this.profileAddresses = profileAddresses; } - static final class Fields { - static final String TRANSPORT = "transport"; - static final String BOUND_ADDRESS = "bound_address"; - static final String PUBLISH_ADDRESS = "publish_address"; - static final String PROFILES = "profiles"; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(Fields.TRANSPORT); - builder.array(Fields.BOUND_ADDRESS, (Object[]) address.boundAddresses()); - builder.field(Fields.PUBLISH_ADDRESS, address.publishAddress().toString()); - builder.startObject(Fields.PROFILES); - if (profileAddresses != null && profileAddresses.size() > 0) { - for (Map.Entry entry : profileAddresses.entrySet()) { - builder.startObject(entry.getKey()); - builder.array(Fields.BOUND_ADDRESS, (Object[]) entry.getValue().boundAddresses()); - builder.field(Fields.PUBLISH_ADDRESS, entry.getValue().publishAddress().toString()); - builder.endObject(); - } - } - builder.endObject(); - builder.endObject(); - return builder; - } - - public static TransportInfo readTransportInfo(StreamInput in) throws IOException { - TransportInfo info = new TransportInfo(); - info.readFrom(in); - return info; - } - - @Override - public void readFrom(StreamInput in) throws IOException { + public TransportInfo(StreamInput in) throws IOException { address = BoundTransportAddress.readBoundTransportAddress(in); int size = in.readVInt(); if (size > 0) { @@ -109,6 +70,32 @@ public class TransportInfo implements Streamable, ToXContent { } } + static final class Fields { + static final String TRANSPORT = "transport"; + static final String BOUND_ADDRESS = "bound_address"; + static final String PUBLISH_ADDRESS = "publish_address"; + static final String PROFILES = "profiles"; + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(Fields.TRANSPORT); + builder.array(Fields.BOUND_ADDRESS, (Object[]) address.boundAddresses()); + builder.field(Fields.PUBLISH_ADDRESS, address.publishAddress().toString()); + builder.startObject(Fields.PROFILES); + if (profileAddresses != null && profileAddresses.size() > 0) { + for (Map.Entry entry : profileAddresses.entrySet()) { + builder.startObject(entry.getKey()); + builder.array(Fields.BOUND_ADDRESS, (Object[]) entry.getValue().boundAddresses()); + builder.field(Fields.PUBLISH_ADDRESS, entry.getValue().publishAddress().toString()); + builder.endObject(); + } + } + builder.endObject(); + builder.endObject(); + return builder; + } + public BoundTransportAddress address() { return address; }