Skip to content

Commit 74ba9ce

Browse files
Remove Obsolete BwC Serialization Code (#40032)
* Same as #39879 and #39883 <- no need for BwC logic that covers pre-7.0 versions in 8.0
1 parent 6c2ec33 commit 74ba9ce

File tree

80 files changed

+283
-1420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+283
-1420
lines changed

server/src/main/java/org/elasticsearch/cluster/RestoreInProgress.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import com.carrotsearch.hppc.cursors.ObjectCursor;
2323
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
24-
2524
import org.elasticsearch.Version;
2625
import org.elasticsearch.cluster.ClusterState.Custom;
2726
import org.elasticsearch.common.collect.ImmutableOpenMap;
@@ -38,18 +37,12 @@
3837
import java.util.Iterator;
3938
import java.util.List;
4039
import java.util.Objects;
41-
import java.util.UUID;
4240

4341
/**
4442
* Meta data about restore processes that are currently executing
4543
*/
4644
public class RestoreInProgress extends AbstractNamedDiffable<Custom> implements Custom, Iterable<RestoreInProgress.Entry> {
4745

48-
/**
49-
* Fallback UUID used for restore operations that were started before v6.6 and don't have a uuid in the cluster state.
50-
*/
51-
public static final String BWC_UUID = new UUID(0, 0).toString();
52-
5346
public static final String TYPE = "restore";
5447

5548
private final ImmutableOpenMap<String, Entry> entries;
@@ -436,11 +429,7 @@ public RestoreInProgress(StreamInput in) throws IOException {
436429
final ImmutableOpenMap.Builder<String, Entry> entriesBuilder = ImmutableOpenMap.builder(count);
437430
for (int i = 0; i < count; i++) {
438431
final String uuid;
439-
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
440-
uuid = in.readString();
441-
} else {
442-
uuid = BWC_UUID;
443-
}
432+
uuid = in.readString();
444433
Snapshot snapshot = new Snapshot(in);
445434
State state = State.fromValue(in.readByte());
446435
int indices = in.readVInt();
@@ -468,9 +457,7 @@ public void writeTo(StreamOutput out) throws IOException {
468457
out.writeVInt(entries.size());
469458
for (ObjectCursor<Entry> v : entries.values()) {
470459
Entry entry = v.value;
471-
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
472-
out.writeString(entry.uuid);
473-
}
460+
out.writeString(entry.uuid);
474461
entry.snapshot().writeTo(out);
475462
out.writeByte(entry.state().value());
476463
out.writeVInt(entry.indices().size());

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java

Lines changed: 25 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -682,16 +682,8 @@ private static class IndexMetaDataDiff implements Diff<IndexMetaData> {
682682
index = in.readString();
683683
routingNumShards = in.readInt();
684684
version = in.readLong();
685-
if (in.getVersion().onOrAfter(Version.V_6_5_0)) {
686-
mappingVersion = in.readVLong();
687-
} else {
688-
mappingVersion = 1;
689-
}
690-
if (in.getVersion().onOrAfter(Version.V_6_5_0)) {
691-
settingsVersion = in.readVLong();
692-
} else {
693-
settingsVersion = 1;
694-
}
685+
mappingVersion = in.readVLong();
686+
settingsVersion = in.readVLong();
695687
state = State.fromId(in.readByte());
696688
settings = Settings.readSettingsFromStream(in);
697689
primaryTerms = in.readVLongArray();
@@ -703,36 +695,25 @@ private static class IndexMetaDataDiff implements Diff<IndexMetaData> {
703695
DiffableStringMap::readDiffFrom);
704696
inSyncAllocationIds = DiffableUtils.readImmutableOpenIntMapDiff(in, DiffableUtils.getVIntKeySerializer(),
705697
DiffableUtils.StringSetValueSerializer.getInstance());
706-
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
707-
rolloverInfos = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), RolloverInfo::new,
708-
RolloverInfo::readDiffFrom);
709-
} else {
710-
ImmutableOpenMap<String, RolloverInfo> emptyMap = ImmutableOpenMap.of();
711-
rolloverInfos = DiffableUtils.diff(emptyMap, emptyMap, DiffableUtils.getStringKeySerializer());
712-
}
698+
rolloverInfos = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), RolloverInfo::new,
699+
RolloverInfo::readDiffFrom);
713700
}
714701

715702
@Override
716703
public void writeTo(StreamOutput out) throws IOException {
717704
out.writeString(index);
718705
out.writeInt(routingNumShards);
719706
out.writeLong(version);
720-
if (out.getVersion().onOrAfter(Version.V_6_5_0)) {
721-
out.writeVLong(mappingVersion);
722-
}
723-
if (out.getVersion().onOrAfter(Version.V_6_5_0)) {
724-
out.writeVLong(settingsVersion);
725-
}
707+
out.writeVLong(mappingVersion);
708+
out.writeVLong(settingsVersion);
726709
out.writeByte(state.id);
727710
Settings.writeSettingsToStream(settings, out);
728711
out.writeVLongArray(primaryTerms);
729712
mappings.writeTo(out);
730713
aliases.writeTo(out);
731714
customData.writeTo(out);
732715
inSyncAllocationIds.writeTo(out);
733-
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
734-
rolloverInfos.writeTo(out);
735-
}
716+
rolloverInfos.writeTo(out);
736717
}
737718

738719
@Override
@@ -757,16 +738,8 @@ public IndexMetaData apply(IndexMetaData part) {
757738
public static IndexMetaData readFrom(StreamInput in) throws IOException {
758739
Builder builder = new Builder(in.readString());
759740
builder.version(in.readLong());
760-
if (in.getVersion().onOrAfter(Version.V_6_5_0)) {
761-
builder.mappingVersion(in.readVLong());
762-
} else {
763-
builder.mappingVersion(1);
764-
}
765-
if (in.getVersion().onOrAfter(Version.V_6_5_0)) {
766-
builder.settingsVersion(in.readVLong());
767-
} else {
768-
builder.settingsVersion(1);
769-
}
741+
builder.mappingVersion(in.readVLong());
742+
builder.settingsVersion(in.readVLong());
770743
builder.setRoutingNumShards(in.readInt());
771744
builder.state(State.fromId(in.readByte()));
772745
builder.settings(readSettingsFromStream(in));
@@ -782,29 +755,20 @@ public static IndexMetaData readFrom(StreamInput in) throws IOException {
782755
builder.putAlias(aliasMd);
783756
}
784757
int customSize = in.readVInt();
785-
if (in.getVersion().onOrAfter(Version.V_6_5_0)) {
786-
for (int i = 0; i < customSize; i++) {
787-
String key = in.readString();
788-
DiffableStringMap custom = new DiffableStringMap(in);
789-
builder.putCustom(key, custom);
790-
}
791-
} else {
792-
assert customSize == 0 : "expected no custom index metadata";
793-
if (customSize > 0) {
794-
throw new IllegalStateException("unexpected custom metadata when none is supported");
795-
}
758+
for (int i = 0; i < customSize; i++) {
759+
String key = in.readString();
760+
DiffableStringMap custom = new DiffableStringMap(in);
761+
builder.putCustom(key, custom);
796762
}
797763
int inSyncAllocationIdsSize = in.readVInt();
798764
for (int i = 0; i < inSyncAllocationIdsSize; i++) {
799765
int key = in.readVInt();
800766
Set<String> allocationIds = DiffableUtils.StringSetValueSerializer.getInstance().read(in, key);
801767
builder.putInSyncAllocationIds(key, allocationIds);
802768
}
803-
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
804-
int rolloverAliasesSize = in.readVInt();
805-
for (int i = 0; i < rolloverAliasesSize; i++) {
806-
builder.putRolloverInfo(new RolloverInfo(in));
807-
}
769+
int rolloverAliasesSize = in.readVInt();
770+
for (int i = 0; i < rolloverAliasesSize; i++) {
771+
builder.putRolloverInfo(new RolloverInfo(in));
808772
}
809773
return builder.build();
810774
}
@@ -813,12 +777,8 @@ public static IndexMetaData readFrom(StreamInput in) throws IOException {
813777
public void writeTo(StreamOutput out) throws IOException {
814778
out.writeString(index.getName()); // uuid will come as part of settings
815779
out.writeLong(version);
816-
if (out.getVersion().onOrAfter(Version.V_6_5_0)) {
817-
out.writeVLong(mappingVersion);
818-
}
819-
if (out.getVersion().onOrAfter(Version.V_6_5_0)) {
820-
out.writeVLong(settingsVersion);
821-
}
780+
out.writeVLong(mappingVersion);
781+
out.writeVLong(settingsVersion);
822782
out.writeInt(routingNumShards);
823783
out.writeByte(state.id());
824784
writeSettingsToStream(settings, out);
@@ -831,25 +791,19 @@ public void writeTo(StreamOutput out) throws IOException {
831791
for (ObjectCursor<AliasMetaData> cursor : aliases.values()) {
832792
cursor.value.writeTo(out);
833793
}
834-
if (out.getVersion().onOrAfter(Version.V_6_5_0)) {
835-
out.writeVInt(customData.size());
836-
for (final ObjectObjectCursor<String, DiffableStringMap> cursor : customData) {
837-
out.writeString(cursor.key);
838-
cursor.value.writeTo(out);
839-
}
840-
} else {
841-
out.writeVInt(0);
794+
out.writeVInt(customData.size());
795+
for (final ObjectObjectCursor<String, DiffableStringMap> cursor : customData) {
796+
out.writeString(cursor.key);
797+
cursor.value.writeTo(out);
842798
}
843799
out.writeVInt(inSyncAllocationIds.size());
844800
for (IntObjectCursor<Set<String>> cursor : inSyncAllocationIds) {
845801
out.writeVInt(cursor.key);
846802
DiffableUtils.StringSetValueSerializer.getInstance().write(cursor.value, out);
847803
}
848-
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
849-
out.writeVInt(rolloverInfos.size());
850-
for (ObjectCursor<RolloverInfo> cursor : rolloverInfos.values()) {
851-
cursor.value.writeTo(out);
852-
}
804+
out.writeVInt(rolloverInfos.size());
805+
for (ObjectCursor<RolloverInfo> cursor : rolloverInfos.values()) {
806+
cursor.value.writeTo(out);
853807
}
854808
}
855809

server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
2323
import org.apache.logging.log4j.LogManager;
2424
import org.elasticsearch.ElasticsearchParseException;
25-
import org.elasticsearch.Version;
2625
import org.elasticsearch.cluster.AbstractDiffable;
2726
import org.elasticsearch.cluster.Diff;
2827
import org.elasticsearch.common.Nullable;
@@ -188,11 +187,7 @@ public int hashCode() {
188187
public static IndexTemplateMetaData readFrom(StreamInput in) throws IOException {
189188
Builder builder = new Builder(in.readString());
190189
builder.order(in.readInt());
191-
if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
192-
builder.patterns(in.readStringList());
193-
} else {
194-
builder.patterns(Collections.singletonList(in.readString()));
195-
}
190+
builder.patterns(in.readStringList());
196191
builder.settings(Settings.readSettingsFromStream(in));
197192
int mappingsSize = in.readVInt();
198193
for (int i = 0; i < mappingsSize; i++) {
@@ -203,14 +198,6 @@ public static IndexTemplateMetaData readFrom(StreamInput in) throws IOException
203198
AliasMetaData aliasMd = new AliasMetaData(in);
204199
builder.putAlias(aliasMd);
205200
}
206-
if (in.getVersion().before(Version.V_6_5_0)) {
207-
// Previously we allowed custom metadata
208-
int customSize = in.readVInt();
209-
assert customSize == 0 : "expected no custom metadata";
210-
if (customSize > 0) {
211-
throw new IllegalStateException("unexpected custom metadata when none is supported");
212-
}
213-
}
214201
builder.version(in.readOptionalVInt());
215202
return builder.build();
216203
}
@@ -223,11 +210,7 @@ public static Diff<IndexTemplateMetaData> readDiffFrom(StreamInput in) throws IO
223210
public void writeTo(StreamOutput out) throws IOException {
224211
out.writeString(name);
225212
out.writeInt(order);
226-
if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
227-
out.writeStringCollection(patterns);
228-
} else {
229-
out.writeString(patterns.get(0));
230-
}
213+
out.writeStringCollection(patterns);
231214
Settings.writeSettingsToStream(settings, out);
232215
out.writeVInt(mappings.size());
233216
for (ObjectObjectCursor<String, CompressedXContent> cursor : mappings) {
@@ -238,9 +221,6 @@ public void writeTo(StreamOutput out) throws IOException {
238221
for (ObjectCursor<AliasMetaData> cursor : aliases.values()) {
239222
cursor.value.writeTo(out);
240223
}
241-
if (out.getVersion().before(Version.V_6_5_0)) {
242-
out.writeVInt(0);
243-
}
244224
out.writeOptionalVInt(version);
245225
}
246226

server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.cluster.metadata;
2121

2222
import org.elasticsearch.ElasticsearchParseException;
23-
import org.elasticsearch.Version;
2423
import org.elasticsearch.cluster.AbstractDiffable;
2524
import org.elasticsearch.cluster.Diff;
2625
import org.elasticsearch.common.bytes.BytesReference;
@@ -30,7 +29,6 @@
3029
import org.elasticsearch.common.xcontent.XContentBuilder;
3130
import org.elasticsearch.common.xcontent.XContentFactory;
3231
import org.elasticsearch.common.xcontent.XContentHelper;
33-
import org.elasticsearch.index.mapper.DateFieldMapper;
3432
import org.elasticsearch.index.mapper.DocumentMapper;
3533

3634
import java.io.IOException;
@@ -171,16 +169,6 @@ public void writeTo(StreamOutput out) throws IOException {
171169
source().writeTo(out);
172170
// routing
173171
out.writeBoolean(routing().required());
174-
if (out.getVersion().before(Version.V_6_0_0_alpha1)) {
175-
// timestamp
176-
out.writeBoolean(false); // enabled
177-
out.writeString(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.pattern());
178-
out.writeOptionalString("now"); // 5.x default
179-
out.writeOptionalBoolean(null);
180-
}
181-
if (out.getVersion().before(Version.V_7_0_0)) {
182-
out.writeBoolean(false); // hasParentField
183-
}
184172
}
185173

186174
@Override
@@ -210,19 +198,6 @@ public MappingMetaData(StreamInput in) throws IOException {
210198
source = CompressedXContent.readCompressedString(in);
211199
// routing
212200
routing = new Routing(in.readBoolean());
213-
if (in.getVersion().before(Version.V_6_0_0_alpha1)) {
214-
// timestamp
215-
boolean enabled = in.readBoolean();
216-
if (enabled) {
217-
throw new IllegalArgumentException("_timestamp may not be enabled");
218-
}
219-
in.readString(); // format
220-
in.readOptionalString(); // defaultTimestamp
221-
in.readOptionalBoolean(); // ignoreMissing
222-
}
223-
if (in.getVersion().before(Version.V_7_0_0)) {
224-
in.readBoolean(); // hasParentField
225-
}
226201
}
227202

228203
public static Diff<MappingMetaData> readDiffFrom(StreamInput in) throws IOException {

0 commit comments

Comments
 (0)