|
|
@@ -222,7 +222,7 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
|
|
|
private final String[] allClosedIndices;
|
|
|
private final String[] visibleClosedIndices;
|
|
|
|
|
|
- private SortedMap<String, IndexAbstraction> indicesLookup;
|
|
|
+ private volatile SortedMap<String, IndexAbstraction> indicesLookup;
|
|
|
private final Map<String, MappingMetadata> mappingsByHash;
|
|
|
|
|
|
private final Version oldestIndexVersion;
|
|
|
@@ -510,10 +510,21 @@ public class Metadata extends AbstractCollection<IndexMetadata> implements Diffa
|
|
|
}
|
|
|
|
|
|
public SortedMap<String, IndexAbstraction> getIndicesLookup() {
|
|
|
- if (indicesLookup == null) {
|
|
|
- indicesLookup = Builder.buildIndicesLookup(custom(DataStreamMetadata.TYPE, DataStreamMetadata.EMPTY), indices);
|
|
|
+ SortedMap<String, IndexAbstraction> lookup = indicesLookup;
|
|
|
+ if (lookup == null) {
|
|
|
+ lookup = buildIndicesLookup();
|
|
|
}
|
|
|
- return indicesLookup;
|
|
|
+ return lookup;
|
|
|
+ }
|
|
|
+
|
|
|
+ private synchronized SortedMap<String, IndexAbstraction> buildIndicesLookup() {
|
|
|
+ SortedMap<String, IndexAbstraction> i = indicesLookup;
|
|
|
+ if (i != null) {
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ i = Builder.buildIndicesLookup(custom(DataStreamMetadata.TYPE, DataStreamMetadata.EMPTY), indices);
|
|
|
+ indicesLookup = i;
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
public boolean sameIndicesLookup(Metadata other) {
|