org.LatencyUtils
Class SimplePauseDetector

java.lang.Object
  extended by java.lang.Thread
      extended by org.LatencyUtils.PauseDetector
          extended by org.LatencyUtils.SimplePauseDetector
All Implemented Interfaces:
Runnable

public class SimplePauseDetector
extends PauseDetector

A Simple PauseDetector that detects pauses using a consensus observation across a configurable number of detection thread. Detection threads can be set to periodically wakeup or continually spin.

All times and time units are in nanoseconds


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SimplePauseDetector()
          Creates a SimplePauseDetector with a default sleep interval (1 msec), a default pause notification threshold (1 msec), and using the default number of consensus detection threads (3).
SimplePauseDetector(long sleepInterval, long pauseNotificationThreshold, int numberOfDetectorThreads)
          Creates a SimplePauseDetector
SimplePauseDetector(long sleepInterval, long pauseNotificationThreshold, int numberOfDetectorThreads, boolean verbose)
          Creates a SimplePauseDetector
 
Method Summary
 void shutdown()
          Shut down the pause detector operation and terminate it's threads.
 void skipConsensusTimeTo(long newConsensusTime)
          A test method that allows the caller to artificially move the consensus observed time forward without causing a pause to be detected as a result of the time skip.
 void stallDetectorThreads(long threadNumberMask, long stallLength)
          A test method that allows the caller to artificially stall a requested set of the detector threads for a given amount of time.
 
Methods inherited from class org.LatencyUtils.PauseDetector
addListener, addListener, notifyListeners, removeListener, 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
 

Constructor Detail

SimplePauseDetector

public SimplePauseDetector(long sleepInterval,
                           long pauseNotificationThreshold,
                           int numberOfDetectorThreads)
Creates a SimplePauseDetector

Parameters:
sleepInterval - sleep interval used by detector threads
pauseNotificationThreshold - minimum threshold for reporting detected pauses
numberOfDetectorThreads - number of consensus detector threads to use

SimplePauseDetector

public SimplePauseDetector(long sleepInterval,
                           long pauseNotificationThreshold,
                           int numberOfDetectorThreads,
                           boolean verbose)
Creates a SimplePauseDetector

Parameters:
sleepInterval - sleep interval used by detector threads
pauseNotificationThreshold - minimum threshold for reporting detected pauses
numberOfDetectorThreads - number of consensus detector threads to use
verbose - provide verbose output when pauses are detected

SimplePauseDetector

public SimplePauseDetector()
Creates a SimplePauseDetector with a default sleep interval (1 msec), a default pause notification threshold (1 msec), and using the default number of consensus detection threads (3).

Method Detail

shutdown

public void shutdown()
Shut down the pause detector operation and terminate it's threads.

Overrides:
shutdown in class PauseDetector

stallDetectorThreads

public void stallDetectorThreads(long threadNumberMask,
                                 long stallLength)
                          throws InterruptedException
A test method that allows the caller to artificially stall a requested set of the detector threads for a given amount of time. Used to verify pause detection when consensus occurs, as well as lack of detection when it does not.

Parameters:
threadNumberMask - a mask designating which threads should be stalled.
stallLength - stall length, in nanosecond units
Throws:
InterruptedException

skipConsensusTimeTo

public void skipConsensusTimeTo(long newConsensusTime)
A test method that allows the caller to artificially move the consensus observed time forward without causing a pause to be detected as a result of the time skip. Useful for test programs that wish to use artificial time services.

Parameters:
newConsensusTime -


Copyright © 2013. All rights reserved.