private void scheduleDBCheckTask() { long checkPeriod = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS); runnableFactory.create("Config Update DB Checker", new AbsRunnable() { @Override public void run() { updateConfigFromDBIfUpdated(); } }).runTaskTimerAsynchronously(checkPeriod, checkPeriod); }
private void scheduleDBCheckTask() { long checkPeriod = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS); taskSystem.registerTask("Config Update DB Checker", new AbsRunnable() { @Override public void run() { checkDBForNewConfigSettings(dbSystem.getDatabase()); } }).runTaskTimerAsynchronously(checkPeriod, checkPeriod); }
@Override public void scheduleClean(long secondsDelay) { dbCleanTask = runnableFactory.create("DB Clean Task", new AbsRunnable() { @Override public void run() { try { if (isOpen()) { clean(); } } catch (DBOpException e) { errorHandler.log(L.ERROR, this.getClass(), e); cancel(); } } }).runTaskTimerAsynchronously( TimeAmount.toTicks(secondsDelay, TimeUnit.SECONDS), TimeAmount.toTicks(config.get(TimeSettings.CLEAN_DATABASE_PERIOD), TimeUnit.MILLISECONDS) ); }
private void startConnectionPingTask() { stopConnectionPingTask(); try { // Maintains Connection. connectionPingTask = runnableFactory.create("DBConnectionPingTask " + getType().getName(), new KeepAliveTask(connection, () -> getNewConnection(databaseFile), logger, errorHandler) ).runTaskTimerAsynchronously(60L * 20L, 60L * 20L); } catch (Exception ignored) { // Task failed to register because plugin is being disabled } }
private void startConnectionPingTask() { stopConnectionPingTask(); try { // Maintains Connection. connectionPingTask = runnableFactory.create("DBConnectionPingTask " + getType().getName(), new KeepAliveTask(connection, () -> getNewConnection(databaseFile), logger, errorHandler) ).runTaskTimerAsynchronously(60L * 20L, 60L * 20L); } catch (Exception ignored) { // Task failed to register because plugin is being disabled } }
private void registerTasks() { registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS)); registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES)); registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS)); plugin.registerListener(pingCountTimer); long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS); runnableFactory.create("PingCountTimer", pingCountTimer).runTaskTimer(startDelay, PingCountTimerVelocity.PING_INTERVAL); registerTask(playersPageRefreshTask) .runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES)); // +40 ticks / 2 seconds so that update check task runs first. long storeDelay = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS) + 40; registerTask("Config Store Task", networkConfigStoreTask).runTaskLaterAsynchronously(storeDelay); } }
private void registerTasks() { registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS)); registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES)); registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS)); plugin.registerListener(pingCountTimer); long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS); runnableFactory.create("PingCountTimer", pingCountTimer).runTaskTimer(startDelay, PingCountTimerBungee.PING_INTERVAL); registerTask(playersPageRefreshTask) .runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES)); // +40 ticks / 2 seconds so that update check task runs first. long storeDelay = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS) + 40; registerTask("Config Store Task", networkConfigStoreTask).runTaskLaterAsynchronously(storeDelay); } }
private void registerTasks() { // Analysis refresh settings long analysisRefreshMs = config.get(TimeSettings.ANALYSIS_REFRESH_PERIOD); boolean analysisRefreshTaskIsEnabled = analysisRefreshMs > 0; long analysisPeriod = TimeAmount.toTicks(analysisRefreshMs, TimeUnit.MILLISECONDS); registerTask(tpsCountTimer).runTaskTimer(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS)); registerTask(bootAnalysisTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS)); if (analysisRefreshTaskIsEnabled) { registerTask(periodicAnalysisTask).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod); } registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS)); registerTask(playersPageRefreshTask) .runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES)); } }