Skip to content

Commit 9023da7

Browse files
committed
[Remove] LegacyESVersion.V_7_8_* and V_7_9_* constants
Removes all usages of LegacyESVersion.V_7_8_ and LegacyESVersion.V_7_9 version constants along with ancient API logic. Signed-off-by: Nicholas Walter Knize <[email protected]>
1 parent 515f84b commit 9023da7

39 files changed

+92
-337
lines changed

server/src/main/java/org/opensearch/LegacyESVersion.java

-6
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ public class LegacyESVersion extends Version {
5353
public static final LegacyESVersion V_7_6_2 = new LegacyESVersion(7060299, org.apache.lucene.util.Version.LUCENE_8_4_0);
5454
public static final LegacyESVersion V_7_7_0 = new LegacyESVersion(7070099, org.apache.lucene.util.Version.LUCENE_8_5_1);
5555
public static final LegacyESVersion V_7_7_1 = new LegacyESVersion(7070199, org.apache.lucene.util.Version.LUCENE_8_5_1);
56-
public static final LegacyESVersion V_7_8_0 = new LegacyESVersion(7080099, org.apache.lucene.util.Version.LUCENE_8_5_1);
57-
public static final LegacyESVersion V_7_8_1 = new LegacyESVersion(7080199, org.apache.lucene.util.Version.LUCENE_8_5_1);
58-
public static final LegacyESVersion V_7_9_0 = new LegacyESVersion(7090099, org.apache.lucene.util.Version.LUCENE_8_6_0);
59-
public static final LegacyESVersion V_7_9_1 = new LegacyESVersion(7090199, org.apache.lucene.util.Version.LUCENE_8_6_2);
60-
public static final LegacyESVersion V_7_9_2 = new LegacyESVersion(7090299, org.apache.lucene.util.Version.LUCENE_8_6_2);
61-
public static final LegacyESVersion V_7_9_3 = new LegacyESVersion(7090399, org.apache.lucene.util.Version.LUCENE_8_6_2);
6256
public static final LegacyESVersion V_7_10_0 = new LegacyESVersion(7100099, org.apache.lucene.util.Version.LUCENE_8_7_0);
6357
public static final LegacyESVersion V_7_10_1 = new LegacyESVersion(7100199, org.apache.lucene.util.Version.LUCENE_8_7_0);
6458
public static final LegacyESVersion V_7_10_2 = new LegacyESVersion(7100299, org.apache.lucene.util.Version.LUCENE_8_7_0);

server/src/main/java/org/opensearch/OpenSearchException.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1576,13 +1576,13 @@ private enum OpenSearchExceptionHandle {
15761576
org.opensearch.indices.recovery.PeerRecoveryNotFound.class,
15771577
org.opensearch.indices.recovery.PeerRecoveryNotFound::new,
15781578
158,
1579-
LegacyESVersion.V_7_9_0
1579+
UNKNOWN_VERSION_ADDED
15801580
),
15811581
NODE_HEALTH_CHECK_FAILURE_EXCEPTION(
15821582
org.opensearch.cluster.coordination.NodeHealthCheckFailureException.class,
15831583
org.opensearch.cluster.coordination.NodeHealthCheckFailureException::new,
15841584
159,
1585-
LegacyESVersion.V_7_9_0
1585+
UNKNOWN_VERSION_ADDED
15861586
),
15871587
NO_SEED_NODE_LEFT_EXCEPTION(
15881588
org.opensearch.transport.NoSeedNodeLeftException.class,

server/src/main/java/org/opensearch/action/DocWriteRequest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ public static OpType fromString(String sOpType) {
231231
* Read a document write (index/delete/update) request
232232
*
233233
* @param shardId shard id of the request. {@code null} when reading as part of a {@link org.opensearch.action.bulk.BulkRequest}
234-
* that does not have a unique shard id or when reading from a stream of version older than
235-
* {@link org.opensearch.action.bulk.BulkShardRequest#COMPACT_SHARD_ID_VERSION}
234+
* that does not have a unique shard id
236235
*/
237236
static DocWriteRequest<?> readDocumentRequest(@Nullable ShardId shardId, StreamInput in) throws IOException {
238237
byte type = in.readByte();

server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
package org.opensearch.action.admin.cluster.configuration;
3333

34-
import org.opensearch.LegacyESVersion;
3534
import org.opensearch.action.ActionRequestValidationException;
3635
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest;
3736
import org.opensearch.cluster.ClusterState;
@@ -110,13 +109,8 @@ public AddVotingConfigExclusionsRequest(String[] nodeDescriptions, String[] node
110109
public AddVotingConfigExclusionsRequest(StreamInput in) throws IOException {
111110
super(in);
112111
nodeDescriptions = in.readStringArray();
113-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
114-
nodeIds = in.readStringArray();
115-
nodeNames = in.readStringArray();
116-
} else {
117-
nodeIds = Strings.EMPTY_ARRAY;
118-
nodeNames = Strings.EMPTY_ARRAY;
119-
}
112+
nodeIds = in.readStringArray();
113+
nodeNames = in.readStringArray();
120114
timeout = in.readTimeValue();
121115

122116
if (nodeDescriptions.length > 0) {
@@ -249,10 +243,8 @@ public ActionRequestValidationException validate() {
249243
public void writeTo(StreamOutput out) throws IOException {
250244
super.writeTo(out);
251245
out.writeStringArray(nodeDescriptions);
252-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
253-
out.writeStringArray(nodeIds);
254-
out.writeStringArray(nodeNames);
255-
}
246+
out.writeStringArray(nodeIds);
247+
out.writeStringArray(nodeNames);
256248
out.writeTimeValue(timeout);
257249
}
258250

server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java

+4-18
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.node.stats;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.Version;
3736
import org.opensearch.action.support.nodes.BaseNodeResponse;
3837
import org.opensearch.cluster.node.DiscoveryNode;
@@ -138,18 +137,10 @@ public NodeStats(StreamInput in) throws IOException {
138137
ingestStats = in.readOptionalWriteable(IngestStats::new);
139138
adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new);
140139
scriptCacheStats = null;
141-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
142-
if (in.getVersion().before(LegacyESVersion.V_7_9_0)) {
143-
scriptCacheStats = in.readOptionalWriteable(ScriptCacheStats::new);
144-
} else if (scriptStats != null) {
145-
scriptCacheStats = scriptStats.toScriptCacheStats();
146-
}
147-
}
148-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) {
149-
indexingPressureStats = in.readOptionalWriteable(IndexingPressureStats::new);
150-
} else {
151-
indexingPressureStats = null;
140+
if (scriptStats != null) {
141+
scriptCacheStats = scriptStats.toScriptCacheStats();
152142
}
143+
indexingPressureStats = in.readOptionalWriteable(IndexingPressureStats::new);
153144
if (in.getVersion().onOrAfter(Version.V_1_2_0)) {
154145
shardIndexingPressureStats = in.readOptionalWriteable(ShardIndexingPressureStats::new);
155146
} else {
@@ -327,12 +318,7 @@ public void writeTo(StreamOutput out) throws IOException {
327318
out.writeOptionalWriteable(discoveryStats);
328319
out.writeOptionalWriteable(ingestStats);
329320
out.writeOptionalWriteable(adaptiveSelectionStats);
330-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0) && out.getVersion().before(LegacyESVersion.V_7_9_0)) {
331-
out.writeOptionalWriteable(scriptCacheStats);
332-
}
333-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) {
334-
out.writeOptionalWriteable(indexingPressureStats);
335-
}
321+
out.writeOptionalWriteable(indexingPressureStats);
336322
if (out.getVersion().onOrAfter(Version.V_1_2_0)) {
337323
out.writeOptionalWriteable(shardIndexingPressureStats);
338324
}

server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequest.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.node.tasks.cancel;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.action.support.tasks.BaseTasksRequest;
3736
import org.opensearch.common.io.stream.StreamInput;
3837
import org.opensearch.common.io.stream.StreamOutput;
@@ -60,18 +59,14 @@ public CancelTasksRequest() {}
6059
public CancelTasksRequest(StreamInput in) throws IOException {
6160
super(in);
6261
this.reason = in.readString();
63-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
64-
waitForCompletion = in.readBoolean();
65-
}
62+
waitForCompletion = in.readBoolean();
6663
}
6764

6865
@Override
6966
public void writeTo(StreamOutput out) throws IOException {
7067
super.writeTo(out);
7168
out.writeString(reason);
72-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
73-
out.writeBoolean(waitForCompletion);
74-
}
69+
out.writeBoolean(waitForCompletion);
7570
}
7671

7772
@Override

server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodeUsage.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.node.usage;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.action.support.nodes.BaseNodeResponse;
3736
import org.opensearch.cluster.node.DiscoveryNode;
3837
import org.opensearch.common.io.stream.StreamInput;
@@ -61,11 +60,7 @@ public NodeUsage(StreamInput in) throws IOException {
6160
timestamp = in.readLong();
6261
sinceTime = in.readLong();
6362
restUsage = (Map<String, Long>) in.readGenericValue();
64-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
65-
aggregationUsage = (Map<String, Object>) in.readGenericValue();
66-
} else {
67-
aggregationUsage = null;
68-
}
63+
aggregationUsage = (Map<String, Object>) in.readGenericValue();
6964
}
7065

7166
/**
@@ -144,9 +139,7 @@ public void writeTo(StreamOutput out) throws IOException {
144139
out.writeLong(timestamp);
145140
out.writeLong(sinceTime);
146141
out.writeGenericValue(restUsage);
147-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
148-
out.writeGenericValue(aggregationUsage);
149-
}
142+
out.writeGenericValue(aggregationUsage);
150143
}
151144

152145
}

server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodesUsageRequest.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.node.usage;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.action.support.nodes.BaseNodesRequest;
3736
import org.opensearch.common.io.stream.StreamInput;
3837
import org.opensearch.common.io.stream.StreamOutput;
@@ -52,9 +51,7 @@ public class NodesUsageRequest extends BaseNodesRequest<NodesUsageRequest> {
5251
public NodesUsageRequest(StreamInput in) throws IOException {
5352
super(in);
5453
this.restActions = in.readBoolean();
55-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
56-
this.aggregations = in.readBoolean();
57-
}
54+
this.aggregations = in.readBoolean();
5855
}
5956

6057
/**
@@ -116,8 +113,6 @@ public NodesUsageRequest aggregations(boolean aggregations) {
116113
public void writeTo(StreamOutput out) throws IOException {
117114
super.writeTo(out);
118115
out.writeBoolean(restActions);
119-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
120-
out.writeBoolean(aggregations);
121-
}
116+
out.writeBoolean(aggregations);
122117
}
123118
}

server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,7 @@ public AliasActions(StreamInput in) throws IOException {
281281
isHidden = in.readOptionalBoolean();
282282
}
283283
originalAliases = in.readStringArray();
284-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) {
285-
mustExist = in.readOptionalBoolean();
286-
} else {
287-
mustExist = null;
288-
}
284+
mustExist = in.readOptionalBoolean();
289285
}
290286

291287
@Override
@@ -303,9 +299,7 @@ public void writeTo(StreamOutput out) throws IOException {
303299
out.writeOptionalBoolean(isHidden);
304300
}
305301
out.writeStringArray(originalAliases);
306-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) {
307-
out.writeOptionalBoolean(mustExist);
308-
}
302+
out.writeOptionalBoolean(mustExist);
309303
}
310304

311305
/**

server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java

+9-14
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
package org.opensearch.action.admin.indices.get;
3434

3535
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
36-
import org.opensearch.LegacyESVersion;
3736
import org.opensearch.Version;
3837
import org.opensearch.action.ActionResponse;
3938
import org.opensearch.cluster.metadata.AliasMetadata;
@@ -152,14 +151,12 @@ public GetIndexResponse(
152151
}
153152
defaultSettings = defaultSettingsMapBuilder.build();
154153

155-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
156-
ImmutableOpenMap.Builder<String, String> dataStreamsMapBuilder = ImmutableOpenMap.builder();
157-
int dataStreamsSize = in.readVInt();
158-
for (int i = 0; i < dataStreamsSize; i++) {
159-
dataStreamsMapBuilder.put(in.readString(), in.readOptionalString());
160-
}
161-
dataStreams = dataStreamsMapBuilder.build();
154+
ImmutableOpenMap.Builder<String, String> dataStreamsMapBuilder = ImmutableOpenMap.builder();
155+
int dataStreamsSize = in.readVInt();
156+
for (int i = 0; i < dataStreamsSize; i++) {
157+
dataStreamsMapBuilder.put(in.readString(), in.readOptionalString());
162158
}
159+
dataStreams = dataStreamsMapBuilder.build();
163160
}
164161

165162
public String[] indices() {
@@ -272,12 +269,10 @@ public void writeTo(StreamOutput out) throws IOException {
272269
out.writeString(indexEntry.key);
273270
Settings.writeSettingsToStream(indexEntry.value, out);
274271
}
275-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) {
276-
out.writeVInt(dataStreams.size());
277-
for (ObjectObjectCursor<String, String> indexEntry : dataStreams) {
278-
out.writeString(indexEntry.key);
279-
out.writeOptionalString(indexEntry.value);
280-
}
272+
out.writeVInt(dataStreams.size());
273+
for (ObjectObjectCursor<String, String> indexEntry : dataStreams) {
274+
out.writeString(indexEntry.key);
275+
out.writeOptionalString(indexEntry.value);
281276
}
282277
}
283278

server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
package org.opensearch.action.admin.indices.mapping.put;
3434

3535
import com.carrotsearch.hppc.ObjectHashSet;
36-
import org.opensearch.LegacyESVersion;
3736
import org.opensearch.OpenSearchGenerationException;
3837
import org.opensearch.Version;
3938
import org.opensearch.action.ActionRequestValidationException;
@@ -119,9 +118,7 @@ public PutMappingRequest(StreamInput in) throws IOException {
119118
source = in.readString();
120119
concreteIndex = in.readOptionalWriteable(Index::new);
121120
origin = in.readOptionalString();
122-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) {
123-
writeIndexOnly = in.readBoolean();
124-
}
121+
writeIndexOnly = in.readBoolean();
125122
}
126123

127124
public PutMappingRequest() {}
@@ -348,9 +345,7 @@ public void writeTo(StreamOutput out) throws IOException {
348345
out.writeString(source);
349346
out.writeOptionalWriteable(concreteIndex);
350347
out.writeOptionalString(origin);
351-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) {
352-
out.writeBoolean(writeIndexOnly);
353-
}
348+
out.writeBoolean(writeIndexOnly);
354349
}
355350

356351
@Override

server/src/main/java/org/opensearch/action/bulk/BulkItemRequest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public class BulkItemRequest implements Writeable, Accountable {
5959
private volatile BulkItemResponse primaryResponse;
6060

6161
/**
62-
* @param shardId {@code null} if reading from a stream before {@link BulkShardRequest#COMPACT_SHARD_ID_VERSION} to force BwC read
63-
* that includes shard id
62+
* @param shardId the shard id
6463
*/
6564
BulkItemRequest(@Nullable ShardId shardId, StreamInput in) throws IOException {
6665
id = in.readVInt();

server/src/main/java/org/opensearch/action/bulk/BulkShardRequest.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
import org.apache.lucene.util.Accountable;
3636
import org.apache.lucene.util.RamUsageEstimator;
37-
import org.opensearch.LegacyESVersion;
38-
import org.opensearch.Version;
3937
import org.opensearch.action.support.replication.ReplicatedWriteRequest;
4038
import org.opensearch.action.support.replication.ReplicationRequest;
4139
import org.opensearch.common.io.stream.StreamInput;
@@ -54,14 +52,13 @@
5452
*/
5553
public class BulkShardRequest extends ReplicatedWriteRequest<BulkShardRequest> implements Accountable {
5654

57-
public static final Version COMPACT_SHARD_ID_VERSION = LegacyESVersion.V_7_9_0;
5855
private static final long SHALLOW_SIZE = RamUsageEstimator.shallowSizeOfInstance(BulkShardRequest.class);
5956

6057
private final BulkItemRequest[] items;
6158

6259
public BulkShardRequest(StreamInput in) throws IOException {
6360
super(in);
64-
final ShardId itemShardId = in.getVersion().onOrAfter(COMPACT_SHARD_ID_VERSION) ? shardId : null;
61+
final ShardId itemShardId = shardId;
6562
items = in.readArray(i -> i.readOptionalWriteable(inpt -> new BulkItemRequest(itemShardId, inpt)), BulkItemRequest[]::new);
6663
}
6764

@@ -95,14 +92,14 @@ public String[] indices() {
9592
@Override
9693
public void writeTo(StreamOutput out) throws IOException {
9794
super.writeTo(out);
98-
out.writeArray(out.getVersion().onOrAfter(COMPACT_SHARD_ID_VERSION) ? (o, item) -> {
95+
out.writeArray((o, item) -> {
9996
if (item != null) {
10097
o.writeBoolean(true);
10198
item.writeThin(o);
10299
} else {
103100
o.writeBoolean(false);
104101
}
105-
} : StreamOutput::writeOptionalWriteable, items);
102+
}, items);
106103
}
107104

108105
@Override

0 commit comments

Comments
 (0)