* Changes to server lock handling and logging.

This commit is contained in:
LevelX2 2014-12-10 15:00:55 +01:00
parent 68fed320f7
commit b3f1cc002e
3 changed files with 33 additions and 20 deletions

View file

@ -1,5 +1,5 @@
woogerworks (Version 1.3.0 dev 2014-10-29V2) :xmage.woogerworks.com:17171
XMage.info 1 (Version 1.3.0 dev 2014-11-29v2) :176.31.186.181:17171
XMage.info 2 (Version 1.3.0 dev 2014-11-29V1) :176.31.186.181:17000
XMage.info 2 (Version 1.3.0 dev 2014-11-29V2) :176.31.186.181:17000
Seedds Server (Version 1.3.0 dev 2014-11-29v1) :115.29.203.80:17171
localhost -> connect to your local server (must be started):localhost:17171

View file

@ -218,9 +218,12 @@ public class Session {
public void userLostConnection() {
boolean lockSet = false;
try {
if(lock.tryLock(500, TimeUnit.MILLISECONDS)) {
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
lockSet = true;
logger.trace("SESSION LOCK SET sessionId: " + sessionId);
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
} else {
logger.error("CAN'T GET LOCK - userId: " + userId);
}
User user = UserManager.getInstance().getUser(userId);
if (user == null || !user.isConnected()) {
return; //user was already disconnected by other thread
@ -232,9 +235,7 @@ public class Session {
}
// logger.info("LOST CONNECTION - " + user.getName() + " id: " + userId);
UserManager.getInstance().disconnect(userId, DisconnectReason.LostConnection);
} else {
logger.error("CAN'T GET LOCK - userId: " + userId);
}
} catch (InterruptedException ex) {
logger.error("SESSION LOCK lost connection - userId: " + userId, ex);
}
@ -250,13 +251,13 @@ public class Session {
public void kill(DisconnectReason reason) {
boolean lockSet = false;
try {
if(lock.tryLock(500, TimeUnit.MILLISECONDS)) {
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
lockSet = true;
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
UserManager.getInstance().removeUser(userId, reason);
} else {
logger.error("SESSION LOCK - kill: userId " + userId);
}
UserManager.getInstance().removeUser(userId, reason);
} catch (InterruptedException ex) {
logger.error("SESSION LOCK - kill: userId " + userId, ex);
}

View file

@ -363,7 +363,19 @@ public class TableManager {
Collection<User> users = UserManager.getInstance().getUsers();
logger.debug("--------User: " + users.size() + " [userId | since | lock | name -----------------------");
for (User user :users) {
logger.debug(user.getId() + " | " + formatter.format(user.getConnectionTime()) + " | " + (SessionManager.getInstance().getSession(user.getSessionId()).isLocked()?"L":"-") + " | " + user.getName() +" (" +user.getUserState().toString() + " - " + user.getPingInfo() + ")");
Session session = SessionManager.getInstance().getSession(user.getSessionId());
String sessionState = "N";
if (session != null) {
if (session.isLocked()) {
sessionState = "L";
} else {
sessionState = "+";
}
}
logger.debug(user.getId()
+ " | " + formatter.format(user.getConnectionTime())
+ " | " + sessionState
+ " | " + user.getName() +" (" +user.getUserState().toString() + " - " + user.getPingInfo() + ")");
}
ArrayList<ChatSession> chatSessions = ChatManager.getInstance().getChatSessions();
logger.debug("------- ChatSessions: " + chatSessions.size() + " ----------------------------------");