Remove LegacyVersion.v6.4.x constants (#1787)

This commit removes the `LegacyVersion.v6.4.x` constants and their usages, since we no longer need to support those in OpenSearch 2.0 onwards.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-12-23 16:54:37 -08:00 committed by GitHub
parent daf2b66481
commit 8b076b81ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 109 additions and 385 deletions

View File

@ -42,7 +42,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Scorer; import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight; import org.apache.lucene.search.Weight;
import org.opensearch.LegacyESVersion;
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.action.ActionRequestValidationException; import org.opensearch.action.ActionRequestValidationException;
@ -314,16 +313,9 @@ public class PainlessExecuteAction extends ActionType<PainlessExecuteAction.Resp
Request(StreamInput in) throws IOException { Request(StreamInput in) throws IOException {
super(in); super(in);
script = new Script(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()); context = fromScriptContextName(in.readString());
contextSetup = in.readOptionalWriteable(ContextSetup::new); contextSetup = in.readOptionalWriteable(ContextSetup::new);
} }
}
public Script getScript() { public Script getScript() {
return script; return script;
@ -358,13 +350,9 @@ public class PainlessExecuteAction extends ActionType<PainlessExecuteAction.Resp
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
script.writeTo(out); script.writeTo(out);
if (out.getVersion().before(LegacyESVersion.V_6_4_0)) {
out.writeByte((byte) 0);
} else {
out.writeString(context.name); out.writeString(context.name);
out.writeOptionalWriteable(contextSetup); out.writeOptionalWriteable(contextSetup);
} }
}
// For testing only: // For testing only:
@Override @Override

View File

@ -351,7 +351,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
client().performRequest(updateSettingsRequest); client().performRequest(updateSettingsRequest);
Request shrinkIndexRequest = new Request("PUT", "/" + index + "/_shrink/" + shrunkenIndex); 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.addParameter("copy_settings", "true");
} }
shrinkIndexRequest.setJsonEntity("{\"settings\": {\"index.number_of_shards\": 1}}"); shrinkIndexRequest.setJsonEntity("{\"settings\": {\"index.number_of_shards\": 1}}");

View File

@ -46,10 +46,6 @@ import java.lang.reflect.Field;
*/ */
public class LegacyESVersion extends Version { 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_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_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); public static final LegacyESVersion V_6_5_2 = new LegacyESVersion(6050299, org.apache.lucene.util.Version.LUCENE_7_5_0);

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.cluster.reroute; package org.opensearch.action.admin.cluster.reroute;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.routing.allocation.RoutingExplanations; import org.opensearch.cluster.routing.allocation.RoutingExplanations;
@ -53,15 +52,9 @@ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXC
private final RoutingExplanations explanations; private final RoutingExplanations explanations;
ClusterRerouteResponse(StreamInput in) throws IOException { ClusterRerouteResponse(StreamInput in) throws IOException {
super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); super(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
state = ClusterState.readFrom(in, null); state = ClusterState.readFrom(in, null);
explanations = RoutingExplanations.readFrom(in); explanations = RoutingExplanations.readFrom(in);
} else {
state = ClusterState.readFrom(in, null);
acknowledged = in.readBoolean();
explanations = RoutingExplanations.readFrom(in);
}
} }
ClusterRerouteResponse(boolean acknowledged, ClusterState state, RoutingExplanations explanations) { ClusterRerouteResponse(boolean acknowledged, ClusterState state, RoutingExplanations explanations) {
@ -83,15 +76,9 @@ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXC
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
super.writeTo(out); super.writeTo(out);
state.writeTo(out); state.writeTo(out);
RoutingExplanations.writeTo(explanations, out); RoutingExplanations.writeTo(explanations, out);
} else {
state.writeTo(out);
out.writeBoolean(acknowledged);
RoutingExplanations.writeTo(explanations, out);
}
} }
@Override @Override

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.cluster.settings; package org.opensearch.action.admin.cluster.settings;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.common.ParseField; import org.opensearch.common.ParseField;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -70,15 +69,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse {
final Settings persistentSettings; final Settings persistentSettings;
ClusterUpdateSettingsResponse(StreamInput in) throws IOException { ClusterUpdateSettingsResponse(StreamInput in) throws IOException {
super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); super(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
transientSettings = Settings.readSettingsFromStream(in); transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in); persistentSettings = Settings.readSettingsFromStream(in);
} else {
transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in);
acknowledged = in.readBoolean();
}
} }
ClusterUpdateSettingsResponse(boolean acknowledged, Settings transientSettings, Settings persistentSettings) { ClusterUpdateSettingsResponse(boolean acknowledged, Settings transientSettings, Settings persistentSettings) {
@ -97,15 +90,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
super.writeTo(out); super.writeTo(out);
Settings.writeSettingsToStream(transientSettings, out); Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out); Settings.writeSettingsToStream(persistentSettings, out);
} else {
Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out);
out.writeBoolean(acknowledged);
}
} }
@Override @Override

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.cluster.snapshots.status; package org.opensearch.action.admin.cluster.snapshots.status;
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;
@ -70,13 +69,8 @@ public class SnapshotStats implements Writeable, ToXContentObject {
incrementalSize = in.readVLong(); incrementalSize = in.readVLong();
processedSize = in.readVLong(); processedSize = in.readVLong();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
totalFileCount = in.readVInt(); totalFileCount = in.readVInt();
totalSize = in.readVLong(); totalSize = in.readVLong();
} else {
totalFileCount = incrementalFileCount;
totalSize = incrementalSize;
}
} }
SnapshotStats( SnapshotStats(
@ -167,11 +161,9 @@ public class SnapshotStats implements Writeable, ToXContentObject {
out.writeVLong(incrementalSize); out.writeVLong(incrementalSize);
out.writeVLong(processedSize); out.writeVLong(processedSize);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeVInt(totalFileCount); out.writeVInt(totalFileCount);
out.writeVLong(totalSize); out.writeVLong(totalSize);
} }
}
static final class Fields { static final class Fields {
static final String STATS = "stats"; static final String STATS = "stats";

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.cluster.storedscripts; package org.opensearch.action.admin.cluster.storedscripts;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionResponse; import org.opensearch.action.ActionResponse;
import org.opensearch.common.ParseField; import org.opensearch.common.ParseField;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -91,10 +90,8 @@ public class GetStoredScriptResponse extends ActionResponse implements StatusToX
source = null; source = null;
} }
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
id = in.readString(); id = in.readString();
} }
}
GetStoredScriptResponse(String id, StoredScriptSource source) { GetStoredScriptResponse(String id, StoredScriptSource source) {
this.id = id; this.id = id;
@ -144,10 +141,8 @@ public class GetStoredScriptResponse extends ActionResponse implements StatusToX
out.writeBoolean(true); out.writeBoolean(true);
source.writeTo(out); source.writeTo(out);
} }
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeString(id); out.writeString(id);
} }
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {

View File

@ -87,11 +87,7 @@ public class Alias implements Writeable, ToXContentFragment {
filter = in.readOptionalString(); filter = in.readOptionalString();
indexRouting = in.readOptionalString(); indexRouting = in.readOptionalString();
searchRouting = in.readOptionalString(); searchRouting = in.readOptionalString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
writeIndex = in.readOptionalBoolean(); writeIndex = in.readOptionalBoolean();
} else {
writeIndex = null;
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
isHidden = in.readOptionalBoolean(); isHidden = in.readOptionalBoolean();
} else { } else {
@ -237,9 +233,7 @@ public class Alias implements Writeable, ToXContentFragment {
out.writeOptionalString(filter); out.writeOptionalString(filter);
out.writeOptionalString(indexRouting); out.writeOptionalString(indexRouting);
out.writeOptionalString(searchRouting); 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)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
out.writeOptionalBoolean(isHidden); out.writeOptionalBoolean(isHidden);
} }

View File

@ -270,9 +270,7 @@ public class IndicesAliasesRequest extends AcknowledgedRequest<IndicesAliasesReq
routing = in.readOptionalString(); routing = in.readOptionalString();
searchRouting = in.readOptionalString(); searchRouting = in.readOptionalString();
indexRouting = 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 // TODO fix for backport of https://github.com/elastic/elasticsearch/pull/52547
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
isHidden = in.readOptionalBoolean(); isHidden = in.readOptionalBoolean();
@ -296,9 +294,7 @@ public class IndicesAliasesRequest extends AcknowledgedRequest<IndicesAliasesReq
out.writeOptionalString(routing); out.writeOptionalString(routing);
out.writeOptionalString(searchRouting); out.writeOptionalString(searchRouting);
out.writeOptionalString(indexRouting); 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 // TODO fix for backport https://github.com/elastic/elasticsearch/pull/52547
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
out.writeOptionalBoolean(isHidden); out.writeOptionalBoolean(isHidden);

View File

@ -31,7 +31,6 @@
package org.opensearch.action.admin.indices.alias.get; package org.opensearch.action.admin.indices.alias.get;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.AliasesRequest; import org.opensearch.action.AliasesRequest;
import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.IndicesOptions;
@ -61,10 +60,8 @@ public class GetAliasesRequest extends MasterNodeReadRequest<GetAliasesRequest>
indices = in.readStringArray(); indices = in.readStringArray();
aliases = in.readStringArray(); aliases = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in); indicesOptions = IndicesOptions.readIndicesOptions(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
originalAliases = in.readStringArray(); originalAliases = in.readStringArray();
} }
}
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
@ -72,10 +69,8 @@ public class GetAliasesRequest extends MasterNodeReadRequest<GetAliasesRequest>
out.writeStringArray(indices); out.writeStringArray(indices);
out.writeStringArray(aliases); out.writeStringArray(aliases);
indicesOptions.writeIndicesOptions(out); indicesOptions.writeIndicesOptions(out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeStringArray(originalAliases); out.writeStringArray(originalAliases);
} }
}
@Override @Override
public GetAliasesRequest indices(String... indices) { public GetAliasesRequest indices(String... indices) {

View File

@ -57,7 +57,7 @@ public class CloseIndexResponse extends ShardsAcknowledgedResponse {
private final List<IndexResult> indices; private final List<IndexResult> indices;
CloseIndexResponse(StreamInput in) throws IOException { 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)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) {
indices = unmodifiableList(in.readList(IndexResult::new)); indices = unmodifiableList(in.readList(IndexResult::new));
} else { } else {

View File

@ -71,7 +71,7 @@ public class CreateIndexResponse extends ShardsAcknowledgedResponse {
private final String index; private final String index;
protected CreateIndexResponse(StreamInput in) throws IOException { protected CreateIndexResponse(StreamInput in) throws IOException {
super(in, true, true); super(in, true);
index = in.readString(); index = in.readString();
} }

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.indices.get; package org.opensearch.action.admin.indices.get;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.master.info.ClusterInfoRequest; import org.opensearch.action.support.master.info.ClusterInfoRequest;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -90,10 +89,8 @@ public class GetIndexRequest extends ClusterInfoRequest<GetIndexRequest> {
super(in); super(in);
features = in.readArray(i -> Feature.fromId(i.readByte()), Feature[]::new); features = in.readArray(i -> Feature.fromId(i.readByte()), Feature[]::new);
humanReadable = in.readBoolean(); humanReadable = in.readBoolean();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
includeDefaults = in.readBoolean(); includeDefaults = in.readBoolean();
} }
}
public GetIndexRequest features(Feature... features) { public GetIndexRequest features(Feature... features) {
if (features == null) { if (features == null) {
@ -156,9 +153,7 @@ public class GetIndexRequest extends ClusterInfoRequest<GetIndexRequest> {
super.writeTo(out); super.writeTo(out);
out.writeArray((o, f) -> o.writeByte(f.id), features); out.writeArray((o, f) -> o.writeByte(f.id), features);
out.writeBoolean(humanReadable); out.writeBoolean(humanReadable);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeBoolean(includeDefaults); out.writeBoolean(includeDefaults);
} }
}
} }

View File

@ -56,7 +56,7 @@ public class OpenIndexResponse extends ShardsAcknowledgedResponse {
} }
public OpenIndexResponse(StreamInput in) throws IOException { public OpenIndexResponse(StreamInput in) throws IOException {
super(in, true, true); super(in, true);
} }
public OpenIndexResponse(boolean acknowledged, boolean shardsAcknowledged) { public OpenIndexResponse(boolean acknowledged, boolean shardsAcknowledged) {

View File

@ -55,7 +55,7 @@ public class AddIndexBlockResponse extends ShardsAcknowledgedResponse {
private final List<AddBlockResult> indices; private final List<AddBlockResult> indices;
AddIndexBlockResponse(StreamInput in) throws IOException { AddIndexBlockResponse(StreamInput in) throws IOException {
super(in, true, true); super(in, true);
indices = unmodifiableList(in.readList(AddBlockResult::new)); indices = unmodifiableList(in.readList(AddBlockResult::new));
} }

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.indices.rollover; package org.opensearch.action.admin.indices.rollover;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.support.master.ShardsAcknowledgedResponse; import org.opensearch.action.support.master.ShardsAcknowledgedResponse;
import org.opensearch.common.ParseField; import org.opensearch.common.ParseField;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -98,8 +97,7 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement
private final boolean shardsAcknowledged; private final boolean shardsAcknowledged;
RolloverResponse(StreamInput in) throws IOException { RolloverResponse(StreamInput in) throws IOException {
super(in, false, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); super(in, false);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
oldIndex = in.readString(); oldIndex = in.readString();
newIndex = in.readString(); newIndex = in.readString();
int conditionSize = in.readVInt(); int conditionSize = in.readVInt();
@ -110,19 +108,6 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement
dryRun = in.readBoolean(); dryRun = in.readBoolean();
rolledOver = in.readBoolean(); rolledOver = in.readBoolean();
shardsAcknowledged = in.readBoolean(); shardsAcknowledged = in.readBoolean();
} else {
oldIndex = in.readString();
newIndex = in.readString();
int conditionSize = in.readVInt();
conditionStatus = new HashMap<>(conditionSize);
for (int i = 0; i < conditionSize; i++) {
conditionStatus.put(in.readString(), in.readBoolean());
}
dryRun = in.readBoolean();
rolledOver = in.readBoolean();
acknowledged = in.readBoolean();
shardsAcknowledged = in.readBoolean();
}
} }
public RolloverResponse( public RolloverResponse(
@ -185,7 +170,6 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
super.writeTo(out); super.writeTo(out);
out.writeString(oldIndex); out.writeString(oldIndex);
out.writeString(newIndex); out.writeString(newIndex);
@ -197,19 +181,6 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement
out.writeBoolean(dryRun); out.writeBoolean(dryRun);
out.writeBoolean(rolledOver); out.writeBoolean(rolledOver);
out.writeBoolean(shardsAcknowledged); out.writeBoolean(shardsAcknowledged);
} else {
out.writeString(oldIndex);
out.writeString(newIndex);
out.writeVInt(conditionStatus.size());
for (Map.Entry<String, Boolean> entry : conditionStatus.entrySet()) {
out.writeString(entry.getKey());
out.writeBoolean(entry.getValue());
}
out.writeBoolean(dryRun);
out.writeBoolean(rolledOver);
out.writeBoolean(acknowledged);
writeShardsAcknowledged(out);
}
} }
@Override @Override

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.indices.settings.get; package org.opensearch.action.admin.indices.settings.get;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.IndicesRequest; import org.opensearch.action.IndicesRequest;
import org.opensearch.action.ValidateActions; import org.opensearch.action.ValidateActions;
@ -82,10 +81,8 @@ public class GetSettingsRequest extends MasterNodeReadRequest<GetSettingsRequest
indicesOptions = IndicesOptions.readIndicesOptions(in); indicesOptions = IndicesOptions.readIndicesOptions(in);
names = in.readStringArray(); names = in.readStringArray();
humanReadable = in.readBoolean(); humanReadable = in.readBoolean();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
includeDefaults = in.readBoolean(); includeDefaults = in.readBoolean();
} }
}
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
@ -94,10 +91,8 @@ public class GetSettingsRequest extends MasterNodeReadRequest<GetSettingsRequest
indicesOptions.writeIndicesOptions(out); indicesOptions.writeIndicesOptions(out);
out.writeStringArray(names); out.writeStringArray(names);
out.writeBoolean(humanReadable); out.writeBoolean(humanReadable);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeBoolean(includeDefaults); out.writeBoolean(includeDefaults);
} }
}
@Override @Override
public String[] indices() { public String[] indices() {

View File

@ -82,12 +82,8 @@ public class ResizeRequest extends AcknowledgedRequest<ResizeRequest> implements
targetIndexRequest = new CreateIndexRequest(in); targetIndexRequest = new CreateIndexRequest(in);
sourceIndex = in.readString(); sourceIndex = in.readString();
type = in.readEnum(ResizeType.class); type = in.readEnum(ResizeType.class);
if (in.getVersion().before(LegacyESVersion.V_6_4_0)) {
copySettings = null;
} else {
copySettings = in.readOptionalBoolean(); copySettings = in.readOptionalBoolean();
} }
}
ResizeRequest() {} ResizeRequest() {}
@ -128,13 +124,8 @@ public class ResizeRequest extends AcknowledgedRequest<ResizeRequest> implements
throw new IllegalArgumentException("can't send clone request to a node that's older than " + LegacyESVersion.V_7_4_0); throw new IllegalArgumentException("can't send clone request to a node that's older than " + LegacyESVersion.V_7_4_0);
} }
out.writeEnum(type); out.writeEnum(type);
// noinspection StatementWithEmptyBody
if (out.getVersion().before(LegacyESVersion.V_6_4_0)) {
} else {
out.writeOptionalBoolean(copySettings); out.writeOptionalBoolean(copySettings);
} }
}
@Override @Override
public String[] indices() { public String[] indices() {

View File

@ -32,7 +32,6 @@
package org.opensearch.action.admin.indices.validate.query; package org.opensearch.action.admin.indices.validate.query;
import org.opensearch.LegacyESVersion;
import org.opensearch.common.ParseField; import org.opensearch.common.ParseField;
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;
@ -84,11 +83,7 @@ public class QueryExplanation implements Writeable, ToXContentFragment {
private String error; private String error;
public QueryExplanation(StreamInput in) throws IOException { public QueryExplanation(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
index = in.readOptionalString(); index = in.readOptionalString();
} else {
index = in.readString();
}
shard = in.readInt(); shard = in.readInt();
valid = in.readBoolean(); valid = in.readBoolean();
explanation = in.readOptionalString(); explanation = in.readOptionalString();
@ -125,11 +120,7 @@ public class QueryExplanation implements Writeable, ToXContentFragment {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalString(index); out.writeOptionalString(index);
} else {
out.writeString(index);
}
out.writeInt(shard); out.writeInt(shard);
out.writeBoolean(valid); out.writeBoolean(valid);
out.writeOptionalString(explanation); out.writeOptionalString(explanation);

View File

@ -36,7 +36,6 @@ import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.support.replication.ReplicatedWriteRequest; import org.opensearch.action.support.replication.ReplicatedWriteRequest;
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.index.seqno.SequenceNumbers;
import org.opensearch.index.shard.ShardId; import org.opensearch.index.shard.ShardId;
import org.opensearch.index.translog.Translog; import org.opensearch.index.translog.Translog;
@ -55,11 +54,7 @@ public final class ResyncReplicationRequest extends ReplicatedWriteRequest<Resyn
ResyncReplicationRequest(StreamInput in) throws IOException { ResyncReplicationRequest(StreamInput in) throws IOException {
super(in); super(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
trimAboveSeqNo = in.readZLong(); trimAboveSeqNo = in.readZLong();
} else {
trimAboveSeqNo = SequenceNumbers.UNASSIGNED_SEQ_NO;
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_5_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_6_5_0)) {
maxSeenAutoIdTimestampOnPrimary = in.readZLong(); maxSeenAutoIdTimestampOnPrimary = in.readZLong();
} else { } else {
@ -95,9 +90,7 @@ public final class ResyncReplicationRequest extends ReplicatedWriteRequest<Resyn
@Override @Override
public void writeTo(final StreamOutput out) throws IOException { public void writeTo(final StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeZLong(trimAboveSeqNo); out.writeZLong(trimAboveSeqNo);
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_5_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_6_5_0)) {
out.writeZLong(maxSeenAutoIdTimestampOnPrimary); out.writeZLong(maxSeenAutoIdTimestampOnPrimary);
} }

View File

@ -62,8 +62,8 @@ public abstract class ShardsAcknowledgedResponse extends AcknowledgedResponse {
private final boolean shardsAcknowledged; private final boolean shardsAcknowledged;
protected ShardsAcknowledgedResponse(StreamInput in, boolean readShardsAcknowledged, boolean readAcknowledged) throws IOException { protected ShardsAcknowledgedResponse(StreamInput in, boolean readShardsAcknowledged) throws IOException {
super(in, readAcknowledged); super(in);
if (readShardsAcknowledged) { if (readShardsAcknowledged) {
this.shardsAcknowledged = in.readBoolean(); this.shardsAcknowledged = in.readBoolean();
} else { } else {

View File

@ -221,9 +221,7 @@ public class AliasMetadata extends AbstractDiffable<AliasMetadata> implements To
out.writeBoolean(false); out.writeBoolean(false);
} }
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalBoolean(writeIndex()); out.writeOptionalBoolean(writeIndex());
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
out.writeOptionalBoolean(isHidden()); out.writeOptionalBoolean(isHidden());
@ -249,11 +247,7 @@ public class AliasMetadata extends AbstractDiffable<AliasMetadata> implements To
searchRouting = null; searchRouting = null;
searchRoutingValues = emptySet(); searchRoutingValues = emptySet();
} }
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
writeIndex = in.readOptionalBoolean(); writeIndex = in.readOptionalBoolean();
} else {
writeIndex = null;
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
isHidden = in.readOptionalBoolean(); isHidden = in.readOptionalBoolean();

View File

@ -968,9 +968,7 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
aliases.writeTo(out); aliases.writeTo(out);
customData.writeTo(out); customData.writeTo(out);
inSyncAllocationIds.writeTo(out); inSyncAllocationIds.writeTo(out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
rolloverInfos.writeTo(out); rolloverInfos.writeTo(out);
}
if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) {
out.writeBoolean(isSystem); out.writeBoolean(isSystem);
} }
@ -1041,12 +1039,10 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
Set<String> allocationIds = DiffableUtils.StringSetValueSerializer.getInstance().read(in, key); Set<String> allocationIds = DiffableUtils.StringSetValueSerializer.getInstance().read(in, key);
builder.putInSyncAllocationIds(key, allocationIds); builder.putInSyncAllocationIds(key, allocationIds);
} }
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
int rolloverAliasesSize = in.readVInt(); int rolloverAliasesSize = in.readVInt();
for (int i = 0; i < rolloverAliasesSize; i++) { for (int i = 0; i < rolloverAliasesSize; i++) {
builder.putRolloverInfo(new RolloverInfo(in)); builder.putRolloverInfo(new RolloverInfo(in));
} }
}
if (in.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { if (in.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) {
builder.system(in.readBoolean()); builder.system(in.readBoolean());
} }
@ -1092,12 +1088,10 @@ public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragmen
out.writeVInt(cursor.key); out.writeVInt(cursor.key);
DiffableUtils.StringSetValueSerializer.getInstance().write(cursor.value, out); DiffableUtils.StringSetValueSerializer.getInstance().write(cursor.value, out);
} }
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeVInt(rolloverInfos.size()); out.writeVInt(rolloverInfos.size());
for (ObjectCursor<RolloverInfo> cursor : rolloverInfos.values()) { for (ObjectCursor<RolloverInfo> cursor : rolloverInfos.values()) {
cursor.value.writeTo(out); cursor.value.writeTo(out);
} }
}
if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) {
out.writeBoolean(isSystem); out.writeBoolean(isSystem);
} }

