Fixed bug with Server monitor.

This commit is contained in:
Jonathan Williams 2014-08-01 00:46:00 -07:00
parent b056733ba1
commit f2d1380478
2 changed files with 22 additions and 9 deletions

View File

@ -6,9 +6,11 @@ import java.util.List;
public class GroupStatusData public class GroupStatusData
{ {
private int _serverNum = 0;
private int _totalCount = 0; private int _totalCount = 0;
private int _joinableCount = 0; private int _joinableCount = 0;
private int _freeServerNum = 0;
private int _freeTotalCount = 0; private int _freeTotalCount = 0;
private int _freeJoinableCount = 0; private int _freeJoinableCount = 0;
@ -135,22 +137,33 @@ public class GroupStatusData
public int getNextServerNumber(boolean free) public int getNextServerNumber(boolean free)
{ {
int startNumber = 1; if (free)
_freeServerNum++;
else
_serverNum++;
while (true) while (true)
{ {
if (free) if (free)
{ {
if (!FreeServers.containsKey(startNumber)) if (!FreeServers.containsKey(_freeServerNum))
return startNumber; break;
} }
else else
{ {
if (!Servers.containsKey(startNumber)) if (!Servers.containsKey(_serverNum))
return startNumber; break;
} }
startNumber++; if (free)
} _freeServerNum++;
else
_serverNum++;
}
if (free)
return _freeServerNum;
else
return _serverNum;
} }
} }

View File

@ -149,7 +149,7 @@ public class ServerMonitor
handleGroupChanges(dynamicServers, serverTracker, serverGroup, groupStatus, false); handleGroupChanges(dynamicServers, serverTracker, serverGroup, groupStatus, false);
if (serverGroup.GenerateFreeVersions && _count % 2 == 0) if (serverGroup.GenerateFreeVersions && _count % 6 == 0)
{ {
handleGroupChanges(dynamicServers, serverTracker, serverGroup, groupStatus, true); handleGroupChanges(dynamicServers, serverTracker, serverGroup, groupStatus, true);
} }
@ -246,12 +246,12 @@ public class ServerMonitor
break; break;
} }
if (serverTracker.containsKey(serverGroup.Prefix + "-" + serverNum)) if (serverTracker.containsKey(serverGroup.Prefix + "-" + serverNum + (free ? "-FREE" : "")))
System.out.println("[WAITING] On " + serverGroup.Prefix + "-" + serverNum + " to finish starting..."); System.out.println("[WAITING] On " + serverGroup.Prefix + "-" + serverNum + " to finish starting...");
else else
{ {
startServer(bestServer, serverGroup, serverNum, free); startServer(bestServer, serverGroup, serverNum, free);
serverTracker.put(serverGroup.Prefix + "-" + serverNum, new AbstractMap.SimpleEntry<String, Long>(bestServer.Address, System.currentTimeMillis())); serverTracker.put(serverGroup.Prefix + "-" + serverNum + (free ? "-FREE" : ""), new AbstractMap.SimpleEntry<String, Long>(bestServer.Address, System.currentTimeMillis()));
} }
serversToAdd--; serversToAdd--;