From ee27ff639e468c7ec6e237956b20ed6c720f788f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 21 Sep 2023 14:40:43 +0200 Subject: [server] Force update of os, virt and org lists every 3 hours --- .../src/main/java/org/openslx/bwlp/sat/App.java | 11 ++++++++++- .../org/openslx/bwlp/sat/database/mappers/DbOrganization.java | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java index 472f2578..898f75e9 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java @@ -43,6 +43,7 @@ import org.openslx.util.AppUtil; import org.openslx.util.GrowingThreadPoolExecutor; import org.openslx.util.PrioThreadFactory; import org.openslx.util.QuickTimer; +import org.openslx.util.QuickTimer.Task; public class App { @@ -144,6 +145,14 @@ public class App { + " Please make sure this server can connect to the internet."); return; } + // Update once an hour + QuickTimer.scheduleAtFixedDelay(new Task() { + public void fire() { + VirtualizerList.get(); + OperatingSystemList.get(); + OrganizationList.get(); + } + }, 3601_000, 3601_000 * 3); // Start file transfer server if (!FileServer.instance().start()) { @@ -152,7 +161,7 @@ public class App { } // Start watch dog to ensure nobody else is messing with the vmstore - QuickTimer.scheduleAtFixedDelay(new StorageUseCheck(), 10000, 60000); + QuickTimer.scheduleAtFixedDelay(new StorageUseCheck(), 10_000, 60_000); // Set a flag that we need to convert userids if applicable DbUser.checkIfLegacyUsersExist(); diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java index 7261b189..6d999573 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java @@ -26,7 +26,7 @@ public class DbOrganization { * @return * @throws SQLException */ - public static boolean storeOrganizations(List organizations) throws SQLException { + public static void storeOrganizations(List organizations) throws SQLException { try (MysqlConnection connection = Database.getConnection()) { MysqlStatement stmt = connection.prepareStatement("INSERT INTO organization" + " (organizationid, displayname, canlogin) VALUES (:id, :name, 0)" @@ -37,7 +37,6 @@ public class DbOrganization { stmt.executeUpdate(); } connection.commit(); - return true; } catch (SQLException e) { LOGGER.error("Query failed in DbOrganization.storeOrganization()", e); throw e; -- cgit v1.2.3-55-g7522