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; }
private void addValidLoadedSession(final MemcachedBackupSession result) { // When the sessionId will be changed later in changeSessionIdOnTomcatFailover/handleSessionTakeOver // (due to a tomcat failover) we don't want to notify listeners via session.activate for the // old sessionId but do that later (in handleSessionTakeOver) // See also http://code.google.com/p/memcached-session-manager/issues/detail?id=92 String jvmRoute; final boolean sessionIdWillBeChanged = _sticky && ( jvmRoute = _manager.getJvmRoute() ) != null && !jvmRoute.equals( getSessionIdFormat().extractJvmRoute( result.getId() ) ); final boolean activate = !sessionIdWillBeChanged; addValidLoadedSession( result, activate ); }
return null; final String localJvmRoute = _manager.getJvmRoute(); if ( localJvmRoute != null && !localJvmRoute.equals( getSessionIdFormat().extractJvmRoute( requestedSessionId ) ) ) { final String newSessionId = _memcachedNodesManager.changeSessionIdForTomcatFailover(requestedSessionId, _manager.getJvmRoute()); if (_manager.getSessionInternal(newSessionId) != null) { return newSessionId;
return null; final String localJvmRoute = _manager.getJvmRoute(); if ( localJvmRoute != null && !localJvmRoute.equals( getSessionIdFormat().extractJvmRoute( requestedSessionId ) ) ) { 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; }
public void setSticky( final boolean sticky ) { if ( sticky == _sticky ) { return; } if ( !sticky && _manager.getJvmRoute() != null ) { _log.warn( "Setting sticky to false while there's still a jvmRoute configured (" + _manager.getJvmRoute() + "), this might cause trouble." + " You should remve the jvmRoute configuration for non-sticky mode." ); } _sticky = sticky; if ( _manager.isInitialized() ) { _log.info( "Changed sticky to " + _sticky + ". Reloading configuration..." ); reloadMemcachedConfig( _memcachedNodes, _failoverNodes ); _log.info( "Finished reloading configuration." ); } }
private void addValidLoadedSession(final MemcachedBackupSession result) { // When the sessionId will be changed later in changeSessionIdOnTomcatFailover/handleSessionTakeOver // (due to a tomcat failover) we don't want to notify listeners via session.activate for the // old sessionId but do that later (in handleSessionTakeOver) // See also http://code.google.com/p/memcached-session-manager/issues/detail?id=92 String jvmRoute; final boolean sessionIdWillBeChanged = _sticky && ( jvmRoute = _manager.getJvmRoute() ) != null && !jvmRoute.equals( getSessionIdFormat().extractJvmRoute( result.getId() ) ); final boolean activate = !sessionIdWillBeChanged; addValidLoadedSession( result, activate ); }
public void setSticky( final boolean sticky ) { if ( sticky == _sticky ) { return; } if ( !sticky && _manager.getJvmRoute() != null ) { _log.warn( "Setting sticky to false while there's still a jvmRoute configured (" + _manager.getJvmRoute() + "), this might cause trouble." + " You should remve the jvmRoute configuration for non-sticky mode." ); } _sticky = sticky; if ( _manager.isInitialized() ) { _log.info( "Changed sticky to " + _sticky + ". Reloading configuration..." ); reloadMemcachedConfig( _memcachedNodes, _failoverNodes ); _log.info( "Finished reloading configuration." ); } }