|
@@ -25,6 +25,7 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
import org.apache.lucene.util.CollectionUtil;
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.action.AliasesRequest;
|
|
|
import org.elasticsearch.cluster.ClusterState;
|
|
|
import org.elasticsearch.cluster.ClusterState.FeatureAware;
|
|
@@ -168,6 +169,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
private final Settings transientSettings;
|
|
|
private final Settings persistentSettings;
|
|
|
private final Settings settings;
|
|
|
+ private final DiffableStringMap hashesOfConsistentSettings;
|
|
|
private final ImmutableOpenMap<String, IndexMetaData> indices;
|
|
|
private final ImmutableOpenMap<String, IndexTemplateMetaData> templates;
|
|
|
private final ImmutableOpenMap<String, Custom> customs;
|
|
@@ -182,7 +184,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
private final SortedMap<String, AliasOrIndex> aliasAndIndexLookup;
|
|
|
|
|
|
MetaData(String clusterUUID, boolean clusterUUIDCommitted, long version, CoordinationMetaData coordinationMetaData,
|
|
|
- Settings transientSettings, Settings persistentSettings,
|
|
|
+ Settings transientSettings, Settings persistentSettings, DiffableStringMap hashesOfConsistentSettings,
|
|
|
ImmutableOpenMap<String, IndexMetaData> indices, ImmutableOpenMap<String, IndexTemplateMetaData> templates,
|
|
|
ImmutableOpenMap<String, Custom> customs, String[] allIndices, String[] allOpenIndices, String[] allClosedIndices,
|
|
|
SortedMap<String, AliasOrIndex> aliasAndIndexLookup) {
|
|
@@ -193,6 +195,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
this.transientSettings = transientSettings;
|
|
|
this.persistentSettings = persistentSettings;
|
|
|
this.settings = Settings.builder().put(persistentSettings).put(transientSettings).build();
|
|
|
+ this.hashesOfConsistentSettings = hashesOfConsistentSettings;
|
|
|
this.indices = indices;
|
|
|
this.customs = customs;
|
|
|
this.templates = templates;
|
|
@@ -244,6 +247,10 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
return this.persistentSettings;
|
|
|
}
|
|
|
|
|
|
+ public Map<String, String> hashesOfConsistentSettings() {
|
|
|
+ return this.hashesOfConsistentSettings;
|
|
|
+ }
|
|
|
+
|
|
|
public CoordinationMetaData coordinationMetaData() {
|
|
|
return this.coordinationMetaData;
|
|
|
}
|
|
@@ -733,6 +740,9 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
if (!metaData1.persistentSettings.equals(metaData2.persistentSettings)) {
|
|
|
return false;
|
|
|
}
|
|
|
+ if (!metaData1.hashesOfConsistentSettings.equals(metaData2.hashesOfConsistentSettings)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
if (!metaData1.templates.equals(metaData2.templates())) {
|
|
|
return false;
|
|
|
}
|
|
@@ -787,6 +797,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
private CoordinationMetaData coordinationMetaData;
|
|
|
private Settings transientSettings;
|
|
|
private Settings persistentSettings;
|
|
|
+ private Diff<DiffableStringMap> hashesOfConsistentSettings;
|
|
|
private Diff<ImmutableOpenMap<String, IndexMetaData>> indices;
|
|
|
private Diff<ImmutableOpenMap<String, IndexTemplateMetaData>> templates;
|
|
|
private Diff<ImmutableOpenMap<String, Custom>> customs;
|
|
@@ -798,6 +809,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
coordinationMetaData = after.coordinationMetaData;
|
|
|
transientSettings = after.transientSettings;
|
|
|
persistentSettings = after.persistentSettings;
|
|
|
+ hashesOfConsistentSettings = after.hashesOfConsistentSettings.diff(before.hashesOfConsistentSettings);
|
|
|
indices = DiffableUtils.diff(before.indices, after.indices, DiffableUtils.getStringKeySerializer());
|
|
|
templates = DiffableUtils.diff(before.templates, after.templates, DiffableUtils.getStringKeySerializer());
|
|
|
customs = DiffableUtils.diff(before.customs, after.customs, DiffableUtils.getStringKeySerializer(), CUSTOM_VALUE_SERIALIZER);
|
|
@@ -810,6 +822,11 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
coordinationMetaData = new CoordinationMetaData(in);
|
|
|
transientSettings = Settings.readSettingsFromStream(in);
|
|
|
persistentSettings = Settings.readSettingsFromStream(in);
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_7_3_0)) {
|
|
|
+ hashesOfConsistentSettings = DiffableStringMap.readDiffFrom(in);
|
|
|
+ } else {
|
|
|
+ hashesOfConsistentSettings = DiffableStringMap.DiffableStringMapDiff.EMPTY;
|
|
|
+ }
|
|
|
indices = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), IndexMetaData::readFrom,
|
|
|
IndexMetaData::readDiffFrom);
|
|
|
templates = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), IndexTemplateMetaData::readFrom,
|
|
@@ -825,6 +842,9 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
coordinationMetaData.writeTo(out);
|
|
|
Settings.writeSettingsToStream(transientSettings, out);
|
|
|
Settings.writeSettingsToStream(persistentSettings, out);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_7_3_0)) {
|
|
|
+ hashesOfConsistentSettings.writeTo(out);
|
|
|
+ }
|
|
|
indices.writeTo(out);
|
|
|
templates.writeTo(out);
|
|
|
customs.writeTo(out);
|
|
@@ -839,6 +859,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
builder.coordinationMetaData(coordinationMetaData);
|
|
|
builder.transientSettings(transientSettings);
|
|
|
builder.persistentSettings(persistentSettings);
|
|
|
+ builder.hashesOfConsistentSettings(hashesOfConsistentSettings.apply(part.hashesOfConsistentSettings));
|
|
|
builder.indices(indices.apply(part.indices));
|
|
|
builder.templates(templates.apply(part.templates));
|
|
|
builder.customs(customs.apply(part.customs));
|
|
@@ -854,6 +875,9 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
builder.coordinationMetaData(new CoordinationMetaData(in));
|
|
|
builder.transientSettings(readSettingsFromStream(in));
|
|
|
builder.persistentSettings(readSettingsFromStream(in));
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_7_3_0)) {
|
|
|
+ builder.hashesOfConsistentSettings(new DiffableStringMap(in));
|
|
|
+ }
|
|
|
int size = in.readVInt();
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
builder.put(IndexMetaData.readFrom(in), false);
|
|
@@ -878,6 +902,9 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
coordinationMetaData.writeTo(out);
|
|
|
writeSettingsToStream(transientSettings, out);
|
|
|
writeSettingsToStream(persistentSettings, out);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_7_3_0)) {
|
|
|
+ hashesOfConsistentSettings.writeTo(out);
|
|
|
+ }
|
|
|
out.writeVInt(indices.size());
|
|
|
for (IndexMetaData indexMetaData : this) {
|
|
|
indexMetaData.writeTo(out);
|
|
@@ -918,6 +945,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
private CoordinationMetaData coordinationMetaData = CoordinationMetaData.EMPTY_META_DATA;
|
|
|
private Settings transientSettings = Settings.Builder.EMPTY_SETTINGS;
|
|
|
private Settings persistentSettings = Settings.Builder.EMPTY_SETTINGS;
|
|
|
+ private DiffableStringMap hashesOfConsistentSettings = new DiffableStringMap(Collections.emptyMap());
|
|
|
|
|
|
private final ImmutableOpenMap.Builder<String, IndexMetaData> indices;
|
|
|
private final ImmutableOpenMap.Builder<String, IndexTemplateMetaData> templates;
|
|
@@ -937,6 +965,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
this.coordinationMetaData = metaData.coordinationMetaData;
|
|
|
this.transientSettings = metaData.transientSettings;
|
|
|
this.persistentSettings = metaData.persistentSettings;
|
|
|
+ this.hashesOfConsistentSettings = metaData.hashesOfConsistentSettings;
|
|
|
this.version = metaData.version;
|
|
|
this.indices = ImmutableOpenMap.builder(metaData.indices);
|
|
|
this.templates = ImmutableOpenMap.builder(metaData.templates);
|
|
@@ -1100,6 +1129,20 @@ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder hashesOfConsistentSettings(Map<String, String> hashesOfConsistentSettings) {
|
|
|
+ this.hashesOfConsistentSettings = new DiffableStringMap(hashesOfConsistentSettings);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
public Builder version(long version) {
|
|
|
this.version = version;
|
|
|
return this;
|
|
@@ -1173,8 +1216,8 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
String[] allClosedIndicesArray = allClosedIndices.toArray(new String[allClosedIndices.size()]);
|
|
|
|
|
|
return new MetaData(clusterUUID, clusterUUIDCommitted, version, coordinationMetaData, transientSettings, persistentSettings,
|
|
|
- indices.build(), templates.build(), customs.build(), allIndicesArray, allOpenIndicesArray, allClosedIndicesArray,
|
|
|
- aliasAndIndexLookup);
|
|
|
+ hashesOfConsistentSettings, indices.build(), templates.build(), customs.build(), allIndicesArray, allOpenIndicesArray,
|
|
|
+ allClosedIndicesArray, aliasAndIndexLookup);
|
|
|
}
|
|
|
|
|
|
private SortedMap<String, AliasOrIndex> buildAliasAndIndexLookup() {
|
|
@@ -1298,6 +1341,8 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
|
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
|
|
builder.put(IndexMetaData.Builder.fromXContent(parser), false);
|
|
|
}
|
|
|
+ } else if ("hashes_of_consistent_settings".equals(currentFieldName)) {
|
|
|
+ builder.hashesOfConsistentSettings(parser.mapStrings());
|
|
|
} else if ("templates".equals(currentFieldName)) {
|
|
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
|
|
builder.put(IndexTemplateMetaData.Builder.fromXContent(parser, parser.currentName()));
|