Remove LegacyESVersion.V_6_3_x constants (#1691)

This commit removes LegacyESVersion.V_6_3_x constants including all
pre-release versions and bug fixes.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
Nick Knize 2021-12-17 17:24:50 -05:00 committed by GitHub
parent 4a82eb977d
commit 3f210dcfce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 52 additions and 209 deletions

View File

@ -215,15 +215,11 @@ public class Build {
// (Integ test zip still write OSS as distribution) // (Integ test zip still write OSS as distribution)
// See issue: https://github.com/opendistro-for-elasticsearch/search/issues/159 // See issue: https://github.com/opendistro-for-elasticsearch/search/issues/159
// todo change to V_1_3_0 after backporting // todo change to V_1_3_0 after backporting
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0) && in.getVersion().before(Version.V_2_0_0)) { if (in.getVersion().before(Version.V_2_0_0)) {
String flavor = in.readString(); String flavor = in.readString();
} }
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { // be lenient when reading on the wire, the enumeration values from other versions might be different than what we know
// be lenient when reading on the wire, the enumeration values from other versions might be different than what we know type = Type.fromDisplayName(in.readString(), false);
type = Type.fromDisplayName(in.readString(), false);
} else {
type = Type.UNKNOWN;
}
String hash = in.readString(); String hash = in.readString();
String date = in.readString(); String date = in.readString();
boolean snapshot = in.readBoolean(); boolean snapshot = in.readBoolean();
@ -247,18 +243,16 @@ public class Build {
// TODO - clean up this code when we remove all v6 bwc tests. // TODO - clean up this code when we remove all v6 bwc tests.
// TODO - clean this up when OSS flavor is removed in all of the code base // TODO - clean this up when OSS flavor is removed in all of the code base
// todo change to V_1_3_0 after backporting // todo change to V_1_3_0 after backporting
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0) && out.getVersion().before(Version.V_2_0_0)) { if (out.getVersion().before(Version.V_2_0_0)) {
out.writeString("oss"); out.writeString("oss");
} }
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { final Type buildType;
final Type buildType; if (out.getVersion().before(LegacyESVersion.V_6_7_0) && build.type() == Type.DOCKER) {
if (out.getVersion().before(LegacyESVersion.V_6_7_0) && build.type() == Type.DOCKER) { buildType = Type.TAR;
buildType = Type.TAR; } else {
} else { buildType = build.type();
buildType = build.type();
}
out.writeString(buildType.displayName());
} }
out.writeString(buildType.displayName());
out.writeString(build.hash()); out.writeString(build.hash());
out.writeString(build.date()); out.writeString(build.date());
out.writeBoolean(build.isSnapshot()); out.writeBoolean(build.isSnapshot());

View File

@ -46,9 +46,6 @@ import java.lang.reflect.Field;
*/ */
public class LegacyESVersion extends Version { public class LegacyESVersion extends Version {
public static final LegacyESVersion V_6_3_0 = new LegacyESVersion(6030099, org.apache.lucene.util.Version.LUCENE_7_3_1);
public static final LegacyESVersion V_6_3_1 = new LegacyESVersion(6030199, org.apache.lucene.util.Version.LUCENE_7_3_1);
public static final LegacyESVersion V_6_3_2 = new LegacyESVersion(6030299, org.apache.lucene.util.Version.LUCENE_7_3_1);
public static final LegacyESVersion V_6_4_0 = new LegacyESVersion(6040099, org.apache.lucene.util.Version.LUCENE_7_4_0); public static final LegacyESVersion V_6_4_0 = new LegacyESVersion(6040099, org.apache.lucene.util.Version.LUCENE_7_4_0);
public static final LegacyESVersion V_6_4_1 = new LegacyESVersion(6040199, org.apache.lucene.util.Version.LUCENE_7_4_0); public static final LegacyESVersion V_6_4_1 = new LegacyESVersion(6040199, org.apache.lucene.util.Version.LUCENE_7_4_0);
public static final LegacyESVersion V_6_4_2 = new LegacyESVersion(6040299, org.apache.lucene.util.Version.LUCENE_7_4_0); public static final LegacyESVersion V_6_4_2 = new LegacyESVersion(6040299, org.apache.lucene.util.Version.LUCENE_7_4_0);

View File

@ -34,7 +34,6 @@ package org.opensearch.action.admin.cluster.reroute;
import org.opensearch.LegacyESVersion; import org.opensearch.LegacyESVersion;
import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.routing.allocation.RoutingExplanations; import org.opensearch.cluster.routing.allocation.RoutingExplanations;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -89,11 +88,7 @@ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXC
state.writeTo(out); state.writeTo(out);
RoutingExplanations.writeTo(explanations, out); RoutingExplanations.writeTo(explanations, out);
} else { } else {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { state.writeTo(out);
state.writeTo(out);
} else {
ClusterModule.filterCustomsForPre63Clients(state).writeTo(out);
}
out.writeBoolean(acknowledged); out.writeBoolean(acknowledged);
RoutingExplanations.writeTo(explanations, out); RoutingExplanations.writeTo(explanations, out);
} }

