Skip to content

Commit

Permalink
Remove most uses of 7.5 and 7.6 transport versions
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop committed Dec 11, 2024
1 parent 368d471 commit 861cebb
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.index.rankeval;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
Expand Down Expand Up @@ -46,9 +45,7 @@ public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) {
rankingEvaluationSpec = new RankEvalSpec(in);
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_6_0)) {
searchType = SearchType.fromId(in.readByte());
}
searchType = SearchType.fromId(in.readByte());
}

RankEvalRequest() {}
Expand Down Expand Up @@ -127,9 +124,7 @@ public void writeTo(StreamOutput out) throws IOException {
rankingEvaluationSpec.writeTo(out);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_6_0)) {
out.writeByte(searchType.id());
}
out.writeByte(searchType.id());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.elasticsearch.persistent.PersistentTaskNodeNotAssignedException;
import org.elasticsearch.rest.ApiNotAvailableException;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchException;
import org.elasticsearch.search.TooManyScrollContextsException;
import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.search.aggregations.MultiBucketConsumerService;
Expand Down Expand Up @@ -319,10 +318,6 @@ protected void writeTo(StreamOutput out, Writer<Throwable> nestedExceptionsWrite
public static ElasticsearchException readException(StreamInput input, int id) throws IOException {
CheckedFunction<StreamInput, ? extends ElasticsearchException, IOException> elasticsearchException = ID_TO_SUPPLIER.get(id);
if (elasticsearchException == null) {
if (id == 127 && input.getTransportVersion().before(TransportVersions.V_7_5_0)) {
// was SearchContextException
return new SearchException(input);
}
throw new IllegalStateException("unknown exception for id: " + id);
}
return elasticsearchException.apply(input);
Expand Down Expand Up @@ -1817,13 +1812,13 @@ private enum ElasticsearchExceptionHandle {
org.elasticsearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException.class,
org.elasticsearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException::new,
156,
TransportVersions.V_7_5_0
UNKNOWN_VERSION_ADDED
),
INGEST_PROCESSOR_EXCEPTION(
org.elasticsearch.ingest.IngestProcessorException.class,
org.elasticsearch.ingest.IngestProcessorException::new,
157,
TransportVersions.V_7_5_0
UNKNOWN_VERSION_ADDED
),
PEER_RECOVERY_NOT_FOUND_EXCEPTION(
org.elasticsearch.indices.recovery.PeerRecoveryNotFound.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ static TransportVersion def(int id) {
public static final TransportVersion V_7_2_1 = def(7_02_01_99);
public static final TransportVersion V_7_3_0 = def(7_03_00_99);
public static final TransportVersion V_7_4_0 = def(7_04_00_99);
public static final TransportVersion V_7_5_0 = def(7_05_00_99);
public static final TransportVersion V_7_6_0 = def(7_06_00_99);
public static final TransportVersion V_7_7_0 = def(7_07_00_99);
public static final TransportVersion V_7_8_0 = def(7_08_00_99);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
Expand Down Expand Up @@ -239,11 +238,7 @@ public static class NodeRequest extends TransportRequest {
public NodeRequest(StreamInput in) throws IOException {
super(in);
shardId = new ShardId(in);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_6_0)) {
customDataPath = in.readString();
} else {
customDataPath = null;
}
customDataPath = in.readString();
}

public NodeRequest(Request request) {
Expand All @@ -255,10 +250,7 @@ public NodeRequest(Request request) {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
shardId.writeTo(out);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_6_0)) {
assert customDataPath != null;
out.writeString(customDataPath);
}
out.writeString(customDataPath);
}

public ShardId getShardId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
Expand Down Expand Up @@ -49,25 +47,14 @@ public RemoteConnectionInfo(
}

public RemoteConnectionInfo(StreamInput input) throws IOException {
if (input.getTransportVersion().onOrAfter(TransportVersions.V_7_6_0)) {
RemoteConnectionStrategy.ConnectionStrategy mode = input.readEnum(RemoteConnectionStrategy.ConnectionStrategy.class);
modeInfo = mode.getReader().read(input);
initialConnectionTimeout = input.readTimeValue();
clusterAlias = input.readString();
skipUnavailable = input.readBoolean();
if (input.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
hasClusterCredentials = input.readBoolean();
} else {
hasClusterCredentials = false;
}
RemoteConnectionStrategy.ConnectionStrategy mode = input.readEnum(RemoteConnectionStrategy.ConnectionStrategy.class);
modeInfo = mode.getReader().read(input);
initialConnectionTimeout = input.readTimeValue();
clusterAlias = input.readString();
skipUnavailable = input.readBoolean();
if (input.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
hasClusterCredentials = input.readBoolean();
} else {
List<String> seedNodes = Arrays.asList(input.readStringArray());
int connectionsPerCluster = input.readVInt();
initialConnectionTimeout = input.readTimeValue();
int numNodesConnected = input.readVInt();
clusterAlias = input.readString();
skipUnavailable = input.readBoolean();
modeInfo = new SniffConnectionStrategy.SniffModeInfo(seedNodes, connectionsPerCluster, numNodesConnected);
hasClusterCredentials = false;
}
}
Expand All @@ -90,24 +77,9 @@ public boolean hasClusterCredentials() {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_6_0)) {
out.writeEnum(modeInfo.modeType());
modeInfo.writeTo(out);
out.writeTimeValue(initialConnectionTimeout);
} else {
if (modeInfo.modeType() == RemoteConnectionStrategy.ConnectionStrategy.SNIFF) {
SniffConnectionStrategy.SniffModeInfo sniffInfo = (SniffConnectionStrategy.SniffModeInfo) this.modeInfo;
out.writeStringCollection(sniffInfo.seedNodes);
out.writeVInt(sniffInfo.maxConnectionsPerCluster);
out.writeTimeValue(initialConnectionTimeout);
out.writeVInt(sniffInfo.numNodesConnected);
} else {
out.writeStringArray(new String[0]);
out.writeVInt(0);
out.writeTimeValue(initialConnectionTimeout);
out.writeVInt(0);
}
}
out.writeEnum(modeInfo.modeType());
modeInfo.writeTo(out);
out.writeTimeValue(initialConnectionTimeout);
out.writeString(clusterAlias);
out.writeBoolean(skipUnavailable);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ public boolean equals(Object obj) {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_6_0;
return TransportVersions.ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,7 @@ private AutoFollowPattern(
this.leaderIndexPatterns = leaderIndexPatterns;
this.followIndexPattern = followIndexPattern;
this.settings = Objects.requireNonNull(settings);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_5_0)) {
this.active = in.readBoolean();
} else {
this.active = true;
}
this.active = in.readBoolean();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_14_0)) {
this.leaderIndexExclusionPatterns = in.readStringCollectionAsList();
} else {
Expand Down Expand Up @@ -351,9 +347,7 @@ public void writeTo(StreamOutput out) throws IOException {
settings.writeTo(out);
}
super.writeTo(out);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_5_0)) {
out.writeBoolean(active);
}
out.writeBoolean(active);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_14_0)) {
out.writeStringCollection(leaderIndexExclusionPatterns);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public EnrichFeatureSetUsage(StreamInput input) throws IOException {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_5_0;
return TransportVersions.ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public EnumSet<Metadata.XContentContext> context() {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_5_0;
return TransportVersions.ZERO;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public SecurityFeatureSetUsage(StreamInput in) throws IOException {
ipFilterUsage = in.readGenericMap();
anonymousUsage = in.readGenericMap();
roleMappingStoreUsage = in.readGenericMap();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_5_0)) {
fips140Usage = in.readGenericMap();
}
fips140Usage = in.readGenericMap();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_11_0)) {
operatorPrivilegesUsage = in.readGenericMap();
}
Expand Down Expand Up @@ -129,9 +127,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeGenericMap(ipFilterUsage);
out.writeGenericMap(anonymousUsage);
out.writeGenericMap(roleMappingStoreUsage);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_5_0)) {
out.writeGenericMap(fips140Usage);
}
out.writeGenericMap(fips140Usage);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_11_0)) {
out.writeGenericMap(operatorPrivilegesUsage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package org.elasticsearch.xpack.core.security.action.saml;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.common.io.stream.StreamInput;
Expand All @@ -33,9 +32,7 @@ public SamlPrepareAuthenticationRequest(StreamInput in) throws IOException {
super(in);
realmName = in.readOptionalString();
assertionConsumerServiceURL = in.readOptionalString();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_5_0)) {
relayState = in.readOptionalString();
}
relayState = in.readOptionalString();
}

