Added a delay to killing 'dead' servers and a verification run after the initial test before killing.

This commit is contained in:
Jonathan Williams 2015-01-06 10:39:18 -06:00
parent fc45b80e2b
commit 836547f4f6

View File

@ -39,6 +39,7 @@ public class ServerMonitor
private static Collection<ServerGroup> _serverGroups = null;
private static Map<String, ServerGroup> _serverGroupMap = null;
private static List<DedicatedServer> _dedicatedServers = null;
private static HashSet<String> _deadServers = new HashSet<String>();
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
private static Logger _logger = Logger.getLogger("ServerMonitor");
@ -192,7 +193,7 @@ public class ServerMonitor
if (onlineServers.contains(entry.getKey()))
iterator.remove();
else if (System.currentTimeMillis() - entry.getValue().getValue() > 30000)
else if (System.currentTimeMillis() - entry.getValue().getValue() > 35000)
{
String serverName = entry.getKey();
String serverAddress = entry.getValue().getKey();
@ -275,11 +276,23 @@ public class ServerMonitor
private static void killDeadServers()
{
HashSet<String> deadServers = new HashSet<String>();
deadServers.addAll(_deadServers);
_deadServers.clear();
for (MinecraftServer deadServer : _repository.getDeadServers())
{
killServer(deadServer.getName(), deadServer.getPublicAddress(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true);
handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup()));
if (deadServers.contains(deadServer.getName()))
{
killServer(deadServer.getName(), deadServer.getPublicAddress(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true);
handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup()));
}
else
{
_deadServers.add(deadServer.getName());
System.out.println("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress());
}
}
}