diff --git a/Mage.Client/release/config/log4j.properties b/Mage.Client/release/config/log4j.properties index f1f6e4f3db..932d8c7106 100644 --- a/Mage.Client/release/config/log4j.properties +++ b/Mage.Client/release/config/log4j.properties @@ -1,5 +1,5 @@ #default levels -log4j.rootLogger=debug, console, logfile +log4j.rootLogger=info, console, logfile #console log log4j.appender.console=org.apache.log4j.ConsoleAppender diff --git a/Mage.Client/src/main/resources/log4j.properties b/Mage.Client/src/main/resources/log4j.properties index ef74d7a438..b881e305ad 100644 --- a/Mage.Client/src/main/resources/log4j.properties +++ b/Mage.Client/src/main/resources/log4j.properties @@ -5,10 +5,10 @@ log4j.logger.com.j256.ormlite=warn #log4j.logger.org.jboss.remoting=debug #log4j.logger.org.jboss.logging=debug -log4j.logger.mage.player.ai.ComputerPlayer6=debug -log4j.logger.mage.client.remote.CallbackClientImpl=debug +#log4j.logger.mage.player.ai.ComputerPlayer6=debug #log4j.logger.mage.client.remote.CallbackClientImpl=debug -log4j.logger.mage.client.game.FeedbackPanel=debug +#log4j.logger.mage.client.remote.CallbackClientImpl=debug +#log4j.logger.mage.client.game.FeedbackPanel=debug #console log log4j.appender.console=org.apache.log4j.ConsoleAppender diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java index bbe69dbe0c..0ee667a2d2 100644 --- a/Mage.Server/src/main/java/mage/server/ChatManager.java +++ b/Mage.Server/src/main/java/mage/server/ChatManager.java @@ -28,6 +28,7 @@ package mage.server; +import java.util.ArrayList; import java.util.Locale; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -176,4 +177,10 @@ public class ChatManager { } Logger.getLogger(ChatManager.class).debug("ChatManager: Remove user end"); } + + public ArrayList getChatSessions() { + ArrayList chatSessionList = new ArrayList<>(); + chatSessionList.addAll(chatSessions.values()); + return chatSessionList; + } } diff --git a/Mage.Server/src/main/java/mage/server/ChatSession.java b/Mage.Server/src/main/java/mage/server/ChatSession.java index c99102af04..3c30490e8a 100644 --- a/Mage.Server/src/main/java/mage/server/ChatSession.java +++ b/Mage.Server/src/main/java/mage/server/ChatSession.java @@ -69,10 +69,10 @@ public class ChatSession { try { if (userId != null && clients.containsKey(userId)) { + String userName = clients.get(userId); clients.remove(userId); logger.debug("ChatSession.kill chatSession: " + chatId + " userId: " + userId + " reason: " + (reason == null?"null":reason.toString()) - + " clients.size " + clients.size()); - String userName = clients.get(userId); + + " clients.size " + clients.size()); String message = null; switch (reason) { case Disconnected: @@ -90,7 +90,7 @@ public class ChatSession { } } } catch(Exception ex) { - logger.fatal(ex); + logger.fatal("ChatSession.kill exception: " + ex.toString()); } } @@ -157,4 +157,7 @@ public class ChatSession { return clients.containsKey(userId); } + public ConcurrentHashMap getClients() { + return clients; + } } diff --git a/Mage.Server/src/main/java/mage/server/TableManager.java b/Mage.Server/src/main/java/mage/server/TableManager.java index ccd9550290..0f2139badb 100644 --- a/Mage.Server/src/main/java/mage/server/TableManager.java +++ b/Mage.Server/src/main/java/mage/server/TableManager.java @@ -72,7 +72,7 @@ public class TableManager { * * In minutes. */ - private static final int EXPIRE_CHECK_PERIOD = 10; + private static final int EXPIRE_CHECK_PERIOD = 5; /** * This parameters defines when table can be counted as expired. @@ -355,7 +355,21 @@ public class TableManager { } private void checkExpired() { - logger.debug("Table expire checking..."); + logger.debug("--- Table expire checking -----------------------------------------------------------------------"); + Collection users = UserManager.getInstance().getUsers(); + logger.debug("------- Users: " + users.size() + " ------------------------"); + for (User user :users) { + logger.debug(user.getName() + " SessionId: " + user.getSessionId() + " ConnectionTime: " + user.getConnectionTime()); + } + ArrayList chatSessions = ChatManager.getInstance().getChatSessions(); + logger.debug("------- ChatSessions: " + chatSessions.size() + " ------------------------"); + for (ChatSession chatSession: chatSessions) { + logger.debug(chatSession.getChatId() + " Clients: " + chatSession.getClients().values().toString()); + } + logger.debug("------- Tables: " + tables.size() + " ------------------------"); + for (Table table: tables.values()) { + logger.debug(table.getId() + " Name: [" + table.getName()+ "] StartTime: " + table.getStartTime()); + } Date now = new Date(); List toRemove = new ArrayList<>(); diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 791c6c4373..6533b1df41 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -123,11 +123,11 @@ public class GameController implements GameCallback { break; case INFO: ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, ChatMessage.MessageType.GAME); - logger.debug(game.getId() + " " + event.getMessage()); + logger.trace(game.getId() + " " + event.getMessage()); break; case STATUS: ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.ORANGE, event.getWithTime(), ChatMessage.MessageType.GAME); - logger.debug(game.getId() + " " + event.getMessage()); + logger.trace(game.getId() + " " + event.getMessage()); break; case ERROR: error(event.getMessage(), event.getException()); diff --git a/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java b/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java index 2b6c09cf10..7d43376a60 100644 --- a/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java +++ b/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java @@ -69,11 +69,16 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable { private final ConcurrentHashMap tables = new ConcurrentHashMap<>(); - public GamesRoomImpl() { + public GamesRoomImpl() { updateExecutor.scheduleAtFixedRate(new Runnable() { @Override - public void run() { - update(); + public void run(){ + try { + update(); + } catch (Exception ex) { + logger.fatal("Games room update exception!", ex); + } + } }, 2, 2, TimeUnit.SECONDS); } diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java index 8f2da2624d..aab98b012e 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java @@ -165,12 +165,17 @@ public class TournamentController { // first join of player TournamentSession tournamentSession = new TournamentSession(tournament, userId, tableId, playerId); tournamentSessions.put(playerId, tournamentSession); - UserManager.getInstance().getUser(userId).addTournament(playerId, tournamentSession); - TournamentPlayer player = tournament.getPlayer(playerId); - player.setJoined(); - logger.debug("player " +player.getPlayer().getName() + " - client has joined tournament " + tournament.getId()); - ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS); - checkStart(); + User user = UserManager.getInstance().getUser(userId); + if (user != null) { + user.addTournament(playerId, tournamentSession); + TournamentPlayer player = tournament.getPlayer(playerId); + player.setJoined(); + logger.debug("player " +player.getPlayer().getName() + " - client has joined tournament " + tournament.getId()); + ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS); + checkStart(); + } else { + logger.error("TournamentController.join user not found uderId: " +userId + " tournamentId: " + tournament.getId()); + } } private void checkStart() { diff --git a/Mage/src/mage/game/GameStates.java b/Mage/src/mage/game/GameStates.java index ef34bf91f0..990bbaa9b8 100644 --- a/Mage/src/mage/game/GameStates.java +++ b/Mage/src/mage/game/GameStates.java @@ -48,7 +48,7 @@ public class GameStates implements Serializable { public void save(GameState gameState) { // states.add(new Copier().copyCompressed(gameState)); states.add(gameState.copy()); - logger.debug("Saved game state: " + states.size()); + logger.trace("Saved game state: " + states.size()); } public int getSize() { diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 668d12a1a6..4b818a0461 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -1562,14 +1562,14 @@ public abstract class PlayerImpl implements Player, Serializable { public void passTurnPriority(Game game) { passedTurn = true; this.skip(); - log.debug("Passed priority for turn"); + log.trace("Passed priority for turn"); } @Override public void restorePriority(Game game) { passedAllTurns = false; passedTurn = false; - log.debug("Restore priority"); + log.trace("Restore priority"); } @Override