@@ -34,22 +34,16 @@ public class LocalCheckpointTracker {
34
34
35
35
/**
36
36
* We keep a bit for each sequence number that is still pending. To optimize allocation, we do so in multiple arrays allocating them on
37
- * demand and cleaning up while completed. This setting controls the size of the arrays.
37
+ * demand and cleaning up while completed. This constant controls the size of the arrays.
38
38
*/
39
- public static Setting <Integer > SETTINGS_BIT_ARRAYS_SIZE =
40
- Setting .intSetting ("index.seq_no.checkpoint.bit_arrays_size" , 1024 , 4 , Setting .Property .IndexScope );
39
+ static final int BIT_ARRAYS_SIZE = 1024 ;
41
40
42
41
/**
43
42
* An ordered list of bit arrays representing pending sequence numbers. The list is "anchored" in {@link #firstProcessedSeqNo} which
44
43
* marks the sequence number the fist bit in the first array corresponds to.
45
44
*/
46
45
final LinkedList <FixedBitSet > processedSeqNo = new LinkedList <>();
47
46
48
- /**
49
- * The size of each bit set representing processed sequence numbers.
50
- */
51
- private final int bitArraysSize ;
52
-
53
47
/**
54
48
* The sequence number that the first bit in the first array corresponds to.
55
49
*/
@@ -70,11 +64,10 @@ public class LocalCheckpointTracker {
70
64
* {@link SequenceNumbers#NO_OPS_PERFORMED} and {@code localCheckpoint} should be set to the last known local checkpoint,
71
65
* or {@link SequenceNumbers#NO_OPS_PERFORMED}.
72
66
*
73
- * @param indexSettings the index settings
74
67
* @param maxSeqNo the last sequence number assigned, or {@link SequenceNumbers#NO_OPS_PERFORMED}
75
68
* @param localCheckpoint the last known local checkpoint, or {@link SequenceNumbers#NO_OPS_PERFORMED}
76
69
*/
77
- public LocalCheckpointTracker (final IndexSettings indexSettings , final long maxSeqNo , final long localCheckpoint ) {
70
+ public LocalCheckpointTracker (final long maxSeqNo , final long localCheckpoint ) {
78
71
if (localCheckpoint < 0 && localCheckpoint != SequenceNumbers .NO_OPS_PERFORMED ) {
79
72
throw new IllegalArgumentException (
80
73
"local checkpoint must be non-negative or [" + SequenceNumbers .NO_OPS_PERFORMED + "] "
@@ -84,7 +77,6 @@ public LocalCheckpointTracker(final IndexSettings indexSettings, final long maxS
84
77
throw new IllegalArgumentException (
85
78
"max seq. no. must be non-negative or [" + SequenceNumbers .NO_OPS_PERFORMED + "] but was [" + maxSeqNo + "]" );
86
79
}
87
- bitArraysSize = SETTINGS_BIT_ARRAYS_SIZE .get (indexSettings .getSettings ());
88
80
firstProcessedSeqNo = localCheckpoint == SequenceNumbers .NO_OPS_PERFORMED ? 0 : localCheckpoint + 1 ;
89
81
nextSeqNo = maxSeqNo == SequenceNumbers .NO_OPS_PERFORMED ? 0 : maxSeqNo + 1 ;
90
82
checkpoint = localCheckpoint ;
@@ -183,7 +175,7 @@ synchronized void waitForOpsToComplete(final long seqNo) throws InterruptedExcep
183
175
@ SuppressForbidden (reason = "Object#notifyAll" )
184
176
private void updateCheckpoint () {
185
177
assert Thread .holdsLock (this );
186
- assert checkpoint < firstProcessedSeqNo + bitArraysSize - 1 :
178
+ assert checkpoint < firstProcessedSeqNo + BIT_ARRAYS_SIZE - 1 :
187
179
"checkpoint should be below the end of the first bit set (o.w. current bit set is completed and shouldn't be there)" ;
188
180
assert getBitSetForSeqNo (checkpoint + 1 ) == processedSeqNo .getFirst () :
189
181
"checkpoint + 1 doesn't point to the first bit set (o.w. current bit set is completed and shouldn't be there)" ;
@@ -196,10 +188,10 @@ assert getBitSetForSeqNo(checkpoint + 1).get(seqNoToBitSetOffset(checkpoint + 1)
196
188
checkpoint ++;
197
189
// the checkpoint always falls in the first bit set or just before. If it falls
198
190
// on the last bit of the current bit set, we can clean it.
199
- if (checkpoint == firstProcessedSeqNo + bitArraysSize - 1 ) {
191
+ if (checkpoint == firstProcessedSeqNo + BIT_ARRAYS_SIZE - 1 ) {
200
192
processedSeqNo .removeFirst ();
201
- firstProcessedSeqNo += bitArraysSize ;
202
- assert checkpoint - firstProcessedSeqNo < bitArraysSize ;
193
+ firstProcessedSeqNo += BIT_ARRAYS_SIZE ;
194
+ assert checkpoint - firstProcessedSeqNo < BIT_ARRAYS_SIZE ;
203
195
current = processedSeqNo .peekFirst ();
204
196
}
205
197
} while (current != null && current .get (seqNoToBitSetOffset (checkpoint + 1 )));
@@ -218,13 +210,13 @@ assert getBitSetForSeqNo(checkpoint + 1).get(seqNoToBitSetOffset(checkpoint + 1)
218
210
private FixedBitSet getBitSetForSeqNo (final long seqNo ) {
219
211
assert Thread .holdsLock (this );
220
212
assert seqNo >= firstProcessedSeqNo : "seqNo: " + seqNo + " firstProcessedSeqNo: " + firstProcessedSeqNo ;
221
- final long bitSetOffset = (seqNo - firstProcessedSeqNo ) / bitArraysSize ;
213
+ final long bitSetOffset = (seqNo - firstProcessedSeqNo ) / BIT_ARRAYS_SIZE ;
222
214
if (bitSetOffset > Integer .MAX_VALUE ) {
223
215
throw new IndexOutOfBoundsException (
224
216
"sequence number too high; got [" + seqNo + "], firstProcessedSeqNo [" + firstProcessedSeqNo + "]" );
225
217
}
226
218
while (bitSetOffset >= processedSeqNo .size ()) {
227
- processedSeqNo .add (new FixedBitSet (bitArraysSize ));
219
+ processedSeqNo .add (new FixedBitSet (BIT_ARRAYS_SIZE ));
228
220
}
229
221
return processedSeqNo .get ((int ) bitSetOffset );
230
222
}
@@ -239,7 +231,7 @@ private FixedBitSet getBitSetForSeqNo(final long seqNo) {
239
231
private int seqNoToBitSetOffset (final long seqNo ) {
240
232
assert Thread .holdsLock (this );
241
233
assert seqNo >= firstProcessedSeqNo ;
242
- return ((int ) (seqNo - firstProcessedSeqNo )) % bitArraysSize ;
234
+ return ((int ) (seqNo - firstProcessedSeqNo )) % BIT_ARRAYS_SIZE ;
243
235
}
244
236
245
237
}
0 commit comments