@@ -386,8 +386,7 @@ private ImmutableOpenMap<String, List<AliasMetadata>> findAliases(final String[]
386
386
*
387
387
*/
388
388
public ImmutableOpenMap <String , MappingMetadata > findMappings (String [] concreteIndices ,
389
- Function <String , Predicate <String >> fieldFilter )
390
- throws IOException {
389
+ Function <String , Predicate <String >> fieldFilter ) {
391
390
assert concreteIndices != null ;
392
391
if (concreteIndices .length == 0 ) {
393
392
return ImmutableOpenMap .of ();
@@ -560,22 +559,7 @@ public String resolveWriteIndexRouting(@Nullable String routing, String aliasOrI
560
559
if (writeIndex == null ) {
561
560
throw new IllegalArgumentException ("alias [" + aliasOrIndex + "] does not have a write index" );
562
561
}
563
- AliasMetadata aliasMd = writeIndex .getAliases ().get (result .getName ());
564
- if (aliasMd .indexRouting () != null ) {
565
- if (aliasMd .indexRouting ().indexOf (',' ) != -1 ) {
566
- throw new IllegalArgumentException ("index/alias [" + aliasOrIndex + "] provided with routing value ["
567
- + aliasMd .getIndexRouting () + "] that resolved to several routing values, rejecting operation" );
568
- }
569
- if (routing != null ) {
570
- if (!routing .equals (aliasMd .indexRouting ())) {
571
- throw new IllegalArgumentException ("Alias [" + aliasOrIndex + "] has index routing associated with it ["
572
- + aliasMd .indexRouting () + "], and was provided with routing value [" + routing + "], rejecting operation" );
573
- }
574
- }
575
- // Alias routing overrides the parent routing (if any).
576
- return aliasMd .indexRouting ();
577
- }
578
- return routing ;
562
+ return resolveRouting (routing , aliasOrIndex , writeIndex .getAliases ().get (result .getName ()));
579
563
}
580
564
581
565
/**
@@ -596,7 +580,10 @@ public String resolveIndexRouting(@Nullable String routing, String aliasOrIndex)
596
580
if (result .getIndices ().size () > 1 ) {
597
581
rejectSingleIndexOperation (aliasOrIndex , result );
598
582
}
599
- AliasMetadata aliasMd = alias .getFirstAliasMetadata ();
583
+ return resolveRouting (routing , aliasOrIndex , alias .getFirstAliasMetadata ());
584
+ }
585
+
586
+ private static String resolveRouting (@ Nullable String routing , String aliasOrIndex , AliasMetadata aliasMd ) {
600
587
if (aliasMd .indexRouting () != null ) {
601
588
if (aliasMd .indexRouting ().indexOf (',' ) != -1 ) {
602
589
throw new IllegalArgumentException ("index/alias [" + aliasOrIndex + "] provided with routing value [" +
@@ -709,10 +696,6 @@ public ImmutableOpenMap<String, Custom> customs() {
709
696
return this .customs ;
710
697
}
711
698
712
- public ImmutableOpenMap <String , Custom > getCustoms () {
713
- return this .customs ;
714
- }
715
-
716
699
/**
717
700
* The collection of index deletions in the cluster.
718
701
*/
@@ -748,28 +731,6 @@ public int getTotalOpenIndexShards() {
748
731
return this .totalOpenIndexShards ;
749
732
}
750
733
751
- /**
752
- * Identifies whether the array containing type names given as argument refers to all types
753
- * The empty or null array identifies all types
754
- *
755
- * @param types the array containing types
756
- * @return true if the provided array maps to all types, false otherwise
757
- */
758
- public static boolean isAllTypes (String [] types ) {
759
- return types == null || types .length == 0 || isExplicitAllType (types );
760
- }
761
-
762
- /**
763
- * Identifies whether the array containing type names given as argument explicitly refers to all types
764
- * The empty or null array doesn't explicitly map to all types
765
- *
766
- * @param types the array containing index names
767
- * @return true if the provided array explicitly maps to all types, false otherwise
768
- */
769
- public static boolean isExplicitAllType (String [] types ) {
770
- return types != null && types .length == 1 && ALL .equals (types [0 ]);
771
- }
772
-
773
734
/**
774
735
* @param concreteIndex The concrete index to check if routing is required
775
736
* @return Whether routing is required according to the mapping for the specified index and type
@@ -973,19 +934,7 @@ public void writeTo(StreamOutput out) throws IOException {
973
934
for (ObjectCursor <IndexTemplateMetadata > cursor : templates .values ()) {
974
935
cursor .value .writeTo (out );
975
936
}
976
- // filter out custom states not supported by the other node
977
- int numberOfCustoms = 0 ;
978
- for (final ObjectCursor <Custom > cursor : customs .values ()) {
979
- if (VersionedNamedWriteable .shouldSerialize (out , cursor .value )) {
980
- numberOfCustoms ++;
981
- }
982
- }
983
- out .writeVInt (numberOfCustoms );
984
- for (final ObjectCursor <Custom > cursor : customs .values ()) {
985
- if (VersionedNamedWriteable .shouldSerialize (out , cursor .value )) {
986
- out .writeNamedWriteable (cursor .value );
987
- }
988
- }
937
+ VersionedNamedWriteable .writeVersionedWritables (out , customs );
989
938
}
990
939
991
940
public static Builder builder () {
@@ -1215,8 +1164,7 @@ public Builder indexGraveyard(final IndexGraveyard indexGraveyard) {
1215
1164
}
1216
1165
1217
1166
public IndexGraveyard indexGraveyard () {
1218
- IndexGraveyard graveyard = (IndexGraveyard ) getCustom (IndexGraveyard .TYPE );
1219
- return graveyard ;
1167
+ return (IndexGraveyard ) getCustom (IndexGraveyard .TYPE );
1220
1168
}
1221
1169
1222
1170
public Builder updateSettings (Settings settings , String ... indices ) {
@@ -1275,10 +1223,6 @@ public Builder persistentSettings(Settings settings) {
1275
1223
return this ;
1276
1224
}
1277
1225
1278
- public DiffableStringMap hashesOfConsistentSettings () {
1279
- return this .hashesOfConsistentSettings ;
1280
- }
1281
-
1282
1226
public Builder hashesOfConsistentSettings (DiffableStringMap hashesOfConsistentSettings ) {
1283
1227
this .hashesOfConsistentSettings = hashesOfConsistentSettings ;
1284
1228
return this ;
0 commit comments