View File

@ -35,7 +35,6 @@ package org.opensearch.index.query;
import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.SetOnce; import org.apache.lucene.util.SetOnce;
import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListener;
import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetRequest;
import org.opensearch.action.get.GetResponse; import org.opensearch.action.get.GetResponse;
@ -204,11 +203,7 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
indexedShapeType = in.readOptionalString(); indexedShapeType = in.readOptionalString();
indexedShapeIndex = in.readOptionalString(); indexedShapeIndex = in.readOptionalString();
indexedShapePath = in.readOptionalString(); indexedShapePath = in.readOptionalString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
indexedShapeRouting = in.readOptionalString(); indexedShapeRouting = in.readOptionalString();
} else {
indexedShapeRouting = null;
}
} }
relation = ShapeRelation.readFromStream(in); relation = ShapeRelation.readFromStream(in);
ignoreUnmapped = in.readBoolean(); ignoreUnmapped = in.readBoolean();
@ -230,11 +225,7 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
out.writeOptionalString(indexedShapeType); out.writeOptionalString(indexedShapeType);
out.writeOptionalString(indexedShapeIndex); out.writeOptionalString(indexedShapeIndex);
out.writeOptionalString(indexedShapePath); out.writeOptionalString(indexedShapePath);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalString(indexedShapeRouting); out.writeOptionalString(indexedShapeRouting);
} else if (indexedShapeRouting != null) {
throw new IllegalStateException("indexed shape routing cannot be serialized to older nodes");
}
} }
relation.writeTo(out); relation.writeTo(out);
out.writeBoolean(ignoreUnmapped); out.writeBoolean(ignoreUnmapped);

View File

@ -61,7 +61,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import static org.opensearch.common.xcontent.XContentParser.Token.END_OBJECT; import static org.opensearch.common.xcontent.XContentParser.Token.END_OBJECT;
@ -191,17 +190,7 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
} }
trackScores = in.readBoolean(); trackScores = in.readBoolean();
storedFieldsContext = in.readOptionalWriteable(StoredFieldsContext::new); storedFieldsContext = in.readOptionalWriteable(StoredFieldsContext::new);
if (in.getVersion().before(LegacyESVersion.V_6_4_0)) {
@SuppressWarnings("unchecked")
List<String> fieldList = (List<String>) in.readGenericValue();
if (fieldList == null) {
docValueFields = null;
} else {
docValueFields = fieldList.stream().map(field -> new FieldAndFormat(field, null)).collect(Collectors.toList());
}
} else {
docValueFields = in.readBoolean() ? in.readList(FieldAndFormat::new) : null; docValueFields = in.readBoolean() ? in.readList(FieldAndFormat::new) : null;
}
if (in.readBoolean()) { if (in.readBoolean()) {
int size = in.readVInt(); int size = in.readVInt();
scriptFields = new HashSet<>(size); scriptFields = new HashSet<>(size);
@ -218,9 +207,7 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
} }
} }
highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new); highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
this.innerCollapseBuilder = in.readOptionalWriteable(CollapseBuilder::new); this.innerCollapseBuilder = in.readOptionalWriteable(CollapseBuilder::new);
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) {
if (in.readBoolean()) { if (in.readBoolean()) {
@ -242,14 +229,11 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
} }
out.writeBoolean(trackScores); out.writeBoolean(trackScores);
out.writeOptionalWriteable(storedFieldsContext); out.writeOptionalWriteable(storedFieldsContext);
if (out.getVersion().before(LegacyESVersion.V_6_4_0)) {
out.writeGenericValue(docValueFields == null ? null : docValueFields.stream().map(ff -> ff.field).collect(Collectors.toList()));
} else {
out.writeBoolean(docValueFields != null); out.writeBoolean(docValueFields != null);
if (docValueFields != null) { if (docValueFields != null) {
out.writeList(docValueFields); out.writeList(docValueFields);
} }
}
boolean hasScriptFields = scriptFields != null; boolean hasScriptFields = scriptFields != null;
out.writeBoolean(hasScriptFields); out.writeBoolean(hasScriptFields);
if (hasScriptFields) { if (hasScriptFields) {
@ -269,9 +253,7 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
} }
} }
out.writeOptionalWriteable(highlightBuilder); out.writeOptionalWriteable(highlightBuilder);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalWriteable(innerCollapseBuilder); out.writeOptionalWriteable(innerCollapseBuilder);
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) {
out.writeBoolean(fetchFields != null); out.writeBoolean(fetchFields != null);

View File

@ -32,7 +32,6 @@
package org.opensearch.index.reindex; package org.opensearch.index.reindex;
import org.opensearch.LegacyESVersion;
import org.opensearch.common.Nullable; import org.opensearch.common.Nullable;
import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.bytes.BytesReference;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -130,11 +129,7 @@ public class RemoteInfo implements Writeable, ToXContentObject {
this.headers = unmodifiableMap(headers); this.headers = unmodifiableMap(headers);
socketTimeout = in.readTimeValue(); socketTimeout = in.readTimeValue();
connectTimeout = in.readTimeValue(); connectTimeout = in.readTimeValue();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
pathPrefix = in.readOptionalString(); pathPrefix = in.readOptionalString();
} else {
pathPrefix = null;
}
} }
@Override @Override
@ -152,10 +147,8 @@ public class RemoteInfo implements Writeable, ToXContentObject {
} }
out.writeTimeValue(socketTimeout); out.writeTimeValue(socketTimeout);
out.writeTimeValue(connectTimeout); out.writeTimeValue(connectTimeout);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalString(pathPrefix); out.writeOptionalString(pathPrefix);
} }
}
public String getScheme() { public String getScheme() {
return scheme; return scheme;

View File

@ -33,7 +33,6 @@
package org.opensearch.search.aggregations.bucket.range; package org.opensearch.search.aggregations.bucket.range;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
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.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentBuilder;
@ -93,7 +92,7 @@ public final class InternalBinaryRange extends InternalMultiBucketAggregation<In
} }
private static Bucket createFromStream(StreamInput in, DocValueFormat format, boolean keyed) throws IOException { private static Bucket createFromStream(StreamInput in, DocValueFormat format, boolean keyed) throws IOException {
String key = in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0) ? in.readString() : in.readOptionalString(); String key = in.readString();
BytesRef from = in.readBoolean() ? in.readBytesRef() : null; BytesRef from = in.readBoolean() ? in.readBytesRef() : null;
BytesRef to = in.readBoolean() ? in.readBytesRef() : null; BytesRef to = in.readBoolean() ? in.readBytesRef() : null;
@ -105,11 +104,7 @@ public final class InternalBinaryRange extends InternalMultiBucketAggregation<In
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeString(key); out.writeString(key);
} else {
out.writeOptionalString(key);
}
out.writeBoolean(from != null); out.writeBoolean(from != null);
if (from != null) { if (from != null) {
out.writeBytesRef(from); out.writeBytesRef(from);

View File

@ -31,7 +31,6 @@
package org.opensearch.search.aggregations.bucket.range; package org.opensearch.search.aggregations.bucket.range;
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.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentBuilder;
@ -178,11 +177,7 @@ public class InternalRange<B extends InternalRange.Bucket, R extends InternalRan
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeString(key); out.writeString(key);
} else {
out.writeOptionalString(key);
}
out.writeDouble(from); out.writeDouble(from);
out.writeDouble(to); out.writeDouble(to);
out.writeVLong(docCount); out.writeVLong(docCount);
@ -278,7 +273,7 @@ public class InternalRange<B extends InternalRange.Bucket, R extends InternalRan
int size = in.readVInt(); int size = in.readVInt();
List<B> ranges = new ArrayList<>(size); List<B> ranges = new ArrayList<>(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
String key = in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0) ? in.readString() : in.readOptionalString(); String key = in.readString();
ranges.add( ranges.add(
getFactory().createBucket( getFactory().createBucket(
key, key,

View File

@ -78,7 +78,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import static org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder; import static org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder;
import static org.opensearch.search.internal.SearchContext.TRACK_TOTAL_HITS_ACCURATE; import static org.opensearch.search.internal.SearchContext.TRACK_TOTAL_HITS_ACCURATE;
@ -219,20 +218,11 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
aggregations = in.readOptionalWriteable(AggregatorFactories.Builder::new); aggregations = in.readOptionalWriteable(AggregatorFactories.Builder::new);
explain = in.readOptionalBoolean(); explain = in.readOptionalBoolean();
fetchSourceContext = in.readOptionalWriteable(FetchSourceContext::new); fetchSourceContext = in.readOptionalWriteable(FetchSourceContext::new);
if (in.getVersion().before(LegacyESVersion.V_6_4_0)) {
List<String> dvFields = (List<String>) in.readGenericValue();
if (dvFields == null) {
docValueFields = null;
} else {
docValueFields = dvFields.stream().map(field -> new FieldAndFormat(field, null)).collect(Collectors.toList());
}
} else {
if (in.readBoolean()) { if (in.readBoolean()) {
docValueFields = in.readList(FieldAndFormat::new); docValueFields = in.readList(FieldAndFormat::new);
} else { } else {
docValueFields = null; docValueFields = null;
} }
}
storedFieldsContext = in.readOptionalWriteable(StoredFieldsContext::new); storedFieldsContext = in.readOptionalWriteable(StoredFieldsContext::new);
from = in.readVInt(); from = in.readVInt();
highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new); highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new);
@ -292,14 +282,10 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R
out.writeOptionalWriteable(aggregations); out.writeOptionalWriteable(aggregations);
out.writeOptionalBoolean(explain); out.writeOptionalBoolean(explain);
out.writeOptionalWriteable(fetchSourceContext); out.writeOptionalWriteable(fetchSourceContext);
if (out.getVersion().before(LegacyESVersion.V_6_4_0)) {
out.writeGenericValue(docValueFields == null ? null : docValueFields.stream().map(ff -> ff.field).collect(Collectors.toList()));
} else {
out.writeBoolean(docValueFields != null); out.writeBoolean(docValueFields != null);
if (docValueFields != null) { if (docValueFields != null) {
out.writeList(docValueFields); out.writeList(docValueFields);
} }
}
out.writeOptionalWriteable(storedFieldsContext); out.writeOptionalWriteable(storedFieldsContext);
out.writeVInt(from); out.writeVInt(from);
out.writeOptionalWriteable(highlightBuilder); out.writeOptionalWriteable(highlightBuilder);

View File

@ -32,7 +32,6 @@
package org.opensearch.search.fetch.subphase; package org.opensearch.search.fetch.subphase;
import org.opensearch.LegacyESVersion;
import org.opensearch.common.Nullable; import org.opensearch.common.Nullable;
import org.opensearch.common.ParseField; import org.opensearch.common.ParseField;
import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamInput;
@ -91,20 +90,14 @@ public final class FieldAndFormat implements Writeable, ToXContentObject {
/** Serialization constructor. */ /** Serialization constructor. */
public FieldAndFormat(StreamInput in) throws IOException { public FieldAndFormat(StreamInput in) throws IOException {
this.field = in.readString(); this.field = in.readString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
format = in.readOptionalString(); format = in.readOptionalString();
} else {
format = null;
}
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeString(field); out.writeString(field);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeOptionalString(format); out.writeOptionalString(format);
} }
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {

View File

@ -255,13 +255,8 @@ public class ShardSearchRequest extends TransportRequest implements IndicesReque
} else { } else {
allowPartialSearchResults = false; allowPartialSearchResults = false;
} }
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
indexRoutings = in.readStringArray(); indexRoutings = in.readStringArray();
preference = in.readOptionalString(); preference = in.readOptionalString();
} else {
indexRoutings = Strings.EMPTY_ARRAY;
preference = null;
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
canReturnNullResponseIfMatchNoDocs = in.readBoolean(); canReturnNullResponseIfMatchNoDocs = in.readBoolean();
bottomSortValues = in.readOptionalWriteable(SearchSortValuesAndFormats::new); bottomSortValues = in.readOptionalWriteable(SearchSortValuesAndFormats::new);
@ -335,11 +330,9 @@ public class ShardSearchRequest extends TransportRequest implements IndicesReque
out.writeBoolean(allowPartialSearchResults); out.writeBoolean(allowPartialSearchResults);
} }
if (asKey == false) { if (asKey == false) {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeStringArray(indexRoutings); out.writeStringArray(indexRoutings);
out.writeOptionalString(preference); out.writeOptionalString(preference);
} }
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0) && asKey == false) { if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0) && asKey == false) {
out.writeBoolean(canReturnNullResponseIfMatchNoDocs); out.writeBoolean(canReturnNullResponseIfMatchNoDocs);
out.writeOptionalWriteable(bottomSortValues); out.writeOptionalWriteable(bottomSortValues);

View File

@ -227,20 +227,17 @@ public class SliceBuilder implements Writeable, ToXContentObject {
int shardId = request.shardId().id(); int shardId = request.shardId().id();
int numShards = context.getIndexSettings().getNumberOfShards(); int numShards = context.getIndexSettings().getNumberOfShards();
if (minNodeVersion.onOrAfter(LegacyESVersion.V_6_4_0) && (request.preference() != null || request.indexRoutings().length > 0)) { if ((request.preference() != null || request.indexRoutings().length > 0)) {
GroupShardsIterator<ShardIterator> group = buildShardIterator(clusterService, request); GroupShardsIterator<ShardIterator> group = buildShardIterator(clusterService, request);
assert group.size() <= numShards : "index routing shards: " assert group.size() <= numShards : "index routing shards: "
+ group.size() + group.size()
+ " cannot be greater than total number of shards: " + " cannot be greater than total number of shards: "
+ numShards; + numShards;
if (group.size() < numShards) { if (group.size() < numShards) {
/** /*
* The routing of this request targets a subset of the shards of this index so we need to we retrieve * The routing of this request targets a subset of the shards of this index so we need to we retrieve
* the original {@link GroupShardsIterator} and compute the request shard id and number of * the original {@link GroupShardsIterator} and compute the request shard id and number of
* shards from it. * shards from it.
* This behavior has been added in {@link LegacyESVersion#V_6_4_0} so if there is another node in the cluster
* with an older version we use the original shard id and number of shards in order to ensure that all
* slices use the same numbers.
*/ */
numShards = group.size(); numShards = group.size();
int ord = 0; int ord = 0;

View File

@ -189,10 +189,8 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
nestedPath = in.readOptionalString(); nestedPath = in.readOptionalString();
nestedSort = in.readOptionalWriteable(NestedSortBuilder::new); nestedSort = in.readOptionalWriteable(NestedSortBuilder::new);
validation = GeoValidationMethod.readFromStream(in); validation = GeoValidationMethod.readFromStream(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
ignoreUnmapped = in.readBoolean(); ignoreUnmapped = in.readBoolean();
} }
}
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
@ -206,10 +204,8 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
out.writeOptionalString(nestedPath); out.writeOptionalString(nestedPath);
out.writeOptionalWriteable(nestedSort); out.writeOptionalWriteable(nestedSort);
validation.writeTo(out); validation.writeTo(out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) {
out.writeBoolean(ignoreUnmapped); out.writeBoolean(ignoreUnmapped);
} }
}
/** /**
* Returns the geo point like field the distance based sort operates on. * Returns the geo point like field the distance based sort operates on.

View File

@ -37,7 +37,6 @@ import org.opensearch.Version;
import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.IndicesOptions;
import org.opensearch.common.Strings; import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.unit.TimeValue; import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.util.ArrayUtils; import org.opensearch.common.util.ArrayUtils;
import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.QueryBuilders;
@ -52,7 +51,6 @@ import org.opensearch.test.VersionUtils;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64;
import java.util.List; import java.util.List;
import static java.util.Collections.emptyMap; import static java.util.Collections.emptyMap;
@ -134,25 +132,6 @@ public class SearchRequestTests extends AbstractSearchTestCase {
} }
} }
public void testReadFromPre6_7_0() throws IOException {
String msg = "AAEBBWluZGV4AAAAAQACAAAA/////w8AAAAAAAAA/////w8AAAAAAAACAAAAAAABAAMCBAUBAAKABACAAQIAAA==";
try (StreamInput in = StreamInput.wrap(Base64.getDecoder().decode(msg))) {
in.setVersion(
VersionUtils.randomVersionBetween(
random(),
LegacyESVersion.V_6_4_0,
VersionUtils.getPreviousVersion(LegacyESVersion.V_6_7_0)
)
);
SearchRequest searchRequest = new SearchRequest(in);
assertArrayEquals(new String[] { "index" }, searchRequest.indices());
assertNull(searchRequest.getLocalClusterAlias());
assertAbsoluteStartMillisIsCurrentTime(searchRequest);
assertTrue(searchRequest.isCcsMinimizeRoundtrips());
assertTrue(searchRequest.isFinalReduce());
}
}
private static void assertAbsoluteStartMillisIsCurrentTime(SearchRequest searchRequest) { private static void assertAbsoluteStartMillisIsCurrentTime(SearchRequest searchRequest) {
long before = System.currentTimeMillis(); long before = System.currentTimeMillis();
long absoluteStartMillis = searchRequest.getOrCreateAbsoluteStartMillis(); long absoluteStartMillis = searchRequest.getOrCreateAbsoluteStartMillis();

View File

@ -50,26 +50,17 @@ public class ShardsAcknowledgedResponseTests extends OpenSearchTestCase {
ShardsAcknowledgedResponse result = copyWriteable( ShardsAcknowledgedResponse result = copyWriteable(
testInstance, testInstance,
new NamedWriteableRegistry(Collections.emptyList()), new NamedWriteableRegistry(Collections.emptyList()),
in -> new TestImpl(in, true, true), in -> new TestImpl(in, true),
Version.CURRENT Version.CURRENT
); );
assertThat(result.isAcknowledged(), is(true)); assertThat(result.isAcknowledged(), is(true));
assertThat(result.isShardsAcknowledged(), is(true)); assertThat(result.isShardsAcknowledged(), is(true));
result = copyWriteable(
testInstance,
new NamedWriteableRegistry(Collections.emptyList()),
in -> new TestImpl(in, false, false),
Version.CURRENT
);
assertThat(result.isAcknowledged(), is(false));
assertThat(result.isShardsAcknowledged(), is(false));
} }
private static class TestImpl extends ShardsAcknowledgedResponse { private static class TestImpl extends ShardsAcknowledgedResponse {
private TestImpl(StreamInput in, boolean readShardsAcknowledged, boolean readAcknowledged) throws IOException { private TestImpl(StreamInput in, boolean readShardsAcknowledged) throws IOException {
super(in, readShardsAcknowledged, readAcknowledged); super(in, readShardsAcknowledged);
} }
private TestImpl(boolean acknowledged, boolean shardsAcknowledged) { private TestImpl(boolean acknowledged, boolean shardsAcknowledged) {

View File

@ -119,7 +119,7 @@ public class JoinTaskExecutorTests extends OpenSearchTestCase {
} }
if (minNodeVersion.onOrAfter(LegacyESVersion.V_7_0_0)) { if (minNodeVersion.onOrAfter(LegacyESVersion.V_7_0_0)) {
Version oldMajor = LegacyESVersion.V_6_4_0.minimumCompatibilityVersion(); Version oldMajor = minNodeVersion.minimumCompatibilityVersion();
expectThrows(IllegalStateException.class, () -> JoinTaskExecutor.ensureMajorVersionBarrier(oldMajor, minNodeVersion)); expectThrows(IllegalStateException.class, () -> JoinTaskExecutor.ensureMajorVersionBarrier(oldMajor, minNodeVersion));
} }

View File

@ -58,27 +58,6 @@ public class IngestStatsTests extends OpenSearchTestCase {
assertIngestStats(ingestStats, serializedStats, true, true); assertIngestStats(ingestStats, serializedStats, true, true);
} }
public void testReadLegacyStream() throws IOException {
IngestStats.Stats totalStats = new IngestStats.Stats(50, 100, 200, 300);
List<IngestStats.PipelineStat> pipelineStats = createPipelineStats();
// legacy output logic
BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(VersionUtils.getPreviousVersion(LegacyESVersion.V_6_5_0));
totalStats.writeTo(out);
out.writeVInt(pipelineStats.size());
for (IngestStats.PipelineStat pipelineStat : pipelineStats) {
out.writeString(pipelineStat.getPipelineId());
pipelineStat.getStats().writeTo(out);
}
StreamInput in = out.bytes().streamInput();
in.setVersion(VersionUtils.getPreviousVersion(LegacyESVersion.V_6_5_0));
IngestStats serializedStats = new IngestStats(in);
IngestStats expectedStats = new IngestStats(totalStats, pipelineStats, Collections.emptyMap());
assertIngestStats(expectedStats, serializedStats, false, true);
}
public void testBWCIngestProcessorTypeStats() throws IOException { public void testBWCIngestProcessorTypeStats() throws IOException {
IngestStats.Stats totalStats = new IngestStats.Stats(50, 100, 200, 300); IngestStats.Stats totalStats = new IngestStats.Stats(50, 100, 200, 300);
List<IngestStats.PipelineStat> pipelineStats = createPipelineStats(); List<IngestStats.PipelineStat> pipelineStats = createPipelineStats();