Added performance logging in ServerMonitor

Added date tracking for gem/coin/account transactions in preparation for Customer Support server.
This commit is contained in:
Jonathan Williams 2014-08-18 15:46:23 -04:00
parent 8aec9e345e
commit d73ffcccfd
15 changed files with 294 additions and 240 deletions

View File

@ -8,5 +8,6 @@ public class DonorToken
public boolean Donated; public boolean Donated;
public List<Integer> SalesPackages; public List<Integer> SalesPackages;
public List<String> UnknownSalesPackages; public List<String> UnknownSalesPackages;
public List<TransactionToken> Transactions;
public int Coins; public int Coins;
} }

View File

@ -0,0 +1,9 @@
package mineplex.core.donation.repository.token;
public class TransactionToken
{
public long Date;
public String SalesPackageName;
public int Gems;
public int Coins;
}

View File

@ -45,8 +45,8 @@ public class DDoSProtectionSwitcher
_repository = new DnsMadeEasyRepository(); _repository = new DnsMadeEasyRepository();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
while (true) //while (true)
{ //{
if (_repository.switchToDDOSProt()) if (_repository.switchToDDOSProt())
{ {
System.out.println("Starting DDoS Protection Switch at " + dateFormat.format(new Date())); System.out.println("Starting DDoS Protection Switch at " + dateFormat.format(new Date()));
@ -203,7 +203,7 @@ public class DDoSProtectionSwitcher
{ {
e.printStackTrace(); e.printStackTrace();
} }
} //}
/* /*
* // Switch off ddos protection for (DnsRecord record : records.data) { * // Switch off ddos protection for (DnsRecord record : records.data) {
* if (record.type.equalsIgnoreCase("CNAME")) { if * if (record.type.equalsIgnoreCase("CNAME")) { if

View File

@ -9,7 +9,8 @@ import java.text.SimpleDateFormat;
public class DnsMadeEasyRepository public class DnsMadeEasyRepository
{ {
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10"; // Yip Yip actual IP because if null route happens we can't resolve the HOSTNAME DERP FACE DEFEK7!!! -defek7
private String _connectionString = "jdbc:mysql://10.35.74.133:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
private String _userName = "root"; private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh"; private String _password = "tAbechAk3wR7tuTh";
@ -119,6 +120,9 @@ public class DnsMadeEasyRepository
} }
} }
return countOffline >= 20; //if (countOffline > 5)
System.out.println(countOffline + " offline bungees.");
return true;
} }
} }

View File

@ -76,7 +76,7 @@ public class ServerMonitor
for (MinecraftServer deadServer : _repository.getDeadServers()) for (MinecraftServer deadServer : _repository.getDeadServers())
{ {
killServer(deadServer.getName(), deadServer.getPublicAddress(), true); killServer(deadServer.getName(), deadServer.getPublicAddress(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true);
} }
List<DedicatedServer> dedicatedServers = new ArrayList<DedicatedServer>(_repository.getDedicatedServers()); List<DedicatedServer> dedicatedServers = new ArrayList<DedicatedServer>(_repository.getDedicatedServers());
@ -139,11 +139,9 @@ public class ServerMonitor
iterator.remove(); iterator.remove();
else if (System.currentTimeMillis() - entry.getValue().getValue() > 20000) else if (System.currentTimeMillis() - entry.getValue().getValue() > 20000)
{ {
System.out.println("-=[SERVER STARTUP TOO SLOW]=- " + entry.getKey());
String serverName = entry.getKey(); String serverName = entry.getKey();
String serverAddress = entry.getValue().getKey(); String serverAddress = entry.getValue().getKey();
killServer(serverName, serverAddress, true); killServer(serverName, serverAddress, "[KILLED] [SLOW-STARTUP] " + serverName + ":" + serverAddress, true);
iterator.remove(); iterator.remove();
} }
} }
@ -220,7 +218,6 @@ public class ServerMonitor
private static void handleGroupChanges(List<DedicatedServer> dedicatedServers, HashMap<String, Entry<String, Long>> serverTracker, ServerGroup serverGroup, boolean free) private static void handleGroupChanges(List<DedicatedServer> dedicatedServers, HashMap<String, Entry<String, Long>> serverTracker, ServerGroup serverGroup, boolean free)
{ {
int serverNum = 0; int serverNum = 0;
//GroupStatusData groupStatus = groupStatusList.get(serverGroup.Name);
int requiredTotal = serverGroup.getRequiredTotalServers(); int requiredTotal = serverGroup.getRequiredTotalServers();
int requiredJoinable = serverGroup.getRequiredJoinableServers(); int requiredJoinable = serverGroup.getRequiredJoinableServers();
int joinableServers = serverGroup.getJoinableCount(); int joinableServers = serverGroup.getJoinableCount();
@ -231,8 +228,12 @@ public class ServerMonitor
// Minimum 1500 slot bufferzone // Minimum 1500 slot bufferzone
if (serverGroup.getName().equalsIgnoreCase("Lobby")) if (serverGroup.getName().equalsIgnoreCase("Lobby"))
{ {
if (serverGroup.getMaxPlayerCount() - serverGroup.getPlayerCount() < 1500) int availableSlots = serverGroup.getMaxPlayerCount() - serverGroup.getPlayerCount();
serversToAdd = requiredJoinable;
if (availableSlots < 1500)
serversToAdd = Math.max(1, (1500 / availableSlots) - serverGroup.getMaxPlayers());
else if (serversToKill > 0)
serversToKill = Math.min(serversToKill, (availableSlots - 1500) / 80);
} }
while (serversToAdd > 0) while (serversToAdd > 0)
@ -262,12 +263,12 @@ public class ServerMonitor
{ {
List<MinecraftServer> emptyServers = new ArrayList<MinecraftServer>(serverGroup.getEmptyServers()); List<MinecraftServer> emptyServers = new ArrayList<MinecraftServer>(serverGroup.getEmptyServers());
MinecraftServer emptyServer = emptyServers.get(serversToKill - 1); MinecraftServer emptyServer = emptyServers.get(serversToKill - 1);
killServer(emptyServer); killServer(emptyServer, "[KILLED] [EXCESS] " + emptyServer.getName() + ":" + emptyServer.getPublicAddress());
serversToKill--; serversToKill--;
} }
} }
private static void killServer(final String serverName, final String serverAddress, final boolean announce) private static void killServer(final String serverName, final String serverAddress, final String message, final boolean announce)
{ {
String cmd = "/home/mineplex/easyRemoteKillServer.sh"; String cmd = "/home/mineplex/easyRemoteKillServer.sh";
@ -291,7 +292,7 @@ public class ServerMonitor
if (error) if (error)
System.out.println("[" + serverName + ":" + serverAddress + "] Kill errored."); System.out.println("[" + serverName + ":" + serverAddress + "] Kill errored.");
else else
System.out.println("Sent kill command to " + serverAddress + " for " + serverName + " completed"); System.out.println(message);
} }
} }
}); });
@ -366,9 +367,9 @@ public class ServerMonitor
return bestServer; return bestServer;
} }
private static void killServer(final MinecraftServer serverToKill) private static void killServer(final MinecraftServer serverToKill, String message)
{ {
killServer(serverToKill.getName(), serverToKill.getPublicAddress(), true); killServer(serverToKill.getName(), serverToKill.getPublicAddress(), message, true);
} }
private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free) private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free)

View File

@ -82,6 +82,7 @@
<Compile Include="Model\Server\PvpServer\Weapon.cs" /> <Compile Include="Model\Server\PvpServer\Weapon.cs" />
<Compile Include="Tokens\AccountBatchToken.cs" /> <Compile Include="Tokens\AccountBatchToken.cs" />
<Compile Include="Tokens\AccountNameToken.cs" /> <Compile Include="Tokens\AccountNameToken.cs" />
<Compile Include="Tokens\Client\AccountTransactionToken.cs" />
<Compile Include="Tokens\Client\RankUpdateToken.cs" /> <Compile Include="Tokens\Client\RankUpdateToken.cs" />
<Compile Include="Tokens\Client\DonationBenefitToken.cs" /> <Compile Include="Tokens\Client\DonationBenefitToken.cs" />
<Compile Include="Model\Server\PetExtra.cs" /> <Compile Include="Model\Server\PetExtra.cs" />

View File

@ -6,6 +6,8 @@
public Account.Account Account { get; set; } public Account.Account Account { get; set; }
public long Date { get; set; }
public string SalesPackageName { get; set; } public string SalesPackageName { get; set; }
public int Gems { get; set; } public int Gems { get; set; }

View File

@ -6,6 +6,8 @@
public Account.Account Account { get; set; } public Account.Account Account { get; set; }
public long Date { get; set; }
public string Source { get; set; } public string Source { get; set; }
public int Amount { get; set; } public int Amount { get; set; }

View File

@ -6,6 +6,8 @@
public Account.Account Account { get; set; } public Account.Account Account { get; set; }
public long Date { get; set; }
public string Source { get; set; } public string Source { get; set; }
public int Amount { get; set; } public int Amount { get; set; }

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LOC.Core.Tokens.Client
{
public class AccountTransactionToken
{
public long Date { get; set; }
public string SalesPackageName { get; set; }
public int Gems { get; set; }
public int Coins { get; set; }
public AccountTransactionToken(Model.Sales.AccountTransaction transaction)
{
SalesPackageName = transaction.SalesPackageName;
Date = transaction.Date;
Gems = transaction.Gems;
Coins = transaction.Coins;
}
}
}

View File

@ -42,6 +42,7 @@
Donated = account.Donated, Donated = account.Donated,
SalesPackages = new List<int>(), SalesPackages = new List<int>(),
UnknownSalesPackages = new List<string>(), UnknownSalesPackages = new List<string>(),
Transactions = new List<AccountTransactionToken>(),
CustomBuilds = new List<CustomBuildToken>(), CustomBuilds = new List<CustomBuildToken>(),
Pets = new List<PetToken>(), Pets = new List<PetToken>(),
PetNameTagCount = account.PetNameTagCount PetNameTagCount = account.PetNameTagCount
@ -86,6 +87,7 @@
foreach (var transaction in account.AccountTransactions) foreach (var transaction in account.AccountTransactions)
{ {
DonorToken.UnknownSalesPackages.Add(transaction.SalesPackageName); DonorToken.UnknownSalesPackages.Add(transaction.SalesPackageName);
DonorToken.Transactions.Add(new AccountTransactionToken(transaction));
} }
if (account.CustomBuilds == null) if (account.CustomBuilds == null)

View File

@ -9,6 +9,7 @@
public bool Donated { get; set; } public bool Donated { get; set; }
public List<int> SalesPackages { get; set; } public List<int> SalesPackages { get; set; }
public List<string> UnknownSalesPackages { get; set; } public List<string> UnknownSalesPackages { get; set; }
public List<AccountTransactionToken> Transactions { get; set; }
public List<CustomBuildToken> CustomBuilds { get; set; } public List<CustomBuildToken> CustomBuilds { get; set; }
public List<PetToken> Pets { get; set; } public List<PetToken> Pets { get; set; }
public int PetNameTagCount { get; set; } public int PetNameTagCount { get; set; }

View File

@ -207,7 +207,8 @@
{ {
Source = token.Source, Source = token.Source,
Account = account, Account = account,
Amount = token.Amount Amount = token.Amount,
Date = (long)TimeUtil.GetCurrentMilliseconds()
}; };
repository.Add<GemTransaction>(gemTransaction); repository.Add<GemTransaction>(gemTransaction);
@ -238,7 +239,8 @@
{ {
Source = token.Source, Source = token.Source,
Account = account, Account = account,
Amount = token.Amount Amount = token.Amount,
Date = (long)TimeUtil.GetCurrentMilliseconds()
}; };
repository.Add<CoinTransaction>(coinTransaction); repository.Add<CoinTransaction>(coinTransaction);
@ -502,6 +504,7 @@
{ {
Account = account, Account = account,
SalesPackageName = token.SalesPackageName, SalesPackageName = token.SalesPackageName,
Date = (long)TimeUtil.GetCurrentMilliseconds(),
Gems = token.CoinPurchase ? 0 : token.Cost, Gems = token.CoinPurchase ? 0 : token.Cost,
Coins = token.CoinPurchase ? token.Cost : 0 Coins = token.CoinPurchase ? token.Cost : 0
}; };

File diff suppressed because it is too large Load Diff

Binary file not shown.