* 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,23 +218,24 @@ 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);
User user = UserManager.getInstance().getUser(userId);
if (user == null || !user.isConnected()) {
return; //user was already disconnected by other thread
}
if (!user.getSessionId().equals(sessionId)) {
// user already reconnected with another instance
logger.info("OLD SESSION IGNORED - " + user.getName());
return;
}
// logger.info("LOST CONNECTION - " + user.getName() + " id: " + userId);
UserManager.getInstance().disconnect(userId, DisconnectReason.LostConnection);
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
}
if (!user.getSessionId().equals(sessionId)) {
// user already reconnected with another instance
logger.info("OLD SESSION IGNORED - " + user.getName());
return;
}
// logger.info("LOST CONNECTION - " + user.getName() + " id: " + userId);
UserManager.getInstance().disconnect(userId, DisconnectReason.LostConnection);
} 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);
}
@ -272,8 +273,8 @@ public class Session {
public void fireCallback(final ClientCallback call) {
try {
call.setMessageId(messageId++);
callbackHandler.handleCallbackOneway(new Callback(call));
call.setMessageId(messageId++);
callbackHandler.handleCallbackOneway(new Callback(call));
} catch (HandleCallbackException ex) {
User user = UserManager.getInstance().getUser(userId);
logger.warn("SESSION CALLBACK EXCEPTION - " + (user != null ? user.getName():"") + " userId " + userId);

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() + " ----------------------------------");