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 LegacyESVersion.V_6_3_x constants #1691

Merged
merged 1 commit into from
Dec 17, 2021
Merged
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
26 changes: 10 additions & 16 deletions server/src/main/java/org/opensearch/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,11 @@ public static Build readBuild(StreamInput in) throws IOException {
// (Integ test zip still write OSS as distribution)
// See issue: https://github.com/opendistro-for-elasticsearch/search/issues/159
// 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();
}
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
type = Type.fromDisplayName(in.readString(), false);
} else {
type = Type.UNKNOWN;
}
// 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);
String hash = in.readString();
String date = in.readString();
boolean snapshot = in.readBoolean();
Expand All @@ -247,18 +243,16 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException
// 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 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");
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
final Type buildType;
if (out.getVersion().before(LegacyESVersion.V_6_7_0) && build.type() == Type.DOCKER) {
buildType = Type.TAR;
} else {
buildType = build.type();
}
out.writeString(buildType.displayName());
final Type buildType;
if (out.getVersion().before(LegacyESVersion.V_6_7_0) && build.type() == Type.DOCKER) {
buildType = Type.TAR;
} else {
buildType = build.type();
}
out.writeString(buildType.displayName());
out.writeString(build.hash());
out.writeString(build.date());
out.writeBoolean(build.isSnapshot());
Expand Down
3 changes: 0 additions & 3 deletions server/src/main/java/org/opensearch/LegacyESVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
*/
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_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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import org.opensearch.LegacyESVersion;
import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.routing.allocation.RoutingExplanations;
import org.opensearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -89,11 +88,7 @@ public void writeTo(StreamOutput out) throws IOException {
state.writeTo(out);
RoutingExplanations.writeTo(explanations, out);
} else {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
state.writeTo(out);
} else {
ClusterModule.filterCustomsForPre63Clients(state).writeTo(out);
}
state.writeTo(out);
out.writeBoolean(acknowledged);
RoutingExplanations.writeTo(explanations, out);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionResponse;
import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.node.DiscoveryNodes;
Expand Down Expand Up @@ -105,11 +104,7 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeOptionalWriteable(clusterState);
} else {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
clusterState.writeTo(out);
} else {
ClusterModule.filterCustomsForPre63Clients(clusterState).writeTo(out);
}
clusterState.writeTo(out);
}
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
ByteSizeValue.ZERO.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ public SearchRequest(StreamInput in) throws IOException {
} else {
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)) {
localClusterAlias = in.readOptionalString();
if (localClusterAlias != null) {
Expand Down Expand Up @@ -280,9 +278,7 @@ public void writeTo(StreamOutput out) throws IOException {
} else {
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)) {
out.writeOptionalString(localClusterAlias);
if (localClusterAlias != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,7 @@ public static class FailedShardEntry extends TransportRequest {
primaryTerm = in.readVLong();
message = in.readString();
failure = in.readException();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
markAsStale = in.readBoolean();
} else {
markAsStale = true;
}
markAsStale = in.readBoolean();
}

public FailedShardEntry(
Expand Down Expand Up @@ -605,9 +601,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(primaryTerm);
out.writeString(message);
out.writeException(failure);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
out.writeBoolean(markAsStale);
}
out.writeBoolean(markAsStale);
}

@Override
Expand Down Expand Up @@ -825,19 +819,12 @@ public static class StartedShardEntry extends TransportRequest {
super(in);
shardId = new ShardId(in);
allocationId = in.readString();
if (in.getVersion().before(LegacyESVersion.V_6_3_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)) {
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
primaryTerm = in.readVLong();
} else {
primaryTerm = UNASSIGNED_PRIMARY_TERM;
}
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) {
Expand All @@ -852,15 +839,10 @@ public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
shardId.writeTo(out);
out.writeString(allocationId);
if (out.getVersion().before(LegacyESVersion.V_6_3_0)) {
out.writeVLong(0L);
} else if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) {
out.writeVLong(primaryTerm);
}
out.writeString(message);
if (out.getVersion().before(LegacyESVersion.V_6_3_0)) {
out.writeException(null);
}
}

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

package org.opensearch.index.flush;

