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
Extract a common base class to allow services to listen to remote cluster config updates #24367
Extract a common base class to allow services to listen to remote cluster config updates #24367
Conversation
…ster config updates RemoteClusterService is an internal service that should not necessarily be exposed to plugins or other parts of the system. Yet, for cluster name parsing for instance it is crucial to reuse some code that is used for the RemoteClusterService. This change extracts a base class that allows to share the settings related code as well as cluster settings updates to `search.remote.*` to be observed by other services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small changes, but otherwise it seems good.
I've done some testing and this makes it simple for a plugin to track + parse remote cluster names.
"seeds", (key) -> Setting.listSetting(key, Collections.emptyList(), RemoteClusterAware::parseSeedAddress, | ||
Setting.Property.NodeScope, Setting.Property.Dynamic)); | ||
protected static final char REMOTE_CLUSTER_INDEX_SEPARATOR = ':'; | ||
static final String LOCAL_CLUSTER_GROUP_KEY = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be protected
so that derived classes can safely interpret the result from groupClusterIndices
?
* {@link #LOCAL_CLUSTER_GROUP_KEY}. The returned map is mutable. | ||
* | ||
* @param requestIndices the indices in the search request to filter | ||
* @param indexExists a predicate that can test if a certain index or alias exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We we append "locally" or "in the local cluster" to this param description?
protected abstract void updateRemoteCluster(String clusterAlias, List<InetSocketAddress> addresses); | ||
|
||
/** | ||
* Registers this instance to listen to updates ont the cluster settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ont/to/ (or on?)
boolean executeImmediate = false; | ||
synchronized (this) { | ||
boolean executeImmediate = false; | ||
synchronized (this) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this indenting is intended.
for (Map.Entry<String, List<DiscoveryNode>> entry : seeds.entrySet()) { | ||
updateRemoteCluster(entry.getKey(), entry.getValue().stream().map(n -> n.getAddress().address()) | ||
.collect(Collectors.toList())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pull this initialisation code into a method.
I imagine most derived classes will implement updateRemoteCluster
by storing the cluster names/addresses into some form of collection.
But if that collection is a field, then it won't have been initialised at this point (in the parent constructor).
The typical constructor is going to need to look like:
{
super(settings, false);
clusterNames = new ArrayList<>();
initialize();
}
@tvernum can you look again... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LTGM.
…ster config updates (#24367) RemoteClusterService is an internal service that should not necessarily be exposed to plugins or other parts of the system. Yet, for cluster name parsing for instance it is crucial to reuse some code that is used for the RemoteClusterService. This change extracts a base class that allows to share the settings related code as well as cluster settings updates to `search.remote.*` to be observed by other services.
* master: (27 commits) Check index sorting with no replica since we cannot ensure that the replica index is ready when forceMerge is called. Closes elastic#24416 Docs: correct indentation on callout Build that java api docs from a test (elastic#24354) Move RemoteClusterService into TransportService (elastic#24424) Fix license header in WildflyIT.java Try not to lose stacktraces (elastic#24426) [DOCS] Update XPack Reference URL for 5.4 (elastic#24425) Painless: Add tests to check for existence and correct detection of the special Java 9 optimizations: Indified String concat and MethodHandles#ArrayLengthHelper() (elastic#24405) Extract a common base class to allow services to listen to remote cluster config updates (elastic#24367) Adds check to snapshot repository incompatible-snapshots blob to delete a pre-existing one before attempting to overwrite it. Added docs for batched_reduce_size Fixes checkstyle errors Allow scripted metric agg to access `_score` (elastic#24295) [Test] Add unit tests for HDR/TDigest PercentilesAggregators (elastic#24245) Fix FieldCaps documentation Upgrade to JUnit 4.12 (elastic#23877) Set available processors for Netty Painless: Fix method references to ctor with the new LambdaBootstrap and cleanup code (elastic#24406) Doc test: use propery regex for file size [DOCS] Tweak doc test to sync_flush ...
RemoteClusterService is an internal service that should not necessarily be exposed
to plugins or other parts of the system. Yet, for cluster name parsing for instance
it is crucial to reuse some code that is used for the RemoteClusterService. This
change extracts a base class that allows to share the settings related code as well
as cluster settings updates to
search.remote.*
to be observed by other services.