13
0

Commits vergleichen

...
Dieses Repository wurde am 2024-08-04 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.

1 Commits

Autor SHA1 Nachricht Datum
yoyosource
24524036a8 Add Initial setup
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-02-20 12:15:03 +01:00
2 geänderte Dateien mit 23 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -48,4 +48,10 @@ public class Storage {
public static final Map<Integer, ServerInfo> teamServers = new HashMap<>(); // TeamID -> ServerInfo map public static final Map<Integer, ServerInfo> teamServers = new HashMap<>(); // TeamID -> ServerInfo map
public static final Map<ProxiedPlayer, Map<UUID, PlayerListItem.Item>> directTabItems = new HashMap<>(); public static final Map<ProxiedPlayer, Map<UUID, PlayerListItem.Item>> directTabItems = new HashMap<>();
public static final Map<Subserver, String> serverToNodeMap = new HashMap<>();
public static final Map<String, List<Subserver>> nodeToServerMap = new HashMap<>();
public static final Map<Subserver, Long> timeOfServerEmpty = new HashMap<>();
} }

Datei anzeigen

@ -140,6 +140,7 @@ public class Subserver implements Runnable {
if(!process.waitFor(1, TimeUnit.MINUTES)) if(!process.waitFor(1, TimeUnit.MINUTES))
process.destroyForcibly(); process.destroyForcibly();
thread.join(); thread.join();
cleanup();
}catch(InterruptedException e){ }catch(InterruptedException e){
logger.log(Level.SEVERE, "Subserver stop interrupted!", e); logger.log(Level.SEVERE, "Subserver stop interrupted!", e);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
@ -152,12 +153,24 @@ public class Subserver implements Runnable {
process.destroy(); process.destroy();
} }
thread.join(); thread.join();
cleanup();
}catch(InterruptedException e){ }catch(InterruptedException e){
logger.log(Level.SEVERE, "Subserver stop interrupted!", e); logger.log(Level.SEVERE, "Subserver stop interrupted!", e);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
private void cleanup() {
String nodeName = Storage.serverToNodeMap.remove(this);
if (nodeName != null) {
Storage.nodeToServerMap.computeIfPresent(nodeName, (s, list) -> {
list.remove(this);
if (list.isEmpty()) return null;
return list;
});
}
}
static void shutdown(){ static void shutdown(){
while (!serverList.isEmpty()) { while (!serverList.isEmpty()) {
Subserver server = serverList.get(0); Subserver server = serverList.get(0);
@ -240,4 +253,8 @@ public class Subserver implements Runnable {
shutdownCallback.run(); shutdownCallback.run();
} }
} }
public long getPID() {
return process.pid();
}
} }