@@ -682,16 +682,8 @@ private static class IndexMetaDataDiff implements Diff<IndexMetaData> {
682
682
index = in .readString ();
683
683
routingNumShards = in .readInt ();
684
684
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 ();
695
687
state = State .fromId (in .readByte ());
696
688
settings = Settings .readSettingsFromStream (in );
697
689
primaryTerms = in .readVLongArray ();
@@ -703,36 +695,25 @@ private static class IndexMetaDataDiff implements Diff<IndexMetaData> {
703
695
DiffableStringMap ::readDiffFrom );
704
696
inSyncAllocationIds = DiffableUtils .readImmutableOpenIntMapDiff (in , DiffableUtils .getVIntKeySerializer (),
705
697
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 );
713
700
}
714
701
715
702
@ Override
716
703
public void writeTo (StreamOutput out ) throws IOException {
717
704
out .writeString (index );
718
705
out .writeInt (routingNumShards );
719
706
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 );
726
709
out .writeByte (state .id );
727
710
Settings .writeSettingsToStream (settings , out );
728
711
out .writeVLongArray (primaryTerms );
729
712
mappings .writeTo (out );
730
713
aliases .writeTo (out );
731
714
customData .writeTo (out );
732
715
inSyncAllocationIds .writeTo (out );
733
- if (out .getVersion ().onOrAfter (Version .V_6_4_0 )) {
734
- rolloverInfos .writeTo (out );
735
- }
716
+ rolloverInfos .writeTo (out );
736
717
}
737
718
738
719
@ Override
@@ -757,16 +738,8 @@ public IndexMetaData apply(IndexMetaData part) {
757
738
public static IndexMetaData readFrom (StreamInput in ) throws IOException {
758
739
Builder builder = new Builder (in .readString ());
759
740
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 ());
770
743
builder .setRoutingNumShards (in .readInt ());
771
744
builder .state (State .fromId (in .readByte ()));
772
745
builder .settings (readSettingsFromStream (in ));
@@ -782,29 +755,20 @@ public static IndexMetaData readFrom(StreamInput in) throws IOException {
782
755
builder .putAlias (aliasMd );
783
756
}
784
757
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 );
796
762
}
797
763
int inSyncAllocationIdsSize = in .readVInt ();
798
764
for (int i = 0 ; i < inSyncAllocationIdsSize ; i ++) {
799
765
int key = in .readVInt ();
800
766
Set <String > allocationIds = DiffableUtils .StringSetValueSerializer .getInstance ().read (in , key );
801
767
builder .putInSyncAllocationIds (key , allocationIds );
802
768
}
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 ));
808
772
}
809
773
return builder .build ();
810
774
}
@@ -813,12 +777,8 @@ public static IndexMetaData readFrom(StreamInput in) throws IOException {
813
777
public void writeTo (StreamOutput out ) throws IOException {
814
778
out .writeString (index .getName ()); // uuid will come as part of settings
815
779
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 );
822
782
out .writeInt (routingNumShards );
823
783
out .writeByte (state .id ());
824
784
writeSettingsToStream (settings , out );
@@ -831,25 +791,19 @@ public void writeTo(StreamOutput out) throws IOException {
831
791
for (ObjectCursor <AliasMetaData > cursor : aliases .values ()) {
832
792
cursor .value .writeTo (out );
833
793
}
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 );
842
798
}
843
799
out .writeVInt (inSyncAllocationIds .size ());
844
800
for (IntObjectCursor <Set <String >> cursor : inSyncAllocationIds ) {
845
801
out .writeVInt (cursor .key );
846
802
DiffableUtils .StringSetValueSerializer .getInstance ().write (cursor .value , out );
847
803
}
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 );
853
807
}
854
808
}
855
809
0 commit comments