Name SubServers threads

This change does not apply to SubServers.Client because those apps use the platform's native scheduler instead of threads
This commit is contained in:
ME1312 2019-01-06 01:58:13 -05:00
parent 4792e5f8b1
commit 94a95de495
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
22 changed files with 36 additions and 29 deletions

View File

@ -138,7 +138,7 @@ public class ExternalSubServer extends SubServerContainer {
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}, "SubServers.Bungee::External_Server_Restart_Handler(" + getName() + ')').start();
}
}
}

View File

@ -183,7 +183,7 @@ public class InternalHost extends Host {
e.printStackTrace();
}
System.out.println("SubServers > Deleted SubServer: " + server);
}).start();
}, "SubServers.Bungee::Internal_Server_Deletion(" + name + ')').start();
return true;
} else return false;
}
@ -228,7 +228,7 @@ public class InternalHost extends Host {
e.printStackTrace();
}
System.out.println("SubServers > Deleted SubServer: " + server);
}).start();
}, "SubServers.Bungee::Internal_Server_Deletion(" + name + ')').start();
return true;
} else return false;
}

View File

@ -49,6 +49,7 @@ public class InternalSubCreator extends SubCreator {
private Process process;
private CreatorTask(UUID player, String name, ServerTemplate template, Version version, int port, Callback<SubServer> callback) {
super("SubServers.Bungee::Internal_SubCreator_Process_Handler(" + name + ')');
this.player = player;
this.name = name;
this.template = template;

View File

@ -61,8 +61,8 @@ public class InternalSubLogger extends SubLogger {
e.printStackTrace();
}
}
if (out == null) (out = new Thread(() -> start(process.getInputStream(), false))).start();
if (err == null) (err = new Thread(() -> start(process.getErrorStream(), true))).start();
if (out == null) (out = new Thread(() -> start(process.getInputStream(), false), "SubServers.Bungee::Internal_Log_Spooler(" + name + ')')).start();
if (err == null) (err = new Thread(() -> start(process.getErrorStream(), true), "SubServers.Bungee::Internal_Error_Spooler(" + name + ')')).start();
List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
filters.addAll(this.filters);
for (SubLogFilter filter : filters) try {

View File

@ -172,7 +172,7 @@ public class InternalSubServer extends SubServerContainer {
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}, "SubServers.Bungee::Internal_Server_Restart_Handler(" + getName() + ')').start();
}
}
}
@ -185,7 +185,7 @@ public class InternalSubServer extends SubServerContainer {
host.plugin.getPluginManager().callEvent(event);
lock = false;
if (!event.isCancelled()) {
(thread = new Thread(this::run)).start();
(thread = new Thread(this::run, "SubServers.Bungee::Internal_Server_Process_Handler(" + getName() + ')')).start();
return true;
} else return false;
} else return false;

View File

