|
64 | 64 | import java.util.UUID; |
65 | 65 | import java.util.concurrent.ExecutorService; |
66 | 66 | import java.util.concurrent.Executors; |
| 67 | +import java.util.concurrent.TimeUnit; |
67 | 68 | import java.util.concurrent.atomic.AtomicInteger; |
68 | 69 | import java.util.stream.Collectors; |
69 | 70 | import java.util.stream.Stream; |
@@ -572,12 +573,35 @@ private TransactionResourceManager getTransactionManager() { |
572 | 573 | ? config.getObject(ConfigConstants.TRANSACTIONS).unwrapped() |
573 | 574 | : Collections.emptyMap(); |
574 | 575 | transactionManager = new TransactionResourceManager(this, cfg); |
| 576 | + runManagerHousekeeping(); |
575 | 577 | } |
576 | 578 | } |
577 | 579 | } |
578 | 580 | return transactionManager; |
579 | 581 | } |
580 | 582 |
|
| 583 | + private void runManagerHousekeeping() { |
| 584 | + context |
| 585 | + .getExecutorService() |
| 586 | + .submit( |
| 587 | + () -> { |
| 588 | + while (!Thread.currentThread().isInterrupted()) { |
| 589 | + try { |
| 590 | + transactionManager.houseKeeping(); |
| 591 | + log.info( |
| 592 | + "Terminated housekeeping of {}", |
| 593 | + transactionManager.getClass().getSimpleName()); |
| 594 | + TimeUnit.MINUTES.sleep(1); |
| 595 | + } catch (InterruptedException ex) { |
| 596 | + Thread.currentThread().interrupt(); |
| 597 | + } catch (Throwable err) { |
| 598 | + log.warn("Error in housekeeping thread", err); |
| 599 | + } |
| 600 | + } |
| 601 | + log.info("Terminating housekeeping by request."); |
| 602 | + }); |
| 603 | + } |
| 604 | + |
581 | 605 | @Override |
582 | 606 | public Repository getRepository() { |
583 | 607 | return repo; |
|
0 commit comments