Fixed global player count.

Fixed tasks.
This commit is contained in:
Jonathan Williams 2015-05-22 14:33:25 -07:00
parent 303cfd02fa
commit 96b1df4ee0
16 changed files with 276 additions and 306 deletions

View File

@ -377,10 +377,7 @@
<zipfileset src="../Libraries/jedis-2.4.2.jar" />
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
<zipfileset src="../Libraries/commons-dbcp2-2.0.1.jar" />
<zipfileset src="../Libraries/cxf-bundle-2.7.2.jar" />
<zipfileset src="../Libraries/wss4j-1.6.9.jar" />
<zipfileset src="../Libraries/org-apache-commons-lang.jar" />
<zipfileset src="../Libraries/cxf-rt-ws-policy-2.7.2.jar" />
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
</jar>
<copy file="../bin/BungeeRotator.jar" todir="../../Testing/BungeeRotator/"/>
</target>

View File

@ -9,6 +9,7 @@ import mineplex.serverdata.Region;
import mineplex.serverdata.data.BungeeServer;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ConnectionData;
import mineplex.serverdata.servers.ServerManager;
import mineplex.serverdata.servers.ServerRepository;
import net.md_5.bungee.api.ServerPing.Players;
@ -21,6 +22,7 @@ import net.md_5.bungee.event.EventHandler;
public class PlayerCount implements Listener, Runnable
{
private DataRepository<BungeeServer> _repository;
private DataRepository<BungeeServer> _secondRepository;
private UUID _uuid;
private Region _region;
@ -42,11 +44,17 @@ public class PlayerCount implements Listener, Runnable
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
Region.ALL, BungeeServer.class, "bungeeServers");
if (_region == Region.US)
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.81.1.156", 6379), new ConnectionData("10.81.1.156", 6377),
Region.ALL, BungeeServer.class, "bungeeServers");
else
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.33.53.16", 6379), new ConnectionData("10.33.53.16", 6377),
Region.ALL, BungeeServer.class, "bungeeServers");
}
public void run()
{
BungeeServer snapshot = generateSnapshot();
_repository.addElement(snapshot, 15); // Update with a 15 second expiry on session
@ -64,6 +72,11 @@ public class PlayerCount implements Listener, Runnable
totalPlayers += server.getPlayerCount();
}
for (BungeeServer server : _secondRepository.getElements())
{
totalPlayers += server.getPlayerCount();
}
return totalPlayers;
}

View File

@ -4,7 +4,6 @@ import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
@ -14,14 +13,6 @@ import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.apache.commons.lang.RandomStringUtils;
import biz.neustar.ultra.client.UltraAPIClient;
import biz.neustar.ultra.client.UltraAPIClientImpl;
import biz.neustar.ultra.client.UltraAPIException;
import com.neustar.ultraservice.schema.v01.AccountDetailsList;
import mineplex.bungee.api.ApiDeleteCall;
import mineplex.bungee.api.ApiGetCall;
import mineplex.bungee.api.ApiPostCall;
@ -33,11 +24,13 @@ import mineplex.serverdata.Region;
import mineplex.serverdata.data.BungeeServer;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ConnectionData;
import mineplex.serverdata.servers.ServerManager;
public class BungeeRotator
{
private static DataRepository<BungeeServer> _repository;
private static DataRepository<BungeeServer> _secondRepository;
private static PlayerStatsRepository _ipRepository;
//private static ServerRepository _repository = null;
@ -76,6 +69,7 @@ public class BungeeRotator
}
/*
String username = "mineplex";
String password = "gjxcVf%nk.";
String accountId = null;
@ -105,13 +99,16 @@ public class BungeeRotator
e.printStackTrace();
}
/*
*/
_debug = new File("debug.dat").exists();
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
Region.ALL, BungeeServer.class, "bungeeServers");
_ipRepository = new PlayerStatsRepository();
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.81.1.156", 6379), new ConnectionData("10.81.1.156", 6377),
Region.ALL, BungeeServer.class, "bungeeServers");
//_ipRepository = new PlayerStatsRepository();
BungeeSorter bungeeSorter = new BungeeSorter();
int maxRecordCount = 10;
@ -121,6 +118,8 @@ public class BungeeRotator
try
{
List<BungeeServer> bungeeServers = new ArrayList<BungeeServer>(_repository.getElements());
bungeeServers.addAll(_secondRepository.getElements());
Collections.sort(bungeeServers, bungeeSorter);
if (_debug)
@ -249,6 +248,7 @@ public class BungeeRotator
}
}
/*
List<IpInfo> updatedAddresses = new ArrayList<IpInfo>(1000);
for (IpInfo ipInfo : _ipRepository.getIpAddresses())
@ -269,7 +269,7 @@ public class BungeeRotator
}
_ipRepository.updateIps(updatedAddresses);
*/
try
{
Thread.sleep(15000);
@ -279,6 +279,7 @@ public class BungeeRotator
{
e.printStackTrace();
}
}
catch (Exception ex)
{
@ -295,7 +296,6 @@ public class BungeeRotator
}
}
}
*/
}
private static void log(String message)

View File

@ -40,7 +40,7 @@ public class ChestConverter
}
_repository = new ChestConverterRepository();
int lastId = 11056929;
int lastId = 18279475;
int count = 50000;
int numOfRowsProcessed = lastId;

View File

@ -5,10 +5,10 @@ import java.util.List;
public class TaskClient
{
public List<String> TasksCompleted;
public List<Integer> TasksCompleted;
public TaskClient()
{
TasksCompleted = new ArrayList<String>();
TasksCompleted = new ArrayList<Integer>();
}
}

