diff --git a/lophine-server/src/main/java/fun/bm/lophine/config/modules/experiment/CommandConfig.java b/lophine-server/src/main/java/fun/bm/lophine/config/modules/experiment/CommandConfig.java index fdc8655..5e875cc 100644 --- a/lophine-server/src/main/java/fun/bm/lophine/config/modules/experiment/CommandConfig.java +++ b/lophine-server/src/main/java/fun/bm/lophine/config/modules/experiment/CommandConfig.java @@ -39,4 +39,8 @@ public class CommandConfig implements IConfigModule { """ Log all process of save-all command to console""") public static boolean logAllProcess = false; + + @ConfigInfo(name = "save_all_command_timeout", directory = {"save_all_command"}, comments = """ + Maximum seconds to save before the chunk report it is timeout.""") + public static long saveAllTimeout = 30; } \ No newline at end of file diff --git a/lophine-server/src/main/java/fun/bm/lophine/utils/SaveAllUtil.java b/lophine-server/src/main/java/fun/bm/lophine/utils/SaveAllUtil.java index 9c717c8..c23cdf9 100644 --- a/lophine-server/src/main/java/fun/bm/lophine/utils/SaveAllUtil.java +++ b/lophine-server/src/main/java/fun/bm/lophine/utils/SaveAllUtil.java @@ -13,7 +13,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; public class SaveAllUtil { - private static final long TIMEOUT = 1000 * 30; // 30 seconds public static final Object lock = new Object(); public static volatile long lastSaveAllTime = 0; private static volatile Pair currentSaveAll = null; @@ -76,7 +75,7 @@ public class SaveAllUtil { public static void checkTimeout() { Pair currentSaveAll = SaveAllUtil.currentSaveAll; if (!isSaving()) return; - if (System.currentTimeMillis() - lastSaveAllTime > TIMEOUT) { + if (System.currentTimeMillis() - lastSaveAllTime > CommandConfig.saveAllTimeout) { currentSaveAll.getFirst().sendFailure(Component.literal("At least one region save data timeout!")); currentSaveAll.getFirst().sendFailure(Component.literal("Regions need to save expect is " + regionCount + ", but only " + savedRegionCount.get() + " saved!")); SaveAllUtil.currentSaveAll = null;