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 @@ -206,11 +206,7 @@ public InternalAutoDateHistogram(StreamInput in) throws IOException {
format = in.readNamedWriteable(DocValueFormat.class);
buckets = in.readCollectionAsList(stream -> Bucket.readFrom(stream, format));
this.targetBuckets = in.readVInt();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0)) {
bucketInnerInterval = in.readVLong();
} else {
bucketInnerInterval = 1; // Calculated on merge.
}
bucketInnerInterval = in.readVLong();
// we changed the order format in 8.13 for partial reduce, therefore we need to order them to perform merge sort
if (in.getTransportVersion().between(TransportVersions.V_8_13_0, TransportVersions.V_8_14_0)) {
// list is mutable by #readCollectionAsList contract
Expand All @@ -224,9 +220,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeNamedWriteable(format);
out.writeCollection(buckets);
out.writeVInt(targetBuckets);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0)) {
out.writeVLong(bucketInnerInterval);
}
out.writeVLong(bucketInnerInterval);
}

long getBucketInnerInterval() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.ingest.geoip.direct;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.cluster.metadata.MetadataCreateIndexService;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -138,12 +137,7 @@ public DatabaseConfiguration(StreamInput in) throws IOException {
}

private static Provider readProvider(StreamInput in) throws IOException {
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_16_0)) {
return in.readNamedWriteable(Provider.class);
} else {
// prior to the above version, everything was always a maxmind, so this half of the if is logical
return new Maxmind(in.readString());
}
return in.readNamedWriteable(Provider.class);
}

