Skip to content

Commit

Permalink
[ML] Adjust BWC after daily_model_snapshot_retention_after_days backp…
Browse files Browse the repository at this point in the history
…ort (#55911)

Simplifying BWC code after merging #55891
  • Loading branch information
droberts195 authored Apr 29, 2020
1 parent cefc6af commit e0f3889
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 88 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ task verifyVersions {
* after the backport of the backcompat code is complete.
*/

boolean bwc_tests_enabled = false
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/55911" /* place a PR link here when committing bwc changes */
boolean bwc_tests_enabled = true
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
if (bwc_tests_enabled == false) {
if (bwc_tests_disabled_issue.isEmpty()) {
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ teardown:
---
"Throw exception when adding voting config exclusion without specifying nodes":
- do:
catch: /You must set \[node_names\] or \[node_ids\] but not both/
catch: /(You must set \[node_names\] or \[node_ids\] but not both|Please set node identifiers correctly. One and only one of \[node_name\], \[node_names\] and \[node_ids\] has to be set)/
cluster.post_voting_config_exclusions: {}

---
"Throw exception when adding voting config exclusion and specifying both node_ids and node_names":
- do:
catch: /You must set \[node_names\] or \[node_ids\] but not both/
catch: /(You must set \[node_names\] or \[node_ids\] but not both|Please set node identifiers correctly. One and only one of \[node_name\], \[node_names\] and \[node_ids\] has to be set)/
cluster.post_voting_config_exclusions:
node_ids: nodeId
node_names: nodeName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,41 +207,26 @@ public Job(StreamInput in) throws IOException {
description = in.readOptionalString();
createTime = new Date(in.readVLong());
finishedTime = in.readBoolean() ? new Date(in.readVLong()) : null;
// for removed last_data_time field
if (in.getVersion().before(Version.V_7_0_0)) {
if (in.readBoolean()) {
in.readVLong();
}
}
analysisConfig = new AnalysisConfig(in);
analysisLimits = in.readOptionalWriteable(AnalysisLimits::new);
dataDescription = in.readOptionalWriteable(DataDescription::new);
modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new);
renormalizationWindowDays = in.readOptionalLong();
backgroundPersistInterval = in.readOptionalTimeValue();
modelSnapshotRetentionDays = in.readOptionalLong();
// TODO: change version in backport
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
dailyModelSnapshotRetentionAfterDays = in.readOptionalLong();
} else {
dailyModelSnapshotRetentionAfterDays = null;
}
dailyModelSnapshotRetentionAfterDays = in.readOptionalLong();
resultsRetentionDays = in.readOptionalLong();
Map<String, Object> readCustomSettings = in.readMap();
customSettings = readCustomSettings == null ? null : Collections.unmodifiableMap(readCustomSettings);
modelSnapshotId = in.readOptionalString();
if (in.getVersion().onOrAfter(Version.V_7_0_0) && in.readBoolean()) {
if (in.readBoolean()) {
modelSnapshotMinVersion = Version.readVersion(in);
} else {
modelSnapshotMinVersion = null;
}
resultsIndexName = in.readString();
deleting = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_7_5_0)) {
allowLazyOpen = in.readBoolean();
} else {
allowLazyOpen = false;
}
allowLazyOpen = in.readBoolean();
}

/**
Expand Down Expand Up @@ -486,37 +471,26 @@ public void writeTo(StreamOutput out) throws IOException {
} else {
out.writeBoolean(false);
}
// for removed last_data_time field
if (out.getVersion().before(Version.V_7_0_0)) {
out.writeBoolean(false);
}
analysisConfig.writeTo(out);
out.writeOptionalWriteable(analysisLimits);
out.writeOptionalWriteable(dataDescription);
out.writeOptionalWriteable(modelPlotConfig);
out.writeOptionalLong(renormalizationWindowDays);
out.writeOptionalTimeValue(backgroundPersistInterval);
out.writeOptionalLong(modelSnapshotRetentionDays);
// TODO: change version in backport
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
out.writeOptionalLong(dailyModelSnapshotRetentionAfterDays);
}
out.writeOptionalLong(dailyModelSnapshotRetentionAfterDays);
out.writeOptionalLong(resultsRetentionDays);
out.writeMap(customSettings);
out.writeOptionalString(modelSnapshotId);
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
if (modelSnapshotMinVersion != null) {
out.writeBoolean(true);
Version.writeVersion(modelSnapshotMinVersion, out);
} else {
out.writeBoolean(false);
}
if (modelSnapshotMinVersion != null) {
out.writeBoolean(true);
Version.writeVersion(modelSnapshotMinVersion, out);
} else {
out.writeBoolean(false);
}
out.writeString(resultsIndexName);
out.writeBoolean(deleting);
if (out.getVersion().onOrAfter(Version.V_7_5_0)) {
out.writeBoolean(allowLazyOpen);
}
out.writeBoolean(allowLazyOpen);
}

@Override
Expand Down Expand Up @@ -732,23 +706,18 @@ public Builder(StreamInput in) throws IOException {
renormalizationWindowDays = in.readOptionalLong();
backgroundPersistInterval = in.readOptionalTimeValue();
modelSnapshotRetentionDays = in.readOptionalLong();
// TODO: change version in backport
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
dailyModelSnapshotRetentionAfterDays = in.readOptionalLong();
}
dailyModelSnapshotRetentionAfterDays = in.readOptionalLong();
resultsRetentionDays = in.readOptionalLong();
customSettings = in.readMap();
modelSnapshotId = in.readOptionalString();
if (in.getVersion().onOrAfter(Version.V_7_0_0) && in.readBoolean()) {
if (in.readBoolean()) {
modelSnapshotMinVersion = Version.readVersion(in);
} else {
modelSnapshotMinVersion = null;
}
resultsIndexName = in.readOptionalString();
deleting = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_7_5_0)) {
allowLazyOpen = in.readBoolean();
}
allowLazyOpen = in.readBoolean();
}

public Builder setId(String id) {
Expand Down Expand Up @@ -934,26 +903,19 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalLong(renormalizationWindowDays);
out.writeOptionalTimeValue(backgroundPersistInterval);
out.writeOptionalLong(modelSnapshotRetentionDays);
// TODO: change version in backport
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
out.writeOptionalLong(dailyModelSnapshotRetentionAfterDays);
}
out.writeOptionalLong(dailyModelSnapshotRetentionAfterDays);
out.writeOptionalLong(resultsRetentionDays);
out.writeMap(customSettings);
out.writeOptionalString(modelSnapshotId);
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
if (modelSnapshotMinVersion != null) {
out.writeBoolean(true);
Version.writeVersion(modelSnapshotMinVersion, out);
} else {
out.writeBoolean(false);
}
if (modelSnapshotMinVersion != null) {
out.writeBoolean(true);
Version.writeVersion(modelSnapshotMinVersion, out);
} else {
out.writeBoolean(false);
}
out.writeOptionalString(resultsIndexName);
out.writeBoolean(deleting);
if (out.getVersion().onOrAfter(Version.V_7_5_0)) {
out.writeBoolean(allowLazyOpen);
}
out.writeBoolean(allowLazyOpen);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,7 @@ public JobUpdate(StreamInput in) throws IOException {
renormalizationWindowDays = in.readOptionalLong();
backgroundPersistInterval = in.readOptionalTimeValue();
modelSnapshotRetentionDays = in.readOptionalLong();
// TODO: change version on backport
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
dailyModelSnapshotRetentionAfterDays = in.readOptionalLong();
} else {
dailyModelSnapshotRetentionAfterDays = null;
}
dailyModelSnapshotRetentionAfterDays = in.readOptionalLong();
resultsRetentionDays = in.readOptionalLong();
if (in.readBoolean()) {
categorizationFilters = in.readStringList();
Expand All @@ -147,16 +142,12 @@ public JobUpdate(StreamInput in) throws IOException {
jobVersion = null;
}
clearJobFinishTime = in.readOptionalBoolean();
if (in.getVersion().onOrAfter(Version.V_7_0_0) && in.readBoolean()) {
if (in.readBoolean()) {
modelSnapshotMinVersion = Version.readVersion(in);
} else {
modelSnapshotMinVersion = null;
}
if (in.getVersion().onOrAfter(Version.V_7_5_0)) {
allowLazyOpen = in.readOptionalBoolean();
} else {
allowLazyOpen = null;
}
allowLazyOpen = in.readOptionalBoolean();
}

@Override
Expand All @@ -174,10 +165,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalLong(renormalizationWindowDays);
out.writeOptionalTimeValue(backgroundPersistInterval);
out.writeOptionalLong(modelSnapshotRetentionDays);
// TODO: change on backport
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
out.writeOptionalLong(dailyModelSnapshotRetentionAfterDays);
}
out.writeOptionalLong(dailyModelSnapshotRetentionAfterDays);
out.writeOptionalLong(resultsRetentionDays);
out.writeBoolean(categorizationFilters != null);
if (categorizationFilters != null) {
Expand All @@ -192,17 +180,13 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(false);
}
out.writeOptionalBoolean(clearJobFinishTime);
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
if (modelSnapshotMinVersion != null) {
out.writeBoolean(true);
Version.writeVersion(modelSnapshotMinVersion, out);
} else {
out.writeBoolean(false);
}
}
if (out.getVersion().onOrAfter(Version.V_7_5_0)) {
out.writeOptionalBoolean(allowLazyOpen);
if (modelSnapshotMinVersion != null) {
out.writeBoolean(true);
Version.writeVersion(modelSnapshotMinVersion, out);
} else {
out.writeBoolean(false);
}
out.writeOptionalBoolean(allowLazyOpen);
}

public String getJobId() {
Expand Down

0 comments on commit e0f3889

Please sign in to comment.