SteamWar/BungeeCore
Archiviert
13
2

Prefer local node

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-09-17 07:56:26 +02:00
Ursprung 4d563983f8
Commit 265fa45371

Datei anzeigen

@ -39,8 +39,11 @@ public abstract class Node {
public static Node local = null;
public static Node getNode() {
Node node = null;
double minLoad = Double.POSITIVE_INFINITY;
Node node = local;
double minLoad = local.getLoad();
if(minLoad < 0.5)
return local;
synchronized (nodes) {
Iterator<Node> it = nodes.iterator();
while(it.hasNext()) {
@ -59,17 +62,12 @@ public abstract class Node {
}
public static void forEach(Consumer<Node> consumer) {
consumer.accept(local);
synchronized (nodes) {
nodes.forEach(consumer);
}
}
protected Node() {
synchronized (nodes) {
nodes.add(this);
}
}
public abstract ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String xmx, String... dParams);
public abstract void execute(String... command);
public abstract String getName();
@ -120,7 +118,6 @@ public abstract class Node {
private final int cores;
public LocalNode() {
super();
this.cores = Runtime.getRuntime().availableProcessors();
local = this;
}
@ -172,7 +169,6 @@ public abstract class Node {
private final String remote;
public RemoteNode(String remote) {
super();
this.remote = remote;
//Determin core count
@ -199,6 +195,10 @@ public abstract class Node {
c = 1;
}
cores = c;
synchronized (nodes) {
nodes.add(this);
}
}
@Override