Class PhiAccrualFailureDetector
- All Implemented Interfaces:
FailureDetector,FailureDetectorWithAddress
The suspicion level of failure is given by a value called φ (phi). The basic idea of the φ failure detector is to express the value of φ on a scale that is dynamically adjusted to reflect current network conditions. A configurable threshold is used to decide if φ is considered to be a failure.
The value of φ is calculated as:
φ = -log10(1 - F(timeSinceLastHeartbeat)
where F is the cumulative distribution function of a normal distribution with mean
and standard deviation estimated from historical heartbeat inter-arrival times.
param: threshold A low threshold is prone to generate many wrong suspicions but ensures a quick detection in the event of a real crash. Conversely, a high threshold generates fewer mistakes but needs more time to detect actual crashes param: maxSampleSize Number of samples to use for calculation of mean and standard deviation of inter-arrival times. param: minStdDeviation Minimum standard deviation to use for the normal distribution used when calculating phi. Too low standard deviation might result in too much sensitivity for sudden, but normal, deviations in heartbeat inter arrival times. param: acceptableHeartbeatPause Duration corresponding to number of potentially lost/delayed heartbeats that will be accepted before considering it to be an anomaly. This margin is important to be able to survive sudden, occasional, pauses in heartbeat arrivals, due to for example garbage collect or network drop. param: firstHeartbeatEstimate Bootstrap the stats with heartbeats that corresponds to to this duration, with a with rather high standard deviation (since environment is unknown in the beginning) param: clock The clock, returning current time in milliseconds, but can be faked for testing purposes. It is only used for measuring intervals (duration).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.pekko.remote.FailureDetector
FailureDetector.Clock -
Constructor Summary
ConstructorsConstructorDescriptionPhiAccrualFailureDetector(double threshold, int maxSampleSize, scala.concurrent.duration.FiniteDuration minStdDeviation, scala.concurrent.duration.FiniteDuration acceptableHeartbeatPause, scala.concurrent.duration.FiniteDuration firstHeartbeatEstimate, FailureDetector.Clock clock) Constructor without eventStream to support backwards compatibilityPhiAccrualFailureDetector(double threshold, int maxSampleSize, scala.concurrent.duration.FiniteDuration minStdDeviation, scala.concurrent.duration.FiniteDuration acceptableHeartbeatPause, scala.concurrent.duration.FiniteDuration firstHeartbeatEstimate, scala.Option<EventStream> eventStream, FailureDetector.Clock clock) PhiAccrualFailureDetector(com.typesafe.config.Config config, EventStream ev) Constructor that reads parameters from config. -
Method Summary
Modifier and TypeMethodDescriptionscala.concurrent.duration.FiniteDurationscala.concurrent.duration.FiniteDurationfinal voidNotifies the FailureDetector that a heartbeat arrived from the monitored resource.booleanReturns true if the resource is considered to be up and healthy and returns false otherwise.booleanReturns true if the failure detector has received any heartbeats and started monitoring of the resource.intscala.concurrent.duration.FiniteDurationdoublephi()The suspicion level of the accrual failure detector.protected org.apache.pekko.remote.HeartbeatHistoryrecordInterval(long interval) voidsetAddress(String addr) Address of observed host will be set after detector creation.double
-
Constructor Details
-
PhiAccrualFailureDetector
public PhiAccrualFailureDetector(double threshold, int maxSampleSize, scala.concurrent.duration.FiniteDuration minStdDeviation, scala.concurrent.duration.FiniteDuration acceptableHeartbeatPause, scala.concurrent.duration.FiniteDuration firstHeartbeatEstimate, scala.Option<EventStream> eventStream, FailureDetector.Clock clock) -
PhiAccrualFailureDetector
public PhiAccrualFailureDetector(double threshold, int maxSampleSize, scala.concurrent.duration.FiniteDuration minStdDeviation, scala.concurrent.duration.FiniteDuration acceptableHeartbeatPause, scala.concurrent.duration.FiniteDuration firstHeartbeatEstimate, FailureDetector.Clock clock) Constructor without eventStream to support backwards compatibility -
PhiAccrualFailureDetector
Constructor that reads parameters from config. Expecting config properties namedthreshold,max-sample-size,min-std-deviation,acceptable-heartbeat-pauseandheartbeat-interval.
-
-
Method Details
-
acceptableHeartbeatPause
public scala.concurrent.duration.FiniteDuration acceptableHeartbeatPause() -
firstHeartbeatEstimate
public scala.concurrent.duration.FiniteDuration firstHeartbeatEstimate() -
heartbeat
public final void heartbeat()Description copied from interface:FailureDetectorNotifies the FailureDetector that a heartbeat arrived from the monitored resource. This causes the FailureDetector to update its state.- Specified by:
heartbeatin interfaceFailureDetector
-
isAvailable
public boolean isAvailable()Description copied from interface:FailureDetectorReturns true if the resource is considered to be up and healthy and returns false otherwise.- Specified by:
isAvailablein interfaceFailureDetector
-
isMonitoring
public boolean isMonitoring()Description copied from interface:FailureDetectorReturns true if the failure detector has received any heartbeats and started monitoring of the resource.- Specified by:
isMonitoringin interfaceFailureDetector
-
maxSampleSize
public int maxSampleSize() -
minStdDeviation
public scala.concurrent.duration.FiniteDuration minStdDeviation() -
phi
public double phi()The suspicion level of the accrual failure detector.If a connection does not have any records in failure detector then it is considered healthy.
-
recordInterval
protected org.apache.pekko.remote.HeartbeatHistory recordInterval(long interval) -
setAddress
Description copied from interface:FailureDetectorWithAddressAddress of observed host will be set after detector creation.- Specified by:
setAddressin interfaceFailureDetectorWithAddress
-
threshold
public double threshold()
-