Check a session for being inactive and
thus being able to be evicted, if eviction
is enabled.

@param session session to check
771920
public void checkInactiveSession(Session session) {
        if (session == null) {
            return;
        }
        if (log.isDebugEnabled()) {
            log.debug("Checking for idle " +  session.getId());
        }
        try (Lock ignored = session.lock()) {
            if (getEvictionPolicy() > 0 && session.isIdleLongerThan(getEvictionPolicy()) &&
                    session.isValid() && session.isResident() && session.getRequests() <= 0) {
                // Be careful with saveOnInactiveEviction - you may be able to re-animate a session that was
                // being managed on another node and has expired.
                try {
                    if (log.isDebugEnabled()) {
                        log.debug("Evicting idle session " + session.getId());
                    }

                    // save before evicting
                    if (isSaveOnInactiveEviction() && sessionDataStore != null) {
                        if (sessionDataStore.isPassivating()) {
                            sessionHandler.willPassivate(session);
                        }
                        sessionDataStore.store(session.getId(), session.getSessionData());
                    }

                    doDelete(session.getId()); // detach from this cache
                    session.setResident(false);
                } catch (Exception e) {
                    log.warn("Passivation of idle session" + session.getId() + " failed", e);
                    session.updateInactivityTimer();
                }
            }
        }
    }
805733
protected void onSessionClose(SessionImpl session) {
        Lock lock = lockManager.getLock(getLockingKey(session.keyspace()));
        lock.lock();
        try {
            if (keyspaceCacheMap.containsKey(session.keyspace())) {
                KeyspaceCacheContainer cacheContainer = keyspaceCacheMap.get(session.keyspace());
                cacheContainer.removeSessionReference(session);
                // If there are no more sessions associated to current keyspace,
                // close graph and remove reference from cache.
                if (cacheContainer.referenceCount() == 0) {
                    JanusGraph graph = cacheContainer.graph();
                    graph.close();
                    keyspaceCacheMap.remove(session.keyspace());
                }
            }
        } finally {
            lock.unlock();
        }
    }
934302
private void release(TestSession session, SessionTerminationReason reason) {
    try {
      lock.lock();
      boolean removed = activeTestSessions.remove(session, reason);
      if (removed) {
        fireMatcherStateChanged();
      }
    } finally {
      lock.unlock();
    }
  }
1090967
@Override
	public void deleteSession(String sessionName) {
		logger.debug("deleteSession " + sessionName);
	    if (databaseServer == null) {
	    	return;
	    }
        databaseServer = null;
    }
326348
public void destroySession() {
		if (entryPoint != null) {
			entryPoint.onSessionDestruction(this, session);
		}
		if (accessManager != null) {
			accessManager.destroyCurrentSession();
		}
		session = null;
	}
251976
private void deleteNoCheck(Session session, Row row) {

        if (row.isDeleted(session)) {
            return;
        }

        session.addDeleteAction(this, row);
    }
331360
@Deactivate
    protected void deactivate(int reason) {
        final String methodName = "deactivate";
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(tc, methodName, "Entry Count: " + ++JDBCMBeanRuntime.counterDeactivate);
        if (trace && tc.isEventEnabled())
            Tr.event(tc, className + methodName + ", reason=" + reason);
        if (trace && tc.isEntryEnabled())
            Tr.exit(tc, methodName, "Normal Exit");
    }
235222
public void fireHttpSessionUpdated(final HttpSession session) {
		if (View.isInitialised() && !EventQueue.isDispatchThread()) {
			EventQueue.invokeLater(new Runnable() {

				@Override
				public void run() {
					fireHttpSessionUpdated(session);
				}
			});

			return;
		}

		int index = sessions.indexOf(session);
		fireTableRowsUpdated(index, index);
	}
276247
@Override
    public void removeSession(String id) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            String s = id + appNameForLogging;
            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, "removeSession", s);
        }
        Object removedEntry = _sessions.remove(id);
        if (removedEntry != null) {
            _storeCallback.sessionLiveCountDec(removedEntry);
        }
    }
264636
public static function check()
    {
        if (Session::has(self::ENVIRONMENT_NAME)) {
            return true;
        }

        Session::forget(self::ENVIRONMENT_NAME);
        return false;
    }
959077
void give(NGSession session) {
    synchronized (lock) {
      if (done) {
        // session is already signalled shutdown and removed from all collections
        return;
      }
      workingPool.remove(session);

      if (idlePool.size() < maxIdleSessions) {
        idlePool.add(session);
        return;
      }
    }
    session.shutdown();
  }
