@@ -149,6 +149,7 @@ public final class RemoteClusterService extends RemoteClusterAware
149
149
150
150
private final boolean enabled ;
151
151
private final boolean remoteClusterServerEnabled ;
152
+ private final boolean isStateless ;
152
153
153
154
public boolean isEnabled () {
154
155
return enabled ;
@@ -167,6 +168,7 @@ public boolean isRemoteClusterServerEnabled() {
167
168
RemoteClusterService (Settings settings , TransportService transportService ) {
168
169
super (settings );
169
170
this .enabled = DiscoveryNode .isRemoteClusterClient (settings );
171
+ this .isStateless = DiscoveryNode .isStateless (settings );
170
172
this .remoteClusterServerEnabled = REMOTE_CLUSTER_SERVER_ENABLED .get (settings );
171
173
this .transportService = transportService ;
172
174
this .projectResolver = DefaultProjectResolver .INSTANCE ;
@@ -294,7 +296,7 @@ void ensureConnected(String clusterAlias, ActionListener<Void> listener) {
294
296
* Returns whether the cluster identified by the provided alias is configured to be skipped when unavailable
295
297
*/
296
298
public boolean isSkipUnavailable (String clusterAlias ) {
297
- return getRemoteClusterConnection (clusterAlias ).isSkipUnavailable ();
299
+ return isStateless || getRemoteClusterConnection (clusterAlias ).isSkipUnavailable ();
298
300
}
299
301
300
302
public Transport .Connection getConnection (String cluster ) {
@@ -351,10 +353,13 @@ public RemoteClusterConnection getRemoteClusterConnection(String cluster) {
351
353
@ Override
352
354
public void listenForUpdates (ClusterSettings clusterSettings ) {
353
355
super .listenForUpdates (clusterSettings );
354
- clusterSettings .addAffixUpdateConsumer (REMOTE_CLUSTER_SKIP_UNAVAILABLE , this ::updateSkipUnavailable , (alias , value ) -> {});
356
+ if (isStateless == false ) {
357
+ clusterSettings .addAffixUpdateConsumer (REMOTE_CLUSTER_SKIP_UNAVAILABLE , this ::updateSkipUnavailable , (alias , value ) -> {});
358
+ }
355
359
}
356
360
357
361
private synchronized void updateSkipUnavailable (String clusterAlias , Boolean skipUnavailable ) {
362
+ assert isStateless == false : "Cannot configure setting [" + REMOTE_CLUSTER_SKIP_UNAVAILABLE + "] in stateless environments." ;
358
363
RemoteClusterConnection remote = getConnectionsMapForCurrentProject ().get (clusterAlias );
359
364
if (remote != null ) {
360
365
remote .setSkipUnavailable (skipUnavailable );
@@ -667,6 +672,13 @@ public RemoteClusterClient getRemoteClusterClient(
667
672
"this node does not have the " + DiscoveryNodeRole .REMOTE_CLUSTER_CLIENT_ROLE .roleName () + " role"
668
673
);
669
674
}
675
+ if (isStateless && disconnectedStrategy == DisconnectedStrategy .RECONNECT_UNLESS_SKIP_UNAVAILABLE ) {
676
+ throw new IllegalArgumentException (
677
+ "DisconnectedStrategy ["
678
+ + DisconnectedStrategy .RECONNECT_UNLESS_SKIP_UNAVAILABLE
679
+ + "] is not supported in stateless environments"
680
+ );
681
+ }
670
682
if (transportService .getRemoteClusterService ().getRegisteredRemoteClusterNames ().contains (clusterAlias ) == false ) {
671
683
throw new NoSuchRemoteClusterException (clusterAlias );
672
684
}
0 commit comments