diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java index 165f78b586d..8a291f586e3 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java @@ -11,9 +11,11 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.ParseFieldMatcherSupplier; import org.elasticsearch.common.component.LifecycleListener; +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; @@ -156,6 +158,21 @@ public class PrelertPlugin extends Plugin implements ActionPlugin { AutodetectProcessManager.MAX_RUNNING_JOBS_PER_NODE)); } + @Override + public List getNamedWriteables() { + return Collections.singletonList(new NamedWriteableRegistry.Entry(MetaData.Custom.class, "prelert", PrelertMetadata::new)); + } + + @Override + public List getNamedXContent() { + NamedXContentRegistry.Entry entry = new NamedXContentRegistry.Entry( + MetaData.Custom.class, + new ParseField("prelert"), + parser -> PrelertMetadata.PRELERT_METADATA_PARSER.parse(parser, parseFieldMatcherSupplier).build() + ); + return Collections.singletonList(entry); + } + @Override public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertMetadata.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertMetadata.java index 812c73e5d06..b211437a43d 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertMetadata.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertMetadata.java @@ -50,7 +50,7 @@ public class PrelertMetadata implements MetaData.Custom { public static final PrelertMetadata EMPTY_METADATA = new PrelertMetadata(Collections.emptySortedMap(), Collections.emptySortedMap(), Collections.emptySortedMap()); - static final ObjectParser PRELERT_METADATA_PARSER = new ObjectParser<>("prelert_metadata", + public static final ObjectParser PRELERT_METADATA_PARSER = new ObjectParser<>("prelert_metadata", Builder::new); static {