Align remote info api with new settings (#54102)

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.
This commit is contained in:
Tim Brooks 2020-03-24 10:27:24 -06:00 committed by GitHub
parent 1c1730facd
commit caefa78513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 18 deletions

View File

@ -23,10 +23,11 @@ import java.util.Objects;
public class ProxyModeInfo implements RemoteConnectionInfo.ModeInfo { public class ProxyModeInfo implements RemoteConnectionInfo.ModeInfo {
static final String NAME = "proxy"; 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 SERVER_NAME = "server_name";
static final String NUM_SOCKETS_CONNECTED = "num_sockets_connected"; static final String NUM_PROXY_SOCKETS_CONNECTED = "num_proxy_sockets_connected";
static final String MAX_SOCKET_CONNECTIONS = "max_socket_connections"; static final String MAX_PROXY_SOCKET_CONNECTIONS = "max_proxy_socket_connections";
private final String address; private final String address;
private final String serverName; private final String serverName;
private final int maxSocketConnections; private final int maxSocketConnections;

View File

@ -66,10 +66,10 @@ public final class RemoteConnectionInfo {
PARSER.declareString(constructorArg(), new ParseField(INITIAL_CONNECT_TIMEOUT)); PARSER.declareString(constructorArg(), new ParseField(INITIAL_CONNECT_TIMEOUT));
PARSER.declareBoolean(constructorArg(), new ParseField(SKIP_UNAVAILABLE)); 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.declareString(optionalConstructorArg(), new ParseField(ProxyModeInfo.SERVER_NAME));
PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.MAX_SOCKET_CONNECTIONS)); PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.MAX_PROXY_SOCKET_CONNECTIONS));
PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.NUM_SOCKETS_CONNECTED)); PARSER.declareInt(optionalConstructorArg(), new ParseField(ProxyModeInfo.NUM_PROXY_SOCKETS_CONNECTED));
PARSER.declareStringArray(optionalConstructorArg(), new ParseField(SniffModeInfo.SEEDS)); PARSER.declareStringArray(optionalConstructorArg(), new ParseField(SniffModeInfo.SEEDS));
PARSER.declareInt(optionalConstructorArg(), new ParseField(SniffModeInfo.MAX_CONNECTIONS_PER_CLUSTER)); PARSER.declareInt(optionalConstructorArg(), new ParseField(SniffModeInfo.MAX_CONNECTIONS_PER_CLUSTER));

View File

@ -51,13 +51,13 @@ by the configured remote cluster alias.
Maximum number of connections maintained for the remote cluster when sniff Maximum number of connections maintained for the remote cluster when sniff
mode is configured. mode is configured.
`address`:: `proxy_address`::
Address for remote connections when proxy mode is configured. 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 Number of open socket connections to the remote cluster when proxy mode
is configured. is configured.
`max_socket_connections`:: `max_proxy_socket_connections`::
The maximum number of socket connections to the remote cluster when proxy The maximum number of socket connections to the remote cluster when proxy
mode is configured. mode is configured.

View File

@ -80,9 +80,9 @@
cluster.remote_info: {} cluster.remote_info: {}
- match: { test_remote_cluster.connected: true } - match: { test_remote_cluster.connected: true }
- match: { test_remote_cluster.address: $remote_ip } - match: { test_remote_cluster.proxy_address: $remote_ip }
- gt: { test_remote_cluster.num_sockets_connected: 0} - gt: { test_remote_cluster.num_proxy_sockets_connected: 0}
- match: { test_remote_cluster.max_socket_connections: 10} - match: { test_remote_cluster.max_proxy_socket_connections: 10}
- match: { test_remote_cluster.initial_connect_timeout: "30s" } - match: { test_remote_cluster.initial_connect_timeout: "30s" }
- match: { test_remote_cluster.mode: "proxy" } - match: { test_remote_cluster.mode: "proxy" }

View File

@ -279,10 +279,10 @@ public class ProxyConnectionStrategy extends RemoteConnectionStrategy {
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { 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("server_name", serverName);
builder.field("num_sockets_connected", numSocketsConnected); builder.field("num_proxy_sockets_connected", numSocketsConnected);
builder.field("max_socket_connections", maxSocketConnections); builder.field("max_proxy_socket_connections", maxSocketConnections);
return builder; return builder;
} }

View File

@ -449,9 +449,9 @@ public class RemoteClusterConnectionTests extends ESTestCase {
"\"num_nodes_connected\":2,\"max_connections_per_cluster\":3,\"initial_connect_timeout\":\"30m\"," + "\"num_nodes_connected\":2,\"max_connections_per_cluster\":3,\"initial_connect_timeout\":\"30m\"," +
"\"skip_unavailable\":true}}", Strings.toString(builder)); "\"skip_unavailable\":true}}", Strings.toString(builder));
} else { } else {
assertEquals("{\"test_cluster\":{\"connected\":true,\"mode\":\"proxy\",\"address\":\"seed:1\"," + assertEquals("{\"test_cluster\":{\"connected\":true,\"mode\":\"proxy\",\"proxy_address\":\"seed:1\"," +
"\"server_name\":\"the_server_name\",\"num_sockets_connected\":16,\"max_socket_connections\":18," "\"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)); "\"initial_connect_timeout\":\"30m\",\"skip_unavailable\":true}}", Strings.toString(builder));
} }
} }