File tree Expand file tree Collapse file tree 4 files changed +34
-32
lines changed
main/java/org/elasticsearch
test/java/org/elasticsearch Expand file tree Collapse file tree 4 files changed +34
-32
lines changed Original file line number Diff line number Diff line change @@ -479,26 +479,13 @@ private static void ensureRemoteExpressionRequireIgnoreUnavailable(IndicesOption
479479 return ;
480480 }
481481 if (RemoteClusterAware .isRemoteIndexName (current )) {
482- List <String > crossClusterIndices = getRemoteIndexExpressions (expressions );
482+ List <String > crossClusterIndices = RemoteClusterAware . getRemoteIndexExpressions (expressions );
483483 throw new IllegalArgumentException (
484484 "Cross-cluster calls are not supported in this context but remote indices were requested: " + crossClusterIndices
485485 );
486486 }
487487 }
488488
489- /**
490- * Extracts the list of remote index expressions from the given array of index expressions
491- */
492- public static List <String > getRemoteIndexExpressions (String ... expressions ) {
493- List <String > crossClusterIndices = new ArrayList <>();
494- for (int i = 0 ; i < expressions .length ; i ++) {
495- if (RemoteClusterAware .isRemoteIndexName (expressions [i ])) {
496- crossClusterIndices .add (expressions [i ]);
497- }
498- }
499- return crossClusterIndices ;
500- }
501-
502489 /**
503490 * Translates the provided index expression into actual concrete indices, properly deduplicated.
504491 *
Original file line number Diff line number Diff line change @@ -69,6 +69,19 @@ public static boolean isRemoteIndexName(String indexExpression) {
6969 return idx > 0 && isSelector == false ;
7070 }
7171
72+ /**
73+ * Extracts the list of remote index expressions from the given array of index expressions
74+ */
75+ public static List <String > getRemoteIndexExpressions (String ... expressions ) {
76+ List <String > crossClusterIndices = new ArrayList <>();
77+ for (int i = 0 ; i < expressions .length ; i ++) {
78+ if (isRemoteIndexName (expressions [i ])) {
79+ crossClusterIndices .add (expressions [i ]);
80+ }
81+ }
82+ return crossClusterIndices ;
83+ }
84+
7285 /**
7386 * @param indexExpression expects a single index expression at a time (not a csv list of expression)
7487 * @return cluster alias in the index expression. If none is present, returns RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY
Original file line number Diff line number Diff line change 7878import static org .hamcrest .Matchers .emptyArray ;
7979import static org .hamcrest .Matchers .endsWith ;
8080import static org .hamcrest .Matchers .equalTo ;
81- import static org .hamcrest .Matchers .hasSize ;
8281import static org .hamcrest .Matchers .is ;
8382import static org .hamcrest .Matchers .notNullValue ;
8483import static org .hamcrest .Matchers .nullValue ;
@@ -3487,23 +3486,6 @@ public void testResolveWriteIndexAbstractionMultipleMatches() {
34873486 );
34883487 }
34893488
3490- public void testGetRemoteIndexExpressions () {
3491- {
3492- List <String > remoteIndexExpressions = IndexNameExpressionResolver .getRemoteIndexExpressions ("index-1" );
3493- assertThat (remoteIndexExpressions , empty ());
3494- }
3495- {
3496- List <String > remoteIndexExpressions = IndexNameExpressionResolver .getRemoteIndexExpressions (
3497- "index-1" ,
3498- "remote:index-1" ,
3499- "idx-*" ,
3500- "remote-2:idx-5"
3501- );
3502- assertThat (remoteIndexExpressions , hasSize (2 ));
3503- assertThat (remoteIndexExpressions , contains ("remote:index-1" , "remote-2:idx-5" ));
3504- }
3505- }
3506-
35073489 public static IndexMetadata .Builder indexBuilder (String index ) {
35083490 return indexBuilder (index , Settings .EMPTY );
35093491 }
Original file line number Diff line number Diff line change 1616import java .util .Map ;
1717import java .util .Set ;
1818
19+ import static org .hamcrest .Matchers .contains ;
1920import static org .hamcrest .Matchers .containsInAnyOrder ;
2021import static org .hamcrest .Matchers .containsString ;
22+ import static org .hamcrest .Matchers .empty ;
2123import static org .hamcrest .Matchers .equalTo ;
2224import static org .hamcrest .Matchers .hasKey ;
25+ import static org .hamcrest .Matchers .hasSize ;
2326import static org .hamcrest .Matchers .not ;
2427
2528public class RemoteClusterAwareTests extends ESTestCase {
@@ -158,6 +161,23 @@ public void testGroupClusterIndicesFail() {
158161
159162 }
160163
164+ public void testGetRemoteIndexExpressions () {
165+ {
166+ List <String > remoteIndexExpressions = RemoteClusterAware .getRemoteIndexExpressions ("index-1" );
167+ assertThat (remoteIndexExpressions , empty ());
168+ }
169+ {
170+ List <String > remoteIndexExpressions = RemoteClusterAware .getRemoteIndexExpressions (
171+ "index-1" ,
172+ "remote:index-1" ,
173+ "idx-*" ,
174+ "remote-2:idx-5"
175+ );
176+ assertThat (remoteIndexExpressions , hasSize (2 ));
177+ assertThat (remoteIndexExpressions , contains ("remote:index-1" , "remote-2:idx-5" ));
178+ }
179+ }
180+
161181 private static class RemoteClusterAwareTest extends RemoteClusterAware {
162182 RemoteClusterAwareTest () {
163183 super (Settings .EMPTY );
You can’t perform that action at this time.
0 commit comments