MADARA
3.1.8
|
Provides monitoring capability of a transport's bandwidth. More...
#include <BandwidthMonitor.h>
Public Member Functions | |
BandwidthMonitor (time_t window_in_secs=10) | |
Default constructor. More... | |
BandwidthMonitor (const BandwidthMonitor &rhs) | |
Copy constructor. More... | |
virtual | ~BandwidthMonitor () |
Destructor. More... | |
void | add (uint64_t size) |
Adds a message to the monitor. More... | |
void | add (time_t timestamp, uint64_t size) |
Adds a message to the monitor. More... | |
void | clear (void) |
Clears the bandwidth monitor. More... | |
uint64_t | get_bytes_per_second (void) |
Queries the monitor for the current bandwidth utilization per second over the past window. More... | |
size_t | get_number_of_messages (void) |
Returns the number of messages in the past window. More... | |
uint64_t | get_utilization (void) |
Queries the monitor for the current bandwidth utilization. More... | |
bool | is_bandwidth_violated (int64_t limit) |
Checks send and receive bandwidth against send and receive limits. More... | |
void | operator= (const BandwidthMonitor &rhs) |
Assignment operator. More... | |
void | print_utilization (void) |
Prints the number of messages and utilization within the past window. More... | |
void | set_window (time_t window_in_secs) |
Sets the window in seconds to measure bandwidth. More... | |
Protected Member Functions | |
time_t | update_utilization (void) |
Updates utilization for most public functions. More... | |
Protected Attributes | |
BandwidthMessages | messages_ |
Map of timestamps to messages. More... | |
MADARA_LOCK_TYPE | mutex_ |
Mutex for supporting multithreaded monitor calls. More... | |
uint64_t | utilization_ |
Utilization. More... | |
time_t | window_ |
Time window for useful messages to bandwidth calculations. More... | |
Provides monitoring capability of a transport's bandwidth.
Definition at line 35 of file BandwidthMonitor.h.
madara::transport::BandwidthMonitor::BandwidthMonitor | ( | time_t | window_in_secs = 10 | ) |
Default constructor.
window_in_secs | Time window to measure bandwidth usage |
Definition at line 7 of file BandwidthMonitor.cpp.
madara::transport::BandwidthMonitor::BandwidthMonitor | ( | const BandwidthMonitor & | rhs | ) |
Copy constructor.
rhs | the value to be copied into this class |
Definition at line 13 of file BandwidthMonitor.cpp.
|
virtual |
Destructor.
Definition at line 20 of file BandwidthMonitor.cpp.
void madara::transport::BandwidthMonitor::add | ( | uint64_t | size | ) |
Adds a message to the monitor.
size | the size of the message |
Definition at line 47 of file BandwidthMonitor.cpp.
void madara::transport::BandwidthMonitor::add | ( | time_t | timestamp, |
uint64_t | size | ||
) |
Adds a message to the monitor.
timestamp | the time the message occured |
size | the size of the message |
Definition at line 61 of file BandwidthMonitor.cpp.
void madara::transport::BandwidthMonitor::clear | ( | void | ) |
Clears the bandwidth monitor.
Definition at line 108 of file BandwidthMonitor.cpp.
uint64_t madara::transport::BandwidthMonitor::get_bytes_per_second | ( | void | ) |
Queries the monitor for the current bandwidth utilization per second over the past window.
Definition at line 98 of file BandwidthMonitor.cpp.
size_t madara::transport::BandwidthMonitor::get_number_of_messages | ( | void | ) |
Returns the number of messages in the past window.
Definition at line 130 of file BandwidthMonitor.cpp.
uint64_t madara::transport::BandwidthMonitor::get_utilization | ( | void | ) |
Queries the monitor for the current bandwidth utilization.
Definition at line 88 of file BandwidthMonitor.cpp.
bool madara::transport::BandwidthMonitor::is_bandwidth_violated | ( | int64_t | limit | ) |
Checks send and receive bandwidth against send and receive limits.
limit | if -1, does not check. If positive, checks against current usage |
Definition at line 76 of file BandwidthMonitor.cpp.
void madara::transport::BandwidthMonitor::operator= | ( | const BandwidthMonitor & | rhs | ) |
Assignment operator.
rhs | the value to be copied into this class |
Definition at line 25 of file BandwidthMonitor.cpp.
void madara::transport::BandwidthMonitor::print_utilization | ( | void | ) |
Prints the number of messages and utilization within the past window.
Definition at line 116 of file BandwidthMonitor.cpp.
void madara::transport::BandwidthMonitor::set_window | ( | time_t | window_in_secs | ) |
Sets the window in seconds to measure bandwidth.
window_in_secs | Time window to measure bandwidth usage |
Definition at line 38 of file BandwidthMonitor.cpp.
|
inlineprotected |
Updates utilization for most public functions.
if we have an old message, remove it from utilization and schedule a deletion
Definition at line 8 of file BandwidthMonitor.inl.
|
protected |
Map of timestamps to messages.
Definition at line 132 of file BandwidthMonitor.h.
|
mutableprotected |
Mutex for supporting multithreaded monitor calls.
Definition at line 127 of file BandwidthMonitor.h.
|
protected |
Utilization.
Definition at line 137 of file BandwidthMonitor.h.
|
protected |
Time window for useful messages to bandwidth calculations.
Definition at line 142 of file BandwidthMonitor.h.