public static DatabaseConfiguration parse(XContentParser parser, String id) {
Expand All @@ -154,15 +148,7 @@ public static DatabaseConfiguration parse(XContentParser parser, String id) {
public void writeTo(StreamOutput out) throws IOException {
out.writeString(id);
out.writeString(name);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_16_0)) {
out.writeNamedWriteable(provider);
} else {
if (provider instanceof Maxmind maxmind) {
out.writeString(maxmind.accountId);
} else {
assert false : "non-maxmind DatabaseConfiguration.Provider [" + provider.getWriteableName() + "]";
}
}
out.writeNamedWriteable(provider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.ingest.geoip.stats;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
Expand Down Expand Up @@ -167,11 +166,7 @@ public static class NodeResponse extends BaseNodeResponse {
protected NodeResponse(StreamInput in) throws IOException {
super(in);
downloaderStats = in.readBoolean() ? new GeoIpDownloaderStats(in) : null;
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
cacheStats = in.readBoolean() ? new CacheStats(in) : null;
} else {
cacheStats = null;
}
cacheStats = in.readBoolean() ? new CacheStats(in) : null;
databases = in.readCollectionAsImmutableSet(StreamInput::readString);
filesInTemp = in.readCollectionAsImmutableSet(StreamInput::readString);
configDatabases = in.readCollectionAsImmutableSet(StreamInput::readString);
Expand Down Expand Up @@ -216,11 +211,9 @@ public void writeTo(StreamOutput out) throws IOException {
if (downloaderStats != null) {
downloaderStats.writeTo(out);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
out.writeBoolean(cacheStats != null);
if (cacheStats != null) {
cacheStats.writeTo(out);
}
out.writeBoolean(cacheStats != null);
if (cacheStats != null) {
cacheStats.writeTo(out);
}
out.writeStringCollection(databases);
out.writeStringCollection(filesInTemp);
Expand Down
29 changes: 6 additions & 23 deletions server/src/main/java/org/elasticsearch/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,9 @@ public static Build readBuild(StreamInput in) throws IOException {
final String minWireVersion;
final String minIndexVersion;
final String displayString;
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
version = in.readString();
qualifier = in.readOptionalString();
snapshot = in.readBoolean();
} else {
snapshot = in.readBoolean();
String rawVersion = in.readString();
// need to separate out qualifiers from older nodes
var versionMatcher = qualfiedVersionRegex.matcher(rawVersion);
if (versionMatcher.matches() == false) {
throw new IllegalStateException(String.format(Locale.ROOT, "Malformed elasticsearch compile version: %s", rawVersion));
}
version = versionMatcher.group(1);
qualifier = versionMatcher.group(2);
}
version = in.readString();
qualifier = in.readOptionalString();
snapshot = in.readBoolean();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) {
minWireVersion = in.readString();
minIndexVersion = in.readString();
Expand All @@ -258,14 +246,9 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException
out.writeString(build.type().displayName());
out.writeString(build.hash());
out.writeString(build.date());
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
out.writeString(build.version());
out.writeOptionalString(build.qualifier());
out.writeBoolean(build.isSnapshot());
} else {
out.writeBoolean(build.isSnapshot());
out.writeString(build.qualifiedVersion());
}
out.writeString(build.version());
out.writeOptionalString(build.qualifier());
out.writeBoolean(build.isSnapshot());
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_10_X)) {
out.writeString(build.minWireCompatVersion());
out.writeString(build.minIndexCompatVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ public TransportGetAllocationStatsAction(

@Override
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
if (clusterService.state().getMinTransportVersion().before(TransportVersions.V_8_14_0)) {
// The action is not available before ALLOCATION_STATS
listener.onResponse(new Response(Map.of(), null));
return;
}
super.doExecute(task, request, listener);
}

Expand Down Expand Up @@ -144,9 +139,7 @@ public Request(StreamInput in) throws IOException {
public void writeTo(StreamOutput out) throws IOException {
assert out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0);
super.writeTo(out);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_16_0)) {
out.writeEnumSet(metrics);
}
out.writeEnumSet(metrics);
}

public EnumSet<Metric> metrics() {
Expand Down Expand Up @@ -177,21 +170,13 @@ public Response(Map<String, NodeAllocationStats> nodeAllocationStats, DiskThresh

public Response(StreamInput in) throws IOException {
this.nodeAllocationStats = in.readImmutableMap(StreamInput::readString, NodeAllocationStats::new);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
this.diskThresholdSettings = in.readOptionalWriteable(DiskThresholdSettings::readFrom);
} else {
this.diskThresholdSettings = null;
}
this.diskThresholdSettings = in.readOptionalWriteable(DiskThresholdSettings::readFrom);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeMap(nodeAllocationStats, StreamOutput::writeString, StreamOutput::writeWriteable);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
out.writeOptionalWriteable(diskThresholdSettings);
} else {
assert diskThresholdSettings == null;
}
out.writeOptionalWriteable(diskThresholdSettings);
}

public Map<String, NodeAllocationStats> getNodeAllocationStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

package org.elasticsearch.action.admin.cluster.node.hotthreads;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.ReleasableBytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand All @@ -28,11 +26,7 @@ public class NodeHotThreads extends BaseNodeResponse {

NodeHotThreads(StreamInput in) throws IOException {
super(in);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) {
bytes = in.readReleasableBytesReference();
} else {
bytes = ReleasableBytesReference.wrap(new BytesArray(in.readString().getBytes(StandardCharsets.UTF_8)));
}
bytes = in.readReleasableBytesReference();
}

public NodeHotThreads(DiscoveryNode node, ReleasableBytesReference hotThreadsUtf8Bytes) {
Expand All @@ -57,11 +51,7 @@ public java.io.Reader getHotThreadsReader() {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) {
out.writeBytesReference(bytes);
} else {
out.writeString(bytes.utf8ToString());
}
out.writeBytesReference(bytes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.elasticsearch.Build;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.version.CompatibilityVersions;
Expand Down Expand Up @@ -64,33 +63,14 @@ public class NodeInfo extends BaseNodeResponse {

public NodeInfo(StreamInput in) throws IOException {
super(in);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
version = in.readString();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_16_1)) {
compatibilityVersions = CompatibilityVersions.readVersion(in);
} else {
compatibilityVersions = new CompatibilityVersions(TransportVersion.readVersion(in), Map.of()); // unknown mappings versions
}
indexVersion = IndexVersion.readVersion(in);
version = in.readString();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_16_1)) {
compatibilityVersions = CompatibilityVersions.readVersion(in);
} else {
Version legacyVersion = Version.readVersion(in);
version = legacyVersion.toString();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
compatibilityVersions = new CompatibilityVersions(TransportVersion.readVersion(in), Map.of()); // unknown mappings versions
} else {
compatibilityVersions = new CompatibilityVersions(TransportVersion.fromId(legacyVersion.id), Map.of());
}
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_11_X)) {
indexVersion = IndexVersion.readVersion(in);
} else {
indexVersion = IndexVersion.fromId(legacyVersion.id);
}
}
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_11_X)) {
componentVersions = in.readImmutableMap(StreamInput::readString, StreamInput::readVInt);
} else {
componentVersions = Map.of();
compatibilityVersions = new CompatibilityVersions(TransportVersion.readVersion(in), Map.of()); // unknown mappings versions
}
indexVersion = IndexVersion.readVersion(in);
componentVersions = in.readImmutableMap(StreamInput::readString, StreamInput::readVInt);
build = Build.readBuild(in);
if (in.readBoolean()) {
totalIndexingBuffer = ByteSizeValue.ofBytes(in.readLong());
Expand All @@ -111,9 +91,7 @@ public NodeInfo(StreamInput in) throws IOException {
addInfoIfNonNull(PluginsAndModules.class, in.readOptionalWriteable(PluginsAndModules::new));
addInfoIfNonNull(IngestInfo.class, in.readOptionalWriteable(IngestInfo::new));
addInfoIfNonNull(AggregationInfo.class, in.readOptionalWriteable(AggregationInfo::new));
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
addInfoIfNonNull(RemoteClusterServerInfo.class, in.readOptionalWriteable(RemoteClusterServerInfo::new));
}
addInfoIfNonNull(RemoteClusterServerInfo.class, in.readOptionalWriteable(RemoteClusterServerInfo::new));
}

