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

#include <failure-detector.h>

Inheritance diagram for impala::TimeoutFailureDetector:
Collaboration diagram for impala::TimeoutFailureDetector:

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_
 

Detailed Description

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.

Member Enumeration Documentation

Enumerator
FAILED 
SUSPECTED 
OK 
UNKNOWN 

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

Constructor & Destructor Documentation

impala::TimeoutFailureDetector::TimeoutFailureDetector ( boost::posix_time::time_duration  failure_timeout,
boost::posix_time::time_duration  suspect_timeout 
)
inline

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

Member Function Documentation

void TimeoutFailureDetector::EvictPeer ( const std::string &  peer)
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_.

FailureDetector::PeerState TimeoutFailureDetector::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 TimeoutFailureDetector::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 43 of file failure-detector.cc.

References GetPeerState(), lock_, and peer_heartbeat_record_.

Member Data Documentation

const boost::posix_time::time_duration impala::TimeoutFailureDetector::failure_timeout_
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().

boost::mutex impala::TimeoutFailureDetector::lock_
private

Protects all members.

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

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

std::map<std::string, boost::system_time> impala::TimeoutFailureDetector::peer_heartbeat_record_
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().

const boost::posix_time::time_duration impala::TimeoutFailureDetector::suspect_timeout_
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().


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