/**
   * Garbage-collects any expired sessions. Must be called before client-inteface functions do
   * anything which relies on the existence a session, that is: creating sessions, using sessions or
   * checking whether sessions exist.
   *
   * <p>FIXME: Before putting the session manager into fred, write a thread which periodically
   * garbage collects old sessions - currently, sessions will only be garbage collected if any
   * client continues using the SessiomManager
   *
   * @param time The current time.
   */
  private synchronized void removeExpiredSessions(long time) {
    for (Session session = mSessionsByID.peekValue();
        session != null && session.isExpired(time);
        session = mSessionsByID.peekValue()) {
      mSessionsByID.popValue();
      mSessionsByUserID.remove(session.getUserID());
    }

    // FIXME: Execute every few hours only.
    verifyQueueOrder();
    verifySessionsByUserIDTable();
  }
예제 #2
0
    /** Callback from SessionManager during apply() */
    public void visit(Session aSession) {
      try {
        // Age the lease
        aSession.age(delta);
        debug("AgingTimerTask: visit: " + aSession);

        // Stop session if lease expired
        if (aSession.isExpired()) {
          info("AgingTimerTask: Session expired: " + aSession);
          aSession.stop();
        }
      } catch (Throwable t) {
        warn("AgingTimerTask: Error in timer task : " + t);
      }
    }
예제 #3
0
 @Test
 public void testSessionIsExpired() {
   Assert.assertTrue(expiredSession.isExpired());
 }
예제 #4
0
 @Test
 public void testSessionIsNotExpired() {
   Assert.assertFalse(session.isExpired());
 }