Finished up changes for game task conversion.
This commit is contained in:
parent
a6cf1309ff
commit
47ff9101fd
@ -414,7 +414,7 @@
|
||||
<copy file="../bin/ServerMonitor.jar" todir="../../Testing/ServerMonitor/"/>
|
||||
</target>
|
||||
<target name ="ChestConverter" description="ChestConverter">
|
||||
<jar jarfile="../bin/ChestConverter.jar">
|
||||
<jar jarfile="../bin/TaskConverter.jar">
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
@ -438,7 +438,7 @@
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/ChestConverter.jar" todir="../../Testing/ChestConverter/"/>
|
||||
<copy file="../bin/TaskConverter.jar" todir="../../Testing/ChestConverter/"/>
|
||||
</target>
|
||||
<target name ="Queuer" description="Queuer">
|
||||
<jar jarfile="../bin/Queuer.jar">
|
||||
|
@ -2,6 +2,7 @@ package mineplex.chestConverter;
|
||||
|
||||
public class AccountTask
|
||||
{
|
||||
public int Id;
|
||||
public String Task;
|
||||
public String UUID;
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
package mineplex.chestConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ChestConverter
|
||||
@ -12,45 +16,95 @@ public class ChestConverter
|
||||
private static ChestConverterRepository _repository = null;
|
||||
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
|
||||
private static Logger _logger = Logger.getLogger("Converter");
|
||||
|
||||
public static void main (String args[])
|
||||
{
|
||||
try
|
||||
{
|
||||
FileHandler fileHandler = new FileHandler("converter.log", true);
|
||||
fileHandler.setFormatter(new Formatter()
|
||||
{
|
||||
@Override
|
||||
public String format(LogRecord record)
|
||||
{
|
||||
return record.getMessage() + "\n";
|
||||
}
|
||||
});
|
||||
_logger.addHandler(fileHandler);
|
||||
_logger.setUseParentHandlers(false);
|
||||
}
|
||||
catch (SecurityException | IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
_repository = new ChestConverterRepository();
|
||||
int count = 0;
|
||||
int batchAmount = 5000;
|
||||
int lastId = 11056929;
|
||||
int count = 50000;
|
||||
int numOfRowsProcessed = lastId;
|
||||
|
||||
HashMap<String, Integer> tasks = _repository.getTaskList();
|
||||
|
||||
while (true)
|
||||
try
|
||||
{
|
||||
long time = System.currentTimeMillis();
|
||||
HashMap<String, List<Integer>> playerMap = new HashMap<String, List<Integer>>();
|
||||
|
||||
|
||||
List<AccountTask> taskList = _repository.getTasks(count, batchAmount);
|
||||
|
||||
if (taskList == null || taskList.size() == 0)
|
||||
return;
|
||||
|
||||
for (AccountTask task : taskList)
|
||||
while (true)
|
||||
{
|
||||
if (!playerMap.containsKey(task.UUID))
|
||||
playerMap.put(task.UUID, new ArrayList<Integer>());
|
||||
long time = System.currentTimeMillis();
|
||||
HashMap<String, List<Integer>> playerMap = new HashMap<String, List<Integer>>();
|
||||
|
||||
playerMap.get(task.UUID).add(tasks.get(task.Task));
|
||||
}
|
||||
|
||||
_repository.incrementClients(playerMap);
|
||||
try
|
||||
{
|
||||
count += batchAmount;
|
||||
log("Natural sleep. " + batchAmount + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + count);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
List<AccountTask> taskList = _repository.getTasks(lastId, count);
|
||||
|
||||
if (taskList != null && taskList.size() > 0)
|
||||
{
|
||||
for (AccountTask task : taskList)
|
||||
{
|
||||
if (!playerMap.containsKey(task.UUID))
|
||||
playerMap.put(task.UUID, new ArrayList<Integer>());
|
||||
|
||||
playerMap.get(task.UUID).add(tasks.get(task.Task));
|
||||
|
||||
if (task.Id > lastId)
|
||||
lastId = task.Id;
|
||||
}
|
||||
|
||||
_repository.incrementClients(playerMap);
|
||||
try
|
||||
{
|
||||
numOfRowsProcessed += count;
|
||||
log("Natural sleep. " + count + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + numOfRowsProcessed);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (numOfRowsProcessed > 17000000)
|
||||
{
|
||||
System.out.println("Count : " + numOfRowsProcessed);
|
||||
_logger.info("Count : " + numOfRowsProcessed);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("No greater than 17 mil");
|
||||
_logger.info("No greater than 17 mil");
|
||||
System.out.println("Count : " + numOfRowsProcessed);
|
||||
_logger.info("Count : " + numOfRowsProcessed);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.info(e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.out.println("Count : " + numOfRowsProcessed);
|
||||
_logger.info("Count : " + numOfRowsProcessed);
|
||||
}
|
||||
}
|
||||
|
||||
private static void log(String message)
|
||||
|
@ -95,9 +95,9 @@ public class ChestConverterRepository
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public List<AccountTask> getTasks(int skip, int count)
|
||||
public List<AccountTask> getTasks(int lastId, int count) throws Exception
|
||||
{
|
||||
return new JsonWebCall("http://accounts.mineplex.com/PlayerAccount/GetTasksByCount").Execute(new com.google.gson.reflect.TypeToken<List<AccountTask>>(){}.getType(), new SearchConf(skip, count));
|
||||
return new JsonWebCall("http://accounts.mineplex.com/PlayerAccount/GetTasksByCount").Execute(new com.google.gson.reflect.TypeToken<List<AccountTask>>(){}.getType(), new SearchConf(lastId, count));
|
||||
}
|
||||
|
||||
public void incrementClients(HashMap<String, List<Integer>> playerList)
|
||||
|
@ -154,7 +154,7 @@ public class JsonWebCall
|
||||
return Execute(returnClass, (Object)null);
|
||||
}
|
||||
|
||||
public <T> T Execute(Type returnType, Object argument)
|
||||
public <T> T Execute(Type returnType, Object argument) throws Exception
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
@ -185,16 +185,6 @@ public class JsonWebCall
|
||||
returnData = new Gson().fromJson(result, returnType);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
@ -2,12 +2,12 @@ package mineplex.chestConverter;
|
||||
|
||||
public class SearchConf
|
||||
{
|
||||
public SearchConf(int skip, int count)
|
||||
public SearchConf(int idIndex, int count)
|
||||
{
|
||||
Skip = skip;
|
||||
IdIndex = idIndex;
|
||||
Count = count;
|
||||
}
|
||||
|
||||
public int Skip;
|
||||
public int IdIndex;
|
||||
public int Count;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace LOC.Core
|
||||
{
|
||||
public class SearchConf
|
||||
{
|
||||
public int Skip { get; set; }
|
||||
public int IdIndex { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ namespace LOC.Core.Tokens
|
||||
{
|
||||
public class AccountTask
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Task { get; set; }
|
||||
public string UUID { get; set; }
|
||||
}
|
||||
|
@ -76,19 +76,27 @@
|
||||
{
|
||||
var tasks = new List<AccountTask>();
|
||||
|
||||
using (var repository = _repositoryFactory.CreateRepository())
|
||||
try
|
||||
{
|
||||
var gameTasks = repository.GetAll<GameTask>().OrderBy(x => x.GameTaskId).Skip(searchConf.Skip).Take(searchConf.Count).Include(x => x.Account).ToList();
|
||||
|
||||
foreach (var task in gameTasks)
|
||||
using (var repository = _repositoryFactory.CreateRepository())
|
||||
{
|
||||
AccountTask accountTask = new AccountTask();
|
||||
accountTask.Task = task.TaskName;
|
||||
accountTask.UUID = task.Account.Uuid;
|
||||
var gameTasks = repository.GetAll<GameTask>().Where(x => x.GameTaskId > searchConf.IdIndex).OrderBy(x => x.GameTaskId).Take(searchConf.Count).Include(x => x.Account).ToList();
|
||||
|
||||
tasks.Add(accountTask);
|
||||
foreach (var task in gameTasks)
|
||||
{
|
||||
AccountTask accountTask = new AccountTask();
|
||||
accountTask.Id = task.GameTaskId;
|
||||
accountTask.Task = task.TaskName;
|
||||
accountTask.UUID = task.Account.Uuid;
|
||||
|
||||
tasks.Add(accountTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Log("ERROR", ex.Message + " : " + ex.StackTrace);
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue
Block a user