/** * Store the provided session in memcached if the session was modified * or if the session needs to be relocated. * * @param session * the session to save * @param sessionRelocationRequired * specifies, if the session id was changed due to a memcached failover or tomcat failover. * @return the {@link BackupResultStatus} */ public Future<BackupResult> backupSession( final String sessionId, final boolean sessionIdChanged, final String requestId ) { final MemcachedBackupSession session = _manager.getSessionInternal( sessionId ); if ( session == null ) { if(_log.isDebugEnabled()) _log.debug( "No session found in session map for " + sessionId ); return new SimpleFuture<BackupResult>( BackupResult.SKIPPED ); } _log.info( "Serializing session data for session " + session.getIdInternal() ); final long startSerialization = System.currentTimeMillis(); final byte[] data = _transcoderService.serializeAttributes( (MemcachedBackupSession) session, ((MemcachedBackupSession) session).getAttributesFiltered() ); _log.info( String.format( "Serializing %1$,.3f kb session data for session %2$s took %3$d ms.", (double)data.length / 1000, session.getIdInternal(), System.currentTimeMillis() - startSerialization ) ); _sessionData.put( session.getIdInternal(), data ); _statistics.registerSince( ATTRIBUTES_SERIALIZATION, startSerialization ); _statistics.register( CACHED_DATA_SIZE, data.length ); return new SimpleFuture<BackupResult>( new BackupResult( BackupResultStatus.SUCCESS ) ); }
result = new BackupResult( BackupResultStatus.SKIPPED );
/** * Store the provided session in memcached if the session was modified * or if the session needs to be relocated. * * @param session * the session to save * @param sessionRelocationRequired * specifies, if the session id was changed due to a memcached failover or tomcat failover. * @return the {@link BackupResultStatus} */ public Future<BackupResult> backupSession( final String sessionId, final boolean sessionIdChanged, final String requestId ) { final MemcachedBackupSession session = _manager.getSessionInternal( sessionId ); if ( session == null ) { if(_log.isDebugEnabled()) _log.debug( "No session found in session map for " + sessionId ); return new SimpleFuture<BackupResult>( BackupResult.SKIPPED ); } _log.info( "Serializing session data for session " + session.getIdInternal() ); final long startSerialization = System.currentTimeMillis(); final byte[] data = _transcoderService.serializeAttributes( (MemcachedBackupSession) session, ((MemcachedBackupSession) session).getAttributesFiltered() ); _log.info( String.format( "Serializing %1$,.3f kb session data for session %2$s took %3$d ms.", (double)data.length / 1000, session.getIdInternal(), System.currentTimeMillis() - startSerialization ) ); _sessionData.put( session.getIdInternal(), data ); _statistics.registerSince( ATTRIBUTES_SERIALIZATION, startSerialization ); _statistics.register( CACHED_DATA_SIZE, data.length ); return new SimpleFuture<BackupResult>( new BackupResult( BackupResultStatus.SUCCESS ) ); }
result = new BackupResult( BackupResultStatus.SKIPPED );
/** * Store the provided session in memcached. * @param session the session to backup * @param data the serialized session data (session fields and session attributes). * @param attributesData just the serialized session attributes. * * @return the {@link BackupResultStatus} */ BackupResult doBackupSession( final MemcachedBackupSession session, final byte[] data, final byte[] attributesData ) throws InterruptedException { if ( _log.isDebugEnabled() ) { _log.debug( "Trying to store session in memcached: " + session.getId() ); } try { storeSessionInMemcached( session, data ); return new BackupResult( BackupResultStatus.SUCCESS, data, attributesData ); } catch (final ExecutionException e) { handleException(session, e); return new BackupResult(BackupResultStatus.FAILURE, data, null); } catch (final TimeoutException e) { handleException(session, e); return new BackupResult(BackupResultStatus.FAILURE, data, null); } }
/** * Store the provided session in memcached. * @param session the session to backup * @param data the serialized session data (session fields and session attributes). * @param attributesData just the serialized session attributes. * * @return the {@link BackupResultStatus} */ BackupResult doBackupSession( final MemcachedBackupSession session, final byte[] data, final byte[] attributesData ) throws InterruptedException { if ( _log.isDebugEnabled() ) { _log.debug( "Trying to store session in memcached: " + session.getId() ); } try { storeSessionInMemcached( session, data ); return new BackupResult( BackupResultStatus.SUCCESS, data, attributesData ); } catch (final ExecutionException e) { handleException(session, e); return new BackupResult(BackupResultStatus.FAILURE, data, null); } catch (final TimeoutException e) { handleException(session, e); return new BackupResult(BackupResultStatus.FAILURE, data, null); } }