public String getCacheKey (String id) { return _context.getCanonicalContextPath()+"_"+_context.getVhost()+"_"+id; }
_context.run(load);
private String canonicalizeContextPath (Context context) { if (context == null) return ""; return canonicalize (context.getContextPath()); }
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; }
if (_context.getWorkerName().equals(sd.getLastNode())) LOG.debug("Session {} managed by {} is expired", candidate, _context.getWorkerName());
_sessionContext = new SessionContext(_sessionIdManager.getWorkerName(), _context); _sessionCache.initialize(_sessionContext); super.doStart();
LOG.debug ("{}- Pass 1: Searching for sessions for context {} managed by me and expired before {}", _context.getWorkerName(), _context.getCanonicalContextPath(),upperBound); try (PreparedStatement statement = _sessionTableSchema.getExpiredSessionsStatement(connection, _context.getCanonicalContextPath(), _context.getVhost(), upperBound)) long exp = result.getLong(_sessionTableSchema.getExpiryTimeColumn()); expiredSessionKeys.add(sessionId); if (LOG.isDebugEnabled()) LOG.debug (_context.getCanonicalContextPath()+"- Found expired sessionId="+sessionId); 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() );
public String getCacheKey( String id ) { return _context.getCanonicalContextPath() + "_" + _context.getVhost() + "_" + id; } }
return null; data.setLastNode(_context.getWorkerName());//we are going to manage the node session = newSession(data); return session;
_context.run(r); if (exception.get() != null) throw exception.get();
@Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new InfinispanSessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
if (_context.getWorkerName().equals(item.getLastNode()))
_context.run(r);
/** * @see org.eclipse.jetty.server.session.AbstractSessionDataStore#newSessionData(java.lang.String, long, long, long, long) */ @Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new SessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
/** * @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; }
@Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new NoSqlSessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
private String getCanonicalContextId () { return canonicalizeVHost(_context.getVhost()) + ":" + _context.getCanonicalContextPath(); }
/** * @see org.eclipse.jetty.server.session.SessionDataStore#newSessionData(java.lang.String, long, long, long, long) */ @Override public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs) { return new SessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs); }
@Override public void initialize(SessionContext context) throws Exception { super.initialize(context); _contextString = _context.getCanonicalContextPath()+"_"+_context.getVhost(); }