-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Wildcard cluster names for cross cluster search #23985
Conversation
This is an initial take at this functionality. But I wanted to create the PR early for early feedback. As listed in this comment there are still some questions to resolve. Additionally, I have not modified the cross cluster qa tests for this functionality yet. However, I plan on doing that once my questions have been resolved. |
ping @javanna @s1monw @jasontedor |
The build failed because of I added a couple of lines >100. I'll fix that in the next revision or merge in the change back to 140. |
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.
Looks great, I left some comments nothing major
@@ -79,7 +79,7 @@ | |||
* {@link RemoteClusterService#REMOTE_CONNECTIONS_PER_CLUSTER} until either all eligible nodes are exhausted or the maximum number of | |||
* connections per cluster has been reached. | |||
*/ | |||
final class RemoteClusterConnection extends AbstractComponent implements TransportConnectionListener, Closeable { | |||
public final class RemoteClusterConnection extends AbstractComponent implements TransportConnectionListener, Closeable { |
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 move this back to be package private?
if (i >= 0) { | ||
String remoteClusterName = index.substring(0, i); | ||
if (isRemoteClusterRegistered(remoteClusterName)) { | ||
List<String> clusters = clusterNameResolver.resolveClusterNames(remoteClusterNames, remoteClusterName); |
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 maybe return an emtpy list instead of null, I think we don't necessarily need the null invariant?
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class ClusterNameExpressionResolver extends AbstractComponent { |
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 final?
|
||
Set<String> matches = matches(remoteClusters, clusterExpression); | ||
if (matches.isEmpty()) { | ||
return null; |
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.
maybe return the empty list?
|
||
public ClusterNameExpressionResolver(Settings settings) { | ||
super(settings); | ||
new WildcardExpressionResolver(); |
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.
this looks like a leftover
} else if (Regex.isSimpleMatchPattern(clusterExpression)) { | ||
return wildcardResolver.resolve(remoteClusters, clusterExpression); | ||
} else { | ||
return null; |
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.
empty list?
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class ClusterNameExpressionResolver extends AbstractComponent { |
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.
some basic javadocs for this please?
new WildcardExpressionResolver(); | ||
} | ||
|
||
public List<String> resolveClusterNames(Set<String> remoteClusters, String clusterExpression) { |
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.
also please add some javadocs what this can resolve etc?
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.
Left one comment LGTM otherwise
@@ -213,7 +213,7 @@ boolean isRemoteNodeConnected(final String remoteCluster, final DiscoveryNode no | |||
if (i >= 0) { | |||
String remoteClusterName = index.substring(0, i); | |||
List<String> clusters = clusterNameResolver.resolveClusterNames(remoteClusterNames, remoteClusterName); | |||
if (clusters != null) { | |||
if (clusters.isEmpty()) { |
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.
hmm this should be cluster.isEmpty() == false
?
LGTM |
This is related to #23893. This commit allows users to use wilcards for cluster names when executing a cross cluster search. So instead of defining every cluster such as: GET one:*,two:*,three:*/_search A user could just search: GET *:*/_search As ":" characters are currently allowed in index names, if the text up to the first ":" does not match a defined cluster name, the entire string is treated as an index name.
* master: (41 commits) Remove awaits fix from evil JNA native tests Correct handling of default and array settings Build: Switch jna dependency to an elastic version (elastic#24081) fix CategoryContextMappingTests compilation bugs testConcurrentGetAndSetOnPrimary - fix a race condition between indexing and updating value map Allow different data types for category in Context suggester (elastic#23491) Restrict build info loading to ES jar, not any jar (elastic#24049) Remove more hidden file leniency from plugins Register error listener in evil logger tests Detect using logging before configuration [DOCS] Added note about Elastic Cloud to improve 'elastic aws' SERP results. Add version constant for 5.5 (elastic#24075) Add unit tests for NestedAggregator (elastic#24054) Add more debugging information to rethrottles Tests: Use random analyzer only on string fields in Match/MultiMatchBuilderTests Cleanup outdated comments for fixing up pom dependencies (elastic#24056) S3 Repository: Eagerly load static settings (elastic#23910) Reject duplicate settings on the command line Wildcard cluster names for cross cluster search (elastic#23985) Update scripts/security docs for sandboxed world (elastic#23977) ...
This is related to #23893. This commit allows users to use wilcards for
cluster names when executing a cross cluster search.
So instead of defining every cluster such as:
GET one:*,two:*,three:*/_search
A user could just search:
GET *:*/_search
As ":" characters are currently allowed in index names, if the text
up to the first ":" does not match a defined cluster name, the entire
string is treated as an index name.
Closes #23893