/** * Sets the session locking mode. Possible values: * <ul> * <li><code>none</code> - does not lock the session at all (default for non-sticky sessions).</li> * <li><code>all</code> - the session is locked for each request accessing the session.</li> * <li><code>auto</code> - locks the session for each request except for those the were detected to access the session only readonly.</li> * <li><code>uriPattern:<regexp></code> - locks the session for each request with a request uri (with appended querystring) matching * the provided regular expression.</li> * </ul> */ @Override public void setLockingMode( @Nullable final String lockingMode ) { _msm.setLockingMode( lockingMode ); }
/** * Sets the session locking mode. Possible values: * <ul> * <li><code>none</code> - does not lock the session at all (default for non-sticky sessions).</li> * <li><code>all</code> - the session is locked for each request accessing the session.</li> * <li><code>auto</code> - locks the session for each request except for those the were detected to access the session only readonly.</li> * <li><code>uriPattern:<regexp></code> - locks the session for each request with a request uri (with appended querystring) matching * the provided regular expression.</li> * </ul> */ @Override public void setLockingMode( @Nullable final String lockingMode ) { _msm.setLockingMode( lockingMode ); }
/** * Sets the session locking mode. Possible values: * <ul> * <li><code>none</code> - does not lock the session at all (default for non-sticky sessions).</li> * <li><code>all</code> - the session is locked for each request accessing the session.</li> * <li><code>auto</code> - locks the session for each request except for those the were detected to access the session only readonly.</li> * <li><code>uriPattern:<regexp></code> - locks the session for each request with a request uri (with appended querystring) matching * the provided regular expression.</li> * </ul> */ @Override public void setLockingMode( @Nullable final String lockingMode ) { _msm.setLockingMode( lockingMode ); }
/** * Sets the session locking mode. Possible values: * <ul> * <li><code>none</code> - does not lock the session at all (default for non-sticky sessions).</li> * <li><code>all</code> - the session is locked for each request accessing the session.</li> * <li><code>auto</code> - locks the session for each request except for those the were detected to access the session only readonly.</li> * <li><code>uriPattern:<regexp></code> - locks the session for each request with a request uri (with appended querystring) matching * the provided regular expression.</li> * </ul> */ @Override public void setLockingMode( @Nullable final String lockingMode ) { _msm.setLockingMode( lockingMode ); }
@Override public void setLockingMode( @Nullable final LockingMode lockingMode, @Nullable final Pattern uriPattern, final boolean storeSecondaryBackup ) { _msm.setLockingMode(lockingMode, uriPattern, storeSecondaryBackup); }
@Override public void setLockingMode( @Nullable final LockingMode lockingMode, @Nullable final Pattern uriPattern, final boolean storeSecondaryBackup ) { _msm.setLockingMode( lockingMode, uriPattern, storeSecondaryBackup ); }
@Override public void setLockingMode( @Nullable final LockingMode lockingMode, @Nullable final Pattern uriPattern, final boolean storeSecondaryBackup ) { _msm.setLockingMode(lockingMode, uriPattern, storeSecondaryBackup); }
@Override public void setLockingMode( @Nullable final LockingMode lockingMode, @Nullable final Pattern uriPattern, final boolean storeSecondaryBackup ) { _msm.setLockingMode( lockingMode, uriPattern, storeSecondaryBackup ); }
private void initNonStickyLockingMode( @Nonnull final MemcachedNodesManager config ) { if ( _sticky ) { setLockingMode( null, null, false ); return; } if ( _sessionAttributeFilter != null ) { _log.warn( "There's a sessionAttributesFilter configured ('" + _sessionAttributeFilter + "')," + " all other session attributes will be lost after the request due to non-sticky configuration!" ); } Pattern uriPattern = null; LockingMode lockingMode = null; if ( _lockingMode != null ) { if ( _lockingMode.startsWith( "uriPattern:" ) ) { lockingMode = LockingMode.URI_PATTERN; uriPattern = Pattern.compile( _lockingMode.substring( "uriPattern:".length() ) ); } else { lockingMode = LockingMode.valueOf( _lockingMode.toUpperCase() ); } } if ( lockingMode == null ) { lockingMode = LockingMode.NONE; } final boolean storeSecondaryBackup = config.getCountNodes() > 1 && !config.isCouchbaseBucketConfig(); setLockingMode( lockingMode, uriPattern, storeSecondaryBackup ); }
@Test public void testInvalidNonStickySessionDoesNotCallOnBackupWithoutLoadedSessionIssue137() throws Exception { _service.setStickyInternal( false ); _service.setLockingMode( LockingMode.NONE, null, false ); _service.startInternal(new MemcachedStorageClient(_memcachedMock)); // we must put in our mock again final String sessionId = "nonStickySessionToTimeOut-n1"; // For findSession needed final Request requestMock = mock(Request.class); when(requestMock.getNote(eq(RequestTrackingContextValve.INVOKED))).thenReturn(Boolean.TRUE); _service.getTrackingHostValve().storeRequestThreadLocal(requestMock); final MemcachedBackupSession session = _service.findSession(sessionId); assertNull(session); _service.backupSession( sessionId, false, null ).get(); // check that validity info is not loaded - this would trigger the // WARNING: Found no validity info for session id ... final String validityKey = new SessionIdFormat().createValidityInfoKeyName( sessionId ); verify( _memcachedMock, times( 0 ) ).get( eq( validityKey ) ); }
_service.setLockingMode( LockingMode.NONE, null, false ); _service.setMemcachedNodes( "n1:127.0.0.1:11211 n2:127.0.0.1:11212" ); // for backup support _service.startInternal(new MemcachedStorageClient(_memcachedMock)); // we must put in our mock again
_service.setLockingMode( LockingMode.NONE, null, false );
_service.setLockingMode( LockingMode.NONE, null, false ); _service.setMemcachedNodes( "n1:127.0.0.1:11211 n2:127.0.0.1:11212" ); // for backup support _service.startInternal(new MemcachedStorageClient(_memcachedMock)); // we must put in our mock again
@Test public void testSessionsRefCountHandlingIssue111() throws Exception { _service.setSticky(false); _service.setLockingMode(LockingMode.ALL.name());
/** * Sets the session locking mode. Possible values: * <ul> * <li><code>none</code> - does not lock the session at all (default for non-sticky sessions).</li> * <li><code>all</code> - the session is locked for each request accessing the session.</li> * <li><code>auto</code> - locks the session for each request except for those the were detected to access the session only readonly.</li> * <li><code>uriPattern:<regexp></code> - locks the session for each request with a request uri (with appended querystring) matching * the provided regular expression.</li> * </ul> */ @Override public void setLockingMode( @Nullable final String lockingMode ) { _msm.setLockingMode( lockingMode ); }
@Override public void setLockingMode( @Nullable final LockingMode lockingMode, @Nullable final Pattern uriPattern, final boolean storeSecondaryBackup ) { _msm.setLockingMode(lockingMode, uriPattern, storeSecondaryBackup); }
private void initNonStickyLockingMode( @Nonnull final MemcachedNodesManager config ) { if ( _sticky ) { setLockingMode( null, null, false ); return; } if ( _sessionAttributeFilter != null ) { _log.warn( "There's a sessionAttributesFilter configured ('" + _sessionAttributeFilter + "')," + " all other session attributes will be lost after the request due to non-sticky configuration!" ); } Pattern uriPattern = null; LockingMode lockingMode = null; if ( _lockingMode != null ) { if ( _lockingMode.startsWith( "uriPattern:" ) ) { lockingMode = LockingMode.URI_PATTERN; uriPattern = Pattern.compile( _lockingMode.substring( "uriPattern:".length() ) ); } else { lockingMode = LockingMode.valueOf( _lockingMode.toUpperCase() ); } } if ( lockingMode == null ) { lockingMode = LockingMode.NONE; } final boolean storeSecondaryBackup = config.getCountNodes() > 1 && !config.isCouchbaseBucketConfig(); setLockingMode( lockingMode, uriPattern, storeSecondaryBackup ); }