Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::MissedHeartbeatFailureDetector Class Reference

#include <failure-detector.h>

Inheritance diagram for impala::MissedHeartbeatFailureDetector:
Collaboration diagram for impala::MissedHeartbeatFailureDetector:

Public Types

enum  PeerState { FAILED = 0, SUSPECTED = 1, OK = 2, UNKNOWN = 3 }
 

Public Member Functions

 MissedHeartbeatFailureDetector (int32_t max_missed_heartbeats, int32_t suspect_missed_heartbeats)
 
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...
 
int32_t max_missed_heartbeats_
 
int32_t suspect_missed_heartbeats_
 
std::map< std::string, int32_t > missed_heartbeat_counts_
 Number of consecutive heartbeats missed by peer. More...
 

Detailed Description

A failure detector based on a maximum number of consecutive heartbeats missed before a peer is considered failed. Clients must call UpdateHeartbeat(..., false) to indicate that a heartbeat has been missed. The MissedHeartbeatFailureDetector is most appropriate when heartbeats are being sent, not being received, because it is easy in that situation to tell when a heartbeat has not been successful. Not thread safe.

Definition at line 108 of file failure-detector.h.

Member Enumeration Documentation

Enumerator
FAILED 
SUSPECTED 
OK 
UNKNOWN 

Definition at line 35 of file failure-detector.h.

Constructor & Destructor Documentation

impala::MissedHeartbeatFailureDetector::MissedHeartbeatFailureDetector ( int32_t  max_missed_heartbeats,
int32_t  suspect_missed_heartbeats 
)
inline

max_missed_heartbeats -> the number of heartbeats that can be missed before a peer is considered failed. suspect_missed_heartbeats -> the number of heartbeats that can be missed before a peer is suspected of failure.

Definition at line 114 of file failure-detector.h.

Member Function Documentation

void MissedHeartbeatFailureDetector::EvictPeer ( const std::string &  peer)
virtual

Remove a peer from the failure detector completely.

Implements impala::FailureDetector.

Definition at line 103 of file failure-detector.cc.

References lock_, and missed_heartbeat_counts_.

FailureDetector::PeerState MissedHeartbeatFailureDetector::GetPeerState ( const std::string &  peer)
virtual
const string & FailureDetector::PeerStateToString ( FailureDetector::PeerState  peer_state)
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.

FailureDetector::PeerState MissedHeartbeatFailureDetector::UpdateHeartbeat ( const std::string &  peer,
bool  seen 
)
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 72 of file failure-detector.cc.

References GetPeerState(), lock_, missed_heartbeat_counts_, and impala::FailureDetector::OK.

Referenced by impala::ImpalaServer::DetectNmFailures().

Member Data Documentation

boost::mutex impala::MissedHeartbeatFailureDetector::lock_
private

Protects all members.

Definition at line 127 of file failure-detector.h.

Referenced by EvictPeer(), GetPeerState(), and UpdateHeartbeat().

int32_t impala::MissedHeartbeatFailureDetector::max_missed_heartbeats_
private

The maximum number of heartbeats that can be missed consecutively before a peer is considered failed.

Definition at line 131 of file failure-detector.h.

Referenced by GetPeerState().

std::map<std::string, int32_t> impala::MissedHeartbeatFailureDetector::missed_heartbeat_counts_
private

Number of consecutive heartbeats missed by peer.

Definition at line 138 of file failure-detector.h.

Referenced by EvictPeer(), GetPeerState(), and UpdateHeartbeat().

int32_t impala::MissedHeartbeatFailureDetector::suspect_missed_heartbeats_
private

The maximum number of heartbeats that can be missed consecutively before a peer is suspected of failure.

Definition at line 135 of file failure-detector.h.

Referenced by GetPeerState().


The documentation for this class was generated from the following files: