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_6_x constants #1804

Merged
merged 1 commit into from
Dec 30, 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
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_6_0 = new LegacyESVersion(6060099, org.apache.lucene.util.Version.LUCENE_7_6_0);
public static final LegacyESVersion V_6_6_1 = new LegacyESVersion(6060199, org.apache.lucene.util.Version.LUCENE_7_6_0);
public static final LegacyESVersion V_6_6_2 = new LegacyESVersion(6060299, org.apache.lucene.util.Version.LUCENE_7_6_0);
public static final LegacyESVersion V_6_7_0 = new LegacyESVersion(6070099, org.apache.lucene.util.Version.LUCENE_7_7_0);
public static final LegacyESVersion V_6_7_1 = new LegacyESVersion(6070199, org.apache.lucene.util.Version.LUCENE_7_7_0);
public static final LegacyESVersion V_6_7_2 = new LegacyESVersion(6070299, org.apache.lucene.util.Version.LUCENE_7_7_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.state;

import org.opensearch.LegacyESVersion;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.IndicesRequest;
import org.opensearch.action.support.IndicesOptions;
Expand Down Expand Up @@ -69,10 +68,8 @@ public ClusterStateRequest(StreamInput in) throws IOException {
customs = in.readBoolean();
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
waitForTimeout = in.readTimeValue();
waitForMetadataVersion = in.readOptionalLong();
}
waitForTimeout = in.readTimeValue();
waitForMetadataVersion = in.readOptionalLong();
}

@Override
Expand All @@ -85,10 +82,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(customs);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeTimeValue(waitForTimeout);
out.writeOptionalLong(waitForMetadataVersion);
}
out.writeTimeValue(waitForTimeout);
out.writeOptionalLong(waitForMetadataVersion);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,11 @@ public class ClusterStateResponse extends ActionResponse {
public ClusterStateResponse(StreamInput in) throws IOException {
super(in);
clusterName = new ClusterName(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null));
} else {
clusterState = ClusterState.readFrom(in, null);
}
clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null));
if (in.getVersion().before(LegacyESVersion.V_7_0_0)) {
new ByteSizeValue(in);
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
waitForTimedOut = in.readBoolean();
}
waitForTimedOut = in.readBoolean();
}

public ClusterStateResponse(ClusterName clusterName, ClusterState clusterState, boolean waitForTimedOut) {
Expand Down Expand Up @@ -101,17 +95,11 @@ public boolean isWaitForTimedOut() {
@Override
public void writeTo(StreamOutput out) throws IOException {
clusterName.writeTo(out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeOptionalWriteable(clusterState);
} else {
clusterState.writeTo(out);
}
out.writeOptionalWriteable(clusterState);
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
ByteSizeValue.ZERO.writeTo(out);
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeBoolean(waitForTimedOut);
}
out.writeBoolean(waitForTimedOut);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,8 @@ public DeleteRequest(@Nullable ShardId shardId, StreamInput in) throws IOExcepti
}
version = in.readLong();
versionType = VersionType.fromValue(in.readByte());
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
ifSeqNo = in.readZLong();
ifPrimaryTerm = in.readVLong();
} else {
ifSeqNo = UNASSIGNED_SEQ_NO;
ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM;
}
ifSeqNo = in.readZLong();
ifPrimaryTerm = in.readVLong();
}

public DeleteRequest() {
Expand Down Expand Up @@ -348,18 +343,8 @@ private void writeBody(StreamOutput out) throws IOException {
}
out.writeLong(version);
out.writeByte(versionType.getValue());
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeZLong(ifSeqNo);
out.writeVLong(ifPrimaryTerm);
} else if (ifSeqNo != UNASSIGNED_SEQ_NO || ifPrimaryTerm != UNASSIGNED_PRIMARY_TERM) {
assert false : "setIfMatch [" + ifSeqNo + "], currentDocTem [" + ifPrimaryTerm + "]";
throw new IllegalStateException(
"sequence number based compare and write is not supported until all nodes are on version 7.0 or higher. "
+ "Stream version ["
+ out.getVersion()
+ "]"
);
}
out.writeZLong(ifSeqNo);
out.writeVLong(ifPrimaryTerm);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,8 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio
} else {
contentType = null;
}
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
ifSeqNo = in.readZLong();
ifPrimaryTerm = in.readVLong();
} else {
ifSeqNo = UNASSIGNED_SEQ_NO;
ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM;
}
ifSeqNo = in.readZLong();
ifPrimaryTerm = in.readVLong();
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) {
requireAlias = in.readBoolean();
} else {
Expand Down Expand Up @@ -765,18 +760,8 @@ private void writeBody(StreamOutput out) throws IOException {
} else {
out.writeBoolean(false);
}
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeZLong(ifSeqNo);
out.writeVLong(ifPrimaryTerm);
} else if (ifSeqNo != UNASSIGNED_SEQ_NO || ifPrimaryTerm != UNASSIGNED_PRIMARY_TERM) {
assert false : "setIfMatch [" + ifSeqNo + "], currentDocTem [" + ifPrimaryTerm + "]";
throw new IllegalStateException(
"sequence number based compare and write is not supported until all nodes are on version 7.0 or higher. "
+ "Stream version ["
+ out.getVersion()
+ "]"
);
}
out.writeZLong(ifSeqNo);
out.writeVLong(ifPrimaryTerm);
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) {
out.writeBoolean(requireAlias);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,6 @@ public EnumSet<WildcardStates> getExpandWildcards() {

public void writeIndicesOptions(StreamOutput out) throws IOException {
EnumSet<Option> options = this.options;
// never write this out to a pre 6.6 version
if (out.getVersion().before(LegacyESVersion.V_6_6_0) && options.contains(Option.IGNORE_THROTTLED)) {
options = EnumSet.copyOf(options);
options.remove(Option.IGNORE_THROTTLED);
}
out.writeEnumSet(options);
if (out.getVersion().before(LegacyESVersion.V_7_7_0) && expandWildcards.contains(WildcardStates.HIDDEN)) {
final EnumSet<WildcardStates> states = EnumSet.copyOf(expandWildcards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version;
import org.opensearch.cluster.ClusterState.Custom;
import org.opensearch.common.collect.ImmutableOpenMap;
Expand Down Expand Up @@ -451,11 +450,7 @@ public RestoreInProgress(StreamInput in) throws IOException {
final ImmutableOpenMap.Builder<String, Entry> entriesBuilder = ImmutableOpenMap.builder(count);
for (int i = 0; i < count; i++) {
final String uuid;
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
uuid = in.readString();
} else {
uuid = BWC_UUID;
}
uuid = in.readString();
Snapshot snapshot = new Snapshot(in);
State state = State.fromValue(in.readByte());
List<String> indexBuilder = in.readStringList();
Expand All @@ -478,9 +473,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(entries.size());
for (ObjectCursor<Entry> v : entries.values()) {
Entry entry = v.value;
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeString(entry.uuid);
}
out.writeString(entry.uuid);
entry.snapshot().writeTo(out);
out.writeByte(entry.state().value());
out.writeStringCollection(entry.indices);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.LegacyESVersion;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfiguration;
import org.opensearch.cluster.coordination.CoordinationState.VoteCollection;
Expand Down Expand Up @@ -197,9 +196,6 @@ String getDescription() {
}

if (clusterState.getLastAcceptedConfiguration().isEmpty()) {

// TODO handle the case that there is a 6.x node around here, when rolling upgrades are supported

final String bootstrappingDescription;

if (INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_MASTER_NODES_SETTING.get(settings))) {
Expand All @@ -214,8 +210,7 @@ String getDescription() {

return String.format(
Locale.ROOT,
"master not discovered yet, this node has not previously joined a bootstrapped (v%d+) cluster, and %s: %s",
LegacyESVersion.V_6_6_0.major + 1,
"master not discovered yet, this node has not previously joined a bootstrapped cluster, and %s: %s",
bootstrappingDescription,
discoveryStateIgnoringQuorum
);
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.Version;
import org.opensearch.cluster.RestoreInProgress;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -249,11 +248,7 @@ public SnapshotRecoverySource(String restoreUUID, Snapshot snapshot, Version ver
}

SnapshotRecoverySource(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
restoreUUID = in.readString();
} else {
restoreUUID = RestoreInProgress.BWC_UUID;
}
restoreUUID = in.readString();
snapshot = new Snapshot(in);
version = Version.readVersion(in);
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
Expand Down Expand Up @@ -287,9 +282,7 @@ public Version version() {

@Override
protected void writeAdditionalFields(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeString(restoreUUID);
}
out.writeString(restoreUUID);
snapshot.writeTo(out);
Version.writeVersion(version, out);
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
Expand Down
15 changes: 4 additions & 11 deletions server/src/main/java/org/opensearch/index/get/GetResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@ public GetResult(StreamInput in) throws IOException {
index = in.readString();
type = in.readOptionalString();
id = in.readString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
seqNo = in.readZLong();
primaryTerm = in.readVLong();
} else {
seqNo = UNASSIGNED_SEQ_NO;
primaryTerm = UNASSIGNED_PRIMARY_TERM;
}
seqNo = in.readZLong();
primaryTerm = in.readVLong();
version = in.readLong();
exists = in.readBoolean();
if (exists) {
Expand Down Expand Up @@ -449,10 +444,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(index);
out.writeOptionalString(type);
out.writeString(id);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeZLong(seqNo);
out.writeVLong(primaryTerm);
}
out.writeZLong(seqNo);
out.writeVLong(primaryTerm);
out.writeLong(version);
out.writeBoolean(exists);
if (exists) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
package org.opensearch.index.mapper;

import org.apache.lucene.document.FieldType;
import org.opensearch.LegacyESVersion;
import org.opensearch.common.Explicit;
import org.opensearch.common.ParseField;
import org.opensearch.common.geo.builders.ShapeBuilder;
Expand Down Expand Up @@ -161,7 +160,7 @@ public Builder parse(String name, Map<String, Object> node, Map<String, Object>
iterator.remove();
}
}
if (parserContext.indexVersionCreated().onOrAfter(LegacyESVersion.V_6_6_0) && parsedDeprecatedParameters == false) {
if (parsedDeprecatedParameters == false) {
params.remove(DEPRECATED_PARAMETERS_KEY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ private void setupFieldTypeDeprecatedParameters(BuilderContext context, GeoShape
}
if (deprecatedParameters.tree != null) {
ft.setTree(deprecatedParameters.tree);
} else if (context.indexCreatedVersion().before(LegacyESVersion.V_6_6_0)) {
ft.setTree(DeprecatedParameters.PrefixTrees.GEOHASH);
}
if (deprecatedParameters.treeLevels != null) {
ft.setTreeLevels(deprecatedParameters.treeLevels);
Expand Down Expand Up @@ -517,13 +515,7 @@ protected boolean docValuesByDefault() {
public void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
super.doXContentBody(builder, includeDefaults, params);

if (includeDefaults
|| (fieldType().tree()
.equals(
indexCreatedVersion.onOrAfter(LegacyESVersion.V_6_6_0)
? DeprecatedParameters.Defaults.TREE
: DeprecatedParameters.PrefixTrees.GEOHASH
)) == false) {
if (includeDefaults || (fieldType().tree().equals(DeprecatedParameters.Defaults.TREE)) == false) {
builder.field(DeprecatedParameters.Names.TREE.getPreferredName(), fieldType().tree());
}

Expand Down
11 changes: 2 additions & 9 deletions server/src/main/java/org/opensearch/monitor/os/OsInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

package org.opensearch.monitor.os;

import org.opensearch.LegacyESVersion;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.unit.TimeValue;
Expand Down Expand Up @@ -74,11 +73,7 @@ public OsInfo(StreamInput in) throws IOException {
this.availableProcessors = in.readInt();
this.allocatedProcessors = in.readInt();
this.name = in.readOptionalString();
if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
this.prettyName = in.readOptionalString();
} else {
this.prettyName = null;
}
this.prettyName = in.readOptionalString();
this.arch = in.readOptionalString();
this.version = in.readOptionalString();
}
Expand All @@ -89,9 +84,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeInt(availableProcessors);
out.writeInt(allocatedProcessors);
out.writeOptionalString(name);
if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) {
out.writeOptionalString(prettyName);
}
out.writeOptionalString(prettyName);
out.writeOptionalString(arch);
out.writeOptionalString(version);
}
Expand Down
Loading