Fixed reconnect for bungee connection in StatusHistoryRepository

Added error catching to ServerMonitor so it doesn't stall program.
This commit is contained in:
Jonathan Williams 2015-01-31 14:19:33 -08:00
parent ff56578d15
commit 9d3f5f9bc8
2 changed files with 18 additions and 11 deletions

View File

@ -146,9 +146,9 @@ public class ServerMonitor
}
for (Iterator<DedicatedServer> iterator = _dedicatedServers.iterator(); iterator.hasNext();)
{
{
DedicatedServer serverData = iterator.next();
if (_badServers.containsKey(serverData.getName()))
iterator.remove();
else
@ -176,17 +176,24 @@ public class ServerMonitor
for (Iterator<MinecraftServer> serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();)
{
MinecraftServer server = serverIterator.next();
int serverNum = Integer.parseInt(server.getName().split("-")[1]);
if (serverMap.containsKey(serverNum))
try
{
killServer(server.getName(), server.getPublicAddress(), server.getPlayerCount(), "[KILLED] [DUPLICATE] " + server.getName() + ":" + server.getPublicAddress(), true);
serverIterator.remove();
MinecraftServer server = serverIterator.next();
int serverNum = Integer.parseInt(server.getName().split("-")[1]);
if (serverMap.containsKey(serverNum))
{
killServer(server.getName(), server.getPublicAddress(), server.getPlayerCount(), "[KILLED] [DUPLICATE] " + server.getName() + ":" + server.getPublicAddress(), true);
serverIterator.remove();
}
else
{
serverMap.put(serverNum, server);
}
}
else
catch (Exception exception)
{
serverMap.put(serverNum, server);
exception.printStackTrace();
}
}

View File

@ -197,7 +197,7 @@ public class StatusHistoryRepository
try
{
if (_bungeeconnection == null || _bungeeconnection.isClosed())
_bungeeconnection = DriverManager.getConnection(_connectionString, _userName, _password);
_bungeeconnection = DriverManager.getConnection(_bungeeConnectionString, _userName, _password);
retrieveStatement = _bungeeconnection.prepareStatement(RETRIEVE_BUNGEE_STATUSES);
ResultSet resultSet = retrieveStatement.executeQuery();