Fixed Account login issues....Nasty LoadNavigationProperties()

Tweaked dynamic server monitor sleep ordering to prevent multiple duplicate starts on boxes.
This commit is contained in:
Jonathan Williams 2014-02-14 13:39:24 -06:00
parent 95210de788
commit ac8748312f
6 changed files with 416 additions and 415 deletions

View File

@ -21,7 +21,7 @@ public class Repository
private static String CREATE_DYNAMIC_TABLE = "CREATE TABLE IF NOT EXISTS DynamicServers (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), address VARCHAR(256), privateAddress VARCHAR(256), US BOOLEAN NOT NULL DEFAULT 'true', PRIMARY KEY (id));";
private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, DynamicServers.privateAddress, DynamicServers.US, DynamicServers.availableCpu, DynamicServers.availableRam, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = false GROUP BY DynamicServers.address, ServerStatus.serverGroup;";
private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, motd, DynamicServers.address, ServerStatus.address, players, maxPlayers, case when TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.lastTimeWithPlayers)) > 300 then 1 else 0 end as empty FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = false AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 10";
private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, motd, DynamicServers.address, ServerStatus.address, players, maxPlayers, case when TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.lastTimeWithPlayers)) > 300 then 1 else 0 end as empty FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = false AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 15";
private static String RETRIEVE_SERVER_GROUP_DATA = "SELECT groupName, prefix, scriptName, requiredRam, cpuRequired, requiredTotal, requiredJoinable FROM ServerGroups;";
private static String DELETE_SERVER_STATUS = "DELETE FROM ServerStatus WHERE address = ? AND serverName = ?;";

View File

@ -19,52 +19,7 @@ public class ServerMonitor
_repository.initialize();
while (true)
{
while (_processes.size() > 0)
{
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
{
ProcessRunner pr = iterator.next();
try
{
pr.join(100);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
if (pr.isDone())
iterator.remove();
}
try
{
System.out.println("Sleeping while processes run...");
Thread.sleep(6000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
if (_count >= 10)
{
System.out.println("Killing stale processes.");
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
{
iterator.next().abort();
iterator.remove();
}
}
_count++;
}
_count = 0;
{
for (ServerStatusData statusData : _repository.retrieveOldServerStatuses())
{
System.out.println("----Old Server Status----> " + statusData.Address + ", " + statusData.Name);
@ -114,10 +69,55 @@ public class ServerMonitor
}
}
while (_processes.size() > 0)
{
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
{
ProcessRunner pr = iterator.next();
try
{
pr.join(100);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
if (pr.isDone())
iterator.remove();
}
try
{
System.out.println("Sleeping while processes run...");
Thread.sleep(6000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
if (_count >= 10)
{
System.out.println("Killing stale processes.");
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
{
iterator.next().abort();
iterator.remove();
}
}
_count++;
}
_count = 0;
try
{
System.out.println("Natural sleep.");
Thread.sleep(5000);
Thread.sleep(8000);
}
catch (InterruptedException e)
{

View File

@ -61,6 +61,5 @@
public List<CaptureThePigPlayerStats> CaptureThePigStats { get; set; }
public List<AccountTransaction> AccountTransactions { get; set; }
public List<GemTransaction> GemTransactions { get; set; }
}
}

View File

@ -42,6 +42,8 @@ namespace LOC.Website.Common.Contexts
public DbSet<DominatePlayerStats> DominatePlayerStats { get; set; }
public DbSet<CaptureThePigPlayerStats> CaptureThePigPlayerStats { get; set; }
public DbSet<GemTransaction> GemTransactions { get; set; }
public DbSet<MineKart> MineKarts { get; set; }
public DbSet<Clan> Clans { get; set; }

View File

@ -160,17 +160,17 @@
account.Gems += token.Amount;
var gemTransaction = new GemTransaction
{
Source = token.Source,
Account = account,
Amount = token.Amount
};
if (!token.Source.Contains("Earned") && !token.Source.Contains("Tutorial") && !token.Source.Contains("Parkour"))
{
var gemTransaction = new GemTransaction
{
Source = token.Source,
Account = account,
Amount = token.Amount
};
if (account.GemTransactions == null)
account.GemTransactions = new List<GemTransaction>();
account.GemTransactions.Add(gemTransaction);
repository.Add<GemTransaction>(gemTransaction);
}
repository.Edit(account);
repository.CommitChanges();

File diff suppressed because it is too large Load Diff