feisty meow concerns codebase
2.140
|
Monitors a periodic heartbeat to track a resource's health. More...
#include <heartbeat.h>
Public Member Functions | |
heartbeat (int misses_allowed=500, int check_interval=10000) | |
creates a heartbeat monitor with the specified interval and maximum skips permitted. More... | |
heartbeat (const heartbeat &to_copy) | |
~heartbeat () | |
DEFINE_CLASS_NAME ("heartbeat") | |
heartbeat & | operator= (const heartbeat &to_copy) |
basis::astring | text_form (bool detailed=false) const |
returns a readable form of the heartbeat's information. More... | |
void | reset (int misses_allowed, int check_interval) |
retrains the heartbeat monitor for a new configuration. More... | |
bool | due () const |
is the next heartbeat due yet? More... | |
bool | dead () const |
is this object considered dead from missing too many heartbeats? More... | |
void | made_request () |
records that another heartbeat request was sent out. More... | |
void | need_beat () |
a synonym for the made_request() method. More... | |
void | kabump () |
registers a heartbeat response and sets the state to healthy. More... | |
void | recycle () |
a synonym for kabump(). More... | |
int | missed_so_far () const |
returns the number of heartbeat responses that are pending. More... | |
int | misses_left () const |
the number of misses that this object is still allowed. More... | |
int | allowed_misses () const |
returns the number of misses allowed overall. More... | |
int | checking_interval () const |
returns the period of the heartbeats. More... | |
timely::time_stamp | heartbeat_time () const |
returns the time when the next heartbeat will be requested. More... | |
int | time_left () const |
number of milliseconds left before the next beat will be requested. More... | |
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 33 of file heartbeat.h.
processes::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 29 of file heartbeat.cpp.
References reset().
processes::heartbeat::heartbeat | ( | const heartbeat & | to_copy | ) |
Definition at line 36 of file heartbeat.cpp.
processes::heartbeat::~heartbeat | ( | ) |
Definition at line 44 of file heartbeat.cpp.
References basis::WHACK().
|
inline |
returns the number of misses allowed overall.
Definition at line 88 of file heartbeat.h.
|
inline |
returns the period of the heartbeats.
Definition at line 90 of file heartbeat.h.
Referenced by text_form().
bool processes::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 60 of file heartbeat.cpp.
References due().
Referenced by text_form().
processes::heartbeat::DEFINE_CLASS_NAME | ( | "heartbeat" | ) |
bool processes::heartbeat::due | ( | ) | const |
is the next heartbeat due yet?
Definition at line 48 of file heartbeat.cpp.
References time_left().
Referenced by dead(), and text_form().
time_stamp processes::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 46 of file heartbeat.cpp.
Referenced by text_form().
void processes::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 52 of file heartbeat.cpp.
Referenced by recycle().
void processes::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 50 of file heartbeat.cpp.
Referenced by need_beat().
|
inline |
returns the number of heartbeat responses that are pending.
Definition at line 83 of file heartbeat.h.
Referenced by text_form().
|
inline |
the number of misses that this object is still allowed.
Definition at line 85 of file heartbeat.h.
Referenced by text_form().
|
inline |
a synonym for the made_request() method.
Definition at line 70 of file heartbeat.h.
References made_request().
Definition at line 90 of file heartbeat.cpp.
|
inline |
void processes::heartbeat::reset | ( | int | misses_allowed, |
int | check_interval | ||
) |
retrains the heartbeat monitor for a new configuration.
Definition at line 68 of file heartbeat.cpp.
Referenced by heartbeat().
astring processes::heartbeat::text_form | ( | bool | detailed = false | ) | const |
returns a readable form of the heartbeat's information.
Definition at line 76 of file heartbeat.cpp.
References checking_interval(), dead(), due(), heartbeat_time(), missed_so_far(), misses_left(), and timely::time_stamp::text_form().
int processes::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 57 of file heartbeat.cpp.
References timely::time_stamp::value().
Referenced by due().