SteamWar/BungeeCore
Archiviert
13
2

Object oriented subserver node system #245

Zusammengeführt
Lixfel hat 3 Commits von nodeSystem nach master 2021-09-17 07:48:21 +02:00 zusammengeführt
2 geänderte Dateien mit 28 neuen und 4 gelöschten Zeilen
Nur Änderungen aus Commit d73c0ea7ea werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -90,8 +90,8 @@ public class BungeeCore extends Plugin {
new BrandListener(); new BrandListener();
new Node.LocalNode(); new Node.LocalNode();
new Node.RemoteNode("lx", 8); new Node.RemoteNode("lx");
new Node.RemoteNode("az", 10); new Node.RemoteNode("az");
commands.put("/tp", null); commands.put("/tp", null);
commands.put("/bc", null); commands.put("/bc", null);

Datei anzeigen

@ -171,10 +171,34 @@ public abstract class Node {
private final int cores; private final int cores;
private final String remote; private final String remote;
public RemoteNode(String remote, int cores) { public RemoteNode(String remote) {
super(); super();
this.cores = cores;
this.remote = remote; this.remote = remote;
//Determin core count
Process process;
try {
process = new ProcessBuilder("ssh", remote, "nproc").start();
if(!process.waitFor(5, TimeUnit.SECONDS))
throw new IOException("Timeout of " + remote + " on init");
} catch (IOException e) {
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not initialize " + remote);
cores = 1;
return;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
cores = 1;
return;
}
int c;
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
c = Integer.parseInt(bufferedReader.readLine());
} catch (IOException e) {
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not read cores of" + remote, e);
c = 1;
}
cores = c;
} }
@Override @Override