public SamlPrepareAuthenticationRequest() {}
Expand Down Expand Up @@ -87,8 +84,6 @@ public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeOptionalString(realmName);
out.writeOptionalString(assertionConsumerServiceURL);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_5_0)) {
out.writeOptionalString(relayState);
}
out.writeOptionalString(relayState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SLMFeatureSetUsage(@Nullable SnapshotLifecycleStats slmStats) {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_5_0;
return TransportVersions.ZERO;
}

public SnapshotLifecycleStats getStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public TransformFeatureSetUsage(

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_5_0;
return TransportVersions.ZERO;
}

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

package org.elasticsearch.xpack.core.transform.transforms;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.test.AbstractXContentSerializingTestCase;
import org.elasticsearch.xcontent.XContentParser;
Expand Down Expand Up @@ -66,39 +63,4 @@ protected boolean supportsUnknownFields() {
protected Predicate<String> getRandomFieldsExcludeFilter() {
return field -> field.isEmpty() == false;
}

public void testBackwardsSerialization() throws IOException {
TransformState state = new TransformState(
randomFrom(TransformTaskState.values()),
randomFrom(IndexerState.values()),
TransformIndexerPositionTests.randomTransformIndexerPosition(),
randomLongBetween(0, 10),
randomBoolean() ? null : randomAlphaOfLength(10),
randomBoolean() ? null : randomTransformProgress(),
randomBoolean() ? null : randomNodeAttributes(),
false,
randomBoolean() ? null : AuthorizationStateTests.randomAuthorizationState()
);
// auth_state will be null after BWC deserialization
TransformState expectedState = new TransformState(
state.getTaskState(),
state.getIndexerState(),
state.getPosition(),
state.getCheckpoint(),
state.getReason(),
state.getProgress(),
state.getNode(),
state.shouldStopAtNextCheckpoint(),
null
);
try (BytesStreamOutput output = new BytesStreamOutput()) {
output.setTransportVersion(TransportVersions.V_7_5_0);
state.writeTo(output);
try (StreamInput in = output.bytes().streamInput()) {
in.setTransportVersion(TransportVersions.V_7_5_0);
TransformState streamedState = new TransformState(in);
assertEquals(expectedState, streamedState);
}
}
}
}

0 comments on commit 861cebb

Please sign in to comment.