/** * Specifies if the session shall be stored asynchronously in memcached as * {@link StorageClient#set(String, int, byte[])} supports it. If this is * false, the timeout set via {@link #setSessionBackupTimeout(int)} is * evaluated. If this is <code>true</code>, the {@link #setBackupThreadCount(int)} * is evaluated. * <p> * By default this property is set to <code>true</code> - the session * backup is performed asynchronously. * </p> * * @param sessionBackupAsync * the sessionBackupAsync to set */ public void setSessionBackupAsync( final boolean sessionBackupAsync ) { _msm.setSessionBackupAsync( sessionBackupAsync ); }
/** * Specifies if the session shall be stored asynchronously in memcached as * {@link StorageClient#set(String, int, byte[])} supports it. If this is * false, the timeout set via {@link #setSessionBackupTimeout(int)} is * evaluated. If this is <code>true</code>, the {@link #setBackupThreadCount(int)} * is evaluated. * <p> * By default this property is set to <code>true</code> - the session * backup is performed asynchronously. * </p> * * @param sessionBackupAsync * the sessionBackupAsync to set */ public void setSessionBackupAsync( final boolean sessionBackupAsync ) { _msm.setSessionBackupAsync( sessionBackupAsync ); }
/** * Specifies if the session shall be stored asynchronously in memcached as * {@link StorageClient#set(String, int, byte[])} supports it. If this is * false, the timeout set via {@link #setSessionBackupTimeout(int)} is * evaluated. If this is <code>true</code>, the {@link #setBackupThreadCount(int)} * is evaluated. * <p> * By default this property is set to <code>true</code> - the session * backup is performed asynchronously. * </p> * * @param sessionBackupAsync * the sessionBackupAsync to set */ public void setSessionBackupAsync( final boolean sessionBackupAsync ) { _msm.setSessionBackupAsync( sessionBackupAsync ); }
/** * Specifies if the session shall be stored asynchronously in memcached as * {@link StorageClient#set(String, int, byte[])} supports it. If this is * false, the timeout set via {@link #setSessionBackupTimeout(int)} is * evaluated. If this is <code>true</code>, the {@link #setBackupThreadCount(int)} * is evaluated. * <p> * By default this property is set to <code>true</code> - the session * backup is performed asynchronously. * </p> * * @param sessionBackupAsync * the sessionBackupAsync to set */ public void setSessionBackupAsync( final boolean sessionBackupAsync ) { _msm.setSessionBackupAsync( sessionBackupAsync ); }
/** * Test for issue #105: Make memcached node optional for single-node setup * http://code.google.com/p/memcached-session-manager/issues/detail?id=105 */ @Test public void testBackupSessionFailureWithoutMemcachedNodeIdConfigured105() throws Exception { _service.setMemcachedNodes( "127.0.0.1:11211" ); _service.setSessionBackupAsync(false); _service.startInternal(new MemcachedStorageClient(_memcachedMock)); final MemcachedBackupSession session = createSession( _service ); session.access(); session.endAccess(); session.setAttribute( "foo", "bar" ); @SuppressWarnings( "unchecked" ) final OperationFuture<Boolean> futureMock = mock( OperationFuture.class ); when( futureMock.get( ) ).thenThrow(new ExecutionException(new RuntimeException("Simulated exception."))); when( futureMock.get( anyInt(), any( TimeUnit.class ) ) ).thenThrow(new ExecutionException(new RuntimeException("Simulated exception."))); when( _memcachedMock.set( eq( session.getId() ), anyInt(), any(), any( Transcoder.class ) ) ).thenReturn( futureMock ); final BackupResult backupResult = _service.backupSession( session.getIdInternal(), false, null ).get(); assertEquals(backupResult.getStatus(), BackupResultStatus.FAILURE); verify( _memcachedMock, times( 1 ) ).set( eq( session.getId() ), anyInt(), any(), any( Transcoder.class ) ); }
@SuppressWarnings("unchecked") @BeforeMethod public void setup() throws Exception { final StandardContext context = createContext(); context.setBackgroundProcessorDelay( 1 ); // needed for test of updateExpiration final SessionManager manager = createSessionManager(context); _service = manager.getMemcachedSessionService(); _service.setMemcachedNodes( "n1:127.0.0.1:11211" ); _service.setSessionBackupAsync( false ); _service.setSticky( true ); _memcachedMock = mock( MemcachedClient.class ); final OperationFuture<Boolean> setResultMock = mock( OperationFuture.class ); when( setResultMock.get( ) ).thenReturn( Boolean.TRUE ); when( setResultMock.get( anyInt(), any( TimeUnit.class ) ) ).thenReturn( Boolean.TRUE ); when( _memcachedMock.set( any( String.class ), anyInt(), any(), any( Transcoder.class ) ) ).thenReturn( setResultMock ); final OperationFuture<Boolean> deleteResultMock = mock( OperationFuture.class ); when( deleteResultMock.get() ).thenReturn( Boolean.TRUE ); when( _memcachedMock.delete( anyString() ) ).thenReturn( deleteResultMock ); startInternal( manager, _memcachedMock ); _executor = Executors.newCachedThreadPool(); }
/** * Specifies if the session shall be stored asynchronously in memcached as * {@link StorageClient#set(String, int, byte[])} supports it. If this is * false, the timeout set via {@link #setSessionBackupTimeout(int)} is * evaluated. If this is <code>true</code>, the {@link #setBackupThreadCount(int)} * is evaluated. * <p> * By default this property is set to <code>true</code> - the session * backup is performed asynchronously. * </p> * * @param sessionBackupAsync * the sessionBackupAsync to set */ public void setSessionBackupAsync( final boolean sessionBackupAsync ) { _msm.setSessionBackupAsync( sessionBackupAsync ); }
manager.setMaxInactiveInterval( 5 ); manager.setMemcachedNodes(memcachedNodes); manager.getMemcachedSessionService().setSessionBackupAsync(false);
manager.setMaxInactiveInterval( 5 ); manager.setMemcachedNodes(memcachedNodes); manager.getMemcachedSessionService().setSessionBackupAsync(false);