private String handleSessionTakeOver( final MemcachedBackupSession session ) { checkMaxActiveSessions(); final String origSessionId = session.getIdInternal(); final String newSessionId = _memcachedNodesManager.changeSessionIdForTomcatFailover(session.getIdInternal(), _manager.getJvmRoute()); // If this session was already loaded we need to remove it from the session map // See http://code.google.com/p/memcached-session-manager/issues/detail?id=92 if ( _manager.getSessionsInternal().containsKey( origSessionId ) ) { _manager.getSessionsInternal().remove( origSessionId ); } session.setIdInternal( newSessionId ); // a concurrent/earlier request might already have added the session (#282) if ( !_manager.getSessionsInternal().containsKey( newSessionId ) ) { addValidLoadedSession(session, true); deleteFromMemcached(origSessionId); _statistics.requestWithTomcatFailover(); } return newSessionId; }
@Test public void testChangeSessionIdForTomcatFailover() { assertEquals(createFor("localhost:11211", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", null, null), null), sessionId("123", null, null)); assertEquals(createFor("localhost:11211", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", null, "tc1"), "tc2"), sessionId("123", null, "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), null), sessionId("123", "n1", null)); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", "tc1"), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n2", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), null), sessionId("123", "n1", null)); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n2", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n2", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", "tc1"), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n1", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), null), sessionId("123", "n2", null)); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n1", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), "tc2"), sessionId("123", "n2", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n1", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", "tc1"), "tc2"), sessionId("123", "n2", "tc2")); }
final String newSessionId = _memcachedNodesManager.changeSessionIdForTomcatFailover(requestedSessionId, _manager.getJvmRoute()); if (_manager.getSessionInternal(newSessionId) != null) { return newSessionId;
private String handleSessionTakeOver( final MemcachedBackupSession session ) { checkMaxActiveSessions(); final String origSessionId = session.getIdInternal(); final String newSessionId = _memcachedNodesManager.changeSessionIdForTomcatFailover(session.getIdInternal(), _manager.getJvmRoute()); // If this session was already loaded we need to remove it from the session map // See http://code.google.com/p/memcached-session-manager/issues/detail?id=92 if ( _manager.getSessionsInternal().containsKey( origSessionId ) ) { _manager.getSessionsInternal().remove( origSessionId ); } session.setIdInternal( newSessionId ); // a concurrent/earlier request might already have added the session (#282) if ( !_manager.getSessionsInternal().containsKey( newSessionId ) ) { addValidLoadedSession(session, true); deleteFromMemcached(origSessionId); _statistics.requestWithTomcatFailover(); } return newSessionId; }
final String newSessionId = _memcachedNodesManager.changeSessionIdForTomcatFailover(requestedSessionId, _manager.getJvmRoute()); if (_manager.getSessionInternal(newSessionId) != null) { return newSessionId;