|
@@ -1296,34 +1296,34 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
|
|
|
public Builder indices(ImmutableOpenMap<String, IndexMetadata> indices) {
|
|
|
previousIndicesLookup = null;
|
|
|
|
|
|
- for (var cursor : indices) {
|
|
|
- put(cursor.value, false);
|
|
|
+ for (var value : indices.values()) {
|
|
|
+ put(value, false);
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
void updateAliases(IndexMetadata previous, IndexMetadata current) {
|
|
|
if (previous == null && current != null) {
|
|
|
- for (var cursor : current.getAliases()) {
|
|
|
- putAlias(cursor.key, current.getIndex());
|
|
|
+ for (var key : current.getAliases().keySet()) {
|
|
|
+ putAlias(key, current.getIndex());
|
|
|
}
|
|
|
} else if (previous != null && current == null) {
|
|
|
- for (var cursor : previous.getAliases()) {
|
|
|
- removeAlias(cursor.key, previous.getIndex());
|
|
|
+ for (var key : previous.getAliases().keySet()) {
|
|
|
+ removeAlias(key, previous.getIndex());
|
|
|
}
|
|
|
} else if (previous != null && current != null) {
|
|
|
if (Objects.equals(previous.getAliases(), current.getAliases())) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- for (var currentCursor : current.getAliases()) {
|
|
|
- if (previous.getAliases().containsKey(currentCursor.key) == false) {
|
|
|
- putAlias(currentCursor.key, current.getIndex());
|
|
|
+ for (var key : current.getAliases().keySet()) {
|
|
|
+ if (previous.getAliases().containsKey(key) == false) {
|
|
|
+ putAlias(key, current.getIndex());
|
|
|
}
|
|
|
}
|
|
|
- for (var previousCursor : previous.getAliases()) {
|
|
|
- if (current.getAliases().containsKey(previousCursor.key) == false) {
|
|
|
- removeAlias(previousCursor.key, current.getIndex());
|
|
|
+ for (var key : previous.getAliases().keySet()) {
|
|
|
+ if (current.getAliases().containsKey(key) == false) {
|
|
|
+ removeAlias(key, current.getIndex());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1378,7 +1378,7 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
|
|
|
}
|
|
|
|
|
|
public Builder templates(ImmutableOpenMap<String, IndexTemplateMetadata> templates) {
|
|
|
- this.templates.putAll(templates);
|
|
|
+ this.templates.putAllFromMap(templates);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
@@ -1602,8 +1602,8 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
|
|
|
}
|
|
|
|
|
|
public Builder customs(ImmutableOpenMap<String, Custom> customs) {
|
|
|
- customs.forEach(entry -> Objects.requireNonNull(entry.value, entry.key));
|
|
|
- this.customs.putAll(customs);
|
|
|
+ customs.forEach((key, value) -> Objects.requireNonNull(value, key));
|
|
|
+ this.customs.putAllFromMap(customs);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
@@ -1749,11 +1749,12 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
|
|
|
}
|
|
|
|
|
|
var aliasedIndices = this.aliasedIndices.build();
|
|
|
- for (var cursor : aliasedIndices) {
|
|
|
- List<IndexMetadata> aliasIndices = cursor.value.stream()
|
|
|
+ for (var entry : aliasedIndices.entrySet()) {
|
|
|
+ List<IndexMetadata> aliasIndices = entry.getValue()
|
|
|
+ .stream()
|
|
|
.map(idx -> indicesMap.get(idx.getName()))
|
|
|
.collect(Collectors.toList());
|
|
|
- validateAlias(cursor.key, aliasIndices);
|
|
|
+ validateAlias(entry.getKey(), aliasIndices);
|
|
|
}
|
|
|
final DataStreamMetadata dataStreamMetadata = (DataStreamMetadata) this.customs.get(DataStreamMetadata.TYPE);
|
|
|
ensureNoNameCollisions(aliasedIndices.keySet(), indicesMap, allIndices, dataStreamMetadata);
|
|
@@ -1967,17 +1968,16 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
|
|
|
}
|
|
|
|
|
|
Map<String, List<IndexMetadata>> aliasToIndices = new HashMap<>();
|
|
|
- for (var entry : indices) {
|
|
|
- final String name = entry.key;
|
|
|
- final IndexMetadata indexMetadata = entry.value;
|
|
|
+ for (var entry : indices.entrySet()) {
|
|
|
+ final String name = entry.getKey();
|
|
|
+ final IndexMetadata indexMetadata = entry.getValue();
|
|
|
final IndexAbstraction.DataStream parent = indexToDataStreamLookup.get(name);
|
|
|
assert parent == null || parent.getIndices().stream().anyMatch(index -> name.equals(index.getName()))
|
|
|
: "Expected data stream [" + parent.getName() + "] to contain index " + indexMetadata.getIndex();
|
|
|
IndexAbstraction existing = indicesLookup.put(name, new ConcreteIndex(indexMetadata, parent));
|
|
|
assert existing == null : "duplicate for " + indexMetadata.getIndex();
|
|
|
|
|
|
- for (var aliasCursor : indexMetadata.getAliases()) {
|
|
|
- AliasMetadata aliasMetadata = aliasCursor.value;
|
|
|
+ for (var aliasMetadata : indexMetadata.getAliases().values()) {
|
|
|
List<IndexMetadata> aliasIndices = aliasToIndices.computeIfAbsent(aliasMetadata.getAlias(), k -> new ArrayList<>());
|
|
|
aliasIndices.add(indexMetadata);
|
|
|
}
|