This commit is contained in:
Clebert Suconic 2018-05-07 10:23:36 -04:00
commit 88b1371e98
2 changed files with 18 additions and 4 deletions

View File

@ -239,8 +239,10 @@ public class PageCursorProviderImpl implements PageCursorProvider {
for (PageSubscription cursor : activeCursors.values()) {
cursor.stop();
}
executor.shutdownNow();
final int pendingCleanupTasks = scheduledCleanup.get();
if (pendingCleanupTasks > 0) {
logger.tracef("Stopping with %d cleanup tasks to be completed yet", pendingCleanupTasks);
}
}
private void waitForFuture() {

View File

@ -348,11 +348,23 @@ public class PagingStoreImpl implements PagingStore {
@Override
public synchronized void stop() throws Exception {
if (running) {
cursorProvider.flushExecutors();
cursorProvider.stop();
running = false;
final List<Runnable> pendingTasks = new ArrayList<>();
final int pendingTasksWhileShuttingDown = executor.shutdownNow(pendingTasks::add);
if (pendingTasksWhileShuttingDown > 0) {
logger.tracef("Try executing %d pending tasks on stop", pendingTasksWhileShuttingDown);
for (Runnable pendingTask : pendingTasks) {
try {
pendingTask.run();
} catch (Throwable t) {
logger.warn("Error while executing a pending task on shutdown", t);
}
}
}
executor.shutdownNow();
running = false;
if (currentPage != null) {
currentPage.close(false);