Class SessionHelper.SessionReaperDaemon

    • Constructor Detail

      • SessionReaperDaemon

        public SessionReaperDaemon​(String sName,
                                   int nPriority)
        Construct a SessionReaperDaemon.
        Parameters:
        sName - the daemon name
        nPriority - the daemon priority
    • Method Detail

      • scheduleTask

        public void scheduleTask​(Runnable task,
                                 long ldt)
        Schedule a task to be run at the specified time, or as soon after as possible.
        Overrides:
        scheduleTask in class TaskDaemon
        Parameters:
        task - a Runnable object to invoke
        ldt - a datetime value at which to run the task
      • run

        public void run()
        The task process: Process a portion of the reaping cycle.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class TaskDaemon
      • onException

        protected void onException​(Throwable e,
                                   Runnable task)
        Process an exception that is thrown during a task execution. The default implementation logs the exception and continues.
        Overrides:
        onException in class TaskDaemon
        Parameters:
        e - Throwable object (a RuntimeException or an Error)
        task - the task that caused the exception
      • getEstimatedReaperSessionCount

        public int getEstimatedReaperSessionCount()
        Determine the estimated number of sessions that will be reaped by the reaper when it runs next.
        Returns:
        an estimate of the number of sessions to reap (if it cannot be determined exactly)
      • setEstimatedReaperSessionCount

        public void setEstimatedReaperSessionCount​(int c)
        Update the estimated number of sessions that will be reaped by the reaper when it runs next.
        Parameters:
        c - the number of sessions that were reaped by the previous reap cycle
      • getTotalReapCycles

        public int getTotalReapCycles()
        Determine the total number of reaping cycles that this node has performed.
        Returns:
        the total number of reaping cycles that this node has performed
      • incTotalReapCycles

        public void incTotalReapCycles()
        Increment the total number of reaping cycles that this node has performed.
      • isFullReapDue

        protected boolean isFullReapDue()
        Determine if this node should run a full reaper scan. This method is only utilized if reaping is cluster-coordinated.
        Returns:
        true if a reaper scan is due and this node has been selected to perform it
      • setLastReapQueueWaitDuration

        public void setLastReapQueueWaitDuration​(long time)
        Sets the duration the last reap task spent in the queue prior to running.
        Specified by:
        setLastReapQueueWaitDuration in interface SessionReaperStatistics
        Parameters:
        time - the duration in milliseconds
      • getLastReapQueueWaitDuration

        public long getLastReapQueueWaitDuration()
        Return the time the last reap task spent in the queue prior to running.
        Specified by:
        getLastReapQueueWaitDuration in interface SessionReaperStatistics
        Returns:
        the time the last reap task spent in the queue prior to running.
      • getAverageReapQueueWaitDuration

        public long getAverageReapQueueWaitDuration()
        Return the average number of milliseconds reap tasks wait in the queue prior to running.
        Specified by:
        getAverageReapQueueWaitDuration in interface SessionReaperStatistics
        Returns:
        the average number of milliseconds reap tasks wait in the queue.
      • getMaxReapQueueWaitDuration

        public long getMaxReapQueueWaitDuration()
        Description copied from interface: SessionReaperStatistics
        Return the max time in milliseconds a reap task has spent in the queue prior to running since the statistics were last reset.
        Specified by:
        getMaxReapQueueWaitDuration in interface SessionReaperStatistics
        Returns:
        the max time in milliseconds a reap task has spent in the queue prior to running since the statistics were last reset
      • getLastReapDuration

        public long getLastReapDuration()
        Gets the duration for the last reap cycle.
        Specified by:
        getLastReapDuration in interface SessionReaperStatistics
        Returns:
        The duration in milliseconds.
      • setLastReapDuration

        public void setLastReapDuration​(long time)
        Sets the duration for the last reap cycle.
        Specified by:
        setLastReapDuration in interface SessionReaperStatistics
        Parameters:
        time - The duration in milliseconds.
      • getReapedSessions

        public long getReapedSessions()
        Gets the number of sessions that were reaped during the last reap cycle.
        Specified by:
        getReapedSessions in interface SessionReaperStatistics
        Returns:
        The number of sessions.
      • setReapedSessions

        public void setReapedSessions​(long l)
        Sets the number of sessions that were reaped during the last reap cycle.
        Specified by:
        setReapedSessions in interface SessionReaperStatistics
        Parameters:
        l - The number of sessions.
      • getTotalReapedSessions

        public long getTotalReapedSessions()
        Gets the number of sessions that were reaped since the statistics was reset. Note! This attribute doesn't have a setter since it is derived from the ReapedSession attr.
        Specified by:
        getTotalReapedSessions in interface SessionReaperStatistics
        Returns:
        The number of sessions.
      • getLastReapTime

        public long getLastReapTime()
        Determine the last time that session reaping started.
        Specified by:
        getLastReapTime in interface SessionReaperStatistics
        Returns:
        the last time that session reaping started
      • setLastReapTime

        public void setLastReapTime​(long dt)
        Update the last time that session reaping started.
        Specified by:
        setLastReapTime in interface SessionReaperStatistics
        Parameters:
        dt - the last time that session reaping started
      • getNextReapTime

        public long getNextReapTime()
        Gets the start time for the next reap cycle.
        Specified by:
        getNextReapTime in interface SessionReaperStatistics
        Returns:
        The time in milliseconds when the next reap cycle is schedule to start.
      • setNextReapTime

        public void setNextReapTime​(long d)
        Sets the start time for the next reap cycle.
        Specified by:
        setNextReapTime in interface SessionReaperStatistics
        Parameters:
        d - The time in milliseconds when the next reap cycle is schedule to start.
      • getAverageReapDuration

        public long getAverageReapDuration()
        Gets the average reap duration since the statistics was reset.
        Specified by:
        getAverageReapDuration in interface SessionReaperStatistics
        Returns:
        The average reap duration.
      • getAverageReapedSessions

        public long getAverageReapedSessions()
        Gets the average number of reaped sessions in a reap cycle since the statistics was reset.
        Specified by:
        getAverageReapedSessions in interface SessionReaperStatistics
        Returns:
        The average number of reaped sessions.
      • getMaxReapDuration

        public long getMaxReapDuration()
        Gets the maximum reap duration since the statistics was reset.
        Specified by:
        getMaxReapDuration in interface SessionReaperStatistics
        Returns:
        The max reap duration.
      • getMaxReapedSessions

        public long getMaxReapedSessions()
        Gets the maximum number of sessions reaped in a reap cycle since the statistics was reset.
        Specified by:
        getMaxReapedSessions in interface SessionReaperStatistics
        Returns:
        The max number of sessions reaped.