-
Notifications
You must be signed in to change notification settings - Fork 3.7k
make ledger rollover check task internal #8946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
96f7eb2
9465d29
facd007
534326d
766e9c6
f94c36e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,6 +176,7 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback { | |
| final EntryCache entryCache; | ||
|
|
||
| private ScheduledFuture<?> timeoutTask; | ||
| private ScheduledFuture<?> checkLedgerRollTask; | ||
|
|
||
| /** | ||
| * This lock is held while the ledgers list or propertiesMap is updated asynchronously on the metadata store. Since we use the store | ||
|
|
@@ -382,6 +383,8 @@ public void operationFailed(MetaStoreException e) { | |
| }); | ||
|
|
||
| scheduleTimeoutTask(); | ||
|
|
||
| scheduleRollOverLedgerTask(); | ||
| } | ||
|
|
||
| private synchronized void initializeBookKeeper(final ManagedLedgerInitializeLedgerCallback callback) { | ||
|
|
@@ -1318,6 +1321,10 @@ public synchronized void asyncClose(final CloseCallback callback, final Object c | |
| this.timeoutTask.cancel(false); | ||
| } | ||
|
|
||
| if (this.checkLedgerRollTask != null) { | ||
| this.checkLedgerRollTask.cancel(false); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| private void closeAllCursors(CloseCallback callback, final Object ctx) { | ||
|
|
@@ -1548,6 +1555,7 @@ synchronized void createLedgerAfterClosed() { | |
| asyncCreateLedger(bookKeeper, config, digestType, this, Collections.emptyMap()); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| @Override | ||
| public void rollCurrentLedgerIfFull() { | ||
| log.info("[{}] Start checking if current ledger is full", name); | ||
|
|
@@ -1561,7 +1569,7 @@ public void closeComplete(int rc, LedgerHandle lh, Object o) { | |
| lh.getId()); | ||
|
|
||
| if (rc == BKException.Code.OK) { | ||
| log.debug("Successfuly closed ledger {}", lh.getId()); | ||
| log.debug("Successfully closed ledger {}", lh.getId()); | ||
| } else { | ||
| log.warn("Error when closing ledger {}. Status={}", lh.getId(), BKException.getMessage(rc)); | ||
| } | ||
|
|
@@ -3467,6 +3475,15 @@ private void scheduleTimeoutTask() { | |
| } | ||
| } | ||
|
|
||
| private void scheduleRollOverLedgerTask() { | ||
| if (config.getMaximumRolloverTimeMs() > 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better to separate the timing task of checking that current ledger is full from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I move it into individual method. |
||
| long interval = config.getMaximumRolloverTimeMs(); | ||
| this.checkLedgerRollTask = this.scheduledExecutor.scheduleAtFixedRate(safeRun(() -> { | ||
| rollCurrentLedgerIfFull(); | ||
| }), interval, interval, TimeUnit.MILLISECONDS); | ||
| } | ||
| } | ||
|
|
||
| private void checkAddTimeout() { | ||
| long timeoutSec = config.getAddEntryTimeoutSeconds(); | ||
| if (timeoutSec < 1) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hangc0276 we shouldn't remove a method from an interface directly. we should keep the method and mark it as deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i move it back.