Skip to content

Commit

Permalink
Implement getMinimalSupportedVersion for all NameDiffs (#81374) (#81408)
Browse files Browse the repository at this point in the history
This removes the default implementation of `getMinimalSupportedVersion`
and implements it in all `NameDiffs` implementations.

The default implementation was rather broad, `minimumIndexCompatibilityVersion`
as the index compatibility are wider than our wire compatibility.
Having a default implementation also had the implementors forget about
adjusting the wire compatibility to the correct version.
  • Loading branch information
andreidan authored Dec 7, 2021
1 parent 504b86c commit 87f5a7c
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public interface NamedDiff<T extends Diffable<T>> extends Diff<T>, NamedWriteabl
/**
* The minimal version of the recipient this custom object can be sent to
*/
default Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumIndexCompatibilityVersion();
}
Version getMinimalSupportedVersion();

}
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,10 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_7_0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,10 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_7_0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,10 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_7_0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ public int getRemovedCount() {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ public void writeTo(StreamOutput out) throws IOException {
static Diff<SingleNodeShutdownMetadata> readNodesDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(SingleNodeShutdownMetadata::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return NODE_SHUTDOWN_VERSION;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public Metadata.Custom apply(Metadata.Custom part) {
public void writeTo(StreamOutput out) throws IOException {
pipelines.writeTo(out);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ public void writeTo(StreamOutput out) throws IOException {
static Diff<SingleFeatureMigrationResult> readDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(SingleFeatureMigrationResult::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return MIGRATION_ADDED_VERSION;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ static Diff<AutoscalingPolicyMetadata> readFrom(final StreamInput in) throws IOE
return AbstractDiffable.readDiffFrom(AutoscalingPolicyMetadata::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_8_0;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}

static Diff<LifecyclePolicyMetadata> readLifecyclePolicyDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(LifecyclePolicyMetadata::new, in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public boolean isResetMode() {

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumIndexCompatibilityVersion();
return Version.CURRENT.minimumCompatibilityVersion();
}

@Override
Expand Down Expand Up @@ -175,6 +175,11 @@ public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}

static Diff<Job> readJobDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(Job::new, in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,11 @@ public void writeTo(StreamOutput out) throws IOException {
static Diff<SnapshotLifecyclePolicyMetadata> readLifecyclePolicyDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(SnapshotLifecyclePolicyMetadata::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_4_0;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean isResetMode() {

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumIndexCompatibilityVersion();
return Version.CURRENT.minimumCompatibilityVersion();
}

@Override
Expand Down Expand Up @@ -117,6 +117,11 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ public String getWriteableName() {
public void writeTo(StreamOutput out) throws IOException {
modelAliasesDiff.writeTo(out);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_13_0;
}

}

public static class ModelAliasEntry extends AbstractDiffable<ModelAliasEntry> implements ToXContentObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ public String getWriteableName() {
return NAME;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_8_0_0;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
modelRoutingEntries.writeTo(out);
Expand Down

0 comments on commit 87f5a7c

Please sign in to comment.