Skip to content

Commit d15b6a3

Browse files
authored
Merge pull request #1022: [direct-core] call housekeeing for all created TransactionResourceManagers
2 parents 4cb60fd + 854499c commit d15b6a3

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

direct/core/src/main/java/cz/o2/proxima/direct/core/DirectDataOperator.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import java.util.UUID;
6565
import java.util.concurrent.ExecutorService;
6666
import java.util.concurrent.Executors;
67+
import java.util.concurrent.TimeUnit;
6768
import java.util.concurrent.atomic.AtomicInteger;
6869
import java.util.stream.Collectors;
6970
import java.util.stream.Stream;
@@ -572,12 +573,35 @@ private TransactionResourceManager getTransactionManager() {
572573
? config.getObject(ConfigConstants.TRANSACTIONS).unwrapped()
573574
: Collections.emptyMap();
574575
transactionManager = new TransactionResourceManager(this, cfg);
576+
runManagerHousekeeping();
575577
}
576578
}
577579
}
578580
return transactionManager;
579581
}
580582

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+
581605
@Override
582606
public Repository getRepository() {
583607
return repo;

0 commit comments

Comments
 (0)