Extract code in CommonSetup which uses a timer

to startPeriodicTasks.
Call that from BisqExecutable.onApplicationLaunched

We have created a non-UI timer before for the
printSystemLoadPeriodically as that was called
before the configUserThread was called (where we
define the UI timer for desktop)
This commit is contained in:
chimp1984 2021-11-10 12:26:54 +01:00
parent 245b76be74
commit faa8bd2ab2
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
2 changed files with 10 additions and 3 deletions

View file

@ -55,19 +55,21 @@ public class CommonSetup {
Version.printVersion();
maybePrintPathOfCodeSource();
Profiler.printSystemLoad();
Profiler.printSystemLoadPeriodically(10, TimeUnit.MINUTES);
// Full DAO nodes (like seed nodes) do not use the GC triggers as it is expected they have sufficient RAM allocated.
GcUtil.setDISABLE_GC_CALLS(config.fullDaoNode);
GcUtil.autoReleaseMemory();
setSystemProperties();
setupSigIntHandlers(gracefulShutDownHandler);
DevEnv.setup(config);
}
public static void startPeriodicTasks() {
Profiler.printSystemLoadPeriodically(10, TimeUnit.MINUTES);
GcUtil.autoReleaseMemory();
}
public static void setupUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread

View file

@ -130,8 +130,13 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
///////////////////////////////////////////////////////////////////////////////////////////
// Headless versions can call inside launchApplication the onApplicationLaunched() manually
// Desktop gets called from JavaFx thread
protected void onApplicationLaunched() {
configUserThread();
// Now we can use the user thread start periodic tasks
CommonSetup.startPeriodicTasks();
// As the handler method might be overwritten by subclasses and they use the application as handler
// we need to setup the handler after the application is created.
CommonSetup.setupUncaughtExceptionHandler(this);