From caefa78513d702a0b8e5b607f916fd3abeda2565 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Tue, 24 Mar 2020 10:27:24 -0600 Subject: [PATCH] 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. --- .../org/elasticsearch/client/cluster/ProxyModeInfo.java | 7 ++++--- .../elasticsearch/client/cluster/RemoteConnectionInfo.java | 6 +++--- docs/reference/cluster/remote-info.asciidoc | 6 +++--- .../resources/rest-api-spec/test/multi_cluster/20_info.yml | 6 +++--- .../elasticsearch/transport/ProxyConnectionStrategy.java | 6 +++--- .../transport/RemoteClusterConnectionTests.java | 6 +++--- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/ProxyModeInfo.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/ProxyModeInfo.java index 7d81753ec2a..56dfda553e9 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/ProxyModeInfo.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/ProxyModeInfo.java @@ -23,10 +23,11 @@ import java.util.Objects; 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; diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteConnectionInfo.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteConnectionInfo.java index 3bd52dcbbe0..cb0fb726297 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteConnectionInfo.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/cluster/RemoteConnectionInfo.java @@ -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)); diff --git a/docs/reference/cluster/remote-info.asciidoc b/docs/reference/cluster/remote-info.asciidoc index 8e81a044488..05931ea2d6a 100644 --- a/docs/reference/cluster/remote-info.asciidoc +++ b/docs/reference/cluster/remote-info.asciidoc @@ -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. diff --git a/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/20_info.yml b/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/20_info.yml index cc7c89c5d1a..35d9c02e7e3 100644 --- a/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/20_info.yml +++ b/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/20_info.yml @@ -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" } diff --git a/server/src/main/java/org/elasticsearch/transport/ProxyConnectionStrategy.java b/server/src/main/java/org/elasticsearch/transport/ProxyConnectionStrategy.java index ede6fe35f7c..cb766ee0616 100644 --- a/server/src/main/java/org/elasticsearch/transport/ProxyConnectionStrategy.java +++ b/server/src/main/java/org/elasticsearch/transport/ProxyConnectionStrategy.java @@ -279,10 +279,10 @@ public class ProxyConnectionStrategy extends RemoteConnectionStrategy { @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; } diff --git a/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java b/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java index 42f4c7d674f..1c4e1ea9337 100644 --- a/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java +++ b/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java @@ -449,9 +449,9 @@ public class RemoteClusterConnectionTests extends ESTestCase { "\"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)); } }