|
|
@@ -386,8 +386,7 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
*
|
|
|
*/
|
|
|
public ImmutableOpenMap<String, MappingMetadata> findMappings(String[] concreteIndices,
|
|
|
- Function<String, Predicate<String>> fieldFilter)
|
|
|
- throws IOException {
|
|
|
+ Function<String, Predicate<String>> fieldFilter) {
|
|
|
assert concreteIndices != null;
|
|
|
if (concreteIndices.length == 0) {
|
|
|
return ImmutableOpenMap.of();
|
|
|
@@ -560,22 +559,7 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
if (writeIndex == null) {
|
|
|
throw new IllegalArgumentException("alias [" + aliasOrIndex + "] does not have a write index");
|
|
|
}
|
|
|
- AliasMetadata aliasMd = writeIndex.getAliases().get(result.getName());
|
|
|
- if (aliasMd.indexRouting() != null) {
|
|
|
- if (aliasMd.indexRouting().indexOf(',') != -1) {
|
|
|
- throw new IllegalArgumentException("index/alias [" + aliasOrIndex + "] provided with routing value ["
|
|
|
- + aliasMd.getIndexRouting() + "] that resolved to several routing values, rejecting operation");
|
|
|
- }
|
|
|
- if (routing != null) {
|
|
|
- if (!routing.equals(aliasMd.indexRouting())) {
|
|
|
- throw new IllegalArgumentException("Alias [" + aliasOrIndex + "] has index routing associated with it ["
|
|
|
- + aliasMd.indexRouting() + "], and was provided with routing value [" + routing + "], rejecting operation");
|
|
|
- }
|
|
|
- }
|
|
|
- // Alias routing overrides the parent routing (if any).
|
|
|
- return aliasMd.indexRouting();
|
|
|
- }
|
|
|
- return routing;
|
|
|
+ return resolveRouting(routing, aliasOrIndex, writeIndex.getAliases().get(result.getName()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -596,7 +580,10 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
if (result.getIndices().size() > 1) {
|
|
|
rejectSingleIndexOperation(aliasOrIndex, result);
|
|
|
}
|
|
|
- AliasMetadata aliasMd = alias.getFirstAliasMetadata();
|
|
|
+ return resolveRouting(routing, aliasOrIndex, alias.getFirstAliasMetadata());
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String resolveRouting(@Nullable String routing, String aliasOrIndex, AliasMetadata aliasMd) {
|
|
|
if (aliasMd.indexRouting() != null) {
|
|
|
if (aliasMd.indexRouting().indexOf(',') != -1) {
|
|
|
throw new IllegalArgumentException("index/alias [" + aliasOrIndex + "] provided with routing value [" +
|
|
|
@@ -709,10 +696,6 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
return this.customs;
|
|
|
}
|
|
|
|
|
|
- public ImmutableOpenMap<String, Custom> getCustoms() {
|
|
|
- return this.customs;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* The collection of index deletions in the cluster.
|
|
|
*/
|
|
|
@@ -748,28 +731,6 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
return this.totalOpenIndexShards;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Identifies whether the array containing type names given as argument refers to all types
|
|
|
- * The empty or null array identifies all types
|
|
|
- *
|
|
|
- * @param types the array containing types
|
|
|
- * @return true if the provided array maps to all types, false otherwise
|
|
|
- */
|
|
|
- public static boolean isAllTypes(String[] types) {
|
|
|
- return types == null || types.length == 0 || isExplicitAllType(types);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Identifies whether the array containing type names given as argument explicitly refers to all types
|
|
|
- * The empty or null array doesn't explicitly map to all types
|
|
|
- *
|
|
|
- * @param types the array containing index names
|
|
|
- * @return true if the provided array explicitly maps to all types, false otherwise
|
|
|
- */
|
|
|
- public static boolean isExplicitAllType(String[] types) {
|
|
|
- return types != null && types.length == 1 && ALL.equals(types[0]);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param concreteIndex The concrete index to check if routing is required
|
|
|
* @return Whether routing is required according to the mapping for the specified index and type
|
|
|
@@ -973,19 +934,7 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
for (ObjectCursor<IndexTemplateMetadata> cursor : templates.values()) {
|
|
|
cursor.value.writeTo(out);
|
|
|
}
|
|
|
- // filter out custom states not supported by the other node
|
|
|
- int numberOfCustoms = 0;
|
|
|
- for (final ObjectCursor<Custom> cursor : customs.values()) {
|
|
|
- if (VersionedNamedWriteable.shouldSerialize(out, cursor.value)) {
|
|
|
- numberOfCustoms++;
|
|
|
- }
|
|
|
- }
|
|
|
- out.writeVInt(numberOfCustoms);
|
|
|
- for (final ObjectCursor<Custom> cursor : customs.values()) {
|
|
|
- if (VersionedNamedWriteable.shouldSerialize(out, cursor.value)) {
|
|
|
- out.writeNamedWriteable(cursor.value);
|
|
|
- }
|
|
|
- }
|
|
|
+ VersionedNamedWriteable.writeVersionedWritables(out, customs);
|
|
|
}
|
|
|
|
|
|
public static Builder builder() {
|
|
|
@@ -1215,8 +1164,7 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
}
|
|
|
|
|
|
public IndexGraveyard indexGraveyard() {
|
|
|
- IndexGraveyard graveyard = (IndexGraveyard) getCustom(IndexGraveyard.TYPE);
|
|
|
- return graveyard;
|
|
|
+ return (IndexGraveyard) getCustom(IndexGraveyard.TYPE);
|
|
|
}
|
|
|
|
|
|
public Builder updateSettings(Settings settings, String... indices) {
|
|
|
@@ -1275,10 +1223,6 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public DiffableStringMap hashesOfConsistentSettings() {
|
|
|
- return this.hashesOfConsistentSettings;
|
|
|
- }
|
|
|
-
|
|
|
public Builder hashesOfConsistentSettings(DiffableStringMap hashesOfConsistentSettings) {
|
|
|
this.hashesOfConsistentSettings = hashesOfConsistentSettings;
|
|
|
return this;
|