[ML] Log deprecation warning for jobs with delimited formats (elastic/x-pack-elasticsearch#3092)

Original commit: elastic/x-pack-elasticsearch@bd75fae990
This commit is contained in:
David Kyle 2017-11-22 11:53:08 +00:00 committed by GitHub
parent 74beb9ca64
commit 0dea758022
2 changed files with 35 additions and 0 deletions

View File

@ -17,6 +17,8 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.CheckedConsumer;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.ToXContent;
@ -28,6 +30,7 @@ import org.elasticsearch.xpack.ml.action.DeleteJobAction;
import org.elasticsearch.xpack.ml.action.PutJobAction;
import org.elasticsearch.xpack.ml.action.RevertModelSnapshotAction;
import org.elasticsearch.xpack.ml.action.util.QueryPage;
import org.elasticsearch.xpack.ml.job.config.DataDescription;
import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.JobState;
import org.elasticsearch.xpack.ml.job.config.JobUpdate;
@ -62,6 +65,9 @@ import java.util.regex.Pattern;
*/
public class JobManager extends AbstractComponent {
private static final DeprecationLogger DEPRECATION_LOGGER =
new DeprecationLogger(Loggers.getLogger(JobManager.class));
private final JobProvider jobProvider;
private final ClusterService clusterService;
private final Auditor auditor;
@ -159,6 +165,9 @@ public class JobManager extends AbstractComponent {
Job job = request.getJobBuilder().build(new Date());
if (job.getDataDescription() != null && job.getDataDescription().getFormat() == DataDescription.DataFormat.DELIMITED) {
DEPRECATION_LOGGER.deprecated("Creating jobs with delimited data format is deprecated. Please use JSON instead.");
}
MlMetadata currentMlMetadata = state.metaData().custom(MlMetadata.TYPE);
if (currentMlMetadata != null && currentMlMetadata.getJobs().containsKey(job.getId())) {

View File

@ -1041,3 +1041,29 @@
- match: { job_id: "job-model-memory-limit-above-removed-global-max" }
- match: { analysis_limits.model_memory_limit: "10240mb" }
---
"Test create job with delimited format":
- skip:
features: "warnings"
reason: deprecation logging for delimited format was introduced in 5.4.0
- do:
warnings:
- Creating jobs with delimited data format is deprecated. Please use JSON instead.
xpack.ml.put_job:
job_id: delimited-format-job
body: >
{
"analysis_config" : {
"bucket_span": "1h",
"detectors" :[{"function":"metric","field_name":"responsetime","by_field_name":"airline"}]
},
"data_description" : {
"format":"delimited",
"field_delimiter":",",
"time_field":"time",
"time_format":"yyyy-MM-dd HH:mm:ssX"
}
}
- match: { job_id: "delimited-format-job" }