Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
public static final long DEFAULT_MODEL_SNAPSHOT_RETENTION_DAYS = 1;

private static ObjectParser<Builder, Void> createParser(boolean ignoreUnknownFields) {
ObjectParser<Builder, Void> parser = new ObjectParser<>("job_details", ignoreUnknownFields, Builder::new);
ObjectParser<Builder, Void> parser = new ObjectParser<>("job_details", ignoreUnknownFields, () -> new Builder(true));

parser.declareString(Builder::setId, ID);
parser.declareString(Builder::setJobType, JOB_TYPE);
Expand Down Expand Up @@ -641,18 +641,30 @@ public static class Builder implements Writeable, ToXContentObject {
private ModelPlotConfig modelPlotConfig;
private Long renormalizationWindowDays;
private TimeValue backgroundPersistInterval;
private Long modelSnapshotRetentionDays = DEFAULT_MODEL_SNAPSHOT_RETENTION_DAYS;
private Long modelSnapshotRetentionDays;
private Long resultsRetentionDays;
private Map<String, Object> customSettings;
private String modelSnapshotId;
private Version modelSnapshotMinVersion;
private String resultsIndexName;
private boolean deleting;

private Builder(boolean ignoreDefaults) {
// Private constructor called by the parser to prevent default
// values being set. If a field with a default has explicitly
// been set to null then it isn't written in toXContent, hence
// won't be read by the parser and so won't be set back to null.
//
// The parameter isn't used it purely serves as a marker
// to differentiate between the different constructors
}

public Builder() {
modelSnapshotRetentionDays = DEFAULT_MODEL_SNAPSHOT_RETENTION_DAYS;
}

public Builder(String id) {
this();
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ public static Job createRandomizedJob() {
}
if (randomBoolean()) {
builder.setModelSnapshotRetentionDays(randomNonNegativeLong());
} else {
builder.setModelSnapshotRetentionDays(null);
}
if (randomBoolean()) {
builder.setResultsRetentionDays(randomNonNegativeLong());
Expand Down