Esempio n. 1
0
  /** Timeout for reaping old sessions. */
  public void handleAlarm(Alarm alarm) {
    try {
      _sessionList.clear();

      int liveSessions = 0;

      if (_isClosed) return;

      long now = Alarm.getCurrentTime();

      synchronized (_sessions) {
        _sessionIter = _sessions.values(_sessionIter);

        while (_sessionIter.hasNext()) {
          SessionArrayValue session = _sessionIter.next();

          long maxIdleTime = session.getMaxInactiveInterval();

          if (session.inUse()) liveSessions++;
          else if (session.getAccessTime() + maxIdleTime < now) _sessionList.add(session);
          else liveSessions++;
        }
      }

      synchronized (_statisticsLock) {
        _sessionTimeoutCount += _sessionList.size();
      }

      for (int i = 0; i < _sessionList.size(); i++) {
        SessionArrayValue session = _sessionList.get(i);

        try {
          long maxIdleTime = session.getMaxInactiveInterval();
          _sessions.remove(session.getId());

          session.invalidate();
        } catch (Throwable e) {
          log.log(Level.FINER, e.toString(), e);
        }
      }
    } finally {
      if (!_isClosed) alarm.queue(60000);
    }
  }
Esempio n. 2
0
  /** Notification from the cluster. */
  public void notifyRemove(String id) {
    SessionArrayValue session = _sessions.remove(id);

    if (session != null) session.invalidate();
  }