Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,13 @@ public RemoteClusterClient getRemoteClusterClient(
DisconnectedStrategy disconnectedStrategy
) {
ensureClientIsEnabled();
if (isStateless && disconnectedStrategy == DisconnectedStrategy.RECONNECT_UNLESS_SKIP_UNAVAILABLE) {
final var message = "DisconnectedStrategy ["
+ DisconnectedStrategy.RECONNECT_UNLESS_SKIP_UNAVAILABLE
+ "] is not supported in stateless environments";
assert false : message;
Comment on lines +654 to +658
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about deferring this change until search side has made its changes. But I guess it's OK to proceed here because the condition is guarded with isStateless?

throw new IllegalArgumentException(message);
}
if (transportService.getRemoteClusterService().getRegisteredRemoteClusterNames().contains(clusterAlias) == false) {
throw new NoSuchRemoteClusterException(clusterAlias);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,34 @@ public void testRemoteClusterServiceNotEnabled() {
}
}

public void testGetRemoteClusterClientRejectsReconnectUnlessSkipUnavailableInStateless() {
final var settings = Settings.builder().put("stateless.enabled", true).putList("node.roles", "remote_cluster_client").build();
try (
MockTransportService service = MockTransportService.createNewService(
settings,
VersionInformation.CURRENT,
TransportVersion.current(),
threadPool,
null
)
) {
final var remoteClusterService = service.getRemoteClusterService();
final var unsupportedDisconnectedStrategy = RemoteClusterService.DisconnectedStrategy.RECONNECT_UNLESS_SKIP_UNAVAILABLE;
final var error = expectThrows(
AssertionError.class,
() -> remoteClusterService.getRemoteClusterClient(
"test",
EsExecutors.DIRECT_EXECUTOR_SERVICE,
unsupportedDisconnectedStrategy
)
);
assertThat(
error.getMessage(),
equalTo("DisconnectedStrategy [" + unsupportedDisconnectedStrategy + "] is not supported in stateless environments")
);
}
}

public void testQuicklySkipUnavailableClusters() throws Exception {
Settings remoteSettings = Settings.builder().put(ClusterName.CLUSTER_NAME_SETTING.getKey(), "foo_bar_cluster").build();
try (
Expand Down