From 1c6a75239f77a768397da9c75946dae8a8df90a4 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Wed, 2 Jan 2019 17:53:34 +0400 Subject: [PATCH] LaunchServer code optimizations. --- .../java/ru/gravit/launchserver/binary/ProguardConf.java | 1 - .../ru/gravit/launchserver/manangers/SessionManager.java | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java index f92464aa..cba2c350 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java @@ -51,7 +51,6 @@ public ProguardConf(LaunchServer srv) { private void genConfig(boolean force) throws IOException { if (IOHelper.exists(config) && !force) return; Files.deleteIfExists(config); - config.toFile().createNewFile(); try (OutputStream out = IOHelper.newOutput(config); InputStream in = IOHelper.newInput(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"))) { IOHelper.transfer(in, out); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java index 9be9aca5..0af27d0b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java @@ -9,7 +9,7 @@ public class SessionManager implements NeedGarbageCollection { public static final long SESSION_TIMEOUT = 10 * 60 * 1000; // 10 минут - public static final boolean NON_GARBAGE_SERVER = true; + public static final boolean GARBAGE_SERVER = Boolean.parseBoolean(System.getProperty("launcher.garbage.sessions", "false")); private HashSet clientSet = new HashSet<>(128); @@ -19,10 +19,9 @@ public boolean addClient(Client client) { } @Override - public void garbageCollection() { long time = System.currentTimeMillis(); - clientSet.removeIf(c -> (c.timestamp + SESSION_TIMEOUT < time) && ((c.type == Client.Type.USER) || ((c.type == Client.Type.SERVER) && !NON_GARBAGE_SERVER))); + clientSet.removeIf(c -> (c.timestamp + SESSION_TIMEOUT < time) && (c.type == Client.Type.USER) && GARBAGE_SERVER); }