Skip to content

Commit 28f9785

Browse files
committed
Allow simple connection strategy to be configured (elastic#49066)
Currently the simple connection strategy only exists in the code. It cannot be configured. This commit moves in the direction of allowing it to be configured. It introduces settings for the addresses and socket count. Additionally it introduces new settings for the sniff strategy so that the more generic number of connections and seed node settings can be deprecated. The simple settings are not yet registered as the registration is dependent on follow-up work to validate the settings.
1 parent 99476db commit 28f9785

21 files changed

+460
-395
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void setupRemoteClusterConfig() throws Exception {
8383
String transportAddress = (String) nodesResponse.get("transport_address");
8484

8585
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
86-
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local_cluster.seeds", transportAddress));
86+
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local_cluster.sniff.seeds", transportAddress));
8787
ClusterUpdateSettingsResponse updateSettingsResponse =
8888
highLevelClient().cluster().putSettings(updateSettingsRequest, RequestOptions.DEFAULT);
8989
assertThat(updateSettingsResponse.isAcknowledged(), is(true));

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CCRDocumentationIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void setupRemoteClusterConfig() throws IOException {
8787
String transportAddress = (String) nodesResponse.get("transport_address");
8888

8989
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
90-
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local.seeds", transportAddress));
90+
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local.sniff.seeds", transportAddress));
9191
ClusterUpdateSettingsResponse updateSettingsResponse =
9292
client.cluster().putSettings(updateSettingsRequest, RequestOptions.DEFAULT);
9393
assertThat(updateSettingsResponse.isAcknowledged(), is(true));

qa/ccs-unavailable-clusters/src/test/java/org/elasticsearch/search/CrossClusterSearchUnavailableClusterIT.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void testSearchSkipUnavailable() throws IOException {
144144
try (MockTransportService remoteTransport = startTransport("node0", new CopyOnWriteArrayList<>(), Version.CURRENT, threadPool)) {
145145
DiscoveryNode remoteNode = remoteTransport.getLocalDiscoNode();
146146

147-
updateRemoteClusterSettings(Collections.singletonMap("seeds", remoteNode.getAddress().toString()));
147+
updateRemoteClusterSettings(Collections.singletonMap("sniff.seeds", remoteNode.getAddress().toString()));
148148

149149
for (int i = 0; i < 10; i++) {
150150
restHighLevelClient.index(
@@ -229,7 +229,7 @@ public void testSearchSkipUnavailable() throws IOException {
229229
assertSearchConnectFailure();
230230

231231
Map<String, Object> map = new HashMap<>();
232-
map.put("seeds", null);
232+
map.put("sniff.seeds", null);
233233
map.put("skip_unavailable", null);
234234
updateRemoteClusterSettings(map);
235235
}
@@ -248,32 +248,32 @@ public void testSkipUnavailableDependsOnSeeds() throws IOException {
248248
() -> client().performRequest(request));
249249
assertEquals(400, responseException.getResponse().getStatusLine().getStatusCode());
250250
assertThat(responseException.getMessage(),
251-
containsString("missing required setting [cluster.remote.remote1.seeds] " +
251+
containsString("missing required setting [cluster.remote.remote1.sniff.seeds] " +
252252
"for setting [cluster.remote.remote1.skip_unavailable]"));
253253
}
254254

255255
Map<String, Object> settingsMap = new HashMap<>();
256-
settingsMap.put("seeds", remoteNode.getAddress().toString());
256+
settingsMap.put("sniff.seeds", remoteNode.getAddress().toString());
257257
settingsMap.put("skip_unavailable", randomBoolean());
258258
updateRemoteClusterSettings(settingsMap);
259259

260260
{
261261
//check that seeds cannot be reset alone if skip_unavailable is set
262262
Request request = new Request("PUT", "/_cluster/settings");
263-
request.setEntity(buildUpdateSettingsRequestBody(Collections.singletonMap("seeds", null)));
263+
request.setEntity(buildUpdateSettingsRequestBody(Collections.singletonMap("sniff.seeds", null)));
264264
ResponseException responseException = expectThrows(ResponseException.class,
265265
() -> client().performRequest(request));
266266
assertEquals(400, responseException.getResponse().getStatusLine().getStatusCode());
267-
assertThat(responseException.getMessage(), containsString("missing required setting [cluster.remote.remote1.seeds] " +
267+
assertThat(responseException.getMessage(), containsString("missing required setting [cluster.remote.remote1.sniff.seeds] " +
268268
"for setting [cluster.remote.remote1.skip_unavailable]"));
269269
}
270270

271271
if (randomBoolean()) {
272272
updateRemoteClusterSettings(Collections.singletonMap("skip_unavailable", null));
273-
updateRemoteClusterSettings(Collections.singletonMap("seeds", null));
273+
updateRemoteClusterSettings(Collections.singletonMap("sniff.seeds", null));
274274
} else {
275275
Map<String, Object> nullMap = new HashMap<>();
276-
nullMap.put("seeds", null);
276+
nullMap.put("sniff.seeds", null);
277277
nullMap.put("skip_unavailable", null);
278278
updateRemoteClusterSettings(nullMap);
279279
}

server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
import org.elasticsearch.threadpool.ThreadPool;
111111
import org.elasticsearch.transport.RemoteClusterAware;
112112
import org.elasticsearch.transport.RemoteClusterService;
113+
import org.elasticsearch.transport.SniffConnectionStrategy;
113114
import org.elasticsearch.transport.TransportSettings;
114115
import org.elasticsearch.watcher.ResourceWatcherService;
115116

@@ -303,10 +304,8 @@ public void apply(Settings value, Settings current, Settings previous) {
303304
SearchService.DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS,
304305
ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING,
305306
TransportSearchAction.SHARD_COUNT_LIMIT_SETTING,
306-
RemoteClusterAware.REMOTE_CLUSTERS_SEEDS,
307307
RemoteClusterAware.SEARCH_REMOTE_CLUSTERS_SEEDS,
308-
RemoteClusterAware.REMOTE_CLUSTERS_PROXY,
309-
RemoteClusterAware.SEARCH_REMOTE_CLUSTERS_PROXY,
308+
SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY,
310309
RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE,
311310
RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE,
312311
RemoteClusterService.REMOTE_CONNECTIONS_PER_CLUSTER,
@@ -319,6 +318,10 @@ public void apply(Settings value, Settings current, Settings previous) {
319318
RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS,
320319
RemoteClusterService.REMOTE_CLUSTER_PING_SCHEDULE,
321320
RemoteClusterService.REMOTE_CLUSTER_COMPRESS,
321+
SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS_OLD,
322+
SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY,
323+
SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS,
324+
SniffConnectionStrategy.REMOTE_NODE_CONNECTIONS,
322325
TransportCloseIndexAction.CLUSTER_INDICES_CLOSE_ENABLE_SETTING,
323326
ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING,
324327
NodeConnectionsService.CLUSTER_NODE_RECONNECT_INTERVAL_SETTING,
@@ -521,7 +524,7 @@ public void apply(Settings value, Settings current, Settings previous) {
521524

522525
public static List<SettingUpgrader<?>> BUILT_IN_SETTING_UPGRADERS = Collections.unmodifiableList(Arrays.asList(
523526
RemoteClusterAware.SEARCH_REMOTE_CLUSTER_SEEDS_UPGRADER,
524-
RemoteClusterAware.SEARCH_REMOTE_CLUSTERS_PROXY_UPGRADER,
527+
SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY_UPGRADER,
525528
RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE_UPGRADER));
526529

527530
}

0 commit comments

Comments
 (0)