SteamWar/BungeeCore
Archiviert
13
2
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-10-09 16:06:31 +02:00
Ursprung e66dd48b89
Commit 801d9da2e1

Datei anzeigen

@ -32,8 +32,7 @@ import java.util.logging.Level;
public abstract class Node { public abstract class Node {
private static final List<String> JVM_ARGS = Arrays.asList("-Dlog4j.configurationFile=log4j2.xml", "-server", "-Xms128M", "-XX:+UseCompressedOops", "-XX:+TieredCompilation", "-XX:TargetSurvivorRatio=90", "-XX:SurvivorRatio=8", "-XX:MaxTenuringThreshold=15", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseBiasedLocking", "-XX:UseSSE=3", "-XX:+UseCodeCacheFlushing", "-XX:+UseThreadPriorities", "-XX:+AggressiveOpts", "-XX:+ReduceSignalUsage", "-XX:+UseInterpreter", "-XX:+UseSharedSpaces", "-XX:AllocatePrefetchStyle=1", "-XX:+AlwaysCompileLoopMethods", "-XX:+UseConcMarkSweepGC", "-XX:+RewriteFrequentPairs", "-XX:+OptimizeStringConcat", "-XX:+CMSCleanOnEnter", "-XX:+UseInlineCaches"); private static final List<String> OPENJ9_ARGS = Arrays.asList("-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings");
private static final List<String> JVM8_ARGS = Arrays.asList("-XX:ThreadPriorityPolicy=42", "-XX:SharedReadOnlySize=30m", "-XX:+UseFastEmptyMethods", "-XX:+UseFastAccessorMethods");
private static final double MIN_FREE_MEM = 4.0 * 1024 * 1024; // 4 GiB private static final double MIN_FREE_MEM = 4.0 * 1024 * 1024; // 4 GiB
private static final List<Node> nodes = new ArrayList<>(); private static final List<Node> nodes = new ArrayList<>();
@ -74,21 +73,15 @@ public abstract class Node {
public abstract String getName(); public abstract String getName();
public abstract double getLoad(); public abstract double getLoad();
protected void constructServerstart(List<String> cmd, String serverJar, String worldDir, String levelName, int port, String xmx, String... dParams) { protected void constructServerstart(File directory, List<String> cmd, String serverJar, String worldDir, String levelName, int port, String xmx, String... dParams) {
boolean jdk11 = serverJar.contains("1.15.2"); cmd.add("/usr/lib/jvm/java-16-openj9-amd64/bin/java");
if(jdk11)
cmd.add("/usr/lib/jvm/java-11-openjdk-amd64/bin/java");
else
cmd.add("java");
for(String param : dParams){ for(String param : dParams){
cmd.add("-D" + param); cmd.add("-D" + param);
} }
cmd.add("-Xmx" + xmx); cmd.add("-Xmx" + xmx);
cmd.addAll(JVM_ARGS); cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
if(!jdk11) cmd.addAll(OPENJ9_ARGS);
cmd.addAll(JVM8_ARGS);
cmd.add("-jar"); cmd.add("-jar");
cmd.add("/binarys/" + serverJar); cmd.add("/binarys/" + serverJar);
cmd.add("--log-strip-color"); cmd.add("--log-strip-color");
@ -126,7 +119,7 @@ public abstract class Node {
@Override @Override
public ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String xmx, String... dParams) { public ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String xmx, String... dParams) {
List<String> cmd = new ArrayList<>(); List<String> cmd = new ArrayList<>();
constructServerstart(cmd, serverJar, worldDir, levelName, port, xmx, dParams); constructServerstart(directory, cmd, serverJar, worldDir, levelName, port, xmx, dParams);
ProcessBuilder builder = new ProcessBuilder(cmd); ProcessBuilder builder = new ProcessBuilder(cmd);
builder.directory(directory); builder.directory(directory);
return builder; return builder;
@ -172,7 +165,7 @@ public abstract class Node {
public RemoteNode(String remote) { public RemoteNode(String remote) {
this.remote = remote; this.remote = remote;
//Determin core count //Determine core count
Process process; Process process;
try { try {
process = new ProcessBuilder("ssh", remote, "nproc").start(); process = new ProcessBuilder("ssh", remote, "nproc").start();
@ -213,7 +206,7 @@ public abstract class Node {
cmd.add("cd"); cmd.add("cd");
cmd.add(directory.getPath()); cmd.add(directory.getPath());
cmd.add(";"); cmd.add(";");
constructServerstart(cmd, serverJar, worldDir, levelName, port, xmx, dParams); constructServerstart(directory, cmd, serverJar, worldDir, levelName, port, xmx, dParams);
return new ProcessBuilder(cmd); return new ProcessBuilder(cmd);
} }