Skip to content
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

Merged

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Apr 27, 2017

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.

…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.
@s1monw
Copy link
Contributor Author

s1monw commented Apr 28, 2017

@javanna @tvernum can you look at this?

Copy link
Contributor

@tvernum tvernum left a 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 = "";
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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) {
Copy link
Contributor

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()));
}
Copy link
Contributor

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();
}

@s1monw s1monw requested a review from tvernum May 2, 2017 07:58
@s1monw
Copy link
Contributor Author

s1monw commented May 2, 2017

@tvernum can you look again...

Copy link
Contributor

@tvernum tvernum left a comment

Choose a reason for hiding this comment

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

LTGM.

@s1monw s1monw merged commit 691ec68 into elastic:master May 2, 2017
@s1monw s1monw deleted the security_needs_love_for_x_cluster_search branch May 2, 2017 14:02
s1monw added a commit that referenced this pull request May 2, 2017
…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.
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request May 2, 2017
* 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
  ...
@clintongormley clintongormley added :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. and removed :Cluster labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. >enhancement v5.5.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants