@@ -51,7 +51,6 @@ final class Checkpoint {
5151 final long minTranslogGeneration ;
5252 final long trimmedAboveSeqNo ;
5353
54- private static final int INITIAL_VERSION = 1 ; // start with 1, just to recognize there was some magic serialization logic before
5554 private static final int VERSION_6_0_0 = 2 ; // introduction of global checkpoints
5655 private static final int CURRENT_VERSION = 3 ; // introduction of trimmed above seq#
5756
@@ -63,10 +62,10 @@ final class Checkpoint {
6362 + Integer .BYTES // ops
6463 + Long .BYTES // offset
6564 + Long .BYTES // generation
66- + Long .BYTES // minimum sequence number, introduced in 6.0.0
67- + Long .BYTES // maximum sequence number, introduced in 6.0.0
68- + Long .BYTES // global checkpoint, introduced in 6.0.0
69- + Long .BYTES // minimum translog generation in the translog - introduced in 6.0.0
65+ + Long .BYTES // minimum sequence number
66+ + Long .BYTES // maximum sequence number
67+ + Long .BYTES // global checkpoint
68+ + Long .BYTES // minimum translog generation in the translog
7069 + Long .BYTES // maximum reachable (trimmed) sequence number, introduced in 6.4.0
7170 + CodecUtil .footerLength ();
7271
@@ -75,17 +74,10 @@ final class Checkpoint {
7574 + Integer .BYTES // ops
7675 + Long .BYTES // offset
7776 + Long .BYTES // generation
78- + Long .BYTES // minimum sequence number, introduced in 6.0.0
79- + Long .BYTES // maximum sequence number, introduced in 6.0.0
80- + Long .BYTES // global checkpoint, introduced in 6.0.0
81- + Long .BYTES // minimum translog generation in the translog - introduced in 6.0.0
82- + CodecUtil .footerLength ();
83-
84- // size of 5.0.0 checkpoint
85- static final int V1_FILE_SIZE = CodecUtil .headerLength (CHECKPOINT_CODEC )
86- + Integer .BYTES // ops
87- + Long .BYTES // offset
88- + Long .BYTES // generation
77+ + Long .BYTES // minimum sequence number
78+ + Long .BYTES // maximum sequence number
79+ + Long .BYTES // global checkpoint
80+ + Long .BYTES // minimum translog generation in the translog
8981 + CodecUtil .footerLength ();
9082
9183 /**
@@ -136,7 +128,7 @@ static Checkpoint emptyTranslogCheckpoint(final long offset, final long generati
136128 return new Checkpoint (offset , 0 , generation , minSeqNo , maxSeqNo , globalCheckpoint , minTranslogGeneration , trimmedAboveSeqNo );
137129 }
138130
139- static Checkpoint readCheckpointV6_4_0 (final DataInput in ) throws IOException {
131+ static Checkpoint readCheckpointV3 (final DataInput in ) throws IOException {
140132 final long offset = in .readLong ();
141133 final int numOps = in .readInt ();
142134 final long generation = in .readLong ();
@@ -148,7 +140,7 @@ static Checkpoint readCheckpointV6_4_0(final DataInput in) throws IOException {
148140 return new Checkpoint (offset , numOps , generation , minSeqNo , maxSeqNo , globalCheckpoint , minTranslogGeneration , trimmedAboveSeqNo );
149141 }
150142
151- static Checkpoint readCheckpointV6_0_0 (final DataInput in ) throws IOException {
143+ static Checkpoint readCheckpointV2 (final DataInput in ) throws IOException {
152144 final long offset = in .readLong ();
153145 final int numOps = in .readInt ();
154146 final long generation = in .readLong ();
@@ -160,19 +152,6 @@ static Checkpoint readCheckpointV6_0_0(final DataInput in) throws IOException {
160152 return new Checkpoint (offset , numOps , generation , minSeqNo , maxSeqNo , globalCheckpoint , minTranslogGeneration , trimmedAboveSeqNo );
161153 }
162154
163- // reads a checksummed checkpoint introduced in ES 5.0.0
164- static Checkpoint readCheckpointV5_0_0 (final DataInput in ) throws IOException {
165- final long offset = in .readLong ();
166- final int numOps = in .readInt ();
167- final long generation = in .readLong ();
168- final long minSeqNo = SequenceNumbers .NO_OPS_PERFORMED ;
169- final long maxSeqNo = SequenceNumbers .NO_OPS_PERFORMED ;
170- final long globalCheckpoint = SequenceNumbers .UNASSIGNED_SEQ_NO ;
171- final long minTranslogGeneration = -1 ;
172- final long trimmedAboveSeqNo = SequenceNumbers .UNASSIGNED_SEQ_NO ;
173- return new Checkpoint (offset , numOps , generation , minSeqNo , maxSeqNo , globalCheckpoint , minTranslogGeneration , trimmedAboveSeqNo );
174- }
175-
176155 @ Override
177156 public String toString () {
178157 return "Checkpoint{" +
@@ -192,17 +171,14 @@ public static Checkpoint read(Path path) throws IOException {
192171 try (IndexInput indexInput = dir .openInput (path .getFileName ().toString (), IOContext .DEFAULT )) {
193172 // We checksum the entire file before we even go and parse it. If it's corrupted we barf right here.
194173 CodecUtil .checksumEntireFile (indexInput );
195- final int fileVersion = CodecUtil .checkHeader (indexInput , CHECKPOINT_CODEC , INITIAL_VERSION , CURRENT_VERSION );
196- if (fileVersion == INITIAL_VERSION ) {
197- assert indexInput .length () == V1_FILE_SIZE : indexInput .length ();
198- return Checkpoint .readCheckpointV5_0_0 (indexInput );
199- } else if (fileVersion == VERSION_6_0_0 ) {
174+ final int fileVersion = CodecUtil .checkHeader (indexInput , CHECKPOINT_CODEC , VERSION_6_0_0 , CURRENT_VERSION );
175+ if (fileVersion == VERSION_6_0_0 ) {
200176 assert indexInput .length () == V2_FILE_SIZE : indexInput .length ();
201- return Checkpoint .readCheckpointV6_0_0 (indexInput );
177+ return Checkpoint .readCheckpointV2 (indexInput );
202178 } else {
203179 assert fileVersion == CURRENT_VERSION : fileVersion ;
204180 assert indexInput .length () == V3_FILE_SIZE : indexInput .length ();
205- return Checkpoint .readCheckpointV6_4_0 (indexInput );
181+ return Checkpoint .readCheckpointV3 (indexInput );
206182 }
207183 } catch (CorruptIndexException | NoSuchFileException | IndexFormatTooOldException | IndexFormatTooNewException e ) {
208184 throw new TranslogCorruptedException (path .toString (), e );
0 commit comments