View File

@ -87,12 +87,26 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
public boolean hasCompletedTask(Player player, String taskName)
{
return Get(player.getName()).TasksCompleted.contains(taskName);
synchronized (_taskLock)
{
if (!_tasks.containsKey(taskName))
{
return false;
}
return Get(player.getName()).TasksCompleted.contains(_tasks.get(taskName));
}
}
public void completedTask(final Callback<Boolean> callback, final Player player, final String taskName)
{
Get(player.getName()).TasksCompleted.add(taskName);
synchronized (_taskLock)
{
if (_tasks.containsKey(taskName))
{
Get(player.getName()).TasksCompleted.add(_tasks.get(taskName));
}
}
addTaskForOfflinePlayer(new Callback<Boolean>()
{
@ -102,9 +116,12 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
{
System.out.println("Add task FAILED for " + player.getName());
if (_tasks.containsKey(taskName))
synchronized (_taskLock)
{
Get(player.getName()).TasksCompleted.remove(taskName);
if (_tasks.containsKey(taskName))
{
Get(player.getName()).TasksCompleted.remove(_tasks.get(taskName));
}
}
}

View File

@ -48,7 +48,7 @@ public class TaskRepository extends RepositoryBase
while (resultSet.next())
{
taskClient.TasksCompleted.add(resultSet.getString(1));
taskClient.TasksCompleted.add(resultSet.getInt(1));
}
return taskClient;

View File

@ -71,7 +71,6 @@
<Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigPlayerStatsToken.cs" />
<Compile Include="Model\Server\GameServer\Dominate\Stats\DominatePlayerStatsToken.cs" />
<Compile Include="Model\Server\GameServer\Dominate\Stats\DominateGameStatsToken.cs" />
<Compile Include="Model\Server\GameServer\GameTask.cs" />
<Compile Include="Model\Server\GameServer\MineKart\KartArmor.cs" />
<Compile Include="Model\Server\GameServer\MineKart\MineKart.cs" />
<Compile Include="Model\Server\GameServer\MineKart\MineKartStats.cs" />

View File

@ -55,8 +55,6 @@
public virtual List<CustomBuild> CustomBuilds { get; set; }
public virtual List<GameTask> Tasks { get; set; }
public virtual List<LoginAddress> IpAddresses { get; set; }
public virtual List<MacAddress> MacAddresses { get; set; }

View File

@ -1,11 +0,0 @@
namespace LOC.Core.Model.Server.GameServer
{
public class GameTask
{
public int GameTaskId { get; set; }
public Account.Account Account { get; set; }
public string TaskName { get; set; }
}
}

View File

@ -52,17 +52,6 @@
PetNameTagCount = account.PetNameTagCount
};
TasksCompleted = new List<string>();
if (account.Tasks != null)
{
foreach (var task in account.Tasks)
{
TasksCompleted.Add(task.TaskName);
}
}
if (account.Clan != null)
{
ClanToken = new ClientClanToken
@ -136,8 +125,6 @@
public List<Punishment> Punishments { get; set; }
public List<String> TasksCompleted { get; set; }
public List<FishToken> FishTokens;
public List<string> IgnoredPlayers { get; set; }

View File

@ -72,6 +72,7 @@
return accounts;
}
/*
public List<AccountTask> GetTasksByCount(SearchConf searchConf)
{
var tasks = new List<AccountTask>();
@ -100,6 +101,7 @@
return tasks;
}
*/
private object getAccountLock(string name)
{
@ -353,31 +355,6 @@
return true;
}
public void AddTask(UpdateTaskToken token)
{
using (var repository = _repositoryFactory.CreateRepository())
{
var account = repository.Where<Account>(x => x.Name == token.Name).OrderByDescending(x => x.LastLogin).Include(x => x.Tasks).FirstOrDefault();
if (account != null)
{
if (account.Tasks == null)
account.Tasks = new List<GameTask>();
var task = new GameTask
{
Account = account,
TaskName = token.NewTaskCompleted,
};
account.Tasks.Add(task);
repository.Edit(account);
repository.CommitChanges();
}
}
}
public PunishmentResponse Punish(PunishToken punish)
{
using (var repository = _repositoryFactory.CreateRepository())

View File

@ -35,14 +35,11 @@
string PurchaseUnknownSalesPackage(UnknownPurchaseToken token);
string UpdateRank(RankUpdateToken token);
void RemoveBan(RemovePunishmentToken token);
void AddTask(UpdateTaskToken token);
void UpdateAccountUUIDs(List<AccountNameToken> tokens);
bool CoinReward(GemRewardToken token);
ClientToken GetAccountByUUID(string uuid);
List<AccountTask> GetTasksByCount(SearchConf searchConf);
}
}

View File

@ -40,6 +40,7 @@
return Content(json, "application/json");
}
/*
[HttpPost]
public ActionResult GetTasksByCount(SearchConf searchConf)
{
@ -48,6 +49,7 @@
var json = JsonConvert.SerializeObject(tasks);
return Content(json, "application/json");
}
*/
[HttpPost]
public ActionResult GetAccountByUUID(string uuid)
@ -86,12 +88,6 @@
return Content(json, "application/json");
}
[HttpPost]
public void AddTask(UpdateTaskToken token)
{
_accountAdministrator.AddTask(token);
}
[HttpPost]
public void ApplyKits(string name)
{

File diff suppressed because it is too large Load Diff

Binary file not shown.