Top Description Inners Fields Constructors Methods
org.LatencyUtils

public Class SimplePauseDetector

extends PauseDetector
Class Inheritance
Imports
java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicLong

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 and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicLong
private static final int
private static final long
private static final long
private static final boolean
private final SimplePauseDetector.SimplePauseDetectorThread[]
private final long
private final long
private volatile long
private volatile long
private boolean

Constructor Summary

AccessConstructor and Description
public
SimplePauseDetector(long
sleep interval used by detector threads
sleepInterval
,
long
minimum threshold for reporting detected pauses
pauseNotificationThreshold
,
int
number of consensus detector threads to use
numberOfDetectorThreads
)

Creates a SimplePauseDetector

public
SimplePauseDetector(long
sleep interval used by detector threads
sleepInterval
,
long
minimum threshold for reporting detected pauses
pauseNotificationThreshold
,
int
number of consensus detector threads to use
numberOfDetectorThreads
,
boolean
provide verbose output when pauses are detected
verbose
)

Creates a 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 Summary

Modifier and TypeMethod and Description
public void
setVerbose(boolean verbose)

public void
shutdown()

Overrides org.LatencyUtils.PauseDetector.shutdown.

Shut down the pause detector operation and terminate it's threads.
public void
skipConsensusTimeTo(long
time to skip to
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.

public void
stallDetectorThreads(long
a mask designating which threads should be stalled.
threadNumberMask
,
long
stall length, in nanosecond units
stallLength
)

A test method that allows the caller to artificially stall a requested set of the detector threads for a given amount of time.

Inherited from org.LatencyUtils.PauseDetector:
addListeneraddListenernotifyListenersremoveListener

Field Detail

consensusLatestTimeback to summary
pack-priv final AtomicLong consensusLatestTime
DEFAULT_NumberOfDetectorThreadsback to summary
private static final int DEFAULT_NumberOfDetectorThreads
DEFAULT_PauseNotificationThresholdback to summary
private static final long DEFAULT_PauseNotificationThreshold
DEFAULT_SleepIntervalback to summary
private static final long DEFAULT_SleepInterval
DEFAULT_Verboseback to summary
private static final boolean DEFAULT_Verbose
detectorsback to summary
private final SimplePauseDetector.SimplePauseDetectorThread[] detectors
pauseNotificationThresholdback to summary
private final long pauseNotificationThreshold
sleepIntervalback to summary
private final long sleepInterval
stallThreadMaskback to summary
private volatile long stallThreadMask
stopThreadMaskback to summary
private volatile long stopThreadMask
verboseback to summary
private boolean verbose

Constructor Detail

SimplePauseDetectorback to summary
public SimplePauseDetector(long sleepInterval, long pauseNotificationThreshold, int numberOfDetectorThreads)

Creates a SimplePauseDetector

Parameters
sleepInterval:long

sleep interval used by detector threads

pauseNotificationThreshold:long

minimum threshold for reporting detected pauses

numberOfDetectorThreads:int

number of consensus detector threads to use

SimplePauseDetectorback to summary
public SimplePauseDetector(long sleepInterval, long pauseNotificationThreshold, int numberOfDetectorThreads, boolean verbose)

Creates a SimplePauseDetector

Parameters
sleepInterval:long

sleep interval used by detector threads

pauseNotificationThreshold:long

minimum threshold for reporting detected pauses

numberOfDetectorThreads:int

number of consensus detector threads to use

verbose:boolean

provide verbose output when pauses are detected

SimplePauseDetectorback to summary
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

setVerboseback to summary
public void setVerbose(boolean verbose)
shutdownback to summary
public void shutdown()

Overrides org.LatencyUtils.PauseDetector.shutdown.

Shut down the pause detector operation and terminate it's threads.

Annotations
@Override
skipConsensusTimeToback to summary
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:long

time to skip to

stallDetectorThreadsback to summary
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:long

a mask designating which threads should be stalled.

stallLength:long

stall length, in nanosecond units

Exceptions
InterruptedException:
if internal sleep implementation throws it
org.LatencyUtils back to summary

private Class SimplePauseDetector.SimplePauseDetectorThread

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile long
pack-priv final long
pack-priv final int
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv
SimplePauseDetectorThread(final int threadNumber)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.
Inherited from java.lang.Thread:
activeCountcheckAccessclonecountStackFramescurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

observedLasUpdateTimeback to summary
pack-priv volatile long observedLasUpdateTime
threadMaskback to summary
pack-priv final long threadMask
threadNumberback to summary
pack-priv final int threadNumber

Constructor Detail

SimplePauseDetectorThreadback to summary
pack-priv SimplePauseDetectorThread(final int threadNumber)

Method Detail

runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.