[ML] Hide AnalysisConfig.latency field if not set (elastic/x-pack-elasticsearch#895)
Original commit: elastic/x-pack-elasticsearch@b2b3567820
This commit is contained in:
parent
d7f3a260fd
commit
9da2853d12
|
@ -380,7 +380,9 @@ public class AnalysisConfig extends ToXContentToBytes implements Writeable {
|
|||
if (categorizationFilters != null) {
|
||||
builder.field(CATEGORIZATION_FILTERS.getPreferredName(), categorizationFilters);
|
||||
}
|
||||
builder.field(LATENCY.getPreferredName(), latency.getStringRep());
|
||||
if (latency != null) {
|
||||
builder.field(LATENCY.getPreferredName(), latency.getStringRep());
|
||||
}
|
||||
if (period != null) {
|
||||
builder.field(PERIOD.getPreferredName(), period);
|
||||
}
|
||||
|
@ -446,7 +448,7 @@ public class AnalysisConfig extends ToXContentToBytes implements Writeable {
|
|||
private List<Detector> detectors;
|
||||
private TimeValue bucketSpan = DEFAULT_BUCKET_SPAN;
|
||||
private TimeValue batchSpan;
|
||||
private TimeValue latency = TimeValue.ZERO;
|
||||
private TimeValue latency;
|
||||
private Long period;
|
||||
private String categorizationFieldName;
|
||||
private List<String> categorizationFilters;
|
||||
|
@ -554,7 +556,9 @@ public class AnalysisConfig extends ToXContentToBytes implements Writeable {
|
|||
if (batchSpan != null) {
|
||||
TimeUtils.checkPositiveMultiple(batchSpan, TimeUnit.SECONDS, BATCH_SPAN);
|
||||
}
|
||||
TimeUtils.checkNonNegativeMultiple(latency, TimeUnit.SECONDS, LATENCY);
|
||||
if (latency != null) {
|
||||
TimeUtils.checkNonNegativeMultiple(latency, TimeUnit.SECONDS, LATENCY);
|
||||
}
|
||||
checkFieldIsNotNegativeIfSpecified(PERIOD.getPreferredName(), period);
|
||||
|
||||
verifyDetectorAreDefined(detectors);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class DataStreamDiagnostics {
|
|||
|
||||
public DataStreamDiagnostics(Job job) {
|
||||
bucketSpan = job.getAnalysisConfig().getBucketSpan().seconds();
|
||||
latency = job.getAnalysisConfig().getLatency().seconds();
|
||||
latency = job.getAnalysisConfig().getLatency() == null ? 0 : job.getAnalysisConfig().getLatency().seconds();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class AbstractDataToProcessWriter implements DataToProcessWriter
|
|||
this.analysisConfig = Objects.requireNonNull(analysisConfig);
|
||||
this.dataCountsReporter = Objects.requireNonNull(dataCountsReporter);
|
||||
this.logger = Objects.requireNonNull(logger);
|
||||
this.latencySeconds = analysisConfig.getLatency().seconds();
|
||||
this.latencySeconds = analysisConfig.getLatency() == null ? 0 : analysisConfig.getLatency().seconds();
|
||||
|
||||
Date date = dataCountsReporter.getLatestRecordTime();
|
||||
latestEpochMsThisUpload = 0;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class MlMetadataTests extends AbstractSerializingTestCase<MlMetadata> {
|
|||
Job job = JobTests.createRandomizedJob();
|
||||
if (randomBoolean()) {
|
||||
AnalysisConfig.Builder analysisConfig = new AnalysisConfig.Builder(job.getAnalysisConfig());
|
||||
analysisConfig.setLatency(TimeValue.ZERO);
|
||||
analysisConfig.setLatency(null);
|
||||
DatafeedConfig datafeedConfig = DatafeedConfigTests.createRandomizedDatafeedConfig(job.getId());
|
||||
if (datafeedConfig.hasAggregations()) {
|
||||
analysisConfig.setSummaryCountFieldName("doc_count");
|
||||
|
|
Loading…
Reference in New Issue