@Override protected void invalidateSessions() 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 - it is not invalidated. for (HashedSession session : sessions) { session.save(false); removeSession(session,false); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
@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()); } }
@Override protected void invalidateSessions() 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 - it is not invalidated. for (HashedSession session : sessions) { session.save(false); removeSession(session,false); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
@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()); } }
@Override protected void invalidateSessions() 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 - it is not invalidated. for (HashedSession session : sessions) { session.save(false); removeSession(session,false); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
@Override protected void invalidateSessions() 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 - it is not invalidated. for (HashedSession session : sessions) { session.save(false); removeSession(session,false); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
@Override protected void invalidateSessions() 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 - it is not invalidated. for (HashedSession session : sessions) { session.save(false); removeSession(session,false); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
@Override protected void invalidateSessions() 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 - it is not invalidated. for (HashedSession session : sessions) { session.save(false); removeSession(session,false); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
@Override protected void invalidateSessions() 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 - it is not invalidated. for (HashedSession session : sessions) { session.save(false); removeSession(session,false); } } else { for (HashedSession session : sessions) session.invalidate(); } // check that no new sessions were created while we were iterating sessions=new ArrayList<HashedSession>(_sessions.values()); } }
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(); } } }
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(); } } }
LOG.warn("Problem de-idling session " + super.getId(), e); if (fis != null) IO.close(fis);//Must ensure closed before invalidate invalidate();
LOG.warn("Problem de-idling session " + super.getId(), e); if (fis != null) IO.close(fis);//Must ensure closed before invalidate invalidate();