-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CCS: Drop http address from remote cluster info #29568
Changes from 2 commits
5cb9d68
13742c2
ccbd414
2ff5917
7fd914a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,30 +27,29 @@ | |
import org.elasticsearch.common.xcontent.ToXContentFragment; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* This class encapsulates all remote cluster information to be rendered on | ||
* <tt>_remote/info</tt> requests. | ||
* {@code _remote/info} requests. | ||
*/ | ||
public final class RemoteConnectionInfo implements ToXContentFragment, Writeable { | ||
final List<TransportAddress> seedNodes; | ||
final List<TransportAddress> httpAddresses; | ||
final int connectionsPerCluster; | ||
final TimeValue initialConnectionTimeout; | ||
final int numNodesConnected; | ||
final String clusterAlias; | ||
final boolean skipUnavailable; | ||
|
||
RemoteConnectionInfo(String clusterAlias, List<TransportAddress> seedNodes, | ||
List<TransportAddress> httpAddresses, | ||
int connectionsPerCluster, int numNodesConnected, | ||
TimeValue initialConnectionTimeout, boolean skipUnavailable) { | ||
this.clusterAlias = clusterAlias; | ||
this.seedNodes = seedNodes; | ||
this.httpAddresses = httpAddresses; | ||
this.connectionsPerCluster = connectionsPerCluster; | ||
this.numNodesConnected = numNodesConnected; | ||
this.initialConnectionTimeout = initialConnectionTimeout; | ||
|
@@ -59,16 +58,45 @@ public final class RemoteConnectionInfo implements ToXContentFragment, Writeable | |
|
||
public RemoteConnectionInfo(StreamInput input) throws IOException { | ||
seedNodes = input.readList(TransportAddress::new); | ||
httpAddresses = input.readList(TransportAddress::new); | ||
if (input.getVersion().before(Version.V_7_0_0_alpha1)) { | ||
/* | ||
* Versions before 7.0 sent the HTTP addresses of all nodes in the | ||
* remote cluster here but it was expensive to fetch and we | ||
* ultimately figured out how to do without it. So we removed it. | ||
* | ||
* We just throw any HTTP addresses received here on the floor | ||
* because we don't need to do anything with them. | ||
*/ | ||
input.readList(TransportAddress::new); | ||
} | ||
connectionsPerCluster = input.readVInt(); | ||
initialConnectionTimeout = input.readTimeValue(); | ||
numNodesConnected = input.readVInt(); | ||
clusterAlias = input.readString(); | ||
if (input.getVersion().onOrAfter(Version.V_6_1_0)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dropped this because I'm not backporting this change to 6.x because it is breaking so I figured this was a good time to remove the bwc for 6.0.x |
||
skipUnavailable = input.readBoolean(); | ||
} else { | ||
skipUnavailable = false; | ||
skipUnavailable = input.readBoolean(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeList(seedNodes); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this next to the ctor because I like to be able to read the read and write on a single screen if possible. |
||
if (out.getVersion().before(Version.V_7_0_0_alpha1)) { | ||
/* | ||
* Versions before 7.0 sent the HTTP addresses of all nodes in the | ||
* remote cluster here but it was expensive to fetch and we | ||
* ultimately figured out how to do without it. So we removed it. | ||
* | ||
* When sending this request to a node that expects HTTP addresses | ||
* here we pretend that we didn't find any. This *should* be fine | ||
* because, after all, we haven't been using this information for | ||
* a while. | ||
*/ | ||
out.writeList(emptyList()); | ||
} | ||
out.writeVInt(connectionsPerCluster); | ||
out.writeTimeValue(initialConnectionTimeout); | ||
out.writeVInt(numNodesConnected); | ||
out.writeString(clusterAlias); | ||
out.writeBoolean(skipUnavailable); | ||
} | ||
|
||
@Override | ||
|
@@ -80,11 +108,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws | |
builder.value(addr.toString()); | ||
} | ||
builder.endArray(); | ||
builder.startArray("http_addresses"); | ||
for (TransportAddress addr : httpAddresses) { | ||
builder.value(addr.toString()); | ||
} | ||
builder.endArray(); | ||
builder.field("connected", numNodesConnected > 0); | ||
builder.field("num_nodes_connected", numNodesConnected); | ||
builder.field("max_connections_per_cluster", connectionsPerCluster); | ||
|
@@ -95,19 +118,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws | |
return builder; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeList(seedNodes); | ||
out.writeList(httpAddresses); | ||
out.writeVInt(connectionsPerCluster); | ||
out.writeTimeValue(initialConnectionTimeout); | ||
out.writeVInt(numNodesConnected); | ||
out.writeString(clusterAlias); | ||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) { | ||
out.writeBoolean(skipUnavailable); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
|
@@ -116,15 +126,14 @@ public boolean equals(Object o) { | |
return connectionsPerCluster == that.connectionsPerCluster && | ||
numNodesConnected == that.numNodesConnected && | ||
Objects.equals(seedNodes, that.seedNodes) && | ||
Objects.equals(httpAddresses, that.httpAddresses) && | ||
Objects.equals(initialConnectionTimeout, that.initialConnectionTimeout) && | ||
Objects.equals(clusterAlias, that.clusterAlias) && | ||
skipUnavailable == that.skipUnavailable; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(seedNodes, httpAddresses, connectionsPerCluster, initialConnectionTimeout, | ||
return Objects.hash(seedNodes, connectionsPerCluster, initialConnectionTimeout, | ||
numNodesConnected, clusterAlias, skipUnavailable); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm returning a
Stream
here because I read https://stackoverflow.com/a/24679745/233833 yesterday. The caller always wants aList
but since we have a stream here it seems sane to return the stream and let the caller do what they want with it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: what difference does it make given that the only caller calls toList on this Stream all the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None. I wouldn't go out of my way to return a
Stream
if I didn't already have one. I just figured, since I do, I may as well return it.