@ -150,7 +150,7 @@ public class Metrics {
}
private void startSubmitting() {
new Timer().schedule( new TimerTask() {
new Timer("SubServers.Bungee::Metrics_Uploader").schedule( new TimerTask() {
@Override
public void run() {
// The data collection is async, as well as sending the data

View File

@ -43,7 +43,7 @@ public class Client {
socket = client;
out = MessagePack.newDefaultPacker(client.getOutputStream());
address = new InetSocketAddress(client.getInetAddress(), client.getPort());
authorized = new Timer();
authorized = new Timer("SubServers.Bungee::SubData_Authorization_Timeout(" + address.toString() + ')');
authorized.schedule(new TimerTask() {
@Override
public void run() {
@ -81,7 +81,7 @@ public class Client {
e1.printStackTrace();
}
}
}).start();
}, "SubServers.Bungee::SubData_Packet_Listener(" + address.toString() + ')').start();
}
private void recievePacket(Value input) {

View File

@ -82,7 +82,7 @@ public class PacketCreateServer implements PacketIn, PacketOut {
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}, "SubServers.Bungee::SubData_SubCreator_Handler(" + client.getAddress().toString() + ')').start();
} else {
client.sendPacket(new PacketCreateServer(0, "Creating SubServer", (data.contains("id")) ? data.getRawString("id") : null));
}

View File

@ -115,7 +115,7 @@ public final class SubCommand extends CommandX {
sender.sendMessage("SubServers.Bungee v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
}
} catch (Exception e) {}
}).start();
}, "SubServers.Bungee::Update_Check").start();
} else if (args[0].equalsIgnoreCase("reload")) {
if (args.length > 1) {
switch (args[1].toLowerCase()) {

View File

@ -396,7 +396,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
e.printStackTrace();
}
}
}));
}, "SubServers.Bungee::System_Shutdown"));
running = true;
List<String> autorun = new LinkedList<String>();
for (String name : config.get().getSection("Servers").getKeys()) {
@ -544,7 +544,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
getPluginManager().registerCommand(null, SubCommand.newInstance(this, "sub").get());
new Metrics(this);
new Timer().schedule(new TimerTask() {
new Timer("SubServers.Bungee::Routine_Update_Check").schedule(new TimerTask() {
@SuppressWarnings("unchecked")
@Override
public void run() {
@ -577,7 +577,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
if (!(e instanceof SocketException)) e.printStackTrace();
}
}
}).start();
}, "SubServers.Bungee::SubData_Connection_Listener").start();
}
/**

View File

@ -20,7 +20,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>19w01a</version>
<version>19w02c</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -4,6 +4,7 @@ import com.dosse.upnp.UPnP;
import net.ME1312.Galaxi.Engine.GalaxiEngine;
import net.ME1312.Galaxi.Engine.GalaxiOption;
import net.ME1312.Galaxi.Event.GalaxiReloadEvent;
import net.ME1312.Galaxi.Galaxi;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.Galaxi.Library.Log.Logger;
@ -213,7 +214,7 @@ public final class ExHost {
log.warn.println("Received request from system to shutdown");
engine.stop();
}
}));
}, SubAPI.getInstance().getAppInfo().getName() + "::System_Shutdown"));
creator = new SubCreator(this);
loadDefaults();

View File

@ -14,6 +14,7 @@ import net.ME1312.SubServers.Host.Network.API.SubCreator.ServerType;
import net.ME1312.SubServers.Host.Network.Packet.PacketExCreateServer;
import net.ME1312.SubServers.Host.Network.Packet.PacketOutExLogMessage;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@ -190,6 +191,7 @@ public class SubCreator {
private Process process;
private CreatorTask(String name, ServerTemplate template, Version version, int port, UUID address, String id) {
super(SubAPI.getInstance().getAppInfo().getName() + "::SubCreator_Process_Handler(" + name + ')');
this.name = name;
this.template = template;
this.version = version;

View File

@ -63,8 +63,8 @@ public class SubLogger {
logger.error.println(e);
}
}
if (out == null) (out = new Thread(() -> start(process.getInputStream(), false))).start();
if (err == null) (err = new Thread(() -> start(process.getErrorStream(), true))).start();
if (out == null) (out = new Thread(() -> start(process.getInputStream(), false), SubAPI.getInstance().getAppInfo().getName() + "::Log_Spooler(" + name + ')')).start();
if (err == null) (err = new Thread(() -> start(process.getErrorStream(), true), SubAPI.getInstance().getAppInfo().getName() + "::Error_Spooler(" + name + ')')).start();
}

View File

@ -7,6 +7,7 @@ import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Host.Library.Exception.InvalidServerException;
import net.ME1312.SubServers.Host.Network.Packet.PacketExUpdateServer;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import java.io.*;
import java.util.LinkedList;
@ -141,7 +142,7 @@ public class SubServer {
public void start(UUID address) {
if (isEnabled() && !(thread != null && thread.isAlive())) {
logger.address = address;
(thread = new Thread(this::run)).start();
(thread = new Thread(this::run, SubAPI.getInstance().getAppInfo().getName() + "::Server_Process_Handler(" + name + ')')).start();
}
}

View File

@ -5,6 +5,7 @@ import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.Galaxi.Library.Log.Logger;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import org.json.JSONArray;
import org.json.JSONObject;
@ -144,7 +145,7 @@ public class Metrics {
* Starts the Scheduler which submits our data every 30 minutes.
*/
private void startSubmitting() {
final Timer timer = new Timer(true);
final Timer timer = new Timer(SubAPI.getInstance().getAppInfo().getName() + "::Metrics_Uploader", true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {

View File

@ -12,6 +12,7 @@ import net.ME1312.SubServers.Host.Network.PacketIn;
import net.ME1312.SubServers.Host.Network.PacketOut;
import net.ME1312.SubServers.Host.Network.SubDataClient;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import java.io.File;
import java.io.FileWriter;
@ -106,7 +107,7 @@ public class PacketExDeleteServer implements PacketIn, PacketOut {
if (UPnP.isUPnPAvailable() && UPnP.isMappedTCP(server.getPort())) UPnP.closePortTCP(server.getPort());
log.info.println("Deleted SubServer: " + data.getRawString("server"));
host.subdata.sendPacket(new PacketExDeleteServer(0, "Server Deleted Successfully", (data.contains("id"))?data.getRawString("id"):null));
}).start();
}, SubAPI.getInstance().getAppInfo().getName() + "::Server_Deletion(" + server.getName() + ')').start();
}
} catch (Throwable e) {
host.subdata.sendPacket(new PacketExDeleteServer(1, e.getClass().getCanonicalName() + ": " + e.getMessage(), (data.contains("id"))?data.getRawString("id"):null));

View File

@ -177,7 +177,7 @@ public final class SubDataClient {
log.error.println(e1);
}
}
}).start();
}, SubAPI.getInstance().getAppInfo().getName() + "::SubData_Packet_Listener").start();
}
private void recieve(Value input) {
@ -550,7 +550,7 @@ public final class SubDataClient {
log.info.println("The SubData Connection was closed");
if (reconnect > 0) {
log.info.println("Attempting to reconnect in " + reconnect + " seconds");
Timer timer = new Timer();
Timer timer = new Timer(SubAPI.getInstance().getAppInfo().getName() + "::SubData_Reconnect_Handler");
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {

View File

@ -130,7 +130,7 @@ public class Metrics {
}
private void startSubmitting() {
new Timer().schedule( new TimerTask() {
new Timer("SubServers.Sync::Metrics_Uploader").schedule( new TimerTask() {
@Override
public void run() {
// The data collection is async, as well as sending the data

View File

@ -189,7 +189,7 @@ public final class SubDataClient {
e1.printStackTrace();
}
}
}).start();
}, "SubServers.Sync::SubData_Packet_Listener").start();
}
private void recieve(Value input) {
@ -470,7 +470,7 @@ public final class SubDataClient {
System.out.println("SubServers > The SubData Connection was closed");
if (reconnect > 0) {
System.out.println("SubServers > Attempting to reconnect in " + reconnect + " seconds");
Timer timer = new Timer();
Timer timer = new Timer("SubServers.Sync::SubData_Reconnect_Handler");
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {

View File

@ -114,7 +114,7 @@ public final class SubCommand extends CommandX {
}
} catch (Exception e) {
}
}).start();
}, "SubServers.Sync::Update_Check").start();
} else if (args[0].equalsIgnoreCase("list")) {
plugin.api.getGroups(groups -> plugin.api.getHosts(hosts -> plugin.api.getServers(servers -> plugin.api.getMasterProxy(proxymaster -> plugin.api.getProxies(proxies -> {
int i = 0;

View File

@ -132,7 +132,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
getPluginManager().registerCommand(null, SubCommand.newInstance(this, "sub").get());
new Metrics(this);
new Timer().schedule(new TimerTask() {
new Timer("SubServers.Sync::Routine_Update_Check").schedule(new TimerTask() {
@SuppressWarnings("unchecked")
@Override
public void run() {