Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some Outdated BwC Logic #62072

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -210,8 +210,7 @@ public static OpType fromString(String sOpType) {
* Read a document write (index/delete/update) request
*
* @param shardId shard id of the request. {@code null} when reading as part of a {@link org.elasticsearch.action.bulk.BulkRequest}
* that does not have a unique shard id or when reading from a stream of version older than
* {@link org.elasticsearch.action.bulk.BulkShardRequest#COMPACT_SHARD_ID_VERSION}
* that does not have a unique shard id.
*/
static DocWriteRequest<?> readDocumentRequest(@Nullable ShardId shardId, StreamInput in) throws IOException {
byte type = in.readByte();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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

import org.elasticsearch.Version;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -47,22 +46,7 @@ public class NodesInfoRequest extends BaseNodesRequest<NodesInfoRequest> {
public NodesInfoRequest(StreamInput in) throws IOException {
super(in);
requestedMetrics.clear();
if (in.getVersion().before(Version.V_7_7_0)){
// prior to version 8.x, a NodesInfoRequest was serialized as a list
// of booleans in a fixed order
optionallyAddMetric(in.readBoolean(), Metric.SETTINGS.metricName());
optionallyAddMetric(in.readBoolean(), Metric.OS.metricName());
optionallyAddMetric(in.readBoolean(), Metric.PROCESS.metricName());
optionallyAddMetric(in.readBoolean(), Metric.JVM.metricName());
optionallyAddMetric(in.readBoolean(), Metric.THREAD_POOL.metricName());
optionallyAddMetric(in.readBoolean(), Metric.TRANSPORT.metricName());
optionallyAddMetric(in.readBoolean(), Metric.HTTP.metricName());
optionallyAddMetric(in.readBoolean(), Metric.PLUGINS.metricName());
optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName());
optionallyAddMetric(in.readBoolean(), Metric.INDICES.metricName());
} else {
requestedMetrics.addAll(Arrays.asList(in.readStringArray()));
}
requestedMetrics.addAll(Arrays.asList(in.readStringArray()));
}

/**
Expand Down Expand Up @@ -149,22 +133,7 @@ private void optionallyAddMetric(boolean addMetric, String metricName) {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (out.getVersion().before(Version.V_7_7_0)){
// prior to version 8.x, a NodesInfoRequest was serialized as a list
// of booleans in a fixed order
out.writeBoolean(Metric.SETTINGS.containedIn(requestedMetrics));
out.writeBoolean(Metric.OS.containedIn(requestedMetrics));
out.writeBoolean(Metric.PROCESS.containedIn(requestedMetrics));
out.writeBoolean(Metric.JVM.containedIn(requestedMetrics));
out.writeBoolean(Metric.THREAD_POOL.containedIn(requestedMetrics));
out.writeBoolean(Metric.TRANSPORT.containedIn(requestedMetrics));
out.writeBoolean(Metric.HTTP.containedIn(requestedMetrics));
out.writeBoolean(Metric.PLUGINS.containedIn(requestedMetrics));
out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics));
out.writeBoolean(Metric.INDICES.containedIn(requestedMetrics));
} else {
out.writeStringArray(requestedMetrics.toArray(String[]::new));
}
out.writeStringArray(requestedMetrics.toArray(String[]::new));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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

import org.elasticsearch.Version;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.common.io.stream.StreamInput;

Expand Down Expand Up @@ -53,18 +52,16 @@ public NodesReloadSecureSettingsRequest() {

public NodesReloadSecureSettingsRequest(StreamInput in) throws IOException {
super(in);
if (in.getVersion().onOrAfter(Version.V_7_7_0)) {
final BytesReference bytesRef = in.readOptionalBytesReference();
if (bytesRef != null) {
byte[] bytes = BytesReference.toBytes(bytesRef);
try {
this.secureSettingsPassword = new SecureString(CharArrays.utf8BytesToChars(bytes));
} finally {
Arrays.fill(bytes, (byte) 0);
}
} else {
this.secureSettingsPassword = null;
final BytesReference bytesRef = in.readOptionalBytesReference();
if (bytesRef != null) {
byte[] bytes = BytesReference.toBytes(bytesRef);
try {
this.secureSettingsPassword = new SecureString(CharArrays.utf8BytesToChars(bytes));
} finally {
Arrays.fill(bytes, (byte) 0);
}
} else {
this.secureSettingsPassword = null;
}
}

Expand Down Expand Up @@ -99,16 +96,14 @@ boolean hasPassword() {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_7_4_0)) {
if (this.secureSettingsPassword == null) {
out.writeOptionalBytesReference(null);
} else {
final byte[] passwordBytes = CharArrays.toUtf8Bytes(this.secureSettingsPassword.getChars());
try {
out.writeOptionalBytesReference(new BytesArray(passwordBytes));
} finally {
Arrays.fill(passwordBytes, (byte) 0);
}
if (this.secureSettingsPassword == null) {
out.writeOptionalBytesReference(null);
} else {
final byte[] passwordBytes = CharArrays.toUtf8Bytes(this.secureSettingsPassword.getChars());
try {
out.writeOptionalBytesReference(new BytesArray(passwordBytes));
} finally {
Arrays.fill(passwordBytes, (byte) 0);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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

import org.elasticsearch.Version;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
Expand Down Expand Up @@ -113,11 +112,7 @@ public NodeStats(StreamInput in) throws IOException {
discoveryStats = in.readOptionalWriteable(DiscoveryStats::new);
ingestStats = in.readOptionalWriteable(IngestStats::new);
adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new);
if (in.getVersion().onOrAfter(Version.V_7_9_0)) {
indexingPressureStats = in.readOptionalWriteable(IndexingPressureStats::new);
} else {
indexingPressureStats = null;
}
indexingPressureStats = in.readOptionalWriteable(IndexingPressureStats::new);
}

public NodeStats(DiscoveryNode node, long timestamp, @Nullable NodeIndicesStats indices,
Expand Down Expand Up @@ -266,9 +261,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(discoveryStats);
out.writeOptionalWriteable(ingestStats);
out.writeOptionalWriteable(adaptiveSelectionStats);
if (out.getVersion().onOrAfter(Version.V_7_9_0)) {
out.writeOptionalWriteable(indexingPressureStats);
}
out.writeOptionalWriteable(indexingPressureStats);
}

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

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

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -49,22 +48,7 @@ public NodesStatsRequest(StreamInput in) throws IOException {

indices = new CommonStatsFlags(in);
requestedMetrics.clear();
if (in.getVersion().before(Version.V_7_7_0)) {
optionallyAddMetric(in.readBoolean(), Metric.OS.metricName());
optionallyAddMetric(in.readBoolean(), Metric.PROCESS.metricName());
optionallyAddMetric(in.readBoolean(), Metric.JVM.metricName());
optionallyAddMetric(in.readBoolean(), Metric.THREAD_POOL.metricName());
optionallyAddMetric(in.readBoolean(), Metric.FS.metricName());
optionallyAddMetric(in.readBoolean(), Metric.TRANSPORT.metricName());
optionallyAddMetric(in.readBoolean(), Metric.HTTP.metricName());
optionallyAddMetric(in.readBoolean(), Metric.BREAKER.metricName());
optionallyAddMetric(in.readBoolean(), Metric.SCRIPT.metricName());
optionallyAddMetric(in.readBoolean(), Metric.DISCOVERY.metricName());
optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName());
optionallyAddMetric(in.readBoolean(), Metric.ADAPTIVE_SELECTION.metricName());
} else {
requestedMetrics.addAll(in.readStringList());
}
requestedMetrics.addAll(in.readStringList());
}

/**
Expand Down Expand Up @@ -185,22 +169,7 @@ private void optionallyAddMetric(boolean includeMetric, String metricName) {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
indices.writeTo(out);
if (out.getVersion().before(Version.V_7_7_0)) {
out.writeBoolean(Metric.OS.containedIn(requestedMetrics));
out.writeBoolean(Metric.PROCESS.containedIn(requestedMetrics));
out.writeBoolean(Metric.JVM.containedIn(requestedMetrics));
out.writeBoolean(Metric.THREAD_POOL.containedIn(requestedMetrics));
out.writeBoolean(Metric.FS.containedIn(requestedMetrics));
out.writeBoolean(Metric.TRANSPORT.containedIn(requestedMetrics));
out.writeBoolean(Metric.HTTP.containedIn(requestedMetrics));
out.writeBoolean(Metric.BREAKER.containedIn(requestedMetrics));
out.writeBoolean(Metric.SCRIPT.containedIn(requestedMetrics));
out.writeBoolean(Metric.DISCOVERY.containedIn(requestedMetrics));
out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics));
out.writeBoolean(Metric.ADAPTIVE_SELECTION.containedIn(requestedMetrics));
} else {
out.writeStringArray(requestedMetrics.toArray(String[]::new));
}
out.writeStringArray(requestedMetrics.toArray(String[]::new));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.action.admin.cluster.node.tasks.cancel;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.tasks.BaseTasksRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand All @@ -45,18 +44,14 @@ public CancelTasksRequest() {}
public CancelTasksRequest(StreamInput in) throws IOException {
super(in);
this.reason = in.readString();
if (in.getVersion().onOrAfter(Version.V_7_8_0)) {
waitForCompletion = in.readBoolean();
}
waitForCompletion = in.readBoolean();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeString(reason);
if (out.getVersion().onOrAfter(Version.V_7_8_0)) {
out.writeBoolean(waitForCompletion);
}
out.writeBoolean(waitForCompletion);
}

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

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

import org.elasticsearch.Version;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
Expand All @@ -43,11 +42,7 @@ public NodeUsage(StreamInput in) throws IOException {
timestamp = in.readLong();
sinceTime = in.readLong();
restUsage = (Map<String, Long>) in.readGenericValue();
if (in.getVersion().onOrAfter(Version.V_7_8_0)) {
aggregationUsage = (Map<String, Object>) in.readGenericValue();
} else {
aggregationUsage = null;
}
aggregationUsage = (Map<String, Object>) in.readGenericValue();
}

/**
Expand Down Expand Up @@ -121,9 +116,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeLong(timestamp);
out.writeLong(sinceTime);
out.writeGenericValue(restUsage);
if (out.getVersion().onOrAfter(Version.V_7_8_0)) {
out.writeGenericValue(aggregationUsage);
}
out.writeGenericValue(aggregationUsage);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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

import org.elasticsearch.Version;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand All @@ -34,9 +33,7 @@ public class NodesUsageRequest extends BaseNodesRequest<NodesUsageRequest> {
public NodesUsageRequest(StreamInput in) throws IOException {
super(in);
this.restActions = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_7_8_0)) {
this.aggregations = in.readBoolean();
}
this.aggregations = in.readBoolean();
}

/**
Expand Down Expand Up @@ -99,8 +96,6 @@ public NodesUsageRequest aggregations(boolean aggregations) {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeBoolean(restActions);
if (out.getVersion().onOrAfter(Version.V_7_8_0)) {
out.writeBoolean(aggregations);
}
out.writeBoolean(aggregations);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@

package org.elasticsearch.action.admin.cluster.state;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.ByteSizeValue;

import java.io.IOException;
import java.util.Objects;
Expand All @@ -44,9 +42,6 @@ public ClusterStateResponse(StreamInput in) throws IOException {
super(in);
clusterName = new ClusterName(in);
clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null));
if (in.getVersion().before(Version.V_7_0_0)) {
new ByteSizeValue(in);
}
waitForTimedOut = in.readBoolean();
}

Expand Down Expand Up @@ -83,9 +78,6 @@ public boolean isWaitForTimedOut() {
public void writeTo(StreamOutput out) throws IOException {
clusterName.writeTo(out);
out.writeOptionalWriteable(clusterState);
if (out.getVersion().before(Version.V_7_0_0)) {
ByteSizeValue.ZERO.writeTo(out);
}
out.writeBoolean(waitForTimedOut);
}

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

package org.elasticsearch.action.admin.cluster.stats;

import org.elasticsearch.Version;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
Expand Down Expand Up @@ -50,14 +49,9 @@ public ClusterStatsResponse(StreamInput in) throws IOException {
// it may be that the master switched on us while doing the operation. In this case the status may be null.
status = in.readOptionalWriteable(ClusterHealthStatus::readFrom);

String clusterUUID = null;
MappingStats mappingStats = null;
AnalysisStats analysisStats = null;
if (in.getVersion().onOrAfter(Version.V_7_7_0)) {
clusterUUID = in.readOptionalString();
mappingStats = in.readOptionalWriteable(MappingStats::new);
analysisStats = in.readOptionalWriteable(AnalysisStats::new);
}
String clusterUUID = in.readOptionalString();
MappingStats mappingStats = in.readOptionalWriteable(MappingStats::new);
AnalysisStats analysisStats = in.readOptionalWriteable(AnalysisStats::new);
this.clusterUUID = clusterUUID;

// built from nodes rather than from the stream directly
Expand Down Expand Up @@ -112,11 +106,9 @@ public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVLong(timestamp);
out.writeOptionalWriteable(status);
if (out.getVersion().onOrAfter(Version.V_7_7_0)) {
out.writeOptionalString(clusterUUID);
out.writeOptionalWriteable(indicesStats.getMappings());
out.writeOptionalWriteable(indicesStats.getAnalysis());
}
out.writeOptionalString(clusterUUID);
out.writeOptionalWriteable(indicesStats.getMappings());
out.writeOptionalWriteable(indicesStats.getAnalysis());
}

@Override
Expand Down
Loading