-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Update RemoteClusterService skip_unavailable handling for CPS #132478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
75e1518
9338680
c1cd712
2273e47
9b41038
754768b
bd2efd7
fefe4ae
f01504f
e535ecc
2aa8d46
e1e06b7
fde9bf6
fff29b3
78cac67
4fc3323
b552484
f93d28b
c1fa91a
0bcd0d4
07a5d1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import org.elasticsearch.cluster.project.DefaultProjectResolver; | ||
import org.elasticsearch.cluster.project.ProjectResolver; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.collect.Iterators; | ||
import org.elasticsearch.common.settings.ClusterSettings; | ||
import org.elasticsearch.common.settings.SecureSetting; | ||
import org.elasticsearch.common.settings.SecureString; | ||
|
@@ -98,7 +99,13 @@ public final class RemoteClusterService extends RemoteClusterAware | |
public static final Setting.AffixSetting<Boolean> REMOTE_CLUSTER_SKIP_UNAVAILABLE = Setting.affixKeySetting( | ||
"cluster.remote.", | ||
"skip_unavailable", | ||
(ns, key) -> boolSetting(key, true, new RemoteConnectionEnabled<>(ns, key), Setting.Property.Dynamic, Setting.Property.NodeScope) | ||
(ns, key) -> boolSetting( | ||
key, | ||
true, | ||
new UnsupportedInStatelessValidator<>(ns, key), | ||
Setting.Property.Dynamic, | ||
Setting.Property.NodeScope | ||
) | ||
); | ||
|
||
public static final Setting.AffixSetting<TimeValue> REMOTE_CLUSTER_PING_SCHEDULE = Setting.affixKeySetting( | ||
|
@@ -343,10 +350,14 @@ public RemoteClusterConnection getRemoteClusterConnection(String cluster) { | |
@Override | ||
public void listenForUpdates(ClusterSettings clusterSettings) { | ||
super.listenForUpdates(clusterSettings); | ||
clusterSettings.addAffixUpdateConsumer(REMOTE_CLUSTER_SKIP_UNAVAILABLE, this::updateSkipUnavailable, (alias, value) -> {}); | ||
if (isStateless == false) { | ||
clusterSettings.addAffixUpdateConsumer(REMOTE_CLUSTER_SKIP_UNAVAILABLE, this::updateSkipUnavailable, (alias, value) -> {}); | ||
} | ||
} | ||
|
||
private synchronized void updateSkipUnavailable(String clusterAlias, Boolean skipUnavailable) { | ||
assert isStateless == false | ||
: "Cannot configure setting [" + REMOTE_CLUSTER_SKIP_UNAVAILABLE.getKey() + "] in stateless environments."; | ||
RemoteClusterConnection remote = getConnectionsMapForCurrentProject().get(clusterAlias); | ||
if (remote != null) { | ||
remote.setSkipUnavailable(skipUnavailable); | ||
|
@@ -748,6 +759,10 @@ private RemoteConnectionEnabled(String clusterAlias, String key) { | |
this.key = key; | ||
} | ||
|
||
protected String getKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public void validate(T value) {} | ||
|
||
|
@@ -772,4 +787,25 @@ private Stream<Setting<?>> settingsStream() { | |
.map(as -> as.getConcreteSettingForNamespace(clusterAlias)); | ||
} | ||
}; | ||
|
||
private static class UnsupportedInStatelessValidator<T> extends RemoteConnectionEnabled<T> { | ||
|
||
private final Setting<Boolean> statelessSetting = Setting.boolSetting(DiscoveryNode.STATELESS_ENABLED_SETTING_NAME, false); | ||
|
||
private UnsupportedInStatelessValidator(String clusterAlias, String key) { | ||
super(clusterAlias, key); | ||
} | ||
|
||
@Override | ||
public void validate(T value, Map<Setting<?>, Object> settings, boolean isPresent) { | ||
if (isPresent && (Boolean) settings.get(statelessSetting)) { | ||
throw new IllegalArgumentException("setting [" + getKey() + "] is unavailable when stateless is enabled"); | ||
} | ||
super.validate(value, settings, isPresent); | ||
} | ||
|
||
@Override | ||
public Iterator<Setting<?>> settings() { | ||
return Iterators.concat(super.settings(), Iterators.single(statelessSetting)); | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.