public PreparedStatement getMyExpiredSessionsStatement (Connection connection, SessionContext sessionContext, long expiry) throws SQLException { // TODO expiry should be a delay rather than an absolute time. if (_dbAdaptor == null) throw new IllegalStateException("No DB adaptor"); String cp = sessionContext.getCanonicalContextPath(); if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp)) cp = NULL_CONTEXT_PATH; PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+ " from "+getSchemaTableName()+" where "+ getLastNodeColumn()+" = ? and "+ getContextPathColumn()+" = ? and "+ getVirtualHostColumn()+" = ? and "+ getExpiryTimeColumn()+" >0 and "+getExpiryTimeColumn()+" <= ?"); statement.setString(1, sessionContext.getWorkerName()); statement.setString(2, cp); statement.setString(3, sessionContext.getVhost()); statement.setLong(4, expiry); return statement; }
LOG.debug ("{}- Pass 1: Searching for sessions for context {} managed by me and expired before {}", _context.getWorkerName(), _context.getCanonicalContextPath(),upperBound); upperBound = _lastExpiryCheckTime - (1000L * _gracePeriodSec); if (LOG.isDebugEnabled()) LOG.debug("{}- Pass 2: Searching for sessions expired before {}",_context.getWorkerName(), upperBound); String vh = result.getString(_sessionTableSchema.getVirtualHostColumn()); expiredSessionKeys.add(sessionId); if (LOG.isDebugEnabled()) LOG.debug ("{}- Found expired sessionId=",_context.getWorkerName(), sessionId); LOG.warn("{} Problem checking if potentially expired session {} exists in db", _context.getWorkerName(), k,e);
if (_context.getWorkerName().equals(sd.getLastNode())) LOG.debug("Session {} managed by {} is expired", candidate, _context.getWorkerName());
if (_context.getWorkerName().equals(sd.getLastNode())) LOG.debug( "Session {} managed by {} is expired", candidate, _context.getWorkerName() );
return null; data.setLastNode(_context.getWorkerName());//we are going to manage the node session = newSession(data); return session;
if (_context.getWorkerName().equals(item.getLastNode()))
/** * @see org.eclipse.jetty.server.session.SessionCache#newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long) */ @Override public Session newSession(HttpServletRequest request, String id, long time, long maxInactiveMs) { if (LOG.isDebugEnabled()) LOG.debug("Creating new session id="+id); Session session = newSession(request, _sessionDataStore.newSessionData(id, time, time, time, maxInactiveMs)); session.getSessionData().setLastNode(_context.getWorkerName()); try { if (isSaveOnCreate() && _sessionDataStore != null) _sessionDataStore.store(id, session.getSessionData()); } catch (Exception e) { LOG.warn("Save of new session {} failed", id, e); } return session; }