no.ntnu.item.router.utilities
Class ServiceSessionBankCleaner

java.lang.Object
  extended by java.lang.Thread
      extended by no.ntnu.item.router.utilities.ServiceSessionBankCleaner
All Implemented Interfaces:
java.lang.Runnable

public class ServiceSessionBankCleaner
extends java.lang.Thread

A separate thread that is responsible for removing ServiceSession objects from the ServiceSessionBank if they are idle.

Author:
Kristian Haugene

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  ServiceSessionBank bank
          Holds the ServiceSessionBank
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServiceSessionBankCleaner(ServiceSessionBank serviceSessionBank)
          Constructor, starts the Thread
 
Method Summary
private  java.util.List<java.lang.String> findInactiveSessions()
           
private  boolean haveNoRecentMeasurements(ServiceSession session)
          Checks if the given session have been inactive for long enough to remove it.
private  void removeInactiveSessions(java.util.List<java.lang.String> sessionsToRemove)
           
 void run()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bank

private ServiceSessionBank bank
Holds the ServiceSessionBank

Constructor Detail

ServiceSessionBankCleaner

public ServiceSessionBankCleaner(ServiceSessionBank serviceSessionBank)
Constructor, starts the Thread

Parameters:
serviceSessionBank - the ServiceSessionBank to watch
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

removeInactiveSessions

private void removeInactiveSessions(java.util.List<java.lang.String> sessionsToRemove)

findInactiveSessions

private java.util.List<java.lang.String> findInactiveSessions()

haveNoRecentMeasurements

private boolean haveNoRecentMeasurements(ServiceSession session)
Checks if the given session have been inactive for long enough to remove it.

Parameters:
session -
Returns:
true if inactive, false otherwise