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_4_x constants #1787

Merged
merged 1 commit into from
Dec 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.opensearch.LegacyESVersion;
import org.apache.lucene.store.ByteBuffersDirectory;
import org.apache.lucene.store.Directory;
import org.opensearch.action.ActionRequestValidationException;
Expand Down Expand Up @@ -314,15 +313,8 @@ static Request parse(XContentParser parser) throws IOException {
Request(StreamInput in) throws IOException {
super(in);
script = new Script(in);
if (in.getVersion().before(LegacyESVersion.V_6_4_0)) {
byte scriptContextId = in.readByte();
assert scriptContextId == 0;
context = null;
contextSetup = null;
} else {
context = fromScriptContextName(in.readString());
contextSetup = in.readOptionalWriteable(ContextSetup::new);
}
context = fromScriptContextName(in.readString());
contextSetup = in.readOptionalWriteable(ContextSetup::new);
}

public Script getScript() {
Expand Down Expand Up @@ -358,12 +350,8 @@ public ActionRequestValidationException validate() {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
script.writeTo(out);
if (out.getVersion().before(LegacyESVersion.V_6_4_0)) {
out.writeByte((byte) 0);
} else {
out.writeString(context.name);
out.writeOptionalWriteable(contextSetup);
}
out.writeString(context.name);
out.writeOptionalWriteable(contextSetup);
}

// For testing only:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public void testShrink() throws IOException {
client().performRequest(updateSettingsRequest);

Request shrinkIndexRequest = new Request("PUT", "/" + index + "/_shrink/" + shrunkenIndex);
if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_4_0) && getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) {
if (getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) {
shrinkIndexRequest.addParameter("copy_settings", "true");
}
shrinkIndexRequest.setJsonEntity("{\"settings\": {\"index.number_of_shards\": 1}}");
Expand Down
4 changes: 0 additions & 4 deletions server/src/main/java/org/opensearch/LegacyESVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
*/
public class LegacyESVersion extends Version {

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);
public static final LegacyESVersion V_6_4_3 = new LegacyESVersion(6040399, org.apache.lucene.util.Version.LUCENE_7_4_0);
public static final LegacyESVersion V_6_5_0 = new LegacyESVersion(6050099, org.apache.lucene.util.Version.LUCENE_7_5_0);
public static final LegacyESVersion V_6_5_1 = new LegacyESVersion(6050199, org.apache.lucene.util.Version.LUCENE_7_5_0);
public static final LegacyESVersion V_6_5_2 = new LegacyESVersion(6050299, org.apache.lucene.util.Version.LUCENE_7_5_0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

package org.opensearch.action.admin.cluster.reroute;

import org.opensearch.LegacyESVersion;
import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.routing.allocation.RoutingExplanations;
Expand All @@ -53,15 +52,9 @@ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXC
private final RoutingExplanations explanations;

ClusterRerouteResponse(StreamInput in) throws IOException {
super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0));
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
state = ClusterState.readFrom(in, null);
explanations = RoutingExplanations.readFrom(in);
} else {
state = ClusterState.readFrom(in, null);
acknowledged = in.readBoolean();
explanations = RoutingExplanations.readFrom(in);
}
super(in);
state = ClusterState.readFrom(in, null);
explanations = RoutingExplanations.readFrom(in);
}

ClusterRerouteResponse(boolean acknowledged, ClusterState state, RoutingExplanations explanations) {
Expand All @@ -83,15 +76,9 @@ public RoutingExplanations getExplanations() {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
super.writeTo(out);
state.writeTo(out);
RoutingExplanations.writeTo(explanations, out);
} else {
state.writeTo(out);
out.writeBoolean(acknowledged);
RoutingExplanations.writeTo(explanations, out);
}
super.writeTo(out);
state.writeTo(out);
RoutingExplanations.writeTo(explanations, out);
}

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

package org.opensearch.action.admin.cluster.settings;

import org.opensearch.LegacyESVersion;
import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.common.ParseField;
import org.opensearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -70,15 +69,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse {
final Settings persistentSettings;

ClusterUpdateSettingsResponse(StreamInput in) throws IOException {
super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0));
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in);
} else {
transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in);
acknowledged = in.readBoolean();
}
super(in);
transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in);
}

ClusterUpdateSettingsResponse(boolean acknowledged, Settings transientSettings, Settings persistentSettings) {
Expand All @@ -97,15 +90,9 @@ public Settings getPersistentSettings() {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
super.writeTo(out);
Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out);
} else {
Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out);
out.writeBoolean(acknowledged);
}
super.writeTo(out);
Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out);
}

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

package org.opensearch.action.admin.cluster.snapshots.status;

import org.opensearch.LegacyESVersion;
import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -70,13 +69,8 @@ public class SnapshotStats implements Writeable, ToXContentObject {
incrementalSize = in.readVLong();
processedSize = in.readVLong();

if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
totalFileCount = in.readVInt();
totalSize = in.readVLong();
} else {
totalFileCount = incrementalFileCount;
totalSize = incrementalSize;
}
totalFileCount = in.readVInt();
totalSize = in.readVLong();
}

