-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
440c0b5
WIP: work on creating initial parsing
Tim-Brooks 85071a2
Work on integrating name resolver
Tim-Brooks 2798d89
Modify remote cluster service tests
Tim-Brooks ad676b5
Merge remote-tracking branch 'upstream/master' into wildcard_clusters
Tim-Brooks adb7f05
Merge remote-tracking branch 'upstream/master' into wildcard_clusters
Tim-Brooks c7a8304
Add basic rest test for wildcard search
Tim-Brooks 5a80f24
Return empty list opposed to null
Tim-Brooks 56168f9
Add basic javadoc
Tim-Brooks b4545d2
Fix boolean error
Tim-Brooks 5db0bd7
Fix test assertions
Tim-Brooks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,7 +213,7 @@ Map<String, List<String>> groupClusterIndices(String[] requestIndices, Predicate | |
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 commentThe reason will be displayed to describe this comment to others. Learn more. hmm this should be |
||
if (indexExists.test(index)) { | ||
// we use : as a separator for remote clusters. might conflict if there is an index that is actually named | ||
// remote_cluster_alias:index_name - for this case we fail the request. the user can easily change the cluster alias | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,22 +29,33 @@ | |
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class ClusterNameExpressionResolver extends AbstractComponent { | ||
/** | ||
* Resolves cluster names from an expression. The expression must be the exact match of a cluster | ||
* name or must be a wildcard expression. | ||
*/ | ||
public final class ClusterNameExpressionResolver extends AbstractComponent { | ||
|
||
private final WildcardExpressionResolver wildcardResolver = new WildcardExpressionResolver(); | ||
|
||
public ClusterNameExpressionResolver(Settings settings) { | ||
super(settings); | ||
new WildcardExpressionResolver(); | ||
} | ||
|
||
/** | ||
* Resolves the provided cluster expression to matching cluster names. This method only | ||
* supports exact or wildcard matches. | ||
* | ||
* @param remoteClusters the aliases for remote clusters | ||
* @param clusterExpression the expressions that can be resolved to cluster names. | ||
* @return the resolved cluster aliases. | ||
*/ | ||
public List<String> resolveClusterNames(Set<String> remoteClusters, String clusterExpression) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also please add some javadocs what this can resolve etc? |
||
if (remoteClusters.contains(clusterExpression)) { | ||
return Collections.singletonList(clusterExpression); | ||
} else if (Regex.isSimpleMatchPattern(clusterExpression)) { | ||
return wildcardResolver.resolve(remoteClusters, clusterExpression); | ||
} else { | ||
return null; | ||
return Collections.emptyList(); | ||
} | ||
} | ||
|
||
|
@@ -57,7 +68,7 @@ private List<String> resolve(Set<String> remoteClusters, String clusterExpressio | |
|
||
Set<String> matches = matches(remoteClusters, clusterExpression); | ||
if (matches.isEmpty()) { | ||
return null; | ||
return Collections.emptyList(); | ||
} else { | ||
return new ArrayList<>(matches); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?