Skip to content

Commit

Permalink
Use versioned named writeable abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed Apr 15, 2020
1 parent 024b790 commit c458420
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Usage(StreamInput in) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
package org.elasticsearch.xpack.core;

import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.VersionedNamedWriteable;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

Expand All @@ -22,7 +22,7 @@ public interface XPackFeatureSet {

boolean enabled();

abstract class Usage implements ToXContentObject, NamedWriteable {
abstract class Usage implements ToXContentObject, VersionedNamedWriteable {

private static final String AVAILABLE_XFIELD = "available";
private static final String ENABLED_XFIELD = "enabled";
Expand All @@ -41,7 +41,7 @@ public Usage(String name, boolean available, boolean enabled) {
this.enabled = enabled;
}

public abstract Version version();
public abstract Version getMinimalSupportedVersion();

This comment has been minimized.

Copy link
@imotov

imotov Apr 15, 2020

Contributor

That's probably unnecessary.

This comment has been minimized.

Copy link
@jasontedor

jasontedor Apr 15, 2020

Author Member

I pushed a759121.


public String name() {
return name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public List<XPackFeatureSet.Usage> getUsages() {
@Override
public void writeTo(final StreamOutput out) throws IOException {
// we can only write the usages with version the coordinating node is compatible with otherwise it will not know the named writeable
final List<XPackFeatureSet.Usage> usagesToWrite =
usages.stream().filter(usage -> out.getVersion().onOrAfter(usage.version())).collect(Collectors.toUnmodifiableList());
final List<XPackFeatureSet.Usage> usagesToWrite = usages
.stream()
.filter(usage -> out.getVersion().onOrAfter(usage.getMinimalSupportedVersion()))
.collect(Collectors.toUnmodifiableList());
writeTo(out, usagesToWrite);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AnalyticsFeatureSetUsage(StreamInput input) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void writeTo(StreamOutput out) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public FrozenIndicesFeatureSetUsage(StreamInput input) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public GraphFeatureSetUsage(boolean available, boolean enabled) {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public IndexLifecycleFeatureSetUsage(StreamInput input) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public LogstashFeatureSetUsage(boolean available, boolean enabled) {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public MachineLearningFeatureSetUsage(StreamInput in) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public MonitoringFeatureSetUsage(boolean available, boolean enabled,
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public RollupFeatureSetUsage(boolean available, boolean enabled) {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public SecurityFeatureSetUsage(boolean available, boolean enabled, Map<String, O
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SLMFeatureSetUsage(boolean available, boolean enabled, @Nullable Snapshot
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public SpatialFeatureSetUsage(StreamInput input) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public SqlFeatureSetUsage(boolean available, boolean enabled, Map<String, Object
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TransformFeatureSetUsage(boolean available, boolean enabled, Map<String,
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void writeTo(StreamOutput out) throws IOException {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public VotingOnlyNodeFeatureSetUsage(boolean available) {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public WatcherFeatureSetUsage(boolean available, boolean enabled, Map<String, Ob
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public OldUsage(final StreamInput in) throws IOException {
}

@Override
public Version version() {
public Version getMinimalSupportedVersion() {
return oldVersion;
}

Expand All @@ -69,7 +69,7 @@ public NewUsage(final StreamInput in) throws IOException {
}

@Override
public Version version() {
public Version getMinimalSupportedVersion() {
return newVersion;
}

Expand Down

0 comments on commit c458420

Please sign in to comment.