public NodeInfo(
Expand Down Expand Up @@ -246,20 +224,10 @@ private <T extends ReportingService.Info> void addInfoIfNonNull(Class<T> clazz,
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
out.writeString(version);
} else {
Version.writeVersion(Version.fromString(version), out);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_16_1)) {
compatibilityVersions.writeTo(out);
} else if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
TransportVersion.writeVersion(compatibilityVersions.transportVersion(), out);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_11_X)) {
IndexVersion.writeVersion(indexVersion, out);
out.writeMap(componentVersions, StreamOutput::writeString, StreamOutput::writeVInt);
}
out.writeString(version);
compatibilityVersions.writeTo(out);
IndexVersion.writeVersion(indexVersion, out);
out.writeMap(componentVersions, StreamOutput::writeString, StreamOutput::writeVInt);
Build.writeBuild(build, out);
if (totalIndexingBuffer == null) {
out.writeBoolean(false);
Expand All @@ -282,8 +250,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(getInfo(PluginsAndModules.class));
out.writeOptionalWriteable(getInfo(IngestInfo.class));
out.writeOptionalWriteable(getInfo(AggregationInfo.class));
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
out.writeOptionalWriteable(getInfo(RemoteClusterServerInfo.class));
}
out.writeOptionalWriteable(getInfo(RemoteClusterServerInfo.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.action.admin.cluster.node.info;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.node.ReportingService;
Expand Down Expand Up @@ -42,11 +41,7 @@ public PluginsAndModules(StreamInput in) throws IOException {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0)) {
out.writeCollection(plugins);
} else {
out.writeCollection(plugins.stream().map(PluginRuntimeInfo::descriptor).toList());
}
out.writeCollection(plugins);
out.writeCollection(modules);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

package org.elasticsearch.action.admin.cluster.node.reload;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
Expand All @@ -23,7 +20,6 @@
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.RefCounted;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.LeakTracker;

Expand Down Expand Up @@ -92,13 +88,6 @@ public static class NodeRequest extends AbstractTransportRequest {
NodeRequest(StreamInput in) throws IOException {
super(in);

if (in.getTransportVersion().before(TransportVersions.V_8_13_0)) {
TaskId.readFromStream(in);
in.readStringArray();
in.readOptionalArray(DiscoveryNode::new, DiscoveryNode[]::new);
in.readOptionalTimeValue();
}

final BytesReference bytesRef = in.readOptionalBytesReference();
if (bytesRef != null) {
byte[] bytes = BytesReference.toBytes(bytesRef);
Expand Down Expand Up @@ -126,13 +115,6 @@ public void writeTo(StreamOutput out) throws IOException {
assert hasReferences();
super.writeTo(out);

if (out.getTransportVersion().before(TransportVersions.V_8_13_0)) {
TaskId.EMPTY_TASK_ID.writeTo(out);
out.writeStringArray(Strings.EMPTY_ARRAY);
out.writeOptionalArray(StreamOutput::writeWriteable, null);
out.writeOptionalTimeValue(null);
}

if (this.secureSettingsPassword == null) {
out.writeOptionalBytesReference(null);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ public void writeTo(StreamOutput out) throws IOException {
}

public static Result readFrom(final StreamInput in) throws IOException {
if (in.getTransportVersion().before(TransportVersions.V_8_7_0)) {
return new Result(in.readBoolean(), null, in.readString());
}
return new Result(in.readBoolean(), Reason.readFrom(in), in.readString());
}

Expand Down
Loading