heartbeat Class Reference

Monitors a periodic heartbeat to track a resource's health. More...

#include <heartbeat.h>

Inheritance diagram for heartbeat:

Inheritance graph
[legend]
Collaboration diagram for heartbeat:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 heartbeat (int misses_allowed=500, int check_interval=10000)
 creates a heartbeat monitor with the specified interval and maximum skips permitted.
 heartbeat (const heartbeat &to_copy)
 ~heartbeat ()
 IMPLEMENT_CLASS_NAME ("heartbeat")
heartbeatoperator= (const heartbeat &to_copy)
istring text_form (bool detailed=false) const
 returns a readable form of the heartbeat's information.
void reset (int misses_allowed, int check_interval)
 retrains the heartbeat monitor for a new configuration.
bool due () const
 is the next heartbeat due yet?
bool dead () const
 is this object considered dead from missing too many heartbeats?
void made_request ()
 records that another heartbeat request was sent out.
void need_beat ()
 a synonym for the made_request() method.
void kabump ()
 registers a heartbeat response and sets the state to healthy.
void recycle ()
 a synonym for kabump().
int missed_so_far () const
 returns the number of heartbeat responses that are pending.
int misses_left () const
 the number of misses that this object is still allowed.
int allowed_misses () const
 returns the number of misses allowed overall.
int checking_interval () const
 returns the period of the heartbeats.
time_stamp heartbeat_time () const
 returns the time when the next heartbeat will be requested.
int time_left () const
 number of milliseconds left before the next beat will be requested.

Detailed Description

Monitors a periodic heartbeat to track a resource's health.

The heartbeat is defined as a "request-and-response" based check; when the next periodic heartbeat is due, a request is sent out. The heartbeat request is considered successfully dealt with only if a response comes back for the request. If the user-defined number of requests are sent without a single response coming back, then the 'patient' is considered dead.

Definition at line 34 of file heartbeat.h.


Constructor & Destructor Documentation

heartbeat::heartbeat ( int  misses_allowed = 500,
int  check_interval = 10000 
)

creates a heartbeat monitor with the specified interval and maximum skips permitted.

this allows the heartbeat request to be missed "misses_allowed" times. the heartbeats will become due every "check_interval" milliseconds. the defaults are a joke; you really need to set them.

Definition at line 24 of file heartbeat.cpp.

References reset().

heartbeat::heartbeat ( const heartbeat to_copy  ) 

Definition at line 31 of file heartbeat.cpp.

heartbeat::~heartbeat (  ) 

Definition at line 39 of file heartbeat.cpp.

References WHACK().


Member Function Documentation

heartbeat::IMPLEMENT_CLASS_NAME ( "heartbeat"   ) 

heartbeat & heartbeat::operator= ( const heartbeat to_copy  ) 

Definition at line 85 of file heartbeat.cpp.

References _check_interval, _misses, _misses_allowed, and _next_heartbeat.

istring heartbeat::text_form ( bool  detailed = false  )  const

returns a readable form of the heartbeat's information.

Definition at line 71 of file heartbeat.cpp.

References checking_interval(), dead(), due(), istring::empty_string(), heartbeat_time(), missed_so_far(), misses_left(), and time_stamp::text_form().

void heartbeat::reset ( int  misses_allowed,
int  check_interval 
)

retrains the heartbeat monitor for a new configuration.

Definition at line 63 of file heartbeat.cpp.

Referenced by heartbeat(), and scheduler::mark_dead().

bool heartbeat::due (  )  const

is the next heartbeat due yet?

Definition at line 43 of file heartbeat.cpp.

References time_left().

Referenced by connection_table::clear_dead(), dead(), and text_form().

bool heartbeat::dead (  )  const

is this object considered dead from missing too many heartbeats?

this is true if the heartbeat being monitored missed too many responses to heartbeat requests. if the maximum allowed requests have been made and there was not even a single response, then the object is considered dead.

Definition at line 55 of file heartbeat.cpp.

References due().

Referenced by connection_table::clear_dead(), and text_form().

void heartbeat::made_request (  ) 

records that another heartbeat request was sent out.

the time for the next heartbeat request is reset to the time between beats. if there were already the maximum allowed number of missed responses, then the object is now dead.

Definition at line 45 of file heartbeat.cpp.

Referenced by connection_table::clear_dead(), life_maintainer::made_request(), and connection_table::record_request().

void heartbeat::need_beat (  )  [inline]

a synonym for the made_request() method.

Definition at line 71 of file heartbeat.h.

void heartbeat::kabump (  ) 

registers a heartbeat response and sets the state to healthy.

this records that a heartbeat response came back from the monitored object. after this call, there are no heartbeats recorded as missed at all.

Definition at line 47 of file heartbeat.cpp.

Referenced by life_maintainer::kabump(), and connection_table::reset_time().

void heartbeat::recycle (  )  [inline]

a synonym for kabump().

Definition at line 79 of file heartbeat.h.

int heartbeat::missed_so_far (  )  const [inline]

returns the number of heartbeat responses that are pending.

Definition at line 84 of file heartbeat.h.

Referenced by text_form().

int heartbeat::misses_left (  )  const [inline]

the number of misses that this object is still allowed.

Definition at line 86 of file heartbeat.h.

Referenced by text_form().

int heartbeat::allowed_misses (  )  const [inline]

returns the number of misses allowed overall.

Definition at line 89 of file heartbeat.h.

int heartbeat::checking_interval (  )  const [inline]

returns the period of the heartbeats.

Definition at line 91 of file heartbeat.h.

Referenced by text_form().

time_stamp heartbeat::heartbeat_time (  )  const

returns the time when the next heartbeat will be requested.

if no heartbeats had been missed yet, then this is the time when the due() method starts returning true.

Definition at line 41 of file heartbeat.cpp.

Referenced by text_form().

int heartbeat::time_left (  )  const

number of milliseconds left before the next beat will be requested.

if the number is zero or negative, then a heartbeat is due.

Definition at line 52 of file heartbeat.cpp.

References time_stamp::value().

Referenced by due(), and schedulable::schedulable_text_form().


The documentation for this class was generated from the following files:
Generated on Sat Oct 11 04:30:21 2008 for HOOPLE Libraries by  doxygen 1.5.1