@Override protected AbstractSession newSession(HttpServletRequest request) { return new HashedSession(this, request); }
protected void checkValid() { if (_hashSessionManager._idleSavePeriodMs!=0) deIdle(); super.checkValid(); }
public synchronized void save(OutputStream os) throws IOException { DataOutputStream out = new DataOutputStream(os); out.writeUTF(getClusterId()); out.writeUTF(getNodeId()); out.writeLong(getCreationTime()); out.writeLong(getAccessed()); /* Don't write these out, as they don't make sense to store because they * either they cannot be true or their value will be restored in the * Session constructor. */ //out.writeBoolean(_invalid); //out.writeBoolean(_doInvalidate); //out.writeBoolean( _newSession); out.writeInt(getRequests()); out.writeInt(getAttributes()); ObjectOutputStream oos = new ObjectOutputStream(out); Enumeration<String> e=getAttributeNames(); while(e.hasMoreElements()) { String key=e.nextElement(); oos.writeUTF(key); oos.writeObject(doGet(key)); } out.writeInt(getMaxInactiveInterval()); }
synchronized void save(boolean reactivate) throws Exception { // Only idle the session if not already idled and no previous save/idle has failed if (!isIdled() && !_saveFailed) { if (LOG.isDebugEnabled()) LOG.debug("Saving {} {}",super.getId(),reactivate); try { willPassivate(); save(); if (reactivate) didActivate(); else clearAttributes(); } catch (Exception e) { LOG.warn("Problem saving session " + super.getId(), e); _idled=false; // assume problem was before _values.clear(); } } }
long idleTime=session.getMaxInactiveInterval()*1000L; if (idleTime>0&&session.getAccessed()+idleTime<now) session.timeout(); else if (_idleSavePeriodMs > 0 && session.getAccessed()+_idleSavePeriodMs < now) session.idle(); __log.warn("Problem idling session "+ session.getId(), e);
public synchronized void deIdle() if (isIdled()) access(System.currentTimeMillis()); _hashSessionManager.restoreSession(fis, this); didActivate(); invalidate();
@Override protected void shutdownSessions() throws Exception { // Invalidate all sessions to cause unbind events ArrayList<HashedSession> sessions=new ArrayList<HashedSession>(_sessions.values()); int loop=100; while (sessions.size()>0 && loop-->0) { // If we are called from doStop if (isStopping() && _storeDir != null && _storeDir.exists() && _storeDir.canWrite()) { // Then we only save and remove the session from memory- it is not invalidated. for (HashedSession session : sessions) { session.save(false); _sessions.remove(session.getClusterId()); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
HashedSession session = restoreSession(in, null); addSession(session, false); session.didActivate(); return session;
synchronized void save(boolean reactivate) throws Exception { // Only idle the session if not already idled and no previous save/idle has failed if (!isIdled() && !_saveFailed) { if (LOG.isDebugEnabled()) LOG.debug("Saving {} {}",super.getId(),reactivate); try { willPassivate(); save(); if (reactivate) didActivate(); else clearAttributes(); } catch (Exception e) { LOG.warn("Problem saving session " + super.getId(), e); _idled=false; // assume problem was before _values.clear(); } } }
long idleTime=session.getMaxInactiveInterval()*1000L; if (idleTime>0&&session.getAccessed()+idleTime<now) session.timeout(); else if (_idleSavePeriodMs > 0 && session.getAccessed()+_idleSavePeriodMs < now) session.idle(); __log.warn("Problem idling session "+ session.getId(), e);
public synchronized void deIdle() { if (isIdled()) { // Access now to prevent race with idling period access(System.currentTimeMillis()); if (LOG.isDebugEnabled()) LOG.debug("De-idling " + super.getId()); FileInputStream fis = null; try { File file = new File(_hashSessionManager._storeDir, super.getId()); if (!file.exists() || !file.canRead()) throw new FileNotFoundException(file.getName()); fis = new FileInputStream(file); _idled = false; _hashSessionManager.restoreSession(fis, this); didActivate(); // If we are doing period saves, then there is no point deleting at this point if (_hashSessionManager._savePeriodMs == 0) file.delete(); } catch (Exception e) { LOG.warn("Problem de-idling session " + super.getId(), e); IO.close(fis); invalidate(); } } }
@Override protected void shutdownSessions() throws Exception { // Invalidate all sessions to cause unbind events ArrayList<HashedSession> sessions=new ArrayList<HashedSession>(_sessions.values()); int loop=100; while (sessions.size()>0 && loop-->0) { // If we are called from doStop if (isStopping() && _storeDir != null && _storeDir.exists() && _storeDir.canWrite()) { // Then we only save and remove the session from memory- it is not invalidated. for (HashedSession session : sessions) { session.save(false); _sessions.remove(session.getClusterId()); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
HashedSession session = restoreSession(in, null); addSession(session, false); session.didActivate(); return session;
public synchronized void save(OutputStream os) throws IOException { DataOutputStream out = new DataOutputStream(os); out.writeUTF(getClusterId()); out.writeUTF(getNodeId()); out.writeLong(getCreationTime()); out.writeLong(getAccessed()); /* Don't write these out, as they don't make sense to store because they * either they cannot be true or their value will be restored in the * Session constructor. */ //out.writeBoolean(_invalid); //out.writeBoolean(_doInvalidate); //out.writeLong(_maxIdleMs); //out.writeBoolean( _newSession); out.writeInt(getRequests()); out.writeInt(getAttributes()); ObjectOutputStream oos = new ObjectOutputStream(out); Enumeration<String> e=getAttributeNames(); while(e.hasMoreElements()) { String key=e.nextElement(); oos.writeUTF(key); oos.writeObject(doGet(key)); } oos.close(); }
synchronized void save(boolean reactivate) throws Exception { // Only idle the session if not already idled and no previous save/idle has failed if (!isIdled() && !_saveFailed) { if (LOG.isDebugEnabled()) LOG.debug("Saving {} {}",super.getId(),reactivate); try { willPassivate(); save(); if (reactivate) didActivate(); else clearAttributes(); } catch (Exception e) { LOG.warn("Problem saving session " + super.getId(), e); _idled=false; // assume problem was before _values.clear(); } } }
long idleTime=session.getMaxInactiveInterval()*1000L; if (idleTime>0&&session.getAccessed()+idleTime<now) session.timeout(); else if (_idleSavePeriodMs > 0 && session.getAccessed()+_idleSavePeriodMs < now) session.idle(); __log.warn("Problem idling session "+ session.getId(), e);
public synchronized void deIdle() if (isIdled() && !_deIdleFailed) access(System.currentTimeMillis()); IO.close(fis); didActivate(); deIdleFailed(); LOG.warn("Problem de-idling session " + super.getId(), e); if (fis != null) IO.close(fis);//Must ensure closed before invalidate invalidate();
@Override protected AbstractSession newSession(HttpServletRequest request) { return new HashedSession(this, request); }
protected void checkValid() { if (!_deIdleFailed && _hashSessionManager._idleSavePeriodMs!=0) deIdle(); super.checkValid(); }
HashedSession session = restoreSession(in, null); addSession(session, false); session.didActivate(); return session;