|
@@ -9,6 +9,7 @@
|
|
|
package org.elasticsearch.cluster.metadata;
|
|
|
|
|
|
import org.elasticsearch.TransportVersion;
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.cluster.Diff;
|
|
|
import org.elasticsearch.cluster.SimpleDiffable;
|
|
|
import org.elasticsearch.common.Strings;
|
|
@@ -46,6 +47,7 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
private static final ParseField METADATA = new ParseField("_meta");
|
|
|
private static final ParseField DATA_STREAM = new ParseField("data_stream");
|
|
|
private static final ParseField ALLOW_AUTO_CREATE = new ParseField("allow_auto_create");
|
|
|
+ private static final ParseField IGNORE_MISSING_COMPONENT_TEMPLATES = new ParseField("ignore_missing_component_templates");
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public static final ConstructingObjectParser<ComposableIndexTemplate, Void> PARSER = new ConstructingObjectParser<>(
|
|
@@ -59,7 +61,8 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
(Long) a[4],
|
|
|
(Map<String, Object>) a[5],
|
|
|
(DataStreamTemplate) a[6],
|
|
|
- (Boolean) a[7]
|
|
|
+ (Boolean) a[7],
|
|
|
+ (List<String>) a[8]
|
|
|
)
|
|
|
);
|
|
|
|
|
@@ -72,6 +75,7 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), (p, c) -> p.map(), METADATA);
|
|
|
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), DataStreamTemplate.PARSER, DATA_STREAM);
|
|
|
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), ALLOW_AUTO_CREATE);
|
|
|
+ PARSER.declareStringArray(ConstructingObjectParser.optionalConstructorArg(), IGNORE_MISSING_COMPONENT_TEMPLATES);
|
|
|
}
|
|
|
|
|
|
private final List<String> indexPatterns;
|
|
@@ -89,6 +93,8 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
private final DataStreamTemplate dataStreamTemplate;
|
|
|
@Nullable
|
|
|
private final Boolean allowAutoCreate;
|
|
|
+ @Nullable
|
|
|
+ private final List<String> ignoreMissingComponentTemplates;
|
|
|
|
|
|
static Diff<ComposableIndexTemplate> readITV2DiffFrom(StreamInput in) throws IOException {
|
|
|
return SimpleDiffable.readDiffFrom(ComposableIndexTemplate::new, in);
|
|
@@ -106,7 +112,7 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
@Nullable Long version,
|
|
|
@Nullable Map<String, Object> metadata
|
|
|
) {
|
|
|
- this(indexPatterns, template, componentTemplates, priority, version, metadata, null, null);
|
|
|
+ this(indexPatterns, template, componentTemplates, priority, version, metadata, null, null, null);
|
|
|
}
|
|
|
|
|
|
public ComposableIndexTemplate(
|
|
@@ -118,7 +124,7 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
@Nullable Map<String, Object> metadata,
|
|
|
@Nullable DataStreamTemplate dataStreamTemplate
|
|
|
) {
|
|
|
- this(indexPatterns, template, componentTemplates, priority, version, metadata, dataStreamTemplate, null);
|
|
|
+ this(indexPatterns, template, componentTemplates, priority, version, metadata, dataStreamTemplate, null, null);
|
|
|
}
|
|
|
|
|
|
public ComposableIndexTemplate(
|
|
@@ -130,6 +136,20 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
@Nullable Map<String, Object> metadata,
|
|
|
@Nullable DataStreamTemplate dataStreamTemplate,
|
|
|
@Nullable Boolean allowAutoCreate
|
|
|
+ ) {
|
|
|
+ this(indexPatterns, template, componentTemplates, priority, version, metadata, dataStreamTemplate, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ComposableIndexTemplate(
|
|
|
+ List<String> indexPatterns,
|
|
|
+ @Nullable Template template,
|
|
|
+ @Nullable List<String> componentTemplates,
|
|
|
+ @Nullable Long priority,
|
|
|
+ @Nullable Long version,
|
|
|
+ @Nullable Map<String, Object> metadata,
|
|
|
+ @Nullable DataStreamTemplate dataStreamTemplate,
|
|
|
+ @Nullable Boolean allowAutoCreate,
|
|
|
+ @Nullable List<String> ignoreMissingComponentTemplates
|
|
|
) {
|
|
|
this.indexPatterns = indexPatterns;
|
|
|
this.template = template;
|
|
@@ -139,6 +159,7 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
this.metadata = metadata;
|
|
|
this.dataStreamTemplate = dataStreamTemplate;
|
|
|
this.allowAutoCreate = allowAutoCreate;
|
|
|
+ this.ignoreMissingComponentTemplates = ignoreMissingComponentTemplates;
|
|
|
}
|
|
|
|
|
|
public ComposableIndexTemplate(StreamInput in) throws IOException {
|
|
@@ -154,6 +175,11 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
this.metadata = in.readMap();
|
|
|
this.dataStreamTemplate = in.readOptionalWriteable(DataStreamTemplate::new);
|
|
|
this.allowAutoCreate = in.readOptionalBoolean();
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_8_7_0)) {
|
|
|
+ this.ignoreMissingComponentTemplates = in.readOptionalStringList();
|
|
|
+ } else {
|
|
|
+ this.ignoreMissingComponentTemplates = null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public List<String> indexPatterns() {
|
|
@@ -204,6 +230,11 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
return this.allowAutoCreate;
|
|
|
}
|
|
|
|
|
|
+ @Nullable
|
|
|
+ public List<String> getIgnoreMissingComponentTemplates() {
|
|
|
+ return ignoreMissingComponentTemplates;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
|
out.writeStringCollection(this.indexPatterns);
|
|
@@ -219,6 +250,9 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
out.writeGenericMap(this.metadata);
|
|
|
out.writeOptionalWriteable(dataStreamTemplate);
|
|
|
out.writeOptionalBoolean(allowAutoCreate);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_8_7_0)) {
|
|
|
+ out.writeOptionalStringCollection(ignoreMissingComponentTemplates);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -246,6 +280,9 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
if (this.allowAutoCreate != null) {
|
|
|
builder.field(ALLOW_AUTO_CREATE.getPreferredName(), allowAutoCreate);
|
|
|
}
|
|
|
+ if (this.ignoreMissingComponentTemplates != null) {
|
|
|
+ builder.stringListField(IGNORE_MISSING_COMPONENT_TEMPLATES.getPreferredName(), ignoreMissingComponentTemplates);
|
|
|
+ }
|
|
|
builder.endObject();
|
|
|
return builder;
|
|
|
}
|
|
@@ -260,7 +297,8 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
this.version,
|
|
|
this.metadata,
|
|
|
this.dataStreamTemplate,
|
|
|
- this.allowAutoCreate
|
|
|
+ this.allowAutoCreate,
|
|
|
+ this.ignoreMissingComponentTemplates
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -280,7 +318,8 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
&& Objects.equals(this.version, other.version)
|
|
|
&& Objects.equals(this.metadata, other.metadata)
|
|
|
&& Objects.equals(this.dataStreamTemplate, other.dataStreamTemplate)
|
|
|
- && Objects.equals(this.allowAutoCreate, other.allowAutoCreate);
|
|
|
+ && Objects.equals(this.allowAutoCreate, other.allowAutoCreate)
|
|
|
+ && Objects.equals(this.ignoreMissingComponentTemplates, other.ignoreMissingComponentTemplates);
|
|
|
}
|
|
|
|
|
|
static boolean componentTemplatesEquals(List<String> c1, List<String> c2) {
|
|
@@ -421,6 +460,7 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
private Map<String, Object> metadata;
|
|
|
private DataStreamTemplate dataStreamTemplate;
|
|
|
private Boolean allowAutoCreate;
|
|
|
+ private List<String> ignoreMissingComponentTemplates;
|
|
|
|
|
|
public Builder() {}
|
|
|
|
|
@@ -464,6 +504,11 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ public Builder ignoreMissingComponentTemplates(List<String> ignoreMissingComponentTemplates) {
|
|
|
+ this.ignoreMissingComponentTemplates = ignoreMissingComponentTemplates;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
public ComposableIndexTemplate build() {
|
|
|
return new ComposableIndexTemplate(
|
|
|
this.indexPatterns,
|
|
@@ -473,7 +518,8 @@ public class ComposableIndexTemplate implements SimpleDiffable<ComposableIndexTe
|
|
|
this.version,
|
|
|
this.metadata,
|
|
|
this.dataStreamTemplate,
|
|
|
- this.allowAutoCreate
|
|
|
+ this.allowAutoCreate,
|
|
|
+ this.ignoreMissingComponentTemplates
|
|
|
);
|
|
|
}
|
|
|
}
|