SnapshotStats(
Expand Down Expand Up @@ -167,10 +161,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(incrementalSize);
out.writeVLong(processedSize);

if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeVInt(totalFileCount);
out.writeVLong(totalSize);
}
out.writeVInt(totalFileCount);
out.writeVLong(totalSize);
}

static final class Fields {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

package org.opensearch.action.admin.cluster.storedscripts;

import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionResponse;
import org.opensearch.common.ParseField;
import org.opensearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -91,9 +90,7 @@ public GetStoredScriptResponse(StreamInput in) throws IOException {
source = null;
}

if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
id = in.readString();
}
id = in.readString();
}

GetStoredScriptResponse(String id, StoredScriptSource source) {
Expand Down Expand Up @@ -144,9 +141,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(true);
source.writeTo(out);
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeString(id);
}
out.writeString(id);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ public Alias(StreamInput in) throws IOException {
filter = in.readOptionalString();
indexRouting = in.readOptionalString();
searchRouting = in.readOptionalString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
writeIndex = in.readOptionalBoolean();
} else {
writeIndex = null;
}
writeIndex = in.readOptionalBoolean();
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
isHidden = in.readOptionalBoolean();
} else {
Expand Down Expand Up @@ -237,9 +233,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(filter);
out.writeOptionalString(indexRouting);
out.writeOptionalString(searchRouting);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalBoolean(writeIndex);
}
out.writeOptionalBoolean(writeIndex);
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
out.writeOptionalBoolean(isHidden);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ public AliasActions(StreamInput in) throws IOException {
routing = in.readOptionalString();
searchRouting = in.readOptionalString();
indexRouting = in.readOptionalString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
writeIndex = in.readOptionalBoolean();
}
writeIndex = in.readOptionalBoolean();
// TODO fix for backport of https://github.com/elastic/elasticsearch/pull/52547
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
isHidden = in.readOptionalBoolean();
Expand All @@ -296,9 +294,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(routing);
out.writeOptionalString(searchRouting);
out.writeOptionalString(indexRouting);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalBoolean(writeIndex);
}
out.writeOptionalBoolean(writeIndex);
// TODO fix for backport https://github.com/elastic/elasticsearch/pull/52547
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
out.writeOptionalBoolean(isHidden);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

package org.opensearch.action.admin.indices.alias.get;

import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.AliasesRequest;
import org.opensearch.action.support.IndicesOptions;
Expand Down Expand Up @@ -61,9 +60,7 @@ public GetAliasesRequest(StreamInput in) throws IOException {
indices = in.readStringArray();
aliases = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
originalAliases = in.readStringArray();
}
originalAliases = in.readStringArray();
}

@Override
Expand All @@ -72,9 +69,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeStringArray(indices);
out.writeStringArray(aliases);
indicesOptions.writeIndicesOptions(out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeStringArray(originalAliases);
}
out.writeStringArray(originalAliases);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class CloseIndexResponse extends ShardsAcknowledgedResponse {
private final List<IndexResult> indices;

CloseIndexResponse(StreamInput in) throws IOException {
super(in, in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0), true);
super(in, in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0));
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) {
indices = unmodifiableList(in.readList(IndexResult::new));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected static <T extends CreateIndexResponse> void declareFields(Constructing
private final String index;

protected CreateIndexResponse(StreamInput in) throws IOException {
super(in, true, true);
super(in, true);
index = in.readString();
}

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

package org.opensearch.action.admin.indices.get;

import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.master.info.ClusterInfoRequest;
import org.opensearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -90,9 +89,7 @@ public GetIndexRequest(StreamInput in) throws IOException {
super(in);
features = in.readArray(i -> Feature.fromId(i.readByte()), Feature[]::new);
humanReadable = in.readBoolean();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
includeDefaults = in.readBoolean();
}
includeDefaults = in.readBoolean();
}

public GetIndexRequest features(Feature... features) {
Expand Down Expand Up @@ -156,9 +153,7 @@ public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeArray((o, f) -> o.writeByte(f.id), features);
out.writeBoolean(humanReadable);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeBoolean(includeDefaults);
}
out.writeBoolean(includeDefaults);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class OpenIndexResponse extends ShardsAcknowledgedResponse {
}

public OpenIndexResponse(StreamInput in) throws IOException {
super(in, true, true);
super(in, true);
}

public OpenIndexResponse(boolean acknowledged, boolean shardsAcknowledged) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class AddIndexBlockResponse extends ShardsAcknowledgedResponse {
private final List<AddBlockResult> indices;

AddIndexBlockResponse(StreamInput in) throws IOException {
super(in, true, true);
super(in, true);
indices = unmodifiableList(in.readList(AddBlockResult::new));
}

Expand Down
Loading