1325167
@Override
    public boolean checkSessionStillValid(ISession s, long accessedTime) {
        final String methodName = "checkSessionStillValid";
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[CHECK_SESSION_STILL_VALID]);
        }
        long nowTime = System.currentTimeMillis();
        boolean rc = true;
        synchronized (s) {
            if (s.isValid()) {
                if (s.getMaxInactiveInterval() != -1) {
                    long maxinact = 1000 * (long) s.getMaxInactiveInterval();
                    boolean active = s.getRefCount() > 0;
                    if (_isApplicationSessionStore) {
                        //the RefCount is not correct when dealing with an applicationSessionStore
                        s.setRefCount(0);
                        active = false;
                    }
                    boolean timedOut = (accessedTime <= nowTime - maxinact);
                    /*
                     * invalidate if:
                     * session has timedOut AND (is not active OR (the Invalidation Multiple has not been set to 0
                     * and the session is that many times the invalidation interval)
                     * 
                     * The default value for the invalidation interval is 3.
                     * 
                     * PK03711 removed check for active and always invalidated timedout sessions for v6.1 and earlier
                     * v7 CTS defect 391577 forced us to put this code back, so we introduced the InvalidateIfActive property
                     * In the service stream, the ForceSessionInvalidationMultiple was used, so we are using the same property
                     */
                    if ((timedOut) && ((!active) ||
                            ((_smc.getForceSessionInvalidationMultiple() != 0) &&
                                    (accessedTime <= nowTime - (_smc.getForceSessionInvalidationMultiple() * maxinact))))) {
                        if (maxinact != 0) {
                            _storeCallback.sessionInvalidatedByTimeout(s);
                        }
                        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                            String message = "Going to invalidate session with id=" + s.getId();
                            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[CHECK_SESSION_STILL_VALID], message);
                        }
                        s.invalidate();
                        rc = false;
                    }
                }
            } else { //isValid
                rc = false;
            }
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[CHECK_SESSION_STILL_VALID]);
        }
        return rc;
    }
1007797
public static void cleanupActiveSession() {
        Session session = AbstractHandler.ACTIVE_SESSION.get();
        if (session != null) {
            try {
                AbstractHandler.ACTIVE_SESSION.remove();
                session.logout();
                LOGGER.debug("Logged out REST service session");
            } catch (Exception e) {
                LOGGER.warn(e, "Error while trying to logout REST service session");
            }
        }
    }
1141388
public void sessionIdle(IoSession session, IdleStatus status)
            throws Exception {
        SingleSessionIoHandler handler = (SingleSessionIoHandler) session
                .getAttribute(HANDLER);
        handler.sessionIdle(status);
    }
1051243
public void removeHttpSession(final HttpSession session) {
		if (View.isInitialised() && !EventQueue.isDispatchThread()) {
			EventQueue.invokeLater(new Runnable() {

				@Override
				public void run() {
					removeHttpSession(session);
				}
			});

			return;
		}

		int index = sessions.indexOf(session);
		sessions.remove(index);
		fireTableRowsDeleted(index, index);
	}
1024360
public void fireSessionDestroyed(IoSession session) {
        // Try to remove the remaining empty session set after removal.
        if (managedSessions.remove(session.getId()) == null) {
            return;
        }

        // Fire session events.
        session.getFilterChain().fireSessionClosed();

        // Fire listener events.
        try {
            for (IoServiceListener l : listeners) {
                try {
                    l.sessionDestroyed(session);
                } catch (Throwable e) {
                    ExceptionMonitor.getInstance().exceptionCaught(e);
                }
            }
        } finally {
            // Fire a virtual service deactivation event for the last session of the connector.
            if (session.getService() instanceof IoConnector) {
                boolean lastSession;
                synchronized (managedSessions) {
                    lastSession = managedSessions.isEmpty();
                }
                if (lastSession) {
                    fireServiceDeactivated();
                }
            }
        }
    }
390981
@Override
	public final void onSessionClosed(Session session) {
		this.hsClient.getConnector().removeSession(session);
		HandlerSocketSession hSession = (HandlerSocketSession) session;

		hSession.destroy();
		if (this.hsClient.getConnector().isStarted()
				&& hSession.isAllowReconnect()) {
			this.reconnect(session);
		}
		for (HSClientStateListener listener : this.hsClient
				.getHSClientStateListeners()) {
			listener.onDisconnected(this.hsClient, session
					.getRemoteSocketAddress());
		}
	}