forked from External/mage
fixed tests
This commit is contained in:
parent
c2ae1386ff
commit
de323a3577
6 changed files with 38 additions and 13 deletions
|
|
@ -9,6 +9,7 @@ import mage.game.events.TableEvent;
|
|||
import mage.players.Player;
|
||||
import mage.server.game.GameController;
|
||||
import mage.server.managers.ManagerFactory;
|
||||
import mage.util.ThreadUtils;
|
||||
import mage.view.DraftPickView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -124,7 +125,7 @@ public class DraftController {
|
|||
}
|
||||
|
||||
private void startDraft() {
|
||||
Thread.currentThread().setName("TOURNEY DRAFT " + tableId);
|
||||
Thread.currentThread().setName(ThreadUtils.THREAD_PREFIX_TOURNEY_DRAFT + " " + tableId);
|
||||
for (final Entry<UUID, DraftSession> entry : draftSessions.entrySet()) {
|
||||
if (!entry.getValue().init()) {
|
||||
logger.fatal("Unable to initialize client for playerId " + entry.getKey());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.server.game;
|
|||
|
||||
import mage.MageException;
|
||||
import mage.game.Game;
|
||||
import mage.util.ThreadUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -30,7 +31,7 @@ public class GameWorker implements Callable<Boolean> {
|
|||
public Boolean call() {
|
||||
try {
|
||||
// play game
|
||||
Thread.currentThread().setName("GAME " + game.getId());
|
||||
Thread.currentThread().setName(ThreadUtils.THREAD_PREFIX_GAME + " " + game.getId());
|
||||
game.start(choosingPlayerId);
|
||||
|
||||
// save result and start next game or close finished table
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import mage.server.User;
|
|||
import mage.server.draft.DraftController;
|
||||
import mage.server.managers.TableManager;
|
||||
import mage.server.managers.ManagerFactory;
|
||||
import mage.util.ThreadUtils;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import mage.view.ChatMessage.MessageType;
|
||||
import mage.view.ChatMessage.SoundToPlay;
|
||||
|
|
@ -191,7 +192,7 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
private synchronized void startTournament() {
|
||||
Thread.currentThread().setName("TOURNEY " + tableId);
|
||||
Thread.currentThread().setName(ThreadUtils.THREAD_PREFIX_TOURNEY + " " + tableId);
|
||||
for (final TournamentSession tournamentSession : tournamentSessions.values()) {
|
||||
if (!tournamentSession.init()) {
|
||||
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
|
||||
|
|
|
|||
|
|
@ -41,31 +41,31 @@ public class ThreadExecutorImpl implements ThreadExecutor {
|
|||
callExecutor = new CachedThreadPoolWithException();
|
||||
((ThreadPoolExecutor) callExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) callExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) callExecutor).setThreadFactory(new XMageThreadFactory("CALL"));
|
||||
((ThreadPoolExecutor) callExecutor).setThreadFactory(new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_CALL_REQUEST));
|
||||
|
||||
//gameExecutor = Executors.newFixedThreadPool(config.getMaxGameThreads());
|
||||
gameExecutor = new FixedThreadPoolWithException(config.getMaxGameThreads());
|
||||
((ThreadPoolExecutor) gameExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) gameExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) gameExecutor).setThreadFactory(new XMageThreadFactory("GAME"));
|
||||
((ThreadPoolExecutor) gameExecutor).setThreadFactory(new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_GAME));
|
||||
|
||||
//tourney = Executors.newFixedThreadPool(config.getMaxGameThreads() / GAMES_PER_TOURNEY_RATIO);
|
||||
tourneyExecutor = new FixedThreadPoolWithException(config.getMaxGameThreads() / GAMES_PER_TOURNEY_RATIO);
|
||||
((ThreadPoolExecutor) tourneyExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) tourneyExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) tourneyExecutor).setThreadFactory(new XMageThreadFactory("TOURNEY"));
|
||||
((ThreadPoolExecutor) tourneyExecutor).setThreadFactory(new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_TOURNEY));
|
||||
|
||||
timeoutExecutor = Executors.newScheduledThreadPool(4);
|
||||
((ThreadPoolExecutor) timeoutExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) timeoutExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) timeoutExecutor).setThreadFactory(new XMageThreadFactory("XMAGE TIMEOUT"));
|
||||
((ThreadPoolExecutor) timeoutExecutor).setThreadFactory(new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_TIMEOUT));
|
||||
|
||||
timeoutIdleExecutor = Executors.newScheduledThreadPool(4);
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).allowCoreThreadTimeOut(true);
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).setThreadFactory(new XMageThreadFactory("XMAGE TIMEOUT_IDLE"));
|
||||
((ThreadPoolExecutor) timeoutIdleExecutor).setThreadFactory(new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_TIMEOUT_IDLE));
|
||||
|
||||
serverHealthExecutor = Executors.newSingleThreadScheduledExecutor(new XMageThreadFactory("HEALTH"));
|
||||
serverHealthExecutor = Executors.newSingleThreadScheduledExecutor(new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_SERVICE_HEALTH));
|
||||
}
|
||||
|
||||
static class CachedThreadPoolWithException extends ThreadPoolExecutor {
|
||||
|
|
@ -157,7 +157,8 @@ class XMageThreadFactory implements ThreadFactory {
|
|||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread thread = new Thread(r);
|
||||
thread.setName(prefix + ' ' + thread.getThreadGroup().getName() + '-' + thread.getId());
|
||||
// default name, but threads can change it (example: on game or tourney start)
|
||||
thread.setName(prefix + " " + thread.getThreadGroup().getName() + "-" + thread.getId());
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue