forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManagedLedgerConfig.java
775 lines (685 loc) · 24.7 KB
/
ManagedLedgerConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.bookkeeper.mledger;
import static com.google.common.base.Preconditions.checkArgument;
import java.nio.charset.StandardCharsets;
import java.time.Clock;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import lombok.Setter;
import org.apache.bookkeeper.client.EnsemblePlacementPolicy;
import org.apache.bookkeeper.client.api.DigestType;
import org.apache.bookkeeper.common.annotation.InterfaceAudience;
import org.apache.bookkeeper.common.annotation.InterfaceStability;
import org.apache.bookkeeper.mledger.impl.NullLedgerOffloader;
import org.apache.bookkeeper.mledger.intercept.ManagedLedgerInterceptor;
import org.apache.commons.collections4.MapUtils;
import org.apache.pulsar.common.util.collections.OpenLongPairRangeSet;
/**
* Configuration class for a ManagedLedger.
*/
@InterfaceAudience.LimitedPrivate
@InterfaceStability.Stable
public class ManagedLedgerConfig {
private boolean createIfMissing = true;
private int maxUnackedRangesToPersist = 10000;
private int maxBatchDeletedIndexToPersist = 10000;
private boolean persistentUnackedRangesWithMultipleEntriesEnabled = false;
private boolean deletionAtBatchIndexLevelEnabled = true;
private int maxUnackedRangesToPersistInMetadataStore = 1000;
private int maxEntriesPerLedger = 50000;
private int maxSizePerLedgerMb = 100;
private int minimumRolloverTimeMs = 0;
private long maximumRolloverTimeMs = TimeUnit.HOURS.toMillis(4);
private int ensembleSize = 3;
private int writeQuorumSize = 2;
private int ackQuorumSize = 2;
private int metadataEnsembleSize = 3;
private int metadataWriteQuorumSize = 2;
private int metadataAckQuorumSize = 2;
private int metadataMaxEntriesPerLedger = 50000;
private int ledgerRolloverTimeout = 4 * 3600;
private double throttleMarkDelete = 0;
private long retentionTimeMs = 0;
private long retentionSizeInMB = 0;
private boolean autoSkipNonRecoverableData;
private boolean lazyCursorRecovery = false;
private long metadataOperationsTimeoutSeconds = 60;
private long readEntryTimeoutSeconds = 120;
private long addEntryTimeoutSeconds = 120;
private DigestType digestType = DigestType.CRC32C;
private byte[] password = "".getBytes(StandardCharsets.UTF_8);
private boolean unackedRangesOpenCacheSetEnabled = true;
private Class<? extends EnsemblePlacementPolicy> bookKeeperEnsemblePlacementPolicyClassName;
private Map<String, Object> bookKeeperEnsemblePlacementPolicyProperties;
private LedgerOffloader ledgerOffloader = NullLedgerOffloader.INSTANCE;
private int newEntriesCheckDelayInMillis = 10;
private Clock clock = Clock.systemUTC();
private ManagedLedgerInterceptor managedLedgerInterceptor;
private Map<String, String> properties;
private int inactiveLedgerRollOverTimeMs = 0;
@Getter
@Setter
private boolean cacheEvictionByMarkDeletedPosition = false;
private int minimumBacklogCursorsForCaching = 0;
private int minimumBacklogEntriesForCaching = 1000;
private int maxBacklogBetweenCursorsForCaching = 1000;
private boolean triggerOffloadOnTopicLoad = false;
@Getter
@Setter
private String shadowSourceName;
public boolean isCreateIfMissing() {
return createIfMissing;
}
public ManagedLedgerConfig setCreateIfMissing(boolean createIfMissing) {
this.createIfMissing = createIfMissing;
return this;
}
/**
* @return the lazyCursorRecovery
*/
public boolean isLazyCursorRecovery() {
return lazyCursorRecovery;
}
/**
* Whether to recover cursors lazily when trying to recover a
* managed ledger backing a persistent topic. It can improve write availability of topics.
* The caveat is now when recovered ledger is ready to write we're not sure if all old consumers last mark
* delete position can be recovered or not.
* @param lazyCursorRecovery if enable lazy cursor recovery.
*/
public ManagedLedgerConfig setLazyCursorRecovery(boolean lazyCursorRecovery) {
this.lazyCursorRecovery = lazyCursorRecovery;
return this;
}
/**
* @return the maxEntriesPerLedger
*/
public int getMaxEntriesPerLedger() {
return maxEntriesPerLedger;
}
/**
* @param maxEntriesPerLedger
* the maxEntriesPerLedger to set
*/
public ManagedLedgerConfig setMaxEntriesPerLedger(int maxEntriesPerLedger) {
this.maxEntriesPerLedger = maxEntriesPerLedger;
return this;
}
/**
* @return the maxSizePerLedgerMb
*/
public int getMaxSizePerLedgerMb() {
return maxSizePerLedgerMb;
}
/**
* @param maxSizePerLedgerMb
* the maxSizePerLedgerMb to set
*/
public ManagedLedgerConfig setMaxSizePerLedgerMb(int maxSizePerLedgerMb) {
this.maxSizePerLedgerMb = maxSizePerLedgerMb;
return this;
}
/**
* @return the minimum rollover time
*/
public int getMinimumRolloverTimeMs() {
return minimumRolloverTimeMs;
}
/**
* Set the minimum rollover time for ledgers in this managed ledger.
*
* <p/>If this time is > 0, a ledger will not be rolled over more frequently than the specified time, even if it has
* reached the maximum number of entries or maximum size. This parameter can be used to reduce the amount of
* rollovers on managed ledger with high write throughput.
*
* @param minimumRolloverTime
* the minimum rollover time
* @param unit
* the time unit
*/
public void setMinimumRolloverTime(int minimumRolloverTime, TimeUnit unit) {
this.minimumRolloverTimeMs = (int) unit.toMillis(minimumRolloverTime);
checkArgument(maximumRolloverTimeMs >= minimumRolloverTimeMs,
"Minimum rollover time needs to be less than maximum rollover time");
}
/**
* @return the maximum rollover time.
*/
public long getMaximumRolloverTimeMs() {
return maximumRolloverTimeMs;
}
/**
* Set the maximum rollover time for ledgers in this managed ledger.
*
* <p/>If the ledger is not rolled over until this time, even if it has not reached the number of entry or size
* limit, this setting will trigger rollover. This parameter can be used for topics with low request rate to force
* rollover, so recovery failure does not have to go far back.
*
* @param maximumRolloverTime
* the maximum rollover time
* @param unit
* the time unit
*/
public void setMaximumRolloverTime(int maximumRolloverTime, TimeUnit unit) {
this.maximumRolloverTimeMs = unit.toMillis(maximumRolloverTime);
checkArgument(maximumRolloverTimeMs >= minimumRolloverTimeMs,
"Maximum rollover time needs to be greater than minimum rollover time");
}
/**
* @return the ensembleSize
*/
public int getEnsembleSize() {
return ensembleSize;
}
/**
* @param ensembleSize
* the ensembleSize to set
*/
public ManagedLedgerConfig setEnsembleSize(int ensembleSize) {
this.ensembleSize = ensembleSize;
return this;
}
/**
* @return the ackQuorumSize
*/
public int getAckQuorumSize() {
return ackQuorumSize;
}
/**
* @return the writeQuorumSize
*/
public int getWriteQuorumSize() {
return writeQuorumSize;
}
/**
* @param writeQuorumSize
* the writeQuorumSize to set
*/
public ManagedLedgerConfig setWriteQuorumSize(int writeQuorumSize) {
this.writeQuorumSize = writeQuorumSize;
return this;
}
/**
* @param ackQuorumSize
* the ackQuorumSize to set
*/
public ManagedLedgerConfig setAckQuorumSize(int ackQuorumSize) {
this.ackQuorumSize = ackQuorumSize;
return this;
}
/**
* @return the digestType
*/
public DigestType getDigestType() {
return digestType;
}
/**
* @param digestType
* the digestType to set
*/
public ManagedLedgerConfig setDigestType(DigestType digestType) {
this.digestType = digestType;
return this;
}
/**
* @return the password
*/
public byte[] getPassword() {
return Arrays.copyOf(password, password.length);
}
/**
* @param password
* the password to set
*/
public ManagedLedgerConfig setPassword(String password) {
this.password = password.getBytes(StandardCharsets.UTF_8);
return this;
}
/**
* should use {@link OpenLongPairRangeSet} to store unacked ranges.
* @return
*/
public boolean isUnackedRangesOpenCacheSetEnabled() {
return unackedRangesOpenCacheSetEnabled;
}
public ManagedLedgerConfig setUnackedRangesOpenCacheSetEnabled(boolean unackedRangesOpenCacheSetEnabled) {
this.unackedRangesOpenCacheSetEnabled = unackedRangesOpenCacheSetEnabled;
return this;
}
/**
* @return the metadataEnsemblesize
*/
public int getMetadataEnsemblesize() {
return metadataEnsembleSize;
}
/**
* @param metadataEnsembleSize
* the metadataEnsembleSize to set
*/
public ManagedLedgerConfig setMetadataEnsembleSize(int metadataEnsembleSize) {
this.metadataEnsembleSize = metadataEnsembleSize;
return this;
}
/**
* @return the metadataAckQuorumSize
*/
public int getMetadataAckQuorumSize() {
return metadataAckQuorumSize;
}
/**
* @return the metadataWriteQuorumSize
*/
public int getMetadataWriteQuorumSize() {
return metadataWriteQuorumSize;
}
/**
* @param metadataAckQuorumSize
* the metadataAckQuorumSize to set
*/
public ManagedLedgerConfig setMetadataAckQuorumSize(int metadataAckQuorumSize) {
this.metadataAckQuorumSize = metadataAckQuorumSize;
return this;
}
/**
* @param metadataWriteQuorumSize
* the metadataWriteQuorumSize to set
*/
public ManagedLedgerConfig setMetadataWriteQuorumSize(int metadataWriteQuorumSize) {
this.metadataWriteQuorumSize = metadataWriteQuorumSize;
return this;
}
/**
* @return the metadataMaxEntriesPerLedger
*/
public int getMetadataMaxEntriesPerLedger() {
return metadataMaxEntriesPerLedger;
}
/**
* @param metadataMaxEntriesPerLedger
* the metadataMaxEntriesPerLedger to set
*/
public ManagedLedgerConfig setMetadataMaxEntriesPerLedger(int metadataMaxEntriesPerLedger) {
this.metadataMaxEntriesPerLedger = metadataMaxEntriesPerLedger;
return this;
}
/**
* @return the ledgerRolloverTimeout
*/
public int getLedgerRolloverTimeout() {
return ledgerRolloverTimeout;
}
/**
* @param ledgerRolloverTimeout
* the ledgerRolloverTimeout to set
*/
public ManagedLedgerConfig setLedgerRolloverTimeout(int ledgerRolloverTimeout) {
this.ledgerRolloverTimeout = ledgerRolloverTimeout;
return this;
}
/**
* @return the throttling rate limit for mark-delete calls
*/
public double getThrottleMarkDelete() {
return throttleMarkDelete;
}
/**
* Set the rate limiter on how many mark-delete calls per second are allowed. If the value is set to 0, the rate
* limiter is disabled. Default is 0.
*
* @param throttleMarkDelete
* the max number of mark-delete calls allowed per second
*/
public ManagedLedgerConfig setThrottleMarkDelete(double throttleMarkDelete) {
checkArgument(throttleMarkDelete >= 0.0);
this.throttleMarkDelete = throttleMarkDelete;
return this;
}
/**
* Set the retention time for the ManagedLedger.
* <p>
* Retention time and retention size ({@link #setRetentionSizeInMB(long)}) are together used to retain the
* ledger data when there are no cursors or when all the cursors have marked the data for deletion.
* Data will be deleted in this case when both retention time and retention size settings don't prevent deleting
* the data marked for deletion.
* <p>
* A retention time of 0 (default) will make data to be deleted immediately.
* <p>
* A retention time of -1, means to have an unlimited retention time.
*
* @param retentionTime
* duration for which messages should be retained
* @param unit
* time unit for retention time
*/
public ManagedLedgerConfig setRetentionTime(int retentionTime, TimeUnit unit) {
this.retentionTimeMs = unit.toMillis(retentionTime);
return this;
}
/**
* @return duration for which messages are retained
*
*/
public long getRetentionTimeMillis() {
return retentionTimeMs;
}
/**
* The retention size is used to set a maximum retention size quota on the ManagedLedger.
* <p>
* Retention size and retention time ({@link #setRetentionTime(int, TimeUnit)}) are together used to retain the
* ledger data when there are no cursors or when all the cursors have marked the data for deletion.
* Data will be deleted in this case when both retention time and retention size settings don't prevent deleting
* the data marked for deletion.
* <p>
* A retention size of 0 (default) will make data to be deleted immediately.
* <p>
* A retention size of -1, means to have an unlimited retention size.
*
* @param retentionSizeInMB
* quota for message retention
*/
public ManagedLedgerConfig setRetentionSizeInMB(long retentionSizeInMB) {
this.retentionSizeInMB = retentionSizeInMB;
return this;
}
/**
* @return quota for message retention
*
*/
public long getRetentionSizeInMB() {
return retentionSizeInMB;
}
/**
* Skip reading non-recoverable/unreadable data-ledger under managed-ledger's list. It helps when data-ledgers gets
* corrupted at bookkeeper and managed-cursor is stuck at that ledger.
*/
public boolean isAutoSkipNonRecoverableData() {
return autoSkipNonRecoverableData;
}
public void setAutoSkipNonRecoverableData(boolean skipNonRecoverableData) {
this.autoSkipNonRecoverableData = skipNonRecoverableData;
}
/**
* @return max unacked message ranges that will be persisted and recovered.
*
*/
public int getMaxUnackedRangesToPersist() {
return maxUnackedRangesToPersist;
}
/**
* @return max batch deleted index that will be persisted and recoverd.
*/
public int getMaxBatchDeletedIndexToPersist() {
return maxBatchDeletedIndexToPersist;
}
public boolean isPersistentUnackedRangesWithMultipleEntriesEnabled() {
return persistentUnackedRangesWithMultipleEntriesEnabled;
}
public void setPersistentUnackedRangesWithMultipleEntriesEnabled(boolean multipleEntriesEnabled) {
this.persistentUnackedRangesWithMultipleEntriesEnabled = multipleEntriesEnabled;
}
/**
* @param maxUnackedRangesToPersist
* max unacked message ranges that will be persisted and receverd.
*/
public ManagedLedgerConfig setMaxUnackedRangesToPersist(int maxUnackedRangesToPersist) {
this.maxUnackedRangesToPersist = maxUnackedRangesToPersist;
return this;
}
/**
* @return max unacked message ranges up to which it can store in Zookeeper
*
*/
public int getMaxUnackedRangesToPersistInMetadataStore() {
return maxUnackedRangesToPersistInMetadataStore;
}
public ManagedLedgerConfig setMaxUnackedRangesToPersistInMetadataStore(
int maxUnackedRangesToPersistInMetadataStore) {
this.maxUnackedRangesToPersistInMetadataStore = maxUnackedRangesToPersistInMetadataStore;
return this;
}
/**
* Get ledger offloader which will be used to offload ledgers to longterm storage.
*
* The default offloader throws an exception on any attempt to offload.
*
* @return a ledger offloader
*/
public LedgerOffloader getLedgerOffloader() {
return ledgerOffloader;
}
/**
* Set ledger offloader to use for offloading ledgers to longterm storage.
*
* @param offloader the ledger offloader to use
*/
public ManagedLedgerConfig setLedgerOffloader(LedgerOffloader offloader) {
this.ledgerOffloader = offloader;
return this;
}
/**
* Get clock to use to time operations.
*
* @return a clock
*/
public Clock getClock() {
return clock;
}
/**
* Set clock to use for time operations.
*
* @param clock the clock to use
*/
public ManagedLedgerConfig setClock(Clock clock) {
this.clock = clock;
return this;
}
/**
*
* Ledger-Op (Create/Delete) timeout.
*
* @return
*/
public long getMetadataOperationsTimeoutSeconds() {
return metadataOperationsTimeoutSeconds;
}
/**
* Ledger-Op (Create/Delete) timeout after which callback will be completed with failure.
*
* @param metadataOperationsTimeoutSeconds
*/
public ManagedLedgerConfig setMetadataOperationsTimeoutSeconds(long metadataOperationsTimeoutSeconds) {
this.metadataOperationsTimeoutSeconds = metadataOperationsTimeoutSeconds;
return this;
}
/**
* Ledger read-entry timeout.
*
* @return
*/
public long getReadEntryTimeoutSeconds() {
return readEntryTimeoutSeconds;
}
/**
* Ledger read entry timeout after which callback will be completed with failure. (disable timeout by setting.
* readTimeoutSeconds <= 0)
*
* @param readEntryTimeoutSeconds
* @return
*/
public ManagedLedgerConfig setReadEntryTimeoutSeconds(long readEntryTimeoutSeconds) {
this.readEntryTimeoutSeconds = readEntryTimeoutSeconds;
return this;
}
public long getAddEntryTimeoutSeconds() {
return addEntryTimeoutSeconds;
}
/**
* Add-entry timeout after which add-entry callback will be failed if add-entry is not succeeded.
*
* @param addEntryTimeoutSeconds
*/
public ManagedLedgerConfig setAddEntryTimeoutSeconds(long addEntryTimeoutSeconds) {
this.addEntryTimeoutSeconds = addEntryTimeoutSeconds;
return this;
}
/**
* Managed-ledger can setup different custom EnsemblePlacementPolicy (eg: affinity to write ledgers to only setup of
* group of bookies).
*
* @return
*/
public Class<? extends EnsemblePlacementPolicy> getBookKeeperEnsemblePlacementPolicyClassName() {
return bookKeeperEnsemblePlacementPolicyClassName;
}
/**
* Returns EnsemblePlacementPolicy configured for the Managed-ledger.
*
* @param bookKeeperEnsemblePlacementPolicyClassName
*/
public void setBookKeeperEnsemblePlacementPolicyClassName(
Class<? extends EnsemblePlacementPolicy> bookKeeperEnsemblePlacementPolicyClassName) {
this.bookKeeperEnsemblePlacementPolicyClassName = bookKeeperEnsemblePlacementPolicyClassName;
}
/**
* Returns properties required by configured bookKeeperEnsemblePlacementPolicy.
*
* @return
*/
public Map<String, Object> getBookKeeperEnsemblePlacementPolicyProperties() {
return bookKeeperEnsemblePlacementPolicyProperties;
}
/**
* Managed-ledger can setup different custom EnsemblePlacementPolicy which needs
* bookKeeperEnsemblePlacementPolicy-Properties.
*
* @param bookKeeperEnsemblePlacementPolicyProperties
*/
public void setBookKeeperEnsemblePlacementPolicyProperties(
Map<String, Object> bookKeeperEnsemblePlacementPolicyProperties) {
this.bookKeeperEnsemblePlacementPolicyProperties = bookKeeperEnsemblePlacementPolicyProperties;
}
public Map<String, String> getProperties() {
return properties;
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
public boolean isDeletionAtBatchIndexLevelEnabled() {
return deletionAtBatchIndexLevelEnabled;
}
public void setDeletionAtBatchIndexLevelEnabled(boolean deletionAtBatchIndexLevelEnabled) {
this.deletionAtBatchIndexLevelEnabled = deletionAtBatchIndexLevelEnabled;
}
public int getNewEntriesCheckDelayInMillis() {
return newEntriesCheckDelayInMillis;
}
public void setNewEntriesCheckDelayInMillis(int newEntriesCheckDelayInMillis) {
this.newEntriesCheckDelayInMillis = newEntriesCheckDelayInMillis;
}
public ManagedLedgerInterceptor getManagedLedgerInterceptor() {
return managedLedgerInterceptor;
}
public void setManagedLedgerInterceptor(ManagedLedgerInterceptor managedLedgerInterceptor) {
this.managedLedgerInterceptor = managedLedgerInterceptor;
}
public int getInactiveLedgerRollOverTimeMs() {
return inactiveLedgerRollOverTimeMs;
}
/**
* Set rollOver time for inactive ledgers.
*
* @param inactiveLedgerRollOverTimeMs
* @param unit
*/
public void setInactiveLedgerRollOverTime(int inactiveLedgerRollOverTimeMs, TimeUnit unit) {
this.inactiveLedgerRollOverTimeMs = (int) unit.toMillis(inactiveLedgerRollOverTimeMs);
}
/**
* Minimum cursors with backlog after which broker is allowed to cache read entries to reuse them for other cursors'
* backlog reads. (Default = 0, broker will not cache backlog reads)
*
* @return
*/
public int getMinimumBacklogCursorsForCaching() {
return minimumBacklogCursorsForCaching;
}
/**
* Set Minimum cursors with backlog after which broker is allowed to cache read entries to reuse them for other
* cursors' backlog reads.
*
* @param minimumBacklogCursorsForCaching
*/
public void setMinimumBacklogCursorsForCaching(int minimumBacklogCursorsForCaching) {
this.minimumBacklogCursorsForCaching = minimumBacklogCursorsForCaching;
}
/**
* Minimum backlog should exist to leverage caching for backlog reads.
*
* @return
*/
public int getMinimumBacklogEntriesForCaching() {
return minimumBacklogEntriesForCaching;
}
/**
* Set Minimum backlog after that broker will start caching backlog reads.
*
* @param minimumBacklogEntriesForCaching
*/
public void setMinimumBacklogEntriesForCaching(int minimumBacklogEntriesForCaching) {
this.minimumBacklogEntriesForCaching = minimumBacklogEntriesForCaching;
}
/**
* Max backlog gap between backlogged cursors while caching to avoid caching entry which can be
* invalidated before other backlog cursor can reuse it from cache.
*
* @return
*/
public int getMaxBacklogBetweenCursorsForCaching() {
return maxBacklogBetweenCursorsForCaching;
}
/**
* Set maximum backlog distance between backlogged curosr to avoid caching unused entry.
*
* @param maxBacklogBetweenCursorsForCaching
*/
public void setMaxBacklogBetweenCursorsForCaching(int maxBacklogBetweenCursorsForCaching) {
this.maxBacklogBetweenCursorsForCaching = maxBacklogBetweenCursorsForCaching;
}
/**
* Trigger offload on topic load.
* @return
*/
public boolean isTriggerOffloadOnTopicLoad() {
return triggerOffloadOnTopicLoad;
}
/**
* Set trigger offload on topic load.
* @param triggerOffloadOnTopicLoad
*/
public void setTriggerOffloadOnTopicLoad(boolean triggerOffloadOnTopicLoad) {
this.triggerOffloadOnTopicLoad = triggerOffloadOnTopicLoad;
}
public String getShadowSource() {
return MapUtils.getString(properties, PROPERTY_SOURCE_TOPIC_KEY);
}
public static final String PROPERTY_SOURCE_TOPIC_KEY = "PULSAR.SHADOW_SOURCE";
}