diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/Job.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/Job.java index 678589b9ae9..eb6ea2af278 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/Job.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/Job.java @@ -46,9 +46,6 @@ import java.util.TreeSet; */ public class Job extends AbstractDiffable implements Writeable, ToXContent { - public static final Job PROTO = - new Job(null, null, null, null, null, 0L, null, null, null, null, null, null, null, null, null, null, null, null, null); - public static final String TYPE = "job"; /* diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/Allocation.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/Allocation.java index b92c8a360cd..68e7041967d 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/Allocation.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/Allocation.java @@ -28,8 +28,6 @@ public class Allocation extends AbstractDiffable implements ToXConte public static final ParseField STATUS = new ParseField("status"); public static final ParseField STATUS_REASON = new ParseField("status_reason"); - static final Allocation PROTO = new Allocation(null, null, false, null, null); - static final ObjectParser PARSER = new ObjectParser<>("allocation", Builder::new); static { diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertInitializationService.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertInitializationService.java index ff104b65af3..86aa73842b2 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertInitializationService.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/metadata/PrelertInitializationService.java @@ -44,7 +44,7 @@ public class PrelertInitializationService extends AbstractComponent implements C public ClusterState execute(ClusterState currentState) throws Exception { ClusterState.Builder builder = new ClusterState.Builder(currentState); MetaData.Builder metadataBuilder = MetaData.builder(currentState.metaData()); - metadataBuilder.putCustom(PrelertMetadata.TYPE, PrelertMetadata.PROTO); + metadataBuilder.putCustom(PrelertMetadata.TYPE, PrelertMetadata.EMPTY_METADATA); builder.metaData(metadataBuilder.build()); return builder.build(); } 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 07190ad818e..812c73e5d06 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 @@ -47,8 +47,8 @@ public class PrelertMetadata implements MetaData.Custom { private static final ParseField SCHEDULERS_FIELD = new ParseField("schedulers"); public static final String TYPE = "prelert"; - public static final PrelertMetadata PROTO = new PrelertMetadata(Collections.emptySortedMap(), Collections.emptySortedMap(), - Collections.emptySortedMap()); + public static final PrelertMetadata EMPTY_METADATA = new PrelertMetadata(Collections.emptySortedMap(), + Collections.emptySortedMap(), Collections.emptySortedMap()); static final ObjectParser PRELERT_METADATA_PARSER = new ObjectParser<>("prelert_metadata", Builder::new); diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/scheduler/Scheduler.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/scheduler/Scheduler.java index d4e3e1d130d..9807d623272 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/scheduler/Scheduler.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/scheduler/Scheduler.java @@ -23,8 +23,6 @@ public class Scheduler extends AbstractDiffable implements ToXContent private static final ParseField CONFIG_FIELD = new ParseField("config"); private static final ParseField STATUS_FIELD = new ParseField("status"); - public static final Scheduler PROTO = new Scheduler(null, null); - // Used for QueryPage public static final ParseField RESULTS_FIELD = new ParseField("schedulers"); diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/manager/JobManagerTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/manager/JobManagerTests.java index 6545023d25e..0700316b345 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/manager/JobManagerTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/manager/JobManagerTests.java @@ -165,7 +165,7 @@ public class JobManagerTests extends ESTestCase { .fPut(AnomalyDetectorsIndex.jobResultsIndexName("my-special-place"), indexMetaData).build(); ClusterState cs = ClusterState.builder(new ClusterName("_name")) - .metaData(MetaData.builder().putCustom(PrelertMetadata.TYPE, PrelertMetadata.PROTO).indices(indexMap)).build(); + .metaData(MetaData.builder().putCustom(PrelertMetadata.TYPE, PrelertMetadata.EMPTY_METADATA).indices(indexMap)).build(); doAnswer(invocationOnMock -> { AckedClusterStateUpdateTask task = (AckedClusterStateUpdateTask) invocationOnMock.getArguments()[1]; @@ -196,7 +196,7 @@ public class JobManagerTests extends ESTestCase { private ClusterState createClusterState() { ClusterState.Builder builder = ClusterState.builder(new ClusterName("_name")); - builder.metaData(MetaData.builder().putCustom(PrelertMetadata.TYPE, PrelertMetadata.PROTO)); + builder.metaData(MetaData.builder().putCustom(PrelertMetadata.TYPE, PrelertMetadata.EMPTY_METADATA)); return builder.build(); } }