Class IoServiceListenerSupport


  • public class IoServiceListenerSupport
    extends java.lang.Object
    A helper class which provides addition and removal of IoServiceListeners and firing events.
    • Field Detail

      • managedSessions

        private final java.util.concurrent.ConcurrentMap<java.lang.Long,​IoSession> managedSessions
        Tracks managed sessions.
      • readOnlyManagedSessions

        private final java.util.Map<java.lang.Long,​IoSession> readOnlyManagedSessions
        Read only version of managedSessions.
      • activated

        private final java.util.concurrent.atomic.AtomicBoolean activated
      • activationTime

        private volatile long activationTime
        Time this listenerSupport has been activated
      • largestManagedSessionCount

        private volatile int largestManagedSessionCount
        A counter used to store the maximum sessions we managed since the listenerSupport has been activated
      • cumulativeManagedSessionCount

        private java.util.concurrent.atomic.AtomicLong cumulativeManagedSessionCount
        A global counter to count the number of sessions managed since the start
    • Constructor Detail

      • IoServiceListenerSupport

        public IoServiceListenerSupport​(IoService service)
        Creates a new instance of the listenerSupport.
        Parameters:
        service - The associated IoService
    • Method Detail

      • add

        public void add​(IoServiceListener listener)
        Adds a new listener.
        Parameters:
        listener - The added listener
      • remove

        public void remove​(IoServiceListener listener)
        Removes an existing listener.
        Parameters:
        listener - The listener to remove
      • getActivationTime

        public long getActivationTime()
        Returns:
        The time (in ms) this instance has been activated
      • getManagedSessions

        public java.util.Map<java.lang.Long,​IoSession> getManagedSessions()
        Returns:
        A Map of the managed IoSessions
      • getManagedSessionCount

        public int getManagedSessionCount()
        Returns:
        The number of managed IoSessions
      • getLargestManagedSessionCount

        public int getLargestManagedSessionCount()
        Returns:
        The largest number of managed session since the creation of this listenerSupport
      • getCumulativeManagedSessionCount

        public long getCumulativeManagedSessionCount()
        Returns:
        The total number of sessions managed since the initilization of this ListenerSupport
      • isActive

        public boolean isActive()
        Returns:
        true if the instance is active
      • disconnectSessions

        private void disconnectSessions()
        Close all the sessions