Package org.apache.cassandra.gms
Class FailureDetector
- java.lang.Object
-
- org.apache.cassandra.gms.FailureDetector
-
- All Implemented Interfaces:
FailureDetectorMBean
,IFailureDetector
public class FailureDetector extends java.lang.Object implements IFailureDetector, FailureDetectorMBean
This FailureDetector is an implementation of the paper titled "The Phi Accrual Failure Detector" by Hayashibara. Check the paper and the IFailureDetector interface for details.
-
-
Field Summary
Fields Modifier and Type Field Description protected static long
INITIAL_VALUE_NANOS
static IFailureDetector
instance
static java.util.function.Predicate<InetAddressAndPort>
isEndpointAlive
static java.util.function.Predicate<Replica>
isReplicaAlive
static java.lang.String
MBEAN_NAME
-
Constructor Summary
Constructors Constructor Description FailureDetector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dumpInterArrivalTimes()
Dump the inter arrival times for examination if necessary.void
forceConviction(InetAddressAndPort ep)
force conviction of endpoint in the failure detectorjava.lang.String
getAllEndpointStates()
java.lang.String
getAllEndpointStates(boolean withPort)
java.lang.String
getAllEndpointStates(boolean withPort, boolean resolveIp)
java.lang.String
getAllEndpointStatesWithPort()
java.lang.String
getAllEndpointStatesWithPortAndResolveIp()
java.lang.String
getAllEndpointStatesWithResolveIp()
int
getDownEndpointCount()
java.lang.String
getEndpointState(java.lang.String address)
double
getPhiConvictThreshold()
javax.management.openmbean.TabularData
getPhiValues()
javax.management.openmbean.TabularData
getPhiValuesWithPort()
java.util.Map<java.lang.String,java.lang.String>
getSimpleStates()
java.util.Map<java.lang.String,java.lang.String>
getSimpleStatesWithPort()
int
getUpEndpointCount()
void
interpret(InetAddressAndPort ep)
This method is invoked by any entity wanting to interrogate the status of an endpoint.boolean
isAlive(InetAddressAndPort ep)
Failure Detector's knowledge of whether a node is up or down.void
registerFailureDetectionEventListener(IFailureDetectionEventListener listener)
Register interest for Failure Detector events.void
remove(InetAddressAndPort ep)
remove endpoint from failure detectorvoid
report(InetAddressAndPort ep)
This method is invoked by the receiver of the heartbeat.void
setPhiConvictThreshold(double phi)
java.lang.String
toString()
void
unregisterFailureDetectionEventListener(IFailureDetectionEventListener listener)
Un-register interest for Failure Detector events.
-
-
-
Field Detail
-
MBEAN_NAME
public static final java.lang.String MBEAN_NAME
- See Also:
- Constant Field Values
-
INITIAL_VALUE_NANOS
protected static final long INITIAL_VALUE_NANOS
-
instance
public static final IFailureDetector instance
-
isEndpointAlive
public static final java.util.function.Predicate<InetAddressAndPort> isEndpointAlive
-
isReplicaAlive
public static final java.util.function.Predicate<Replica> isReplicaAlive
-
-
Method Detail
-
getAllEndpointStates
public java.lang.String getAllEndpointStates()
- Specified by:
getAllEndpointStates
in interfaceFailureDetectorMBean
-
getAllEndpointStatesWithResolveIp
public java.lang.String getAllEndpointStatesWithResolveIp()
- Specified by:
getAllEndpointStatesWithResolveIp
in interfaceFailureDetectorMBean
-
getAllEndpointStatesWithPort
public java.lang.String getAllEndpointStatesWithPort()
- Specified by:
getAllEndpointStatesWithPort
in interfaceFailureDetectorMBean
-
getAllEndpointStatesWithPortAndResolveIp
public java.lang.String getAllEndpointStatesWithPortAndResolveIp()
- Specified by:
getAllEndpointStatesWithPortAndResolveIp
in interfaceFailureDetectorMBean
-
getAllEndpointStates
public java.lang.String getAllEndpointStates(boolean withPort)
-
getAllEndpointStates
public java.lang.String getAllEndpointStates(boolean withPort, boolean resolveIp)
-
getSimpleStates
public java.util.Map<java.lang.String,java.lang.String> getSimpleStates()
- Specified by:
getSimpleStates
in interfaceFailureDetectorMBean
-
getSimpleStatesWithPort
public java.util.Map<java.lang.String,java.lang.String> getSimpleStatesWithPort()
- Specified by:
getSimpleStatesWithPort
in interfaceFailureDetectorMBean
-
getDownEndpointCount
public int getDownEndpointCount()
- Specified by:
getDownEndpointCount
in interfaceFailureDetectorMBean
-
getUpEndpointCount
public int getUpEndpointCount()
- Specified by:
getUpEndpointCount
in interfaceFailureDetectorMBean
-
getPhiValues
public javax.management.openmbean.TabularData getPhiValues() throws javax.management.openmbean.OpenDataException
- Specified by:
getPhiValues
in interfaceFailureDetectorMBean
- Throws:
javax.management.openmbean.OpenDataException
-
getPhiValuesWithPort
public javax.management.openmbean.TabularData getPhiValuesWithPort() throws javax.management.openmbean.OpenDataException
- Specified by:
getPhiValuesWithPort
in interfaceFailureDetectorMBean
- Throws:
javax.management.openmbean.OpenDataException
-
getEndpointState
public java.lang.String getEndpointState(java.lang.String address) throws java.net.UnknownHostException
- Specified by:
getEndpointState
in interfaceFailureDetectorMBean
- Throws:
java.net.UnknownHostException
-
dumpInterArrivalTimes
public void dumpInterArrivalTimes()
Dump the inter arrival times for examination if necessary.- Specified by:
dumpInterArrivalTimes
in interfaceFailureDetectorMBean
-
setPhiConvictThreshold
public void setPhiConvictThreshold(double phi)
- Specified by:
setPhiConvictThreshold
in interfaceFailureDetectorMBean
-
getPhiConvictThreshold
public double getPhiConvictThreshold()
- Specified by:
getPhiConvictThreshold
in interfaceFailureDetectorMBean
-
isAlive
public boolean isAlive(InetAddressAndPort ep)
Description copied from interface:IFailureDetector
Failure Detector's knowledge of whether a node is up or down.- Specified by:
isAlive
in interfaceIFailureDetector
- Parameters:
ep
- endpoint in question.- Returns:
- true if UP and false if DOWN.
-
report
public void report(InetAddressAndPort ep)
Description copied from interface:IFailureDetector
This method is invoked by the receiver of the heartbeat. In our case it would be the Gossiper. Gossiper inform the Failure Detector on receipt of a heartbeat. The FailureDetector will then sample the arrival time as explained in the paper. param ep endpoint being reported.- Specified by:
report
in interfaceIFailureDetector
-
interpret
public void interpret(InetAddressAndPort ep)
Description copied from interface:IFailureDetector
This method is invoked by any entity wanting to interrogate the status of an endpoint. In our case it would be the Gossiper. The Failure Detector will then calculate Phi and deem an endpoint as suspicious or alive as explained in the Hayashibara paper. param ep endpoint for which we interpret the inter arrival times.- Specified by:
interpret
in interfaceIFailureDetector
-
forceConviction
public void forceConviction(InetAddressAndPort ep)
Description copied from interface:IFailureDetector
force conviction of endpoint in the failure detector- Specified by:
forceConviction
in interfaceIFailureDetector
-
remove
public void remove(InetAddressAndPort ep)
Description copied from interface:IFailureDetector
remove endpoint from failure detector- Specified by:
remove
in interfaceIFailureDetector
-
registerFailureDetectionEventListener
public void registerFailureDetectionEventListener(IFailureDetectionEventListener listener)
Description copied from interface:IFailureDetector
Register interest for Failure Detector events.- Specified by:
registerFailureDetectionEventListener
in interfaceIFailureDetector
- Parameters:
listener
- implementation of an application provided IFailureDetectionEventListener
-
unregisterFailureDetectionEventListener
public void unregisterFailureDetectionEventListener(IFailureDetectionEventListener listener)
Description copied from interface:IFailureDetector
Un-register interest for Failure Detector events.- Specified by:
unregisterFailureDetectionEventListener
in interfaceIFailureDetector
- Parameters:
listener
- implementation of an application provided IFailureDetectionEventListener
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-