import org.opensearch.LegacyESVersion;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;
Expand All @@ -55,9 +54,7 @@ public FlushStats() {
public FlushStats(StreamInput in) throws IOException {
total = 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) {
Expand Down Expand Up @@ -135,8 +132,6 @@ static final class Fields {
public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(total);
out.writeVLong(totalTimeInMillis);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
out.writeVLong(periodic);
}
out.writeVLong(periodic);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -693,26 +693,15 @@ public CheckpointState(StreamInput in) throws IOException {
this.localCheckpoint = in.readZLong();
this.globalCheckpoint = in.readZLong();
this.inSync = in.readBoolean();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
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;
}
this.tracked = in.readBoolean();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeZLong(localCheckpoint);
out.writeZLong(globalCheckpoint);
out.writeBoolean(inSync);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
out.writeBoolean(tracked);
}
out.writeBoolean(tracked);
}

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

package org.opensearch.index.translog;

import org.opensearch.LegacyESVersion;
import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
Expand All @@ -57,9 +56,7 @@ public TranslogStats(StreamInput in) throws IOException {
translogSizeInBytes = in.readVLong();
uncommittedOperations = in.readVInt();
uncommittedSizeInBytes = in.readVLong();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
earliestLastModifiedAge = in.readVLong();
}
earliestLastModifiedAge = in.readVLong();
}

public TranslogStats(
Expand Down Expand Up @@ -152,8 +149,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(translogSizeInBytes);
out.writeVInt(uncommittedOperations);
out.writeVLong(uncommittedSizeInBytes);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
out.writeVLong(earliestLastModifiedAge);
}
out.writeVLong(earliestLastModifiedAge);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.opensearch.LegacyESVersion;
import org.opensearch.OpenSearchException;
import org.opensearch.Version;
import org.opensearch.action.ActionListener;
import org.opensearch.action.StepListener;
import org.opensearch.action.admin.indices.flush.FlushRequest;
Expand Down Expand Up @@ -700,9 +699,7 @@ static final class PreSyncedFlushResponse extends TransportResponse {
super(in);
commitId = new Engine.CommitId(in);
numDocs = in.readInt();
if (includeExistingSyncId(in.getVersion())) {
existingSyncId = in.readOptionalString();
}
existingSyncId = in.readOptionalString();
}

PreSyncedFlushResponse(Engine.CommitId commitId, int numDocs, String existingSyncId) {
Expand All @@ -711,17 +708,11 @@ static final class PreSyncedFlushResponse extends TransportResponse {
this.existingSyncId = existingSyncId;
}

boolean includeExistingSyncId(Version version) {
return version.onOrAfter(LegacyESVersion.V_6_3_0);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
commitId.writeTo(out);
out.writeInt(numDocs);
if (includeExistingSyncId(out.getVersion())) {
out.writeOptionalString(existingSyncId);
}
out.writeOptionalString(existingSyncId);
}
}

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

package org.opensearch.persistent;

import org.opensearch.LegacyESVersion;
import org.opensearch.ResourceAlreadyExistsException;
import org.opensearch.ResourceNotFoundException;
import org.opensearch.Version;
Expand Down Expand Up @@ -382,11 +381,7 @@ public PersistentTask(StreamInput in) throws IOException {
id = in.readString();
allocationId = in.readLong();
taskName = in.readString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
params = (P) in.readNamedWriteable(PersistentTaskParams.class);
} else {
params = (P) in.readOptionalNamedWriteable(PersistentTaskParams.class);
}
params = (P) in.readNamedWriteable(PersistentTaskParams.class);
state = in.readOptionalNamedWriteable(PersistentTaskState.class);
assignment = new Assignment(in.readOptionalString(), in.readString());
allocationIdOnLastStatusUpdate = in.readOptionalLong();
Expand All @@ -397,11 +392,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(id);
out.writeLong(allocationId);
out.writeString(taskName);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
out.writeNamedWriteable(params);
} else {
out.writeOptionalNamedWriteable(params);
}
out.writeNamedWriteable(params);
out.writeOptionalNamedWriteable(state);
out.writeOptionalString(assignment.executorNode);
out.writeString(assignment.explanation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

package org.opensearch.persistent;

import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionListener;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionType;
Expand Down Expand Up @@ -83,11 +82,7 @@ public Request(StreamInput in) throws IOException {
super(in);
taskId = in.readString();
taskName = in.readString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
params = in.readNamedWriteable(PersistentTaskParams.class);
} else {
params = in.readOptionalNamedWriteable(PersistentTaskParams.class);
}
params = in.readNamedWriteable(PersistentTaskParams.class);
}

public Request(String taskId, String taskName, PersistentTaskParams params) {
Expand All @@ -101,11 +96,7 @@ public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeString(taskId);
out.writeString(taskName);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) {
out.writeNamedWriteable(params);
} else {
out.writeOptionalNamedWriteable(params);
}
out.writeNamedWriteable(params);
}

@Override
Expand Down
Loading