diff --git a/dev-tools/checkstyle_suppressions.xml b/dev-tools/checkstyle_suppressions.xml index b759549b60e..ca21450138b 100644 --- a/dev-tools/checkstyle_suppressions.xml +++ b/dev-tools/checkstyle_suppressions.xml @@ -154,7 +154,6 @@ - @@ -204,7 +203,6 @@ - @@ -227,7 +225,6 @@ - diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateJobAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateJobAction.java index 9f53d5124a1..70b7087b235 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateJobAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateJobAction.java @@ -200,7 +200,7 @@ public class UpdateJobAction extends Action listener) { UpdateProcessAction.Request updateProcessRequest = new UpdateProcessAction.Request(request.getJobId(), - request.getJobUpdate().getModelDebugConfig(), request.getJobUpdate().getDetectorUpdates()); + request.getJobUpdate().getModelPlotConfig(), request.getJobUpdate().getDetectorUpdates()); client.execute(UpdateProcessAction.INSTANCE, updateProcessRequest, new ActionListener() { @Override diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java index 13b1acf7029..821c5ff883c 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java @@ -25,7 +25,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.job.config.JobUpdate; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager; import java.io.IOException; @@ -113,20 +113,20 @@ public class UpdateProcessAction extends public static class Request extends TransportJobTaskAction.JobTaskRequest { - private ModelDebugConfig modelDebugConfig; + private ModelPlotConfig modelPlotConfig; private List detectorUpdates; Request() { } - public Request(String jobId, ModelDebugConfig modelDebugConfig, List detectorUpdates) { + public Request(String jobId, ModelPlotConfig modelPlotConfig, List detectorUpdates) { super(jobId); - this.modelDebugConfig = modelDebugConfig; + this.modelPlotConfig = modelPlotConfig; this.detectorUpdates = detectorUpdates; } - public ModelDebugConfig getModelDebugConfig() { - return modelDebugConfig; + public ModelPlotConfig getModelPlotConfig() { + return modelPlotConfig; } public List getDetectorUpdates() { @@ -136,7 +136,7 @@ public class UpdateProcessAction extends @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new); + modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new); if (in.readBoolean()) { in.readList(JobUpdate.DetectorUpdate::new); } @@ -145,7 +145,7 @@ public class UpdateProcessAction extends @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeOptionalWriteable(modelDebugConfig); + out.writeOptionalWriteable(modelPlotConfig); boolean hasDetectorUpdates = detectorUpdates != null; out.writeBoolean(hasDetectorUpdates); if (hasDetectorUpdates) { @@ -155,7 +155,7 @@ public class UpdateProcessAction extends @Override public int hashCode() { - return Objects.hash(getJobId(), modelDebugConfig, detectorUpdates); + return Objects.hash(getJobId(), modelPlotConfig, detectorUpdates); } @Override @@ -169,7 +169,7 @@ public class UpdateProcessAction extends Request other = (Request) obj; return Objects.equals(getJobId(), other.getJobId()) && - Objects.equals(modelDebugConfig, other.modelDebugConfig) && + Objects.equals(modelPlotConfig, other.modelPlotConfig) && Objects.equals(detectorUpdates, other.detectorUpdates); } } @@ -196,7 +196,7 @@ public class UpdateProcessAction extends threadPool.executor(MachineLearning.THREAD_POOL_NAME).execute(() -> { try { processManager.writeUpdateProcessMessage(request.getJobId(), request.getDetectorUpdates(), - request.getModelDebugConfig()); + request.getModelPlotConfig()); listener.onResponse(new Response()); } catch (Exception e) { listener.onFailure(e); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java index a815bb91d9e..fc846c36d3d 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java @@ -57,7 +57,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent public static final ParseField DESCRIPTION = new ParseField("description"); public static final ParseField FINISHED_TIME = new ParseField("finished_time"); public static final ParseField LAST_DATA_TIME = new ParseField("last_data_time"); - public static final ParseField MODEL_DEBUG_CONFIG = new ParseField("model_debug_config"); + public static final ParseField MODEL_PLOT_CONFIG = new ParseField("model_plot_config"); public static final ParseField RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days"); public static final ParseField BACKGROUND_PERSIST_INTERVAL = new ParseField("background_persist_interval"); public static final ParseField MODEL_SNAPSHOT_RETENTION_DAYS = new ParseField("model_snapshot_retention_days"); @@ -108,7 +108,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent PARSER.declareObject(Builder::setAnalysisConfig, AnalysisConfig.PARSER, ANALYSIS_CONFIG); PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, ANALYSIS_LIMITS); PARSER.declareObject(Builder::setDataDescription, DataDescription.PARSER, DATA_DESCRIPTION); - PARSER.declareObject(Builder::setModelDebugConfig, ModelDebugConfig.PARSER, MODEL_DEBUG_CONFIG); + PARSER.declareObject(Builder::setModelPlotConfig, ModelPlotConfig.PARSER, MODEL_PLOT_CONFIG); PARSER.declareLong(Builder::setRenormalizationWindowDays, RENORMALIZATION_WINDOW_DAYS); PARSER.declareString((builder, val) -> builder.setBackgroundPersistInterval( TimeValue.parseTimeValue(val, BACKGROUND_PERSIST_INTERVAL.getPreferredName())), BACKGROUND_PERSIST_INTERVAL); @@ -129,7 +129,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent private final AnalysisConfig analysisConfig; private final AnalysisLimits analysisLimits; private final DataDescription dataDescription; - private final ModelDebugConfig modelDebugConfig; + private final ModelPlotConfig modelPlotConfig; private final Long renormalizationWindowDays; private final TimeValue backgroundPersistInterval; private final Long modelSnapshotRetentionDays; @@ -141,7 +141,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent private Job(String jobId, String description, Date createTime, Date finishedTime, Date lastDataTime, AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription, - ModelDebugConfig modelDebugConfig, Long renormalizationWindowDays, TimeValue backgroundPersistInterval, + ModelPlotConfig modelPlotConfig, Long renormalizationWindowDays, TimeValue backgroundPersistInterval, Long modelSnapshotRetentionDays, Long resultsRetentionDays, Map customSettings, String modelSnapshotId, String resultsIndexName, boolean deleted) { @@ -153,7 +153,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent this.analysisConfig = analysisConfig; this.analysisLimits = analysisLimits; this.dataDescription = dataDescription; - this.modelDebugConfig = modelDebugConfig; + this.modelPlotConfig = modelPlotConfig; this.renormalizationWindowDays = renormalizationWindowDays; this.backgroundPersistInterval = backgroundPersistInterval; this.modelSnapshotRetentionDays = modelSnapshotRetentionDays; @@ -173,7 +173,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent analysisConfig = new AnalysisConfig(in); analysisLimits = in.readOptionalWriteable(AnalysisLimits::new); dataDescription = in.readOptionalWriteable(DataDescription::new); - modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new); + modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new); renormalizationWindowDays = in.readOptionalLong(); backgroundPersistInterval = in.readOptionalWriteable(TimeValue::new); modelSnapshotRetentionDays = in.readOptionalLong(); @@ -277,8 +277,8 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent return analysisLimits; } - public ModelDebugConfig getModelDebugConfig() { - return modelDebugConfig; + public ModelPlotConfig getModelPlotConfig() { + return modelPlotConfig; } /** @@ -378,7 +378,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent analysisConfig.writeTo(out); out.writeOptionalWriteable(analysisLimits); out.writeOptionalWriteable(dataDescription); - out.writeOptionalWriteable(modelDebugConfig); + out.writeOptionalWriteable(modelPlotConfig); out.writeOptionalLong(renormalizationWindowDays); out.writeOptionalWriteable(backgroundPersistInterval); out.writeOptionalLong(modelSnapshotRetentionDays); @@ -420,8 +420,8 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent if (dataDescription != null) { builder.field(DATA_DESCRIPTION.getPreferredName(), dataDescription, params); } - if (modelDebugConfig != null) { - builder.field(MODEL_DEBUG_CONFIG.getPreferredName(), modelDebugConfig, params); + if (modelPlotConfig != null) { + builder.field(MODEL_PLOT_CONFIG.getPreferredName(), modelPlotConfig, params); } if (renormalizationWindowDays != null) { builder.field(RENORMALIZATION_WINDOW_DAYS.getPreferredName(), renormalizationWindowDays); @@ -465,7 +465,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent && Objects.equals(this.lastDataTime, that.lastDataTime) && Objects.equals(this.analysisConfig, that.analysisConfig) && Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.dataDescription, that.dataDescription) - && Objects.equals(this.modelDebugConfig, that.modelDebugConfig) + && Objects.equals(this.modelPlotConfig, that.modelPlotConfig) && Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays) && Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval) && Objects.equals(this.modelSnapshotRetentionDays, that.modelSnapshotRetentionDays) @@ -479,7 +479,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent @Override public int hashCode() { return Objects.hash(jobId, description, createTime, finishedTime, lastDataTime, analysisConfig, - analysisLimits, dataDescription, modelDebugConfig, renormalizationWindowDays, + analysisLimits, dataDescription, modelPlotConfig, renormalizationWindowDays, backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId, resultsIndexName, deleted); } @@ -507,7 +507,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent private Date createTime; private Date finishedTime; private Date lastDataTime; - private ModelDebugConfig modelDebugConfig; + private ModelPlotConfig modelPlotConfig; private Long renormalizationWindowDays; private TimeValue backgroundPersistInterval; private Long modelSnapshotRetentionDays = 1L; @@ -533,7 +533,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent this.createTime = job.getCreateTime(); this.finishedTime = job.getFinishedTime(); this.lastDataTime = job.getLastDataTime(); - this.modelDebugConfig = job.getModelDebugConfig(); + this.modelPlotConfig = job.getModelPlotConfig(); this.renormalizationWindowDays = job.getRenormalizationWindowDays(); this.backgroundPersistInterval = job.getBackgroundPersistInterval(); this.modelSnapshotRetentionDays = job.getModelSnapshotRetentionDays(); @@ -610,8 +610,8 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent return this; } - public Builder setModelDebugConfig(ModelDebugConfig modelDebugConfig) { - this.modelDebugConfig = modelDebugConfig; + public Builder setModelPlotConfig(ModelPlotConfig modelPlotConfig) { + this.modelPlotConfig = modelPlotConfig; return this; } @@ -693,7 +693,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent return new Job( id, description, createTime, finishedTime, lastDataTime, analysisConfig, analysisLimits, - dataDescription, modelDebugConfig, renormalizationWindowDays, backgroundPersistInterval, + dataDescription, modelPlotConfig, renormalizationWindowDays, backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId, resultsIndexName, deleted); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/JobUpdate.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/JobUpdate.java index 201144f48c9..15395ca4335 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/JobUpdate.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/JobUpdate.java @@ -29,7 +29,7 @@ public class JobUpdate implements Writeable, ToXContent { static { PARSER.declareStringOrNull(Builder::setDescription, Job.DESCRIPTION); PARSER.declareObjectArray(Builder::setDetectorUpdates, DetectorUpdate.PARSER, DETECTORS); - PARSER.declareObject(Builder::setModelDebugConfig, ModelDebugConfig.PARSER, Job.MODEL_DEBUG_CONFIG); + PARSER.declareObject(Builder::setModelPlotConfig, ModelPlotConfig.PARSER, Job.MODEL_PLOT_CONFIG); PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, Job.ANALYSIS_LIMITS); PARSER.declareString((builder, val) -> builder.setBackgroundPersistInterval( TimeValue.parseTimeValue(val, Job.BACKGROUND_PERSIST_INTERVAL.getPreferredName())), Job.BACKGROUND_PERSIST_INTERVAL); @@ -43,7 +43,7 @@ public class JobUpdate implements Writeable, ToXContent { private final String description; private final List detectorUpdates; - private final ModelDebugConfig modelDebugConfig; + private final ModelPlotConfig modelPlotConfig; private final AnalysisLimits analysisLimits; private final Long renormalizationWindowDays; private final TimeValue backgroundPersistInterval; @@ -54,14 +54,14 @@ public class JobUpdate implements Writeable, ToXContent { private final String modelSnapshotId; private JobUpdate(@Nullable String description, @Nullable List detectorUpdates, - @Nullable ModelDebugConfig modelDebugConfig, @Nullable AnalysisLimits analysisLimits, + @Nullable ModelPlotConfig modelPlotConfig, @Nullable AnalysisLimits analysisLimits, @Nullable TimeValue backgroundPersistInterval, @Nullable Long renormalizationWindowDays, @Nullable Long resultsRetentionDays, @Nullable Long modelSnapshotRetentionDays, @Nullable List categorisationFilters, @Nullable Map customSettings, @Nullable String modelSnapshotId) { this.description = description; this.detectorUpdates = detectorUpdates; - this.modelDebugConfig = modelDebugConfig; + this.modelPlotConfig = modelPlotConfig; this.analysisLimits = analysisLimits; this.renormalizationWindowDays = renormalizationWindowDays; this.backgroundPersistInterval = backgroundPersistInterval; @@ -79,7 +79,7 @@ public class JobUpdate implements Writeable, ToXContent { } else { detectorUpdates = null; } - modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new); + modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new); analysisLimits = in.readOptionalWriteable(AnalysisLimits::new); renormalizationWindowDays = in.readOptionalLong(); backgroundPersistInterval = in.readOptionalWriteable(TimeValue::new); @@ -100,7 +100,7 @@ public class JobUpdate implements Writeable, ToXContent { if (detectorUpdates != null) { out.writeList(detectorUpdates); } - out.writeOptionalWriteable(modelDebugConfig); + out.writeOptionalWriteable(modelPlotConfig); out.writeOptionalWriteable(analysisLimits); out.writeOptionalLong(renormalizationWindowDays); out.writeOptionalWriteable(backgroundPersistInterval); @@ -122,8 +122,8 @@ public class JobUpdate implements Writeable, ToXContent { return detectorUpdates; } - public ModelDebugConfig getModelDebugConfig() { - return modelDebugConfig; + public ModelPlotConfig getModelPlotConfig() { + return modelPlotConfig; } public AnalysisLimits getAnalysisLimits() { @@ -159,7 +159,7 @@ public class JobUpdate implements Writeable, ToXContent { } public boolean isAutodetectProcessUpdate() { - return modelDebugConfig != null || detectorUpdates != null; + return modelPlotConfig != null || detectorUpdates != null; } @Override @@ -171,8 +171,8 @@ public class JobUpdate implements Writeable, ToXContent { if (detectorUpdates != null) { builder.field(DETECTORS.getPreferredName(), detectorUpdates); } - if (modelDebugConfig != null) { - builder.field(Job.MODEL_DEBUG_CONFIG.getPreferredName(), modelDebugConfig); + if (modelPlotConfig != null) { + builder.field(Job.MODEL_PLOT_CONFIG.getPreferredName(), modelPlotConfig); } if (analysisLimits != null) { builder.field(Job.ANALYSIS_LIMITS.getPreferredName(), analysisLimits); @@ -234,8 +234,8 @@ public class JobUpdate implements Writeable, ToXContent { AnalysisConfig.Builder acBuilder = new AnalysisConfig.Builder(ac); builder.setAnalysisConfig(acBuilder); } - if (modelDebugConfig != null) { - builder.setModelDebugConfig(modelDebugConfig); + if (modelPlotConfig != null) { + builder.setModelPlotConfig(modelPlotConfig); } if (analysisLimits != null) { builder.setAnalysisLimits(analysisLimits); @@ -281,7 +281,7 @@ public class JobUpdate implements Writeable, ToXContent { return Objects.equals(this.description, that.description) && Objects.equals(this.detectorUpdates, that.detectorUpdates) - && Objects.equals(this.modelDebugConfig, that.modelDebugConfig) + && Objects.equals(this.modelPlotConfig, that.modelPlotConfig) && Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays) && Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval) @@ -294,7 +294,7 @@ public class JobUpdate implements Writeable, ToXContent { @Override public int hashCode() { - return Objects.hash(description, detectorUpdates, modelDebugConfig, analysisLimits, renormalizationWindowDays, + return Objects.hash(description, detectorUpdates, modelPlotConfig, analysisLimits, renormalizationWindowDays, backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, categorizationFilters, customSettings, modelSnapshotId); } @@ -395,7 +395,7 @@ public class JobUpdate implements Writeable, ToXContent { public static class Builder { private String description; private List detectorUpdates; - private ModelDebugConfig modelDebugConfig; + private ModelPlotConfig modelPlotConfig; private AnalysisLimits analysisLimits; private Long renormalizationWindowDays; private TimeValue backgroundPersistInterval; @@ -417,8 +417,8 @@ public class JobUpdate implements Writeable, ToXContent { return this; } - public Builder setModelDebugConfig(ModelDebugConfig modelDebugConfig) { - this.modelDebugConfig = modelDebugConfig; + public Builder setModelPlotConfig(ModelPlotConfig modelPlotConfig) { + this.modelPlotConfig = modelPlotConfig; return this; } @@ -463,7 +463,7 @@ public class JobUpdate implements Writeable, ToXContent { } public JobUpdate build() { - return new JobUpdate(description, detectorUpdates, modelDebugConfig, analysisLimits, backgroundPersistInterval, + return new JobUpdate(description, detectorUpdates, modelPlotConfig, analysisLimits, backgroundPersistInterval, renormalizationWindowDays, resultsRetentionDays, modelSnapshotRetentionDays, categorizationFilters, customSettings, modelSnapshotId); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/ModelDebugConfig.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfig.java similarity index 79% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/ModelDebugConfig.java rename to plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfig.java index 8a11405b8c6..ae6a3f2b526 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/ModelDebugConfig.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfig.java @@ -16,14 +16,15 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.Objects; -public class ModelDebugConfig extends ToXContentToBytes implements Writeable { +public class ModelPlotConfig extends ToXContentToBytes implements Writeable { - private static final ParseField TYPE_FIELD = new ParseField("model_debug_config"); + private static final ParseField TYPE_FIELD = new ParseField("model_plot_config"); private static final ParseField ENABLED_FIELD = new ParseField("enabled"); public static final ParseField TERMS_FIELD = new ParseField("terms"); - public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( - TYPE_FIELD.getPreferredName(), a -> new ModelDebugConfig((boolean) a[0], (String) a[1])); + public static final ConstructingObjectParser PARSER = + new ConstructingObjectParser<>(TYPE_FIELD.getPreferredName(), + a -> new ModelPlotConfig((boolean) a[0], (String) a[1])); static { PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), ENABLED_FIELD); @@ -33,20 +34,20 @@ public class ModelDebugConfig extends ToXContentToBytes implements Writeable { private final boolean enabled; private final String terms; - public ModelDebugConfig() { + public ModelPlotConfig() { this(true, null); } - public ModelDebugConfig(boolean enabled) { + public ModelPlotConfig(boolean enabled) { this(false, null); } - public ModelDebugConfig(boolean enabled, String terms) { + public ModelPlotConfig(boolean enabled, String terms) { this.enabled = enabled; this.terms = terms; } - public ModelDebugConfig(StreamInput in) throws IOException { + public ModelPlotConfig(StreamInput in) throws IOException { enabled = in.readBoolean(); terms = in.readOptionalString(); } @@ -82,11 +83,11 @@ public class ModelDebugConfig extends ToXContentToBytes implements Writeable { return true; } - if (other instanceof ModelDebugConfig == false) { + if (other instanceof ModelPlotConfig == false) { return false; } - ModelDebugConfig that = (ModelDebugConfig) other; + ModelPlotConfig that = (ModelPlotConfig) other; return this.enabled == that.enabled && Objects.equals(this.terms, that.terms); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappings.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappings.java index ea9cb707e8e..8e1d6d1c50c 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappings.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappings.java @@ -20,7 +20,7 @@ import org.elasticsearch.xpack.ml.job.results.BucketInfluencer; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.Influence; import org.elasticsearch.xpack.ml.job.results.Influencer; -import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; +import org.elasticsearch.xpack.ml.job.results.ModelPlot; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.ReservedFieldNames; import org.elasticsearch.xpack.ml.job.results.Result; @@ -236,17 +236,17 @@ public class ElasticsearchMappings { .endObject() .endObject() - // Model Debug Output - .startObject(ModelDebugOutput.DEBUG_FEATURE.getPreferredName()) + // Model Plot Output + .startObject(ModelPlot.MODEL_FEATURE.getPreferredName()) .field(TYPE, KEYWORD) .endObject() - .startObject(ModelDebugOutput.DEBUG_LOWER.getPreferredName()) + .startObject(ModelPlot.MODEL_LOWER.getPreferredName()) .field(TYPE, DOUBLE) .endObject() - .startObject(ModelDebugOutput.DEBUG_UPPER.getPreferredName()) + .startObject(ModelPlot.MODEL_UPPER.getPreferredName()) .field(TYPE, DOUBLE) .endObject() - .startObject(ModelDebugOutput.DEBUG_MEDIAN.getPreferredName()) + .startObject(ModelPlot.MODEL_MEDIAN.getPreferredName()) .field(TYPE, DOUBLE) .endObject(); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java index 8fe9b607e81..9bd42f6a1d8 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobProvider.java @@ -71,7 +71,7 @@ import org.elasticsearch.xpack.ml.job.results.AnomalyRecord; import org.elasticsearch.xpack.ml.job.results.Bucket; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.Influencer; -import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; +import org.elasticsearch.xpack.ml.job.results.ModelPlot; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.Result; import org.elasticsearch.xpack.security.support.Exceptions; @@ -961,32 +961,32 @@ public class JobProvider { stream.write(0); } - public QueryPage modelDebugOutput(String jobId, int from, int size) { + public QueryPage modelPlot(String jobId, int from, int size) { SearchResponse searchResponse; String indexName = AnomalyDetectorsIndex.jobResultsAliasedName(jobId); LOGGER.trace("ES API CALL: search result type {} from index {} from {}, size {}", - ModelDebugOutput.RESULT_TYPE_VALUE, indexName, from, size); + ModelPlot.RESULT_TYPE_VALUE, indexName, from, size); searchResponse = client.prepareSearch(indexName) .setIndicesOptions(addIgnoreUnavailable(SearchRequest.DEFAULT_INDICES_OPTIONS)) .setTypes(Result.TYPE.getPreferredName()) - .setQuery(new TermsQueryBuilder(Result.RESULT_TYPE.getPreferredName(), ModelDebugOutput.RESULT_TYPE_VALUE)) + .setQuery(new TermsQueryBuilder(Result.RESULT_TYPE.getPreferredName(), ModelPlot.RESULT_TYPE_VALUE)) .setFrom(from).setSize(size) .get(); - List results = new ArrayList<>(); + List results = new ArrayList<>(); for (SearchHit hit : searchResponse.getHits().getHits()) { BytesReference source = hit.getSourceRef(); try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { - ModelDebugOutput modelDebugOutput = ModelDebugOutput.PARSER.apply(parser, null); - results.add(modelDebugOutput); + ModelPlot modelPlot = ModelPlot.PARSER.apply(parser, null); + results.add(modelPlot); } catch (IOException e) { - throw new ElasticsearchParseException("failed to parse modelDebugOutput", e); + throw new ElasticsearchParseException("failed to parse modelPlot", e); } } - return new QueryPage<>(results, searchResponse.getHits().getTotalHits(), ModelDebugOutput.RESULTS_FIELD); + return new QueryPage<>(results, searchResponse.getHits().getTotalHits(), ModelPlot.RESULTS_FIELD); } /** diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersister.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersister.java index b5c534dcea8..b291a94075d 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersister.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersister.java @@ -25,7 +25,7 @@ import org.elasticsearch.xpack.ml.job.results.Bucket; import org.elasticsearch.xpack.ml.job.results.BucketInfluencer; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.Influencer; -import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; +import org.elasticsearch.xpack.ml.job.results.ModelPlot; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.Result; @@ -270,11 +270,11 @@ public class JobResultsPersister extends AbstractComponent { } /** - * Persist model debug output + * Persist model plot output */ - public void persistModelDebugOutput(ModelDebugOutput modelDebugOutput) { - Persistable persistable = new Persistable(modelDebugOutput.getJobId(), modelDebugOutput, Result.TYPE.getPreferredName(), null); - persistable.persist(AnomalyDetectorsIndex.jobResultsAliasedName(modelDebugOutput.getJobId())); + public void persistModelPlot(ModelPlot modelPlot) { + Persistable persistable = new Persistable(modelPlot.getJobId(), modelPlot, Result.TYPE.getPreferredName(), null); + persistable.persist(AnomalyDetectorsIndex.jobResultsAliasedName(modelPlot.getJobId())); // Don't commit as we expect masses of these updates and they're not // read again by this process } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java index d47c277a38f..cc577f8cc6f 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java @@ -10,13 +10,13 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.xpack.ml.job.config.AnalysisLimits; import org.elasticsearch.xpack.ml.job.config.Job; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.NativeController; import org.elasticsearch.xpack.ml.job.process.ProcessCtrl; import org.elasticsearch.xpack.ml.job.process.ProcessPipes; import org.elasticsearch.xpack.ml.job.process.autodetect.writer.AnalysisLimitsWriter; import org.elasticsearch.xpack.ml.job.process.autodetect.writer.FieldConfigWriter; -import org.elasticsearch.xpack.ml.job.process.autodetect.writer.ModelDebugConfigWriter; +import org.elasticsearch.xpack.ml.job.process.autodetect.writer.ModelPlotConfigWriter; import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles; import org.elasticsearch.xpack.ml.job.config.MlFilter; @@ -37,7 +37,7 @@ import java.util.concurrent.TimeoutException; public class AutodetectBuilder { private static final String CONF_EXTENSION = ".conf"; private static final String LIMIT_CONFIG_ARG = "--limitconfig="; - private static final String MODEL_DEBUG_CONFIG_ARG = "--modeldebugconfig="; + private static final String MODEL_PLOT_CONFIG_ARG = "--modelplotconfig="; private static final String FIELD_CONFIG_ARG = "--fieldconfig="; private Job job; @@ -106,7 +106,7 @@ public class AutodetectBuilder { List command = ProcessCtrl.buildAutodetectCommand(env, settings, job, logger, ignoreDowntime, controller.getPid()); buildLimits(command); - buildModelDebugConfig(command); + buildModelPlotConfig(command); buildQuantiles(command); buildFieldConfig(command); @@ -134,22 +134,22 @@ public class AutodetectBuilder { } } - private void buildModelDebugConfig(List command) throws IOException { - if (job.getModelDebugConfig() != null) { - Path modelDebugConfigFile = Files.createTempFile(env.tmpFile(), "modeldebugconfig", CONF_EXTENSION); - filesToDelete.add(modelDebugConfigFile); - writeModelDebugConfig(job.getModelDebugConfig(), modelDebugConfigFile); - String modelDebugConfig = MODEL_DEBUG_CONFIG_ARG + modelDebugConfigFile.toString(); - command.add(modelDebugConfig); + private void buildModelPlotConfig(List command) throws IOException { + if (job.getModelPlotConfig() != null) { + Path modelPlotConfigFile = Files.createTempFile(env.tmpFile(), "modelplotconfig", CONF_EXTENSION); + filesToDelete.add(modelPlotConfigFile); + writeModelPlotConfig(job.getModelPlotConfig(), modelPlotConfigFile); + String modelPlotConfig = MODEL_PLOT_CONFIG_ARG + modelPlotConfigFile.toString(); + command.add(modelPlotConfig); } } - private static void writeModelDebugConfig(ModelDebugConfig config, Path emptyConfFile) + private static void writeModelPlotConfig(ModelPlotConfig config, Path emptyConfFile) throws IOException { try (OutputStreamWriter osw = new OutputStreamWriter( Files.newOutputStream(emptyConfFile), StandardCharsets.UTF_8)) { - new ModelDebugConfigWriter(config, osw).write(); + new ModelPlotConfigWriter(config, osw).write(); } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicator.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicator.java index 4416527dcd1..133488e4939 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicator.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicator.java @@ -15,7 +15,7 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.xpack.ml.job.config.DataDescription; import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.Job; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.messages.Messages; import org.elasticsearch.xpack.ml.job.process.CountingInputStream; import org.elasticsearch.xpack.ml.job.process.DataCountsReporter; @@ -111,9 +111,9 @@ public class AutodetectCommunicator implements Closeable { } - public void writeUpdateModelDebugMessage(ModelDebugConfig config) throws IOException { + public void writeUpdateModelPlotMessage(ModelPlotConfig config) throws IOException { checkAndRun(() -> Messages.getMessage(Messages.JOB_DATA_CONCURRENT_USE_UPDATE, job.getId()), () -> { - autodetectProcess.writeUpdateModelDebugMessage(config); + autodetectProcess.writeUpdateModelPlotMessage(config); return null; }, false); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcess.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcess.java index cb659f287c9..16dc705e750 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcess.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcess.java @@ -6,7 +6,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect; import org.elasticsearch.xpack.ml.job.config.DetectionRule; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams; import org.elasticsearch.xpack.ml.job.results.AutodetectResult; @@ -41,12 +41,12 @@ public interface AutodetectProcess extends Closeable { void writeResetBucketsControlMessage(DataLoadParams params) throws IOException; /** - * Update the model debug configuration + * Update the model plot configuration * - * @param modelDebugConfig New model debug config + * @param modelPlotConfig New model plot config * @throws IOException If the write fails */ - void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException; + void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException; /** * Write message to update the detector rules diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java index 844fe0b8685..f5cb3644168 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java @@ -23,7 +23,7 @@ import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.MlFilter; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobProvider; import org.elasticsearch.xpack.ml.job.persistence.JobRenormalizedResultsPersister; @@ -174,7 +174,7 @@ public class AutodetectProcessManager extends AbstractComponent { } } - public void writeUpdateProcessMessage(String jobId, List updates, ModelDebugConfig config) + public void writeUpdateProcessMessage(String jobId, List updates, ModelPlotConfig config) throws IOException { AutodetectCommunicator communicator = autoDetectCommunicatorByJob.get(jobId); if (communicator == null) { @@ -183,7 +183,7 @@ public class AutodetectProcessManager extends AbstractComponent { } if (config != null) { - communicator.writeUpdateModelDebugMessage(config); + communicator.writeUpdateModelPlotMessage(config); } if (updates != null) { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcess.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcess.java index 7c61bb01f94..5001bba25b5 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcess.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcess.java @@ -6,7 +6,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect; import org.elasticsearch.xpack.ml.job.config.DetectionRule; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.autodetect.output.FlushAcknowledgement; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams; @@ -48,7 +48,7 @@ public class BlackHoleAutodetectProcess implements AutodetectProcess { } @Override - public void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException { + public void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException { } @Override diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcess.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcess.java index e624b18322f..8527bc8f3cb 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcess.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcess.java @@ -9,7 +9,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.xpack.ml.job.config.DetectionRule; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutodetectResultsParser; import org.elasticsearch.xpack.ml.job.process.autodetect.output.StateProcessor; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; @@ -91,9 +91,9 @@ class NativeAutodetectProcess implements AutodetectProcess { } @Override - public void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException { + public void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException { ControlMsgToProcessWriter writer = new ControlMsgToProcessWriter(recordWriter, numberOfAnalysisFields); - writer.writeUpdateModelDebugMessage(modelDebugConfig); + writer.writeUpdateModelPlotMessage(modelPlotConfig); } @Override diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessor.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessor.java index 19bc2eef7f8..15d0d23f58e 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessor.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessor.java @@ -25,7 +25,7 @@ import org.elasticsearch.xpack.ml.job.results.AutodetectResult; import org.elasticsearch.xpack.ml.job.results.Bucket; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.Influencer; -import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; +import org.elasticsearch.xpack.ml.job.results.ModelPlot; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import java.time.Duration; @@ -143,9 +143,9 @@ public class AutoDetectResultProcessor { if (categoryDefinition != null) { persister.persistCategoryDefinition(categoryDefinition); } - ModelDebugOutput modelDebugOutput = result.getModelDebugOutput(); - if (modelDebugOutput != null) { - persister.persistModelDebugOutput(modelDebugOutput); + ModelPlot modelPlot = result.getModelPlot(); + if (modelPlot != null) { + persister.persistModelPlot(modelPlot); } ModelSizeStats modelSizeStats = result.getModelSizeStats(); if (modelSizeStats != null) { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java index 518a0c9e7af..1c8137e9986 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.xpack.ml.job.config.DetectionRule; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams; @@ -149,10 +149,10 @@ public class ControlMsgToProcessWriter { writeMessage(message.toString()); } - public void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException { + public void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException { StringWriter configWriter = new StringWriter(); - configWriter.append(UPDATE_MESSAGE_CODE).append("[modelDebugConfig]\n"); - new ModelDebugConfigWriter(modelDebugConfig, configWriter).write(); + configWriter.append(UPDATE_MESSAGE_CODE).append("[modelPlotConfig]\n"); + new ModelPlotConfigWriter(modelPlotConfig, configWriter).write(); writeMessage(configWriter.toString()); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelDebugConfigWriter.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriter.java similarity index 67% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelDebugConfigWriter.java rename to plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriter.java index 2cc47b131a3..4fb8fedbd44 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelDebugConfigWriter.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriter.java @@ -5,7 +5,7 @@ */ package org.elasticsearch.xpack.ml.job.process.autodetect.writer; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import java.io.IOException; import java.io.Writer; @@ -14,16 +14,16 @@ import java.util.Objects; import static org.elasticsearch.xpack.ml.job.process.autodetect.writer.WriterConstants.EQUALS; import static org.elasticsearch.xpack.ml.job.process.autodetect.writer.WriterConstants.NEW_LINE; -public class ModelDebugConfigWriter { +public class ModelPlotConfigWriter { private static final double BOUNDS_PERCENTILE_DEFAULT = 95.0; private static final double BOUNDS_PERCENTILE_DISABLE_VALUE = -1.0; - private final ModelDebugConfig modelDebugConfig; + private final ModelPlotConfig modelPlotConfig; private final Writer writer; - public ModelDebugConfigWriter(ModelDebugConfig modelDebugConfig, Writer writer) { - this.modelDebugConfig = Objects.requireNonNull(modelDebugConfig); + public ModelPlotConfigWriter(ModelPlotConfig modelPlotConfig, Writer writer) { + this.modelPlotConfig = Objects.requireNonNull(modelPlotConfig); this.writer = Objects.requireNonNull(writer); } @@ -32,11 +32,12 @@ public class ModelDebugConfigWriter { contents.append("boundspercentile") .append(EQUALS) - .append(modelDebugConfig.isEnabled() ? BOUNDS_PERCENTILE_DEFAULT : BOUNDS_PERCENTILE_DISABLE_VALUE) + .append(modelPlotConfig.isEnabled() ? + BOUNDS_PERCENTILE_DEFAULT : BOUNDS_PERCENTILE_DISABLE_VALUE) .append(NEW_LINE); - String terms = modelDebugConfig.getTerms(); - contents.append(ModelDebugConfig.TERMS_FIELD.getPreferredName()) + String terms = modelPlotConfig.getTerms(); + contents.append(ModelPlotConfig.TERMS_FIELD.getPreferredName()) .append(EQUALS) .append(terms == null ? "" : terms) .append(NEW_LINE); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java index 6c2f9dc06a7..5257b910f28 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java @@ -30,7 +30,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( TYPE.getPreferredName(), a -> new AutodetectResult((Bucket) a[0], (List) a[1], (List) a[2], (Quantiles) a[3], (ModelSnapshot) a[4], a[5] == null ? null : ((ModelSizeStats.Builder) a[5]).build(), - (ModelDebugOutput) a[6], (CategoryDefinition) a[7], (FlushAcknowledgement) a[8])); + (ModelPlot) a[6], (CategoryDefinition) a[7], (FlushAcknowledgement) a[8])); static { PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), Bucket.PARSER, Bucket.RESULT_TYPE_FIELD); @@ -40,7 +40,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelSnapshot.PARSER, ModelSnapshot.TYPE); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelSizeStats.PARSER, ModelSizeStats.RESULT_TYPE_FIELD); - PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelDebugOutput.PARSER, ModelDebugOutput.RESULTS_FIELD); + PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelPlot.PARSER, ModelPlot.RESULTS_FIELD); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), CategoryDefinition.PARSER, CategoryDefinition.TYPE); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), FlushAcknowledgement.PARSER, FlushAcknowledgement.TYPE); } @@ -51,12 +51,12 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { private final Quantiles quantiles; private final ModelSnapshot modelSnapshot; private final ModelSizeStats modelSizeStats; - private final ModelDebugOutput modelDebugOutput; + private final ModelPlot modelPlot; private final CategoryDefinition categoryDefinition; private final FlushAcknowledgement flushAcknowledgement; public AutodetectResult(Bucket bucket, List records, List influencers, Quantiles quantiles, - ModelSnapshot modelSnapshot, ModelSizeStats modelSizeStats, ModelDebugOutput modelDebugOutput, + ModelSnapshot modelSnapshot, ModelSizeStats modelSizeStats, ModelPlot modelPlot, CategoryDefinition categoryDefinition, FlushAcknowledgement flushAcknowledgement) { this.bucket = bucket; this.records = records; @@ -64,7 +64,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { this.quantiles = quantiles; this.modelSnapshot = modelSnapshot; this.modelSizeStats = modelSizeStats; - this.modelDebugOutput = modelDebugOutput; + this.modelPlot = modelPlot; this.categoryDefinition = categoryDefinition; this.flushAcknowledgement = flushAcknowledgement; } @@ -101,9 +101,9 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { this.modelSizeStats = null; } if (in.readBoolean()) { - this.modelDebugOutput = new ModelDebugOutput(in); + this.modelPlot = new ModelPlot(in); } else { - this.modelDebugOutput = null; + this.modelPlot = null; } if (in.readBoolean()) { this.categoryDefinition = new CategoryDefinition(in); @@ -125,7 +125,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { writeNullable(quantiles, out); writeNullable(modelSnapshot, out); writeNullable(modelSizeStats, out); - writeNullable(modelDebugOutput, out); + writeNullable(modelPlot, out); writeNullable(categoryDefinition, out); writeNullable(flushAcknowledgement, out); } @@ -155,7 +155,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { addNullableField(Quantiles.TYPE, quantiles, builder); addNullableField(ModelSnapshot.TYPE, modelSnapshot, builder); addNullableField(ModelSizeStats.RESULT_TYPE_FIELD, modelSizeStats, builder); - addNullableField(ModelDebugOutput.RESULTS_FIELD, modelDebugOutput, builder); + addNullableField(ModelPlot.RESULTS_FIELD, modelPlot, builder); addNullableField(CategoryDefinition.TYPE, categoryDefinition, builder); addNullableField(FlushAcknowledgement.TYPE, flushAcknowledgement, builder); builder.endObject(); @@ -198,8 +198,8 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { return modelSizeStats; } - public ModelDebugOutput getModelDebugOutput() { - return modelDebugOutput; + public ModelPlot getModelPlot() { + return modelPlot; } public CategoryDefinition getCategoryDefinition() { @@ -212,7 +212,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { @Override public int hashCode() { - return Objects.hash(bucket, records, influencers, categoryDefinition, flushAcknowledgement, modelDebugOutput, modelSizeStats, + return Objects.hash(bucket, records, influencers, categoryDefinition, flushAcknowledgement, modelPlot, modelSizeStats, modelSnapshot, quantiles); } @@ -230,7 +230,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable { Objects.equals(influencers, other.influencers) && Objects.equals(categoryDefinition, other.categoryDefinition) && Objects.equals(flushAcknowledgement, other.flushAcknowledgement) && - Objects.equals(modelDebugOutput, other.modelDebugOutput) && + Objects.equals(modelPlot, other.modelPlot) && Objects.equals(modelSizeStats, other.modelSizeStats) && Objects.equals(modelSnapshot, other.modelSnapshot) && Objects.equals(quantiles, other.quantiles); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ModelDebugOutput.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ModelPlot.java similarity index 67% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ModelDebugOutput.java rename to plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ModelPlot.java index e86fbbe59fb..c7d54c61c83 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ModelDebugOutput.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ModelPlot.java @@ -22,16 +22,13 @@ import java.util.Date; import java.util.Objects; /** - * Model Debug POJO. - * Some of the fields being with the word "debug". This avoids creation of - * reserved words that are likely to clash with fields in the input data (due to - * the restrictions on Elasticsearch mappings). + * Model Plot POJO. */ -public class ModelDebugOutput extends ToXContentToBytes implements Writeable { +public class ModelPlot extends ToXContentToBytes implements Writeable { /** * Result type */ - public static final String RESULT_TYPE_VALUE = "model_debug_output"; + public static final String RESULT_TYPE_VALUE = "model_plot"; public static final ParseField RESULTS_FIELD = new ParseField(RESULT_TYPE_VALUE); public static final ParseField PARTITION_FIELD_NAME = new ParseField("partition_field_name"); @@ -40,19 +37,19 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { public static final ParseField OVER_FIELD_VALUE = new ParseField("over_field_value"); public static final ParseField BY_FIELD_NAME = new ParseField("by_field_name"); public static final ParseField BY_FIELD_VALUE = new ParseField("by_field_value"); - public static final ParseField DEBUG_FEATURE = new ParseField("debug_feature"); - public static final ParseField DEBUG_LOWER = new ParseField("debug_lower"); - public static final ParseField DEBUG_UPPER = new ParseField("debug_upper"); - public static final ParseField DEBUG_MEDIAN = new ParseField("debug_median"); + public static final ParseField MODEL_FEATURE = new ParseField("model_feature"); + public static final ParseField MODEL_LOWER = new ParseField("model_lower"); + public static final ParseField MODEL_UPPER = new ParseField("model_upper"); + public static final ParseField MODEL_MEDIAN = new ParseField("model_median"); public static final ParseField ACTUAL = new ParseField("actual"); - public static final ConstructingObjectParser PARSER = - new ConstructingObjectParser<>(RESULT_TYPE_VALUE, a -> new ModelDebugOutput((String) a[0])); + public static final ConstructingObjectParser PARSER = + new ConstructingObjectParser<>(RESULT_TYPE_VALUE, a -> new ModelPlot((String) a[0])); static { PARSER.declareString(ConstructingObjectParser.constructorArg(), Job.ID); - PARSER.declareString((modelDebugOutput, s) -> {}, Result.RESULT_TYPE); - PARSER.declareField(ModelDebugOutput::setTimestamp, p -> { + PARSER.declareString((modelPlot, s) -> {}, Result.RESULT_TYPE); + PARSER.declareField(ModelPlot::setTimestamp, p -> { if (p.currentToken() == Token.VALUE_NUMBER) { return new Date(p.longValue()); } else if (p.currentToken() == Token.VALUE_STRING) { @@ -61,17 +58,17 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for [" + Result.TIMESTAMP.getPreferredName() + "]"); }, Result.TIMESTAMP, ValueType.VALUE); - PARSER.declareString(ModelDebugOutput::setPartitionFieldName, PARTITION_FIELD_NAME); - PARSER.declareString(ModelDebugOutput::setPartitionFieldValue, PARTITION_FIELD_VALUE); - PARSER.declareString(ModelDebugOutput::setOverFieldName, OVER_FIELD_NAME); - PARSER.declareString(ModelDebugOutput::setOverFieldValue, OVER_FIELD_VALUE); - PARSER.declareString(ModelDebugOutput::setByFieldName, BY_FIELD_NAME); - PARSER.declareString(ModelDebugOutput::setByFieldValue, BY_FIELD_VALUE); - PARSER.declareString(ModelDebugOutput::setDebugFeature, DEBUG_FEATURE); - PARSER.declareDouble(ModelDebugOutput::setDebugLower, DEBUG_LOWER); - PARSER.declareDouble(ModelDebugOutput::setDebugUpper, DEBUG_UPPER); - PARSER.declareDouble(ModelDebugOutput::setDebugMedian, DEBUG_MEDIAN); - PARSER.declareDouble(ModelDebugOutput::setActual, ACTUAL); + PARSER.declareString(ModelPlot::setPartitionFieldName, PARTITION_FIELD_NAME); + PARSER.declareString(ModelPlot::setPartitionFieldValue, PARTITION_FIELD_VALUE); + PARSER.declareString(ModelPlot::setOverFieldName, OVER_FIELD_NAME); + PARSER.declareString(ModelPlot::setOverFieldValue, OVER_FIELD_VALUE); + PARSER.declareString(ModelPlot::setByFieldName, BY_FIELD_NAME); + PARSER.declareString(ModelPlot::setByFieldValue, BY_FIELD_VALUE); + PARSER.declareString(ModelPlot::setModelFeature, MODEL_FEATURE); + PARSER.declareDouble(ModelPlot::setModelLower, MODEL_LOWER); + PARSER.declareDouble(ModelPlot::setModelUpper, MODEL_UPPER); + PARSER.declareDouble(ModelPlot::setModelMedian, MODEL_MEDIAN); + PARSER.declareDouble(ModelPlot::setActual, ACTUAL); } private final String jobId; @@ -83,17 +80,17 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { private String overFieldValue; private String byFieldName; private String byFieldValue; - private String debugFeature; - private double debugLower; - private double debugUpper; - private double debugMedian; + private String modelFeature; + private double modelLower; + private double modelUpper; + private double modelMedian; private double actual; - public ModelDebugOutput(String jobId) { + public ModelPlot(String jobId) { this.jobId = jobId; } - public ModelDebugOutput(StreamInput in) throws IOException { + public ModelPlot(StreamInput in) throws IOException { jobId = in.readString(); if (in.readBoolean()) { timestamp = new Date(in.readLong()); @@ -105,10 +102,10 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { overFieldValue = in.readOptionalString(); byFieldName = in.readOptionalString(); byFieldValue = in.readOptionalString(); - debugFeature = in.readOptionalString(); - debugLower = in.readDouble(); - debugUpper = in.readDouble(); - debugMedian = in.readDouble(); + modelFeature = in.readOptionalString(); + modelLower = in.readDouble(); + modelUpper = in.readDouble(); + modelMedian = in.readDouble(); actual = in.readDouble(); } @@ -127,10 +124,10 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { out.writeOptionalString(overFieldValue); out.writeOptionalString(byFieldName); out.writeOptionalString(byFieldValue); - out.writeOptionalString(debugFeature); - out.writeDouble(debugLower); - out.writeDouble(debugUpper); - out.writeDouble(debugMedian); + out.writeOptionalString(modelFeature); + out.writeDouble(modelLower); + out.writeDouble(modelUpper); + out.writeDouble(modelMedian); out.writeDouble(actual); } @@ -140,7 +137,8 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { builder.field(Job.ID.getPreferredName(), jobId); builder.field(Result.RESULT_TYPE.getPreferredName(), RESULT_TYPE_VALUE); if (timestamp != null) { - builder.dateField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); + builder.dateField(Result.TIMESTAMP.getPreferredName(), + Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); } if (partitionFieldName != null) { builder.field(PARTITION_FIELD_NAME.getPreferredName(), partitionFieldName); @@ -160,12 +158,12 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { if (byFieldValue != null) { builder.field(BY_FIELD_VALUE.getPreferredName(), byFieldValue); } - if (debugFeature != null) { - builder.field(DEBUG_FEATURE.getPreferredName(), debugFeature); + if (modelFeature != null) { + builder.field(MODEL_FEATURE.getPreferredName(), modelFeature); } - builder.field(DEBUG_LOWER.getPreferredName(), debugLower); - builder.field(DEBUG_UPPER.getPreferredName(), debugUpper); - builder.field(DEBUG_MEDIAN.getPreferredName(), debugMedian); + builder.field(MODEL_LOWER.getPreferredName(), modelLower); + builder.field(MODEL_UPPER.getPreferredName(), modelUpper); + builder.field(MODEL_MEDIAN.getPreferredName(), modelMedian); builder.field(ACTUAL.getPreferredName(), actual); builder.endObject(); return builder; @@ -239,36 +237,36 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { this.byFieldValue = byFieldValue; } - public String getDebugFeature() { - return debugFeature; + public String getModelFeature() { + return modelFeature; } - public void setDebugFeature(String debugFeature) { - this.debugFeature = debugFeature; + public void setModelFeature(String modelFeature) { + this.modelFeature = modelFeature; } - public double getDebugLower() { - return debugLower; + public double getModelLower() { + return modelLower; } - public void setDebugLower(double debugLower) { - this.debugLower = debugLower; + public void setModelLower(double modelLower) { + this.modelLower = modelLower; } - public double getDebugUpper() { - return debugUpper; + public double getModelUpper() { + return modelUpper; } - public void setDebugUpper(double debugUpper) { - this.debugUpper = debugUpper; + public void setModelUpper(double modelUpper) { + this.modelUpper = modelUpper; } - public double getDebugMedian() { - return debugMedian; + public double getModelMedian() { + return modelMedian; } - public void setDebugMedian(double debugMedian) { - this.debugMedian = debugMedian; + public void setModelMedian(double modelMedian) { + this.modelMedian = modelMedian; } public double getActual() { @@ -284,11 +282,11 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { if (this == other) { return true; } - if (other instanceof ModelDebugOutput == false) { + if (other instanceof ModelPlot == false) { return false; } // id excluded here as it is generated by the datastore - ModelDebugOutput that = (ModelDebugOutput) other; + ModelPlot that = (ModelPlot) other; return Objects.equals(this.jobId, that.jobId) && Objects.equals(this.timestamp, that.timestamp) && Objects.equals(this.partitionFieldValue, that.partitionFieldValue) && @@ -297,10 +295,10 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { Objects.equals(this.overFieldName, that.overFieldName) && Objects.equals(this.byFieldValue, that.byFieldValue) && Objects.equals(this.byFieldName, that.byFieldName) && - Objects.equals(this.debugFeature, that.debugFeature) && - this.debugLower == that.debugLower && - this.debugUpper == that.debugUpper && - this.debugMedian == that.debugMedian && + Objects.equals(this.modelFeature, that.modelFeature) && + this.modelLower == that.modelLower && + this.modelUpper == that.modelUpper && + this.modelMedian == that.modelMedian && this.actual == that.actual; } @@ -309,6 +307,6 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable { // id excluded here as it is generated by the datastore return Objects.hash(jobId, timestamp, partitionFieldName, partitionFieldValue, overFieldName, overFieldValue, byFieldName, byFieldValue, - debugFeature, debugLower, debugUpper, debugMedian, actual); + modelFeature, modelLower, modelUpper, modelMedian, actual); } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNames.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNames.java index 8a1decbf16c..d9b6886482f 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNames.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNames.java @@ -126,12 +126,12 @@ public final class ReservedFieldNames { Influencer.BUCKET_SPAN.getPreferredName(), Influencer.SEQUENCE_NUM.getPreferredName(), - ModelDebugOutput.PARTITION_FIELD_NAME.getPreferredName(), ModelDebugOutput.PARTITION_FIELD_VALUE.getPreferredName(), - ModelDebugOutput.OVER_FIELD_NAME.getPreferredName(), ModelDebugOutput.OVER_FIELD_VALUE.getPreferredName(), - ModelDebugOutput.BY_FIELD_NAME.getPreferredName(), ModelDebugOutput.BY_FIELD_VALUE.getPreferredName(), - ModelDebugOutput.DEBUG_FEATURE.getPreferredName(), ModelDebugOutput.DEBUG_LOWER.getPreferredName(), - ModelDebugOutput.DEBUG_UPPER.getPreferredName(), ModelDebugOutput.DEBUG_MEDIAN.getPreferredName(), - ModelDebugOutput.ACTUAL.getPreferredName(), + ModelPlot.PARTITION_FIELD_NAME.getPreferredName(), ModelPlot.PARTITION_FIELD_VALUE.getPreferredName(), + ModelPlot.OVER_FIELD_NAME.getPreferredName(), ModelPlot.OVER_FIELD_VALUE.getPreferredName(), + ModelPlot.BY_FIELD_NAME.getPreferredName(), ModelPlot.BY_FIELD_VALUE.getPreferredName(), + ModelPlot.MODEL_FEATURE.getPreferredName(), ModelPlot.MODEL_LOWER.getPreferredName(), + ModelPlot.MODEL_UPPER.getPreferredName(), ModelPlot.MODEL_MEDIAN.getPreferredName(), + ModelPlot.ACTUAL.getPreferredName(), ModelSizeStats.MODEL_BYTES_FIELD.getPreferredName(), ModelSizeStats.TOTAL_BY_FIELD_COUNT_FIELD.getPreferredName(), diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java index 5277684d8d5..62001a78b7d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java @@ -6,7 +6,7 @@ package org.elasticsearch.xpack.ml.action; import org.elasticsearch.xpack.ml.job.config.JobUpdate; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase; import java.util.List; @@ -16,9 +16,9 @@ public class UpdateProcessActionRequestTests extends AbstractStreamableTestCase< @Override protected UpdateProcessAction.Request createTestInstance() { - ModelDebugConfig config = null; + ModelPlotConfig config = null; if (randomBoolean()) { - config = new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10)); + config = new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10)); } List updates = null; if (randomBoolean()) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java index 760fe5525b4..dd6c7e6aa41 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java @@ -37,8 +37,8 @@ import org.elasticsearch.xpack.ml.job.results.BucketTests; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.CategoryDefinitionTests; import org.elasticsearch.xpack.ml.job.results.Influencer; -import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; -import org.elasticsearch.xpack.ml.job.results.ModelDebugOutputTests; +import org.elasticsearch.xpack.ml.job.results.ModelPlot; +import org.elasticsearch.xpack.ml.job.results.ModelPlotTests; import org.junit.Before; import java.util.ArrayList; @@ -98,8 +98,8 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase { builder.addInfluencers(influencers); CategoryDefinition categoryDefinition = createCategoryDefinition(); builder.addCategoryDefinition(categoryDefinition); - ModelDebugOutput modelDebugOutput = createModelDebugOutput(); - builder.addModelDebugOutput(modelDebugOutput); + ModelPlot modelPlot = createmodelPlot(); + builder.addmodelPlot(modelPlot); ModelSizeStats modelSizeStats = createModelSizeStats(); builder.addModelSizeStats(modelSizeStats); ModelSnapshot modelSnapshot = createModelSnapshot(); @@ -129,9 +129,9 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase { assertEquals(1, persistedDefinition.count()); assertEquals(categoryDefinition, persistedDefinition.results().get(0)); - QueryPage persistedModelDebugOutput = jobProvider.modelDebugOutput(JOB_ID, 0, 100); - assertEquals(1, persistedModelDebugOutput.count()); - assertEquals(modelDebugOutput, persistedModelDebugOutput.results().get(0)); + QueryPage persistedmodelPlot = jobProvider.modelPlot(JOB_ID, 0, 100); + assertEquals(1, persistedmodelPlot.count()); + assertEquals(modelPlot, persistedmodelPlot.results().get(0)); ModelSizeStats persistedModelSizeStats = getModelSizeStats(); assertEquals(modelSizeStats, persistedModelSizeStats); @@ -286,8 +286,8 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase { return new CategoryDefinitionTests().createTestInstance(JOB_ID); } - private ModelDebugOutput createModelDebugOutput() { - return new ModelDebugOutputTests().createTestInstance(JOB_ID); + private ModelPlot createmodelPlot() { + return new ModelPlotTests().createTestInstance(JOB_ID); } private ModelSizeStats createModelSizeStats() { @@ -343,8 +343,8 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase { return this; } - ResultsBuilder addModelDebugOutput(ModelDebugOutput modelDebugOutput) { - results.add(new AutodetectResult(null, null, null, null, null, null, modelDebugOutput, null, null)); + ResultsBuilder addmodelPlot(ModelPlot modelPlot) { + results.add(new AutodetectResult(null, null, null, null, null, null, modelPlot, null, null)); return this; } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java index 1c915cdb8fe..36b87a9137e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java @@ -52,7 +52,7 @@ public class JobTests extends AbstractSerializingTestCase { assertNull(job.getDescription()); assertNull(job.getFinishedTime()); assertNull(job.getLastDataTime()); - assertNull(job.getModelDebugConfig()); + assertNull(job.getModelPlotConfig()); assertNull(job.getRenormalizationWindowDays()); assertNull(job.getBackgroundPersistInterval()); assertThat(job.getModelSnapshotRetentionDays(), equalTo(1L)); @@ -392,7 +392,7 @@ public class JobTests extends AbstractSerializingTestCase { builder.setDataDescription(dataDescription); } if (randomBoolean()) { - builder.setModelDebugConfig(new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10))); + builder.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10))); } if (randomBoolean()) { builder.setRenormalizationWindowDays(randomNonNegativeLong()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java index a4e0a3c9e20..dfbd2a3c7a1 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java @@ -48,7 +48,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { update.setDetectorUpdates(detectorUpdates); } if (randomBoolean()) { - update.setModelDebugConfig(new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10))); + update.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10))); } if (randomBoolean()) { update.setAnalysisLimits(new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong())); @@ -99,7 +99,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, new Condition(Operator.GT, "5"), null)))); detectorUpdates.add(new JobUpdate.DetectorUpdate(1, "description-2", detectionRules2)); - ModelDebugConfig modelDebugConfig = new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10)); + ModelPlotConfig modelPlotConfig = new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10)); AnalysisLimits analysisLimits = new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong()); List categorizationFilters = Arrays.asList(generateRandomStringArray(10, 10, false)); Map customSettings = Collections.singletonMap(randomAsciiOfLength(10), randomAsciiOfLength(10)); @@ -107,7 +107,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { JobUpdate.Builder updateBuilder = new JobUpdate.Builder(); updateBuilder.setDescription("updated_description"); updateBuilder.setDetectorUpdates(detectorUpdates); - updateBuilder.setModelDebugConfig(modelDebugConfig); + updateBuilder.setModelPlotConfig(modelPlotConfig); updateBuilder.setAnalysisLimits(analysisLimits); updateBuilder.setBackgroundPersistInterval(TimeValue.timeValueHours(randomIntBetween(1, 24))); updateBuilder.setResultsRetentionDays(randomNonNegativeLong()); @@ -131,7 +131,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { Job updatedJob = update.mergeWithJob(jobBuilder.build()); assertEquals(update.getDescription(), updatedJob.getDescription()); - assertEquals(update.getModelDebugConfig(), updatedJob.getModelDebugConfig()); + assertEquals(update.getModelPlotConfig(), updatedJob.getModelPlotConfig()); assertEquals(update.getAnalysisLimits(), updatedJob.getAnalysisLimits()); assertEquals(update.getRenormalizationWindowDays(), updatedJob.getRenormalizationWindowDays()); assertEquals(update.getBackgroundPersistInterval(), updatedJob.getBackgroundPersistInterval()); @@ -153,7 +153,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase { public void testIsAutodetectProcessUpdate() { JobUpdate update = new JobUpdate.Builder().build(); assertFalse(update.isAutodetectProcessUpdate()); - update = new JobUpdate.Builder().setModelDebugConfig(new ModelDebugConfig(true, "ff")).build(); + update = new JobUpdate.Builder().setModelPlotConfig(new ModelPlotConfig(true, "ff")).build(); assertTrue(update.isAutodetectProcessUpdate()); update = new JobUpdate.Builder().setDetectorUpdates(Arrays.asList(mock(JobUpdate.DetectorUpdate.class))).build(); assertTrue(update.isAutodetectProcessUpdate()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelDebugConfigTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java similarity index 53% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelDebugConfigTests.java rename to plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java index 7207bc669ff..8e91717a8d9 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelDebugConfigTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java @@ -12,25 +12,25 @@ import org.elasticsearch.xpack.ml.support.AbstractSerializingTestCase; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -public class ModelDebugConfigTests extends AbstractSerializingTestCase { +public class ModelPlotConfigTests extends AbstractSerializingTestCase { public void testConstructorDefaults() { - assertThat(new ModelDebugConfig().isEnabled(), is(true)); - assertThat(new ModelDebugConfig().getTerms(), is(nullValue())); + assertThat(new ModelPlotConfig().isEnabled(), is(true)); + assertThat(new ModelPlotConfig().getTerms(), is(nullValue())); } @Override - protected ModelDebugConfig createTestInstance() { - return new ModelDebugConfig(randomBoolean(), randomAsciiOfLengthBetween(1, 30)); + protected ModelPlotConfig createTestInstance() { + return new ModelPlotConfig(randomBoolean(), randomAsciiOfLengthBetween(1, 30)); } @Override - protected Reader instanceReader() { - return ModelDebugConfig::new; + protected Reader instanceReader() { + return ModelPlotConfig::new; } @Override - protected ModelDebugConfig parseInstance(XContentParser parser) { - return ModelDebugConfig.PARSER.apply(parser, null); + protected ModelPlotConfig parseInstance(XContentParser parser) { + return ModelPlotConfig.PARSER.apply(parser, null); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java index d5ad8ab6d1c..8eef16cdb8f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.xpack.ml.job.config.DataDescription; import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Job; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.DataCountsReporter; import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutoDetectResultProcessor; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; @@ -53,12 +53,12 @@ public class AutodetectCommunicatorTests extends ESTestCase { } } - public void tesWriteUpdateModelDebugMessage() throws IOException { + public void tesWriteUpdateModelPlotMessage() throws IOException { AutodetectProcess process = mockAutodetectProcessWithOutputStream(); try (AutodetectCommunicator communicator = createAutodetectCommunicator(process, mock(AutoDetectResultProcessor.class))) { - ModelDebugConfig config = new ModelDebugConfig(); - communicator.writeUpdateModelDebugMessage(config); - Mockito.verify(process).writeUpdateModelDebugMessage(config); + ModelPlotConfig config = new ModelPlotConfig(); + communicator.writeUpdateModelPlotMessage(config); + Mockito.verify(process).writeUpdateModelPlotMessage(config); } } @@ -195,16 +195,16 @@ public class AutodetectCommunicatorTests extends ESTestCase { communicator.close(); } - public void testWriteUpdateModelDebugConfigMessageInUse() throws Exception { + public void testWriteUpdateModelPlotConfigMessageInUse() throws Exception { AutodetectProcess process = mockAutodetectProcessWithOutputStream(); AutoDetectResultProcessor resultProcessor = mock(AutoDetectResultProcessor.class); AutodetectCommunicator communicator = createAutodetectCommunicator(process, resultProcessor); communicator.inUse.set(new CountDownLatch(1)); - expectThrows(ElasticsearchStatusException.class, () -> communicator.writeUpdateModelDebugMessage(mock(ModelDebugConfig.class))); + expectThrows(ElasticsearchStatusException.class, () -> communicator.writeUpdateModelPlotMessage(mock(ModelPlotConfig.class))); communicator.inUse.set(null); - communicator.writeUpdateModelDebugMessage(mock(ModelDebugConfig.class)); + communicator.writeUpdateModelPlotMessage(mock(ModelPlotConfig.class)); } public void testWriteUpdateDetectorRulesMessageInUse() throws Exception { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java index 0cce2f7e5fc..031f4a188c3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java @@ -23,7 +23,7 @@ import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.MlFilter; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister; @@ -272,11 +272,11 @@ public class AutodetectProcessManagerTests extends ESTestCase { public void testwriteUpdateProcessMessage() throws IOException { AutodetectCommunicator communicator = mock(AutodetectCommunicator.class); AutodetectProcessManager manager = createManagerAndCallProcessData(communicator, "foo"); - ModelDebugConfig debugConfig = mock(ModelDebugConfig.class); + ModelPlotConfig modelConfig = mock(ModelPlotConfig.class); List rules = Collections.singletonList(mock(DetectionRule.class)); List detectorUpdates = Collections.singletonList(new JobUpdate.DetectorUpdate(2, null, rules)); - manager.writeUpdateProcessMessage("foo", detectorUpdates, debugConfig); - verify(communicator).writeUpdateModelDebugMessage(debugConfig); + manager.writeUpdateProcessMessage("foo", detectorUpdates, modelConfig); + verify(communicator).writeUpdateModelPlotMessage(modelConfig); verify(communicator).writeUpdateDetectorRulesMessage(2, rules); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java index 09fb52d91c9..6e7442400cc 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutodetectResultsParser; import org.elasticsearch.xpack.ml.job.process.autodetect.output.StateProcessor; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; @@ -145,7 +145,7 @@ public class NativeAutodetectProcessTests extends ESTestCase { new AutodetectResultsParser(Settings.EMPTY))) { process.start(executorService, mock(StateProcessor.class), mock(InputStream.class)); - process.writeUpdateModelDebugMessage(new ModelDebugConfig()); + process.writeUpdateModelPlotMessage(new ModelPlotConfig()); process.flushStream(); String message = new String(bos.toByteArray(), StandardCharsets.UTF_8); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java index 05dc0da7d3c..ccb143168d9 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java @@ -20,7 +20,7 @@ import org.elasticsearch.xpack.ml.job.results.AutodetectResult; import org.elasticsearch.xpack.ml.job.results.Bucket; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.Influencer; -import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; +import org.elasticsearch.xpack.ml.job.results.ModelPlot; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.junit.Before; import org.mockito.InOrder; @@ -227,17 +227,17 @@ public class AutoDetectResultProcessorTests extends ESTestCase { assertTrue(context.deleteInterimRequired); } - public void testProcessResult_modelDebugOutput() { + public void testProcessResult_modelPlot() { JobResultsPersister.Builder bulkBuilder = mock(JobResultsPersister.Builder.class); AutoDetectResultProcessor.Context context = new AutoDetectResultProcessor.Context(JOB_ID, false, bulkBuilder); context.deleteInterimRequired = false; AutodetectResult result = mock(AutodetectResult.class); - ModelDebugOutput modelDebugOutput = mock(ModelDebugOutput.class); - when(result.getModelDebugOutput()).thenReturn(modelDebugOutput); + ModelPlot modelPlot = mock(ModelPlot.class); + when(result.getModelPlot()).thenReturn(modelPlot); processorUnderTest.processResult(context, result); - verify(persister, times(1)).persistModelDebugOutput(modelDebugOutput); + verify(persister, times(1)).persistModelPlot(modelPlot); verifyNoMoreInteractions(persister); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java index cee1763ecd4..9c599ea178e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java @@ -20,7 +20,7 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.ml.job.config.Condition; import org.elasticsearch.xpack.ml.job.config.Connective; import org.elasticsearch.xpack.ml.job.config.DetectionRule; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.elasticsearch.xpack.ml.job.config.Operator; import org.elasticsearch.xpack.ml.job.config.RuleCondition; import org.elasticsearch.xpack.ml.job.config.RuleConditionType; @@ -148,15 +148,15 @@ public class ControlMsgToProcessWriterTests extends ESTestCase { verifyNoMoreInteractions(lengthEncodedWriter); } - public void testWriteUpdateModelDebugMessage() throws IOException { + public void testWriteUpdateModelPlotMessage() throws IOException { ControlMsgToProcessWriter writer = new ControlMsgToProcessWriter(lengthEncodedWriter, 2); - writer.writeUpdateModelDebugMessage(new ModelDebugConfig(true, "foo,bar")); + writer.writeUpdateModelPlotMessage(new ModelPlotConfig(true, "foo,bar")); InOrder inOrder = inOrder(lengthEncodedWriter); inOrder.verify(lengthEncodedWriter).writeNumFields(4); inOrder.verify(lengthEncodedWriter, times(3)).writeField(""); - inOrder.verify(lengthEncodedWriter).writeField("u[modelDebugConfig]\nboundspercentile = 95.0\nterms = foo,bar\n"); + inOrder.verify(lengthEncodedWriter).writeField("u[modelPlotConfig]\nboundspercentile = 95.0\nterms = foo,bar\n"); verifyNoMoreInteractions(lengthEncodedWriter); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelDebugConfigWriterTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java similarity index 68% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelDebugConfigWriterTests.java rename to plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java index 2ce7ca8c9c9..a67c79f9a67 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelDebugConfigWriterTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java @@ -6,7 +6,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect.writer; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; +import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; import org.junit.After; import org.junit.Before; import org.mockito.Mockito; @@ -17,7 +17,7 @@ import java.io.OutputStreamWriter; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -public class ModelDebugConfigWriterTests extends ESTestCase { +public class ModelPlotConfigWriterTests extends ESTestCase { private OutputStreamWriter writer; @Before @@ -31,8 +31,8 @@ public class ModelDebugConfigWriterTests extends ESTestCase { } public void testWrite_GivenEnabledConfigWithoutTerms() throws IOException { - ModelDebugConfig modelDebugConfig = new ModelDebugConfig(); - ModelDebugConfigWriter writer = new ModelDebugConfigWriter(modelDebugConfig, this.writer); + ModelPlotConfig modelPlotConfig = new ModelPlotConfig(); + ModelPlotConfigWriter writer = new ModelPlotConfigWriter(modelPlotConfig, this.writer); writer.write(); @@ -40,8 +40,8 @@ public class ModelDebugConfigWriterTests extends ESTestCase { } public void testWrite_GivenEnabledConfigWithTerms() throws IOException { - ModelDebugConfig modelDebugConfig = new ModelDebugConfig(true, "foo,bar"); - ModelDebugConfigWriter writer = new ModelDebugConfigWriter(modelDebugConfig, this.writer); + ModelPlotConfig modelPlotConfig = new ModelPlotConfig(true, "foo,bar"); + ModelPlotConfigWriter writer = new ModelPlotConfigWriter(modelPlotConfig, this.writer); writer.write(); @@ -49,8 +49,8 @@ public class ModelDebugConfigWriterTests extends ESTestCase { } public void testWrite_GivenDisabledConfigWithTerms() throws IOException { - ModelDebugConfig modelDebugConfig = new ModelDebugConfig(false, "foo,bar"); - ModelDebugConfigWriter writer = new ModelDebugConfigWriter(modelDebugConfig, this.writer); + ModelPlotConfig modelPlotConfig = new ModelPlotConfig(false, "foo,bar"); + ModelPlotConfigWriter writer = new ModelPlotConfigWriter(modelPlotConfig, this.writer); writer.write(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java index 5bbe59a2f14..3e8b87ee2dd 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java @@ -32,7 +32,7 @@ public class AutodetectResultTests extends AbstractSerializingTestCase { - - @Override - protected ModelDebugOutput createTestInstance() { - return createTestInstance("foo"); - } - - public ModelDebugOutput createTestInstance(String jobId) { - ModelDebugOutput modelDebugOutput = new ModelDebugOutput(jobId); - if (randomBoolean()) { - modelDebugOutput.setByFieldName(randomAsciiOfLengthBetween(1, 20)); - } - if (randomBoolean()) { - modelDebugOutput.setByFieldValue(randomAsciiOfLengthBetween(1, 20)); - } - if (randomBoolean()) { - modelDebugOutput.setPartitionFieldName(randomAsciiOfLengthBetween(1, 20)); - } - if (randomBoolean()) { - modelDebugOutput.setPartitionFieldValue(randomAsciiOfLengthBetween(1, 20)); - } - if (randomBoolean()) { - modelDebugOutput.setDebugFeature(randomAsciiOfLengthBetween(1, 20)); - } - if (randomBoolean()) { - modelDebugOutput.setDebugLower(randomDouble()); - } - if (randomBoolean()) { - modelDebugOutput.setDebugUpper(randomDouble()); - } - if (randomBoolean()) { - modelDebugOutput.setDebugMedian(randomDouble()); - } - if (randomBoolean()) { - modelDebugOutput.setActual(randomDouble()); - } - if (randomBoolean()) { - modelDebugOutput.setTimestamp(new Date(randomLong())); - } - return modelDebugOutput; - } - - @Override - protected Reader instanceReader() { - return ModelDebugOutput::new; - } - - @Override - protected ModelDebugOutput parseInstance(XContentParser parser) { - return ModelDebugOutput.PARSER.apply(parser, null); - } - - public void testEquals_GivenSameObject() { - ModelDebugOutput modelDebugOutput = new ModelDebugOutput(randomAsciiOfLength(15)); - - assertTrue(modelDebugOutput.equals(modelDebugOutput)); - } - - public void testEquals_GivenObjectOfDifferentClass() { - ModelDebugOutput modelDebugOutput = new ModelDebugOutput(randomAsciiOfLength(15)); - - assertFalse(modelDebugOutput.equals("a string")); - } - - public void testEquals_GivenDifferentTimestamp() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setTimestamp(new Date(0L)); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentPartitionFieldName() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setPartitionFieldName("another"); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentPartitionFieldValue() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setPartitionFieldValue("another"); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentByFieldName() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setByFieldName("another"); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentByFieldValue() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setByFieldValue("another"); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentOverFieldName() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setOverFieldName("another"); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentOverFieldValue() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setOverFieldValue("another"); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentDebugFeature() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setDebugFeature("another"); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentDebugLower() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setDebugLower(-1.0); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentDebugUpper() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setDebugUpper(-1.0); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentDebugMean() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setDebugMedian(-1.0); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenDifferentActual() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - modelDebugOutput2.setActual(-1.0); - - assertFalse(modelDebugOutput1.equals(modelDebugOutput2)); - assertFalse(modelDebugOutput2.equals(modelDebugOutput1)); - } - - public void testEquals_GivenEqualModelDebugOutputs() { - ModelDebugOutput modelDebugOutput1 = createFullyPopulated(); - ModelDebugOutput modelDebugOutput2 = createFullyPopulated(); - - assertTrue(modelDebugOutput1.equals(modelDebugOutput2)); - assertTrue(modelDebugOutput2.equals(modelDebugOutput1)); - assertEquals(modelDebugOutput1.hashCode(), modelDebugOutput2.hashCode()); - } - - private ModelDebugOutput createFullyPopulated() { - ModelDebugOutput modelDebugOutput = new ModelDebugOutput("foo"); - modelDebugOutput.setByFieldName("by"); - modelDebugOutput.setByFieldValue("by_val"); - modelDebugOutput.setPartitionFieldName("part"); - modelDebugOutput.setPartitionFieldValue("part_val"); - modelDebugOutput.setDebugFeature("sum"); - modelDebugOutput.setDebugLower(7.9); - modelDebugOutput.setDebugUpper(34.5); - modelDebugOutput.setDebugMedian(12.7); - modelDebugOutput.setActual(100.0); - modelDebugOutput.setTimestamp(new Date(12345678L)); - return modelDebugOutput; - } - -} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java new file mode 100644 index 00000000000..6828854a584 --- /dev/null +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java @@ -0,0 +1,210 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.ml.job.results; + +import org.elasticsearch.common.io.stream.Writeable.Reader; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.xpack.ml.support.AbstractSerializingTestCase; + +import java.util.Date; + +public class ModelPlotTests extends AbstractSerializingTestCase { + + @Override + protected ModelPlot createTestInstance() { + return createTestInstance("foo"); + } + + public ModelPlot createTestInstance(String jobId) { + ModelPlot modelPlot = new ModelPlot(jobId); + if (randomBoolean()) { + modelPlot.setByFieldName(randomAsciiOfLengthBetween(1, 20)); + } + if (randomBoolean()) { + modelPlot.setByFieldValue(randomAsciiOfLengthBetween(1, 20)); + } + if (randomBoolean()) { + modelPlot.setPartitionFieldName(randomAsciiOfLengthBetween(1, 20)); + } + if (randomBoolean()) { + modelPlot.setPartitionFieldValue(randomAsciiOfLengthBetween(1, 20)); + } + if (randomBoolean()) { + modelPlot.setModelFeature(randomAsciiOfLengthBetween(1, 20)); + } + if (randomBoolean()) { + modelPlot.setModelLower(randomDouble()); + } + if (randomBoolean()) { + modelPlot.setModelUpper(randomDouble()); + } + if (randomBoolean()) { + modelPlot.setModelMedian(randomDouble()); + } + if (randomBoolean()) { + modelPlot.setActual(randomDouble()); + } + if (randomBoolean()) { + modelPlot.setTimestamp(new Date(randomLong())); + } + return modelPlot; + } + + @Override + protected Reader instanceReader() { + return ModelPlot::new; + } + + @Override + protected ModelPlot parseInstance(XContentParser parser) { + return ModelPlot.PARSER.apply(parser, null); + } + + public void testEquals_GivenSameObject() { + ModelPlot modelPlot = new ModelPlot(randomAsciiOfLength(15)); + + assertTrue(modelPlot.equals(modelPlot)); + } + + public void testEquals_GivenObjectOfDifferentClass() { + ModelPlot modelPlot = new ModelPlot(randomAsciiOfLength(15)); + + assertFalse(modelPlot.equals("a string")); + } + + public void testEquals_GivenDifferentTimestamp() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setTimestamp(new Date(0L)); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentPartitionFieldName() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setPartitionFieldName("another"); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentPartitionFieldValue() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setPartitionFieldValue("another"); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentByFieldName() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setByFieldName("another"); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentByFieldValue() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setByFieldValue("another"); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentOverFieldName() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setOverFieldName("another"); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentOverFieldValue() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setOverFieldValue("another"); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentModelFeature() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setModelFeature("another"); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentModelLower() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setModelLower(-1.0); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentModelUpper() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setModelUpper(-1.0); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentModelMean() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setModelMedian(-1.0); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenDifferentActual() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + modelPlot2.setActual(-1.0); + + assertFalse(modelPlot1.equals(modelPlot2)); + assertFalse(modelPlot2.equals(modelPlot1)); + } + + public void testEquals_GivenEqualmodelPlots() { + ModelPlot modelPlot1 = createFullyPopulated(); + ModelPlot modelPlot2 = createFullyPopulated(); + + assertTrue(modelPlot1.equals(modelPlot2)); + assertTrue(modelPlot2.equals(modelPlot1)); + assertEquals(modelPlot1.hashCode(), modelPlot2.hashCode()); + } + + private ModelPlot createFullyPopulated() { + ModelPlot modelPlot = new ModelPlot("foo"); + modelPlot.setByFieldName("by"); + modelPlot.setByFieldValue("by_val"); + modelPlot.setPartitionFieldName("part"); + modelPlot.setPartitionFieldValue("part_val"); + modelPlot.setModelFeature("sum"); + modelPlot.setModelLower(7.9); + modelPlot.setModelUpper(34.5); + modelPlot.setModelMedian(12.7); + modelPlot.setActual(100.0); + modelPlot.setTimestamp(new Date(12345678L)); + return modelPlot; + } + +} diff --git a/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yaml b/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yaml index 2c134580c8b..c01e07e5c65 100644 --- a/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yaml +++ b/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yaml @@ -189,7 +189,7 @@ "data_description" : { "field_delimiter":"," }, - "model_debug_config": { + "model_plot_config": { "enabled": true, "terms": "foo,bar" }, @@ -221,7 +221,7 @@ "rule_conditions": [ { "condition_type": "numerical_actual", "condition": {"operator": "gt", "value": "10" } } ] } }, {"index": 1, "description": "updated description"}], - "model_debug_config": { + "model_plot_config": { "enabled": false, "terms": "foobar" }, @@ -239,8 +239,8 @@ } - match: { job_id: "to-update" } - match: { description: "Post update description" } - - match: { model_debug_config.enabled: false } - - match: { model_debug_config.terms: "foobar" } + - match: { model_plot_config.enabled: false } + - match: { model_plot_config.terms: "foobar" } - match: { analysis_limits.model_memory_limit: 20 } - match: { analysis_config.categorization_filters: ["cat3.*"] } - match: { analysis_config.detectors.0.detector_rules.0.target_field_name: "airline" }