Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <failure-detector.h>
Public Types | |
enum | PeerState { FAILED = 0, SUSPECTED = 1, OK = 2, UNKNOWN = 3 } |
Public Member Functions | |
TimeoutFailureDetector (boost::posix_time::time_duration failure_timeout, boost::posix_time::time_duration suspect_timeout) | |
virtual PeerState | UpdateHeartbeat (const std::string &peer, bool seen) |
virtual PeerState | GetPeerState (const std::string &peer) |
Returns the current estimated state of a peer. More... | |
virtual void | EvictPeer (const std::string &peer) |
Remove a peer from the failure detector completely. More... | |
Static Public Member Functions | |
static const std::string & | PeerStateToString (PeerState peer_state) |
Utility method to convert a PeerState enum to a string. More... | |
Private Attributes | |
boost::mutex | lock_ |
Protects all members. More... | |
std::map< std::string, boost::system_time > | peer_heartbeat_record_ |
Record of last time a successful heartbeat was received. More... | |
const boost::posix_time::time_duration | failure_timeout_ |
const boost::posix_time::time_duration | suspect_timeout_ |
A failure detector based on a maximum time between successful heartbeats. Peers that do not successfully heartbeat before the failure_timeout are considered failed; those that do not heartbeat before the suspect_timeout are considered suspected. A timeout failure detector is most appropriate for a client which is receiving periodic heartbeats. Not thread safe.
Definition at line 72 of file failure-detector.h.
|
inherited |
Enumerator | |
---|---|
FAILED | |
SUSPECTED | |
OK | |
UNKNOWN |
Definition at line 35 of file failure-detector.h.
|
inline |
Definition at line 74 of file failure-detector.h.
|
virtual |
Remove a peer from the failure detector completely.
Implements impala::FailureDetector.
Definition at line 67 of file failure-detector.cc.
References lock_, and peer_heartbeat_record_.
|
virtual |
Returns the current estimated state of a peer.
Implements impala::FailureDetector.
Definition at line 52 of file failure-detector.cc.
References impala::FailureDetector::FAILED, failure_timeout_, lock_, impala::FailureDetector::OK, peer_heartbeat_record_, suspect_timeout_, impala::FailureDetector::SUSPECTED, and impala::FailureDetector::UNKNOWN.
Referenced by UpdateHeartbeat().
|
staticinherited |
Utility method to convert a PeerState enum to a string.
Definition at line 36 of file failure-detector.cc.
References PEER_STATE_TO_STRING.
|
virtual |
Updates the state of a peer according to the most recent heartbeat state. If 'seen' is true, this method indicates that a heartbeat has been received. If seen is 'false', this method indicates that a heartbeat has not been received since the last successful heartbeat receipt. This method returns the current state of the updated peer. Note that this may be different from the state implied by seen - a single missed heartbeat, for example, may not cause a peer to enter the SUSPECTED or FAILED states. The failure detector has the benefit of looking at all samples, rather than just the most recent one.
Implements impala::FailureDetector.
Definition at line 43 of file failure-detector.cc.
References GetPeerState(), lock_, and peer_heartbeat_record_.
|
private |
The maximum time that may elapse without a heartbeat before a peer is considered failed
Definition at line 94 of file failure-detector.h.
Referenced by GetPeerState().
|
private |
Protects all members.
Definition at line 87 of file failure-detector.h.
Referenced by EvictPeer(), GetPeerState(), and UpdateHeartbeat().
|
private |
Record of last time a successful heartbeat was received.
Definition at line 90 of file failure-detector.h.
Referenced by EvictPeer(), GetPeerState(), and UpdateHeartbeat().
|
private |
The maximum time that may elapse without a heartbeat before a peer is suspected of failure
Definition at line 98 of file failure-detector.h.
Referenced by GetPeerState().