View File

@ -34,7 +34,6 @@ package org.opensearch.action.admin.cluster.state;
import org.opensearch.LegacyESVersion; import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionResponse; import org.opensearch.action.ActionResponse;
import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.node.DiscoveryNodes;
@ -105,11 +104,7 @@ public class ClusterStateResponse extends ActionResponse {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeOptionalWriteable(clusterState); out.writeOptionalWriteable(clusterState);
} else { } else {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { clusterState.writeTo(out);
clusterState.writeTo(out);
} else {
ClusterModule.filterCustomsForPre63Clients(clusterState).writeTo(out);
}
} }
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
ByteSizeValue.ZERO.writeTo(out); ByteSizeValue.ZERO.writeTo(out);

View File

@ -235,9 +235,7 @@ public class SearchRequest extends ActionRequest implements IndicesRequest.Repla
} else { } else {
preFilterShardSize = in.readVInt(); preFilterShardSize = in.readVInt();
} }
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { allowPartialSearchResults = in.readOptionalBoolean();
allowPartialSearchResults = in.readOptionalBoolean();
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
localClusterAlias = in.readOptionalString(); localClusterAlias = in.readOptionalString();
if (localClusterAlias != null) { if (localClusterAlias != null) {
@ -280,9 +278,7 @@ public class SearchRequest extends ActionRequest implements IndicesRequest.Repla
} else { } else {
out.writeVInt(preFilterShardSize == null ? DEFAULT_BATCHED_REDUCE_SIZE : preFilterShardSize); out.writeVInt(preFilterShardSize == null ? DEFAULT_BATCHED_REDUCE_SIZE : preFilterShardSize);
} }
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeOptionalBoolean(allowPartialSearchResults);
out.writeOptionalBoolean(allowPartialSearchResults);
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
out.writeOptionalString(localClusterAlias); out.writeOptionalString(localClusterAlias);
if (localClusterAlias != null) { if (localClusterAlias != null) {

View File

@ -566,11 +566,7 @@ public class ShardStateAction {
primaryTerm = in.readVLong(); primaryTerm = in.readVLong();
message = in.readString(); message = in.readString();
failure = in.readException(); failure = in.readException();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { markAsStale = in.readBoolean();
markAsStale = in.readBoolean();
} else {
markAsStale = true;
}
} }
public FailedShardEntry( public FailedShardEntry(
@ -605,9 +601,7 @@ public class ShardStateAction {
out.writeVLong(primaryTerm); out.writeVLong(primaryTerm);
out.writeString(message); out.writeString(message);
out.writeException(failure); out.writeException(failure);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeBoolean(markAsStale);
out.writeBoolean(markAsStale);
}
} }
@Override @Override
@ -825,19 +819,12 @@ public class ShardStateAction {
super(in); super(in);
shardId = new ShardId(in); shardId = new ShardId(in);
allocationId = in.readString(); allocationId = in.readString();
if (in.getVersion().before(LegacyESVersion.V_6_3_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
primaryTerm = in.readVLong();
assert primaryTerm == UNASSIGNED_PRIMARY_TERM : "shard is only started by itself: primary term [" + primaryTerm + "]";
} else if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
primaryTerm = in.readVLong(); primaryTerm = in.readVLong();
} else { } else {
primaryTerm = UNASSIGNED_PRIMARY_TERM; primaryTerm = UNASSIGNED_PRIMARY_TERM;
} }
this.message = in.readString(); this.message = in.readString();
if (in.getVersion().before(LegacyESVersion.V_6_3_0)) {
final Exception ex = in.readException();
assert ex == null : "started shard must not have failure [" + ex + "]";
}
} }
public StartedShardEntry(final ShardId shardId, final String allocationId, final long primaryTerm, final String message) { public StartedShardEntry(final ShardId shardId, final String allocationId, final long primaryTerm, final String message) {
@ -852,15 +839,10 @@ public class ShardStateAction {
super.writeTo(out); super.writeTo(out);
shardId.writeTo(out); shardId.writeTo(out);
out.writeString(allocationId); out.writeString(allocationId);
if (out.getVersion().before(LegacyESVersion.V_6_3_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
out.writeVLong(0L);
} else if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
out.writeVLong(primaryTerm); out.writeVLong(primaryTerm);
} }
out.writeString(message); out.writeString(message);
if (out.getVersion().before(LegacyESVersion.V_6_3_0)) {
out.writeException(null);
}
} }
@Override @Override

View File

@ -32,7 +32,6 @@
package org.opensearch.index.flush; package org.opensearch.index.flush;
import org.opensearch.LegacyESVersion;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable; import org.opensearch.common.io.stream.Writeable;
@ -55,9 +54,7 @@ public class FlushStats implements Writeable, ToXContentFragment {
public FlushStats(StreamInput in) throws IOException { public FlushStats(StreamInput in) throws IOException {
total = in.readVLong(); total = in.readVLong();
totalTimeInMillis = in.readVLong(); totalTimeInMillis = in.readVLong();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { periodic = in.readVLong();
periodic = in.readVLong();
}
} }
public FlushStats(long total, long periodic, long totalTimeInMillis) { public FlushStats(long total, long periodic, long totalTimeInMillis) {
@ -135,8 +132,6 @@ public class FlushStats implements Writeable, ToXContentFragment {
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(total); out.writeVLong(total);
out.writeVLong(totalTimeInMillis); out.writeVLong(totalTimeInMillis);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeVLong(periodic);
out.writeVLong(periodic);
}
} }
} }

View File

@ -693,16 +693,7 @@ public class ReplicationTracker extends AbstractIndexShardComponent implements L
this.localCheckpoint = in.readZLong(); this.localCheckpoint = in.readZLong();
this.globalCheckpoint = in.readZLong(); this.globalCheckpoint = in.readZLong();
this.inSync = in.readBoolean(); this.inSync = in.readBoolean();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { this.tracked = in.readBoolean();
this.tracked = in.readBoolean();
} else {
// Every in-sync shard copy is also tracked (see invariant). This was the case even in earlier OpenSearch versions.
// Non in-sync shard copies might be tracked or not. As this information here is only serialized during relocation hand-off,
// after which replica recoveries cannot complete anymore (i.e. they cannot move from in-sync == false to in-sync == true),
// we can treat non in-sync replica shard copies as untracked. They will go through a fresh recovery against the new
// primary and will become tracked again under this primary before they are marked as in-sync.
this.tracked = inSync;
}
} }
@Override @Override
@ -710,9 +701,7 @@ public class ReplicationTracker extends AbstractIndexShardComponent implements L
out.writeZLong(localCheckpoint); out.writeZLong(localCheckpoint);
out.writeZLong(globalCheckpoint); out.writeZLong(globalCheckpoint);
out.writeBoolean(inSync); out.writeBoolean(inSync);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeBoolean(tracked);
out.writeBoolean(tracked);
}
} }
/** /**

View File

@ -31,7 +31,6 @@
package org.opensearch.index.translog; package org.opensearch.index.translog;
import org.opensearch.LegacyESVersion;
import org.opensearch.common.Strings; import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.StreamOutput;
@ -57,9 +56,7 @@ public class TranslogStats implements Writeable, ToXContentFragment {
translogSizeInBytes = in.readVLong(); translogSizeInBytes = in.readVLong();
uncommittedOperations = in.readVInt(); uncommittedOperations = in.readVInt();
uncommittedSizeInBytes = in.readVLong(); uncommittedSizeInBytes = in.readVLong();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { earliestLastModifiedAge = in.readVLong();
earliestLastModifiedAge = in.readVLong();
}
} }
public TranslogStats( public TranslogStats(
@ -152,8 +149,6 @@ public class TranslogStats implements Writeable, ToXContentFragment {
out.writeVLong(translogSizeInBytes); out.writeVLong(translogSizeInBytes);
out.writeVInt(uncommittedOperations); out.writeVInt(uncommittedOperations);
out.writeVLong(uncommittedSizeInBytes); out.writeVLong(uncommittedSizeInBytes);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeVLong(earliestLastModifiedAge);
out.writeVLong(earliestLastModifiedAge);
}
} }
} }

View File

@ -36,7 +36,6 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.message.ParameterizedMessage;
import org.opensearch.LegacyESVersion; import org.opensearch.LegacyESVersion;
import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchException;
import org.opensearch.Version;
import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListener;
import org.opensearch.action.StepListener; import org.opensearch.action.StepListener;
import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.admin.indices.flush.FlushRequest;
@ -700,9 +699,7 @@ public class SyncedFlushService implements IndexEventListener {
super(in); super(in);
commitId = new Engine.CommitId(in); commitId = new Engine.CommitId(in);
numDocs = in.readInt(); numDocs = in.readInt();
if (includeExistingSyncId(in.getVersion())) { existingSyncId = in.readOptionalString();
existingSyncId = in.readOptionalString();
}
} }
PreSyncedFlushResponse(Engine.CommitId commitId, int numDocs, String existingSyncId) { PreSyncedFlushResponse(Engine.CommitId commitId, int numDocs, String existingSyncId) {
@ -711,17 +708,11 @@ public class SyncedFlushService implements IndexEventListener {
this.existingSyncId = existingSyncId; this.existingSyncId = existingSyncId;
} }
boolean includeExistingSyncId(Version version) {
return version.onOrAfter(LegacyESVersion.V_6_3_0);
}
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
commitId.writeTo(out); commitId.writeTo(out);
out.writeInt(numDocs); out.writeInt(numDocs);
if (includeExistingSyncId(out.getVersion())) { out.writeOptionalString(existingSyncId);
out.writeOptionalString(existingSyncId);
}
} }
} }

View File

@ -32,7 +32,6 @@
package org.opensearch.persistent; package org.opensearch.persistent;
import org.opensearch.LegacyESVersion;
import org.opensearch.ResourceAlreadyExistsException; import org.opensearch.ResourceAlreadyExistsException;
import org.opensearch.ResourceNotFoundException; import org.opensearch.ResourceNotFoundException;
import org.opensearch.Version; import org.opensearch.Version;
@ -382,11 +381,7 @@ public final class PersistentTasksCustomMetadata extends AbstractNamedDiffable<M
id = in.readString(); id = in.readString();
allocationId = in.readLong(); allocationId = in.readLong();
taskName = in.readString(); taskName = in.readString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { params = (P) in.readNamedWriteable(PersistentTaskParams.class);
params = (P) in.readNamedWriteable(PersistentTaskParams.class);
} else {
params = (P) in.readOptionalNamedWriteable(PersistentTaskParams.class);
}
state = in.readOptionalNamedWriteable(PersistentTaskState.class); state = in.readOptionalNamedWriteable(PersistentTaskState.class);
assignment = new Assignment(in.readOptionalString(), in.readString()); assignment = new Assignment(in.readOptionalString(), in.readString());
allocationIdOnLastStatusUpdate = in.readOptionalLong(); allocationIdOnLastStatusUpdate = in.readOptionalLong();
@ -397,11 +392,7 @@ public final class PersistentTasksCustomMetadata extends AbstractNamedDiffable<M
out.writeString(id); out.writeString(id);
out.writeLong(allocationId); out.writeLong(allocationId);
out.writeString(taskName); out.writeString(taskName);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeNamedWriteable(params);
out.writeNamedWriteable(params);
} else {
out.writeOptionalNamedWriteable(params);
}
out.writeOptionalNamedWriteable(state); out.writeOptionalNamedWriteable(state);
out.writeOptionalString(assignment.executorNode); out.writeOptionalString(assignment.executorNode);
out.writeString(assignment.explanation); out.writeString(assignment.explanation);

View File

@ -31,7 +31,6 @@
package org.opensearch.persistent; package org.opensearch.persistent;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListener;
import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionType; import org.opensearch.action.ActionType;
@ -83,11 +82,7 @@ public class StartPersistentTaskAction extends ActionType<PersistentTaskResponse
super(in); super(in);
taskId = in.readString(); taskId = in.readString();
taskName = in.readString(); taskName = in.readString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { params = in.readNamedWriteable(PersistentTaskParams.class);
params = in.readNamedWriteable(PersistentTaskParams.class);
} else {
params = in.readOptionalNamedWriteable(PersistentTaskParams.class);
}
} }
public Request(String taskId, String taskName, PersistentTaskParams params) { public Request(String taskId, String taskName, PersistentTaskParams params) {
@ -101,11 +96,7 @@ public class StartPersistentTaskAction extends ActionType<PersistentTaskResponse
super.writeTo(out); super.writeTo(out);
out.writeString(taskId); out.writeString(taskId);
out.writeString(taskName); out.writeString(taskName);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeNamedWriteable(params);
out.writeNamedWriteable(params);
} else {
out.writeOptionalNamedWriteable(params);
}
} }
@Override @Override

View File

@ -32,7 +32,6 @@
package org.opensearch.plugins; package org.opensearch.plugins;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version; import org.opensearch.Version;
import org.opensearch.bootstrap.JarHell; import org.opensearch.bootstrap.JarHell;
import org.opensearch.common.Strings; import org.opensearch.common.Strings;
@ -153,15 +152,8 @@ public class PluginInfo implements Writeable, ToXContentObject {
this.name = in.readString(); this.name = in.readString();
this.description = in.readString(); this.description = in.readString();
this.version = in.readString(); this.version = in.readString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { this.opensearchVersion = Version.readVersion(in);
opensearchVersion = Version.readVersion(in); this.javaVersion = in.readString();
javaVersion = in.readString();
} else {
// the plugin must have the version of whichever node we are talking to, since this is enforced on startup
opensearchVersion = in.getVersion();
// this might not be true, but it is not important, we just need something here for bwc that is a valid java version string
javaVersion = "1.8";
}
this.classname = in.readString(); this.classname = in.readString();
if (in.getVersion().onOrAfter(Version.V_1_1_0)) { if (in.getVersion().onOrAfter(Version.V_1_1_0)) {
customFolderName = in.readString(); customFolderName = in.readString();
@ -170,13 +162,6 @@ public class PluginInfo implements Writeable, ToXContentObject {
} }
extendedPlugins = in.readStringList(); extendedPlugins = in.readStringList();
hasNativeController = in.readBoolean(); hasNativeController = in.readBoolean();
if (in.getVersion().onOrAfter(LegacyESVersion.fromId(6000027)) && in.getVersion().before(LegacyESVersion.V_6_3_0)) {
/*
* Legacy versions in [6.0.0-beta2, 6.3.0) allowed plugins to specify that they require the keystore and this was
* serialized into the plugin info. Therefore, we have to read and ignore this value from the stream.
*/
in.readBoolean();
}
} }
@Override @Override
@ -184,10 +169,8 @@ public class PluginInfo implements Writeable, ToXContentObject {
out.writeString(name); out.writeString(name);
out.writeString(description); out.writeString(description);
out.writeString(version); out.writeString(version);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { Version.writeVersion(opensearchVersion, out);
Version.writeVersion(opensearchVersion, out); out.writeString(javaVersion);
out.writeString(javaVersion);
}
out.writeString(classname); out.writeString(classname);
if (out.getVersion().onOrAfter(Version.V_1_1_0)) { if (out.getVersion().onOrAfter(Version.V_1_1_0)) {
if (customFolderName != null) { if (customFolderName != null) {
@ -198,13 +181,6 @@ public class PluginInfo implements Writeable, ToXContentObject {
} }
out.writeStringCollection(extendedPlugins); out.writeStringCollection(extendedPlugins);
out.writeBoolean(hasNativeController); out.writeBoolean(hasNativeController);
if (out.getVersion().before(LegacyESVersion.V_6_3_0)) {
/*
* Elasticsearch versions in [6.0.0-beta2, 6.3.0) allowed plugins to specify that they require the keystore and this was
* serialized into the plugin info. Therefore, we have to write out a value for this boolean.
*/
out.writeBoolean(false);
}
} }
/** /**
@ -295,10 +271,6 @@ public class PluginInfo implements Writeable, ToXContentObject {
} }
} }
if (opensearchVersion.before(LegacyESVersion.V_6_3_0) && opensearchVersion.onOrAfter(LegacyESVersion.fromId(6000027))) {
propsMap.remove("requires.keystore");
}
if (propsMap.isEmpty() == false) { if (propsMap.isEmpty() == false) {
throw new IllegalArgumentException("Unknown properties in plugin descriptor: " + propsMap.keySet()); throw new IllegalArgumentException("Unknown properties in plugin descriptor: " + propsMap.keySet());
} }

View File

@ -117,6 +117,7 @@ public class InternalComposite extends InternalMultiBucketAggregation<InternalCo
if (afterKey != null) { if (afterKey != null) {
afterKey.writeTo(out); afterKey.writeTo(out);
} }
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) {
out.writeBoolean(earlyTerminated); out.writeBoolean(earlyTerminated);
} }

View File

@ -252,8 +252,6 @@ public class ShardSearchRequest extends TransportRequest implements IndicesReque
clusterAlias = in.readOptionalString(); clusterAlias = in.readOptionalString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) {
allowPartialSearchResults = in.readBoolean(); allowPartialSearchResults = in.readBoolean();
} else if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
allowPartialSearchResults = in.readOptionalBoolean();
} else { } else {
allowPartialSearchResults = false; allowPartialSearchResults = false;
} }
@ -335,8 +333,6 @@ public class ShardSearchRequest extends TransportRequest implements IndicesReque
out.writeOptionalString(clusterAlias); out.writeOptionalString(clusterAlias);
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) {
out.writeBoolean(allowPartialSearchResults); out.writeBoolean(allowPartialSearchResults);
} else if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
out.writeOptionalBoolean(allowPartialSearchResults);
} }
if (asKey == false) { if (asKey == false) {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {

View File

@ -117,23 +117,14 @@ public class SliceBuilder implements Writeable, ToXContentObject {
} }
public SliceBuilder(StreamInput in) throws IOException { public SliceBuilder(StreamInput in) throws IOException {
String field = in.readString(); this.field = in.readString();
if ("_uid".equals(field) && in.getVersion().before(LegacyESVersion.V_6_3_0)) {
// This is safe because _id and _uid are handled the same way in #toFilter
field = IdFieldMapper.NAME;
}
this.field = field;
this.id = in.readVInt(); this.id = in.readVInt();
this.max = in.readVInt(); this.max = in.readVInt();
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (IdFieldMapper.NAME.equals(field) && out.getVersion().before(LegacyESVersion.V_6_3_0)) { out.writeString(field);
out.writeString("_uid");
} else {
out.writeString(field);
}
out.writeVInt(id); out.writeVInt(id);
out.writeVInt(max); out.writeVInt(max);
} }

View File

@ -32,7 +32,6 @@
package org.opensearch.transport; package org.opensearch.transport;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version; import org.opensearch.Version;
import org.opensearch.common.collect.Tuple; import org.opensearch.common.collect.Tuple;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -121,15 +120,11 @@ public class Header {
this.headers = ThreadContext.readHeadersFromStream(input); this.headers = ThreadContext.readHeadersFromStream(input);
if (isRequest()) { if (isRequest()) {
if (version.onOrAfter(LegacyESVersion.V_6_3_0)) { final String[] featuresFound = input.readStringArray();
final String[] featuresFound = input.readStringArray(); if (featuresFound.length == 0) {
if (featuresFound.length == 0) {
features = Collections.emptySet();
} else {
features = Collections.unmodifiableSet(new TreeSet<>(Arrays.asList(featuresFound)));
}
} else {
features = Collections.emptySet(); features = Collections.emptySet();
} else {
features = Collections.unmodifiableSet(new TreeSet<>(Arrays.asList(featuresFound)));
} }
this.actionName = input.readString(); this.actionName = input.readString();
} else { } else {

View File

@ -31,7 +31,6 @@
package org.opensearch.transport; package org.opensearch.transport;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version; import org.opensearch.Version;
import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesArray;
import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.bytes.BytesReference;
@ -136,9 +135,7 @@ abstract class OutboundMessage extends NetworkMessage {
@Override @Override
protected void writeVariableHeader(StreamOutput stream) throws IOException { protected void writeVariableHeader(StreamOutput stream) throws IOException {
super.writeVariableHeader(stream); super.writeVariableHeader(stream);
if (version.onOrAfter(LegacyESVersion.V_6_3_0)) { stream.writeStringArray(features);
stream.writeStringArray(features);
}
stream.writeString(action); stream.writeString(action);
} }

View File

@ -33,7 +33,6 @@ package org.opensearch.transport;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version; import org.opensearch.Version;
import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.bytes.BytesReference;
import org.opensearch.common.compress.CompressorFactory; import org.opensearch.common.compress.CompressorFactory;
@ -120,10 +119,8 @@ public final class TransportLogger {
ThreadContext.readHeadersFromStream(streamInput); ThreadContext.readHeadersFromStream(streamInput);
if (isRequest) { if (isRequest) {
if (streamInput.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { // discard features
// discard features streamInput.readStringArray();
streamInput.readStringArray();
}
sb.append(", action: ").append(streamInput.readString()); sb.append(", action: ").append(streamInput.readString());
} }
sb.append(']'); sb.append(']');

View File

@ -301,9 +301,7 @@ public class BuildTests extends OpenSearchTestCase {
final List<Version> versions = Version.getDeclaredVersions(LegacyESVersion.class); final List<Version> versions = Version.getDeclaredVersions(LegacyESVersion.class);
final Version post63Pre67Version = randomFrom( final Version post63Pre67Version = randomFrom(
versions.stream() versions.stream().filter(v -> v.before(LegacyESVersion.V_6_7_0)).collect(Collectors.toList())
.filter(v -> v.onOrAfter(LegacyESVersion.V_6_3_0) && v.before(LegacyESVersion.V_6_7_0))
.collect(Collectors.toList())
); );
final Version post67Pre70Version = randomFrom( final Version post67Pre70Version = randomFrom(
versions.stream() versions.stream()

View File

@ -64,8 +64,8 @@ public class LegacyESVersionTests extends OpenSearchTestCase {
// compare opensearch version to LegacyESVersion // compare opensearch version to LegacyESVersion
assertThat(Version.V_1_0_0.compareMajor(LegacyESVersion.V_7_0_0), is(0)); assertThat(Version.V_1_0_0.compareMajor(LegacyESVersion.V_7_0_0), is(0));
assertThat(Version.V_1_0_0.compareMajor(LegacyESVersion.V_6_3_0), is(1)); assertThat(Version.V_1_0_0.compareMajor(LegacyESVersion.fromString("6.3.0")), is(1));
assertThat(LegacyESVersion.V_6_3_0.compareMajor(Version.V_1_0_0), is(-1)); assertThat(LegacyESVersion.fromString("6.3.0").compareMajor(Version.V_1_0_0), is(-1));
} }
public void testMin() { public void testMin() {
@ -143,7 +143,7 @@ public class LegacyESVersionTests extends OpenSearchTestCase {
Version major56x = LegacyESVersion.fromString("5.6.0"); Version major56x = LegacyESVersion.fromString("5.6.0");
assertThat(LegacyESVersion.V_6_5_0.minimumCompatibilityVersion(), equalTo(major56x)); assertThat(LegacyESVersion.V_6_5_0.minimumCompatibilityVersion(), equalTo(major56x));
assertThat(LegacyESVersion.V_6_3_1.minimumCompatibilityVersion(), equalTo(major56x)); assertThat(LegacyESVersion.fromString("6.3.1").minimumCompatibilityVersion(), equalTo(major56x));
// from 7.0 on we are supporting the latest minor of the previous major... this might fail once we add a new version ie. 5.x is // from 7.0 on we are supporting the latest minor of the previous major... this might fail once we add a new version ie. 5.x is
// released since we need to bump the supported minor in Version#minimumCompatibilityVersion() // released since we need to bump the supported minor in Version#minimumCompatibilityVersion()

View File

@ -40,6 +40,7 @@ import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.VersionUtils;
import java.util.Locale; import java.util.Locale;
@ -77,7 +78,7 @@ public class ClusterHealthRequestTests extends OpenSearchTestCase {
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) { for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
// Generate a random cluster health request in version < 7.2.0 and serializes it // Generate a random cluster health request in version < 7.2.0 and serializes it
final BytesStreamOutput out = new BytesStreamOutput(); final BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(randomVersionBetween(random(), LegacyESVersion.V_6_3_0, getPreviousVersion(LegacyESVersion.V_7_2_0))); out.setVersion(randomVersionBetween(random(), VersionUtils.getFirstVersion(), getPreviousVersion(LegacyESVersion.V_7_2_0)));
final ClusterHealthRequest expected = randomRequest(); final ClusterHealthRequest expected = randomRequest();
{ {
@ -132,7 +133,7 @@ public class ClusterHealthRequestTests extends OpenSearchTestCase {
// Serialize to node in version < 7.2.0 // Serialize to node in version < 7.2.0
final BytesStreamOutput out = new BytesStreamOutput(); final BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(randomVersionBetween(random(), LegacyESVersion.V_6_3_0, getPreviousVersion(LegacyESVersion.V_7_2_0))); out.setVersion(randomVersionBetween(random(), VersionUtils.getFirstVersion(), getPreviousVersion(LegacyESVersion.V_7_2_0)));
expected.writeTo(out); expected.writeTo(out);
// Deserialize and check the cluster health request // Deserialize and check the cluster health request

View File

@ -42,7 +42,6 @@ import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.ByteBuffersDirectory;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version; import org.opensearch.Version;
import org.opensearch.action.OriginalIndices; import org.opensearch.action.OriginalIndices;
import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchRequest;
@ -361,21 +360,6 @@ public class SliceBuilderTests extends OpenSearchTestCase {
} }
} }
public void testToFilterDeprecationMessage() throws IOException {
Directory dir = new ByteBuffersDirectory();
try (IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())))) {
writer.commit();
}
try (IndexReader reader = DirectoryReader.open(dir)) {
QueryShardContext context = createShardContext(LegacyESVersion.V_6_3_0, reader, "_uid", null, 1, 0);
SliceBuilder builder = new SliceBuilder("_uid", 5, 10);
Query query = builder.toFilter(null, createRequest(0), context, Version.CURRENT);
assertThat(query, instanceOf(TermsSliceQuery.class));
assertThat(builder.toFilter(null, createRequest(0), context, Version.CURRENT), equalTo(query));
assertWarnings("Computing slices on the [_uid] field is deprecated for 6.x indices, use [_id] instead");
}
}
public void testToFilterWithRouting() throws IOException { public void testToFilterWithRouting() throws IOException {
Directory dir = new ByteBuffersDirectory(); Directory dir = new ByteBuffersDirectory();
try (IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())))) { try (IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())))) {

View File

@ -136,7 +136,7 @@ public class SetupSectionTests extends AbstractClientYamlTestFragmentParserTestC
assertThat(setupSection.getSkipSection().isEmpty(), equalTo(false)); assertThat(setupSection.getSkipSection().isEmpty(), equalTo(false));
assertThat(setupSection.getSkipSection(), notNullValue()); assertThat(setupSection.getSkipSection(), notNullValue());
assertThat(setupSection.getSkipSection().getLowerVersion(), equalTo(LegacyESVersion.fromString("6.0.0"))); assertThat(setupSection.getSkipSection().getLowerVersion(), equalTo(LegacyESVersion.fromString("6.0.0")));
assertThat(setupSection.getSkipSection().getUpperVersion(), equalTo(LegacyESVersion.V_6_3_0)); assertThat(setupSection.getSkipSection().getUpperVersion(), equalTo(LegacyESVersion.fromString("6.3.0")));
assertThat(setupSection.getSkipSection().getReason(), equalTo("Update doesn't return metadata fields, waiting for #3259")); assertThat(setupSection.getSkipSection().getReason(), equalTo("Update doesn't return metadata fields, waiting for #3259"));
assertThat(setupSection.getExecutableSections().size(), equalTo(2)); assertThat(setupSection.getExecutableSections().size(), equalTo(2));
assertThat(setupSection.getExecutableSections().get(0), instanceOf(DoSection.class)); assertThat(setupSection.getExecutableSections().get(0), instanceOf(DoSection.class));