Refine search
if (manager.getLogger().isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Handling failover of session ").append(sessionId) .append(" from ").append(requestJvmRoute).append(" to ").append(localJvmRoute); manager.getLogger().debug(builder.toString()); builder.append(this).append(": Caught exception attempting to find session ") .append(sessionId).append(" in ").append(manager); manager.getLogger().warn(builder.toString(), e); builder.append(this).append(": Did not find session ").append(sessionId) .append(" to failover in ").append(manager); manager.getLogger().warn(builder.toString()); } else {
protected void deregisterJmx() { try { if (mbeans.remove(poolName)!=null) { ObjectName oname = getObjectName(getClass(),poolName); ManagementFactory.getPlatformMBeanServer().unregisterMBean(oname); } } catch (MBeanRegistrationException e) { log.debug("Jmx deregistration failed.",e); } catch (InstanceNotFoundException e) { log.debug("Jmx deregistration failed.",e); } catch (MalformedObjectNameException e) { log.warn("Jmx deregistration failed.",e); } catch (RuntimeOperationsException e) { log.warn("Jmx deregistration failed.",e); } }
public void setObjectMaxSize(int objectMaxSize) { if (objectMaxSize * 1024L > Integer.MAX_VALUE) { log.warn(sm.getString("cache.objectMaxSizeTooBigBytes", Integer.valueOf(objectMaxSize))); this.objectMaxSize = Integer.MAX_VALUE; } // Internally bytes, externally kilobytes this.objectMaxSize = objectMaxSize * 1024; }
/** * Find the master of the session state * @return master member of sessions */ protected Member findSessionMasterMember() { Member mbr = null; Member mbrs[] = cluster.getMembers(); if(mbrs.length != 0 ) mbr = mbrs[0]; if(mbr == null && log.isWarnEnabled()) { log.warn(sm.getString("deltaManager.noMasterMember",getName(), "")); } if(mbr != null && log.isDebugEnabled()) { log.debug(sm.getString("deltaManager.foundMasterMember",getName(), mbr)); } return mbr; }
/** * @return list of the allowed cipher suites when connections are made using * StartTLS */ private String[] getCipherSuitesArray() { if (cipherSuites == null || cipherSuitesArray != null) { return cipherSuitesArray; } if (this.cipherSuites.trim().isEmpty()) { containerLog.warn(sm.getString("jndiRealm.emptyCipherSuites")); this.cipherSuitesArray = null; } else { this.cipherSuitesArray = cipherSuites.trim().split("\\s*,\\s*"); containerLog.debug(sm.getString("jndiRealm.cipherSuites", Arrays.toString(this.cipherSuitesArray))); } return this.cipherSuitesArray; }
/** * Find the master of the session state * @return master member of sessions */ protected Member findSessionMasterMember() { Member mbr = null; Member mbrs[] = cluster.getMembers(); if(mbrs.length != 0 ) mbr = mbrs[0]; if(mbr == null && log.isWarnEnabled()) log.warn(sm.getString("deltaManager.noMasterMember",getName(), "")); if(mbr != null && log.isDebugEnabled()) log.warn(sm.getString("deltaManager.foundMasterMember",getName(), mbr)); return mbr; }
@Override public Principal getPrincipal() { if (this.principal == null && this.serializedPrincipal != null) { SerializablePrincipal sp = null; try { sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal); } catch (Exception e) { StringBuilder builder = new StringBuilder(); builder.append(this).append( ": Serialized principal contains a byte[] that cannot be deserialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); return null; } this.principal = sp.getPrincipal(((DeltaSessionManager) this.manager).getTheContext().getRealm()); if (getManager() != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Deserialized principal: " + this.principal); // mgr.logCurrentStack(); } } } return this.principal; }
private boolean pingSessionBackup( @Nonnull final String sessionId ) throws InterruptedException { final String key = _sessionIdFormat.createBackupKey( sessionId ); final Future<Boolean> touchResultFuture = _storage.add( key, 1, BYTE_1 ); try { final boolean touchResult = touchResultFuture.get(200, TimeUnit.MILLISECONDS); if ( touchResult ) { _log.warn( "The secondary backup for session " + sessionId + " should be touched in memcached, but it seemed to be" + " not existing." ); return false; } _log.debug( "The secondary session backup was ping'ed successfully." ); return true; } catch ( final TimeoutException e ) { _log.warn( "The secondary backup for session " + sessionId + " could not be completed within 200 millis, was cancelled now." ); return false; } catch ( final ExecutionException e ) { _log.warn( "An exception occurred when trying to ping session " + sessionId, e ); return false; } } }
/** * Find the master of the session state * @return master member of sessions */ protected Member findSessionMasterMember() { Member mbr = null; Member mbrs[] = cluster.getMembers(); if(mbrs.length != 0 ) mbr = mbrs[0]; if(mbr == null && log.isWarnEnabled()) { log.warn(sm.getString("deltaManager.noMasterMember",getName(), "")); } if(mbr != null && log.isDebugEnabled()) { log.debug(sm.getString("deltaManager.foundMasterMember",getName(), mbr)); } return mbr; }
protected void releaseLock( @Nonnull final String sessionId ) { try { if ( _log.isDebugEnabled() ) { _log.debug( "Releasing lock for session " + sessionId ); } final long start = System.currentTimeMillis(); _storage.delete( _sessionIdFormat.createLockName( sessionId ) ).get(); _stats.registerSince( RELEASE_LOCK, start ); } catch ( final Exception e ) { _log.warn( "Caught exception when trying to release lock for session " + sessionId, e ); } }
private boolean pingSession( @Nonnull final String sessionId ) throws InterruptedException { final Future<Boolean> touchResult = _storage.add( _storageKeyFormat.format(sessionId), 1, BYTE_1 ); try { if ( touchResult.get() ) { _stats.nonStickySessionsPingFailed(); _log.warn( "The session " + sessionId + " should be touched in memcached, but it does not exist therein." ); return false; } _log.debug( "The session was ping'ed successfully." ); return true; } catch ( final ExecutionException e ) { _log.warn( "An exception occurred when trying to ping session " + sessionId, e ); return false; } }
/** * Return the deserialized map * * @param in bytes to deserialize * @return map of deserialized objects */ @Override public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in) { final InputStreamReader inputStream = new InputStreamReader( new ByteArrayInputStream( in ) ); if (LOG.isDebugEnabled()) { LOG.debug("deserialize the stream"); } try { return deserializer.deserializeInto(inputStream, new ConcurrentHashMap<String, Object>()); } catch( final RuntimeException e) { LOG.warn("Caught Exception deserializing JSON "+e); throw new TranscoderDeserializationException(e); } }
public void performJNDILookup(Context context, PoolConfiguration poolProperties) { Object jndiDS = null; try { if (context!=null) { jndiDS = context.lookup(poolProperties.getDataSourceJNDI()); } else { log.warn("dataSourceJNDI property is configued, but local JNDI context is null."); } } catch (NamingException e) { log.debug("The name \""+poolProperties.getDataSourceJNDI()+"\" can not be found in the local context."); } if (jndiDS==null) { try { context = new InitialContext(); jndiDS = context.lookup(poolProperties.getDataSourceJNDI()); } catch (NamingException e) { log.warn("The name \""+poolProperties.getDataSourceJNDI()+"\" can not be found in the InitialContext."); } } if (jndiDS!=null) { poolProperties.setDataSource(jndiDS); } }
@Override public byte[] serializeAttributes(final MemcachedBackupSession sessions, final ConcurrentMap<String, Object> attributes) { if (attributes == null) { throw new NullPointerException(); } final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { // This performs a deep serialization of the target instance. // It's serialized to a string as flexjson doesn't like writing to // an OutputStreamWriter: it throws the exception "Stepping back two steps is not supported". // See https://github.com/moresandeep/memcached-session-manager/commit/db2faaa0a846e16d65ac0b14819689c67bf92c68#commitcomment-512505 final String serResult = serializer.deepSerialize(attributes); if (LOG.isDebugEnabled()) { LOG.debug("JSON Serialised object: " + serResult); } return serResult.getBytes(); // converts to bytes } catch (final Exception e) { LOG.warn("Caught Exception deserializing JSON " + e); throw new IllegalArgumentException(); } finally { close(bos); } }
public void setObjectMaxSize(int objectMaxSize) { if (objectMaxSize * 1024L > Integer.MAX_VALUE) { log.warn(sm.getString("cache.objectMaxSizeTooBigBytes", Integer.valueOf(objectMaxSize))); this.objectMaxSize = Integer.MAX_VALUE; } // Internally bytes, externally kilobytes this.objectMaxSize = objectMaxSize * 1024; }
private void pingSession( @Nonnull final MemcachedBackupSession session, @Nonnull final BackupSessionService backupSessionService ) throws InterruptedException { final Future<Boolean> touchResult = _storage.add( _storageKeyFormat.format(session.getIdInternal()), 5, BYTE_1 ); try { if ( touchResult.get() ) { _stats.nonStickySessionsPingFailed(); _log.warn( "The session " + session.getIdInternal() + " should be touched in memcached, but it does not exist" + " therein. Will store in memcached again." ); updateSession( session, backupSessionService ); } else _log.debug( "The session was ping'ed successfully." ); } catch ( final ExecutionException e ) { _log.warn( "An exception occurred when trying to ping session " + session.getIdInternal(), e ); } }
protected LockStatus lock( final String sessionId, final long timeout, final TimeUnit timeUnit ) { if ( _log.isDebugEnabled() ) { _log.debug( "Locking session " + sessionId ); } final long start = System.currentTimeMillis(); try { acquireLock( sessionId, LOCK_RETRY_INTERVAL, LOCK_MAX_RETRY_INTERVAL, timeUnit.toMillis( timeout ), System.currentTimeMillis() ); _stats.registerSince( ACQUIRE_LOCK, start ); if ( _log.isDebugEnabled() ) { _log.debug( "Locked session " + sessionId ); } return LockStatus.LOCKED; } catch ( final TimeoutException e ) { _log.warn( "Reached timeout when trying to aquire lock for session " + sessionId + ". Will use this session without this lock." ); _stats.registerSince( ACQUIRE_LOCK_FAILURE, start ); return LockStatus.COULD_NOT_AQUIRE_LOCK; } catch ( final InterruptedException e ) { Thread.currentThread().interrupt(); throw new RuntimeException( "Got interrupted while trying to lock session.", e ); } catch ( final ExecutionException e ) { _log.warn( "An exception occurred when trying to aquire lock for session " + sessionId ); _stats.registerSince( ACQUIRE_LOCK_FAILURE, start ); return LockStatus.COULD_NOT_AQUIRE_LOCK; } }