Skip to content

Commit

Permalink
Align remote info api with new settings (elastic#53441)
Browse files Browse the repository at this point in the history
Currently the remote info api has added a number of possible fields
(proxy, num_socket_connections, etc) that are available in proxy mode.
These fields are not aligned with what the settings are named. This
commit modifies this API to align with the settings.
  • Loading branch information
Tim-Brooks committed Mar 24, 2020
1 parent 5206256 commit 755073e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@

public class ProxyModeInfo implements RemoteConnectionInfo.ModeInfo {
static final String NAME = "proxy";
static final String ADDRESS = "address";
static final String PROXY_ADDRESS = "proxy_address";
static final String SERVER_NAME = "server_name";
static final String NUM_SOCKETS_CONNECTED = "num_sockets_connected";
static final String MAX_SOCKET_CONNECTIONS = "max_socket_connections";
static final String NUM_PROXY_SOCKETS_CONNECTED = "num_proxy_sockets_connected";
static final String MAX_PROXY_SOCKET_CONNECTIONS = "max_proxy_socket_connections";

private final String address;
private final String serverName;
private final int maxSocketConnections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public final class RemoteConnectionInfo {
PARSER.declareString(constructorArg(), new ParseField(INITIAL_CONNECT_TIMEOUT));
PARSER.declareBoolean(constructorArg(), new ParseField(SKIP_UNAVAILABLE));

PARSER.declareString(optionalConstructorArg(), new ParseField(ProxyModeInfo.ADDRESS));
PARSER.declareString(optionalConstructorArg(), new ParseField(ProxyModeInfo.PROXY_ADDRESS));
PARSER.declareString(optionalConstructorArg(), new ParseField(ProxyModeInfo.SERVER_NAME));
PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.MAX_SOCKET_CONNECTIONS));
PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.NUM_SOCKETS_CONNECTED));
PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.MAX_PROXY_SOCKET_CONNECTIONS));
PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.NUM_PROXY_SOCKETS_CONNECTED));

PARSER.declareStringArray(optionalConstructorArg(), new ParseField(SniffModeInfo.SEEDS));
PARSER.declareInt(optionalConstructorArg(), new ParseField(SniffModeInfo.MAX_CONNECTIONS_PER_CLUSTER));
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/cluster/remote-info.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ by the configured remote cluster alias.
Maximum number of connections maintained for the remote cluster when sniff
mode is configured.

`address`::
`proxy_address`::
Address for remote connections when proxy mode is configured.

`num_sockets_connected`::
`num_proxy_sockets_connected`::
Number of open socket connections to the remote cluster when proxy mode
is configured.

`max_socket_connections`::
`max_proxy_socket_connections`::
The maximum number of socket connections to the remote cluster when proxy
mode is configured.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
cluster.remote_info: {}

- match: { test_remote_cluster.connected: true }
- match: { test_remote_cluster.address: $remote_ip }
- gt: { test_remote_cluster.num_sockets_connected: 0}
- match: { test_remote_cluster.max_socket_connections: 10}
- match: { test_remote_cluster.proxy_address: $remote_ip }
- gt: { test_remote_cluster.num_proxy_sockets_connected: 0}
- match: { test_remote_cluster.max_proxy_socket_connections: 10}
- match: { test_remote_cluster.initial_connect_timeout: "30s" }
- match: { test_remote_cluster.mode: "proxy" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ private ProxyModeInfo(StreamInput input) throws IOException {

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field("address", address);
builder.field("proxy_address", address);
builder.field("server_name", serverName);
builder.field("num_sockets_connected", numSocketsConnected);
builder.field("max_socket_connections", maxSocketConnections);
builder.field("num_proxy_sockets_connected", numSocketsConnected);
builder.field("max_proxy_socket_connections", maxSocketConnections);
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ public void testRenderConnectionInfoXContent() throws IOException {
"\"num_nodes_connected\":2,\"max_connections_per_cluster\":3,\"initial_connect_timeout\":\"30m\"," +
"\"skip_unavailable\":true}}", Strings.toString(builder));
} else {
assertEquals("{\"test_cluster\":{\"connected\":true,\"mode\":\"proxy\",\"address\":\"seed:1\"," +
"\"server_name\":\"the_server_name\",\"num_sockets_connected\":16,\"max_socket_connections\":18,"
+"\"initial_connect_timeout\":\"30m\",\"skip_unavailable\":true}}", Strings.toString(builder));
assertEquals("{\"test_cluster\":{\"connected\":true,\"mode\":\"proxy\",\"proxy_address\":\"seed:1\"," +
"\"server_name\":\"the_server_name\",\"num_proxy_sockets_connected\":16,\"max_proxy_socket_connections\":18,"+
"\"initial_connect_timeout\":\"30m\",\"skip_unavailable\":true}}", Strings.toString(builder));
}
}

Expand Down

0 comments on commit 755073e

Please sign in to comment.