9 : utilization_ (0), window_ (window_in_secs)
28 MADARA_GUARD_TYPE guard (
mutex_);
39 time_t window_in_secs)
41 MADARA_GUARD_TYPE guard (
mutex_);
49 MADARA_GUARD_TYPE guard (
mutex_);
62 time_t timestamp, uint64_t size)
64 MADARA_GUARD_TYPE guard (
mutex_);
90 MADARA_GUARD_TYPE guard (
mutex_);
100 MADARA_GUARD_TYPE guard (
mutex_);
110 MADARA_GUARD_TYPE guard (
mutex_);
119 MADARA_GUARD_TYPE guard (
mutex_);
124 "for %" PRIu64
" bytes over %lld window (%" PRIu64
" B/s)\n",
messages_.size (),
133 MADARA_GUARD_TYPE guard (
mutex_);
void print_utilization(void)
Prints the number of messages and utilization within the past window.
uint64_t get_bytes_per_second(void)
Queries the monitor for the current bandwidth utilization per second over the past window...
MADARA_LOCK_TYPE mutex_
Mutex for supporting multithreaded monitor calls.
bool is_bandwidth_violated(int64_t limit)
Checks send and receive bandwidth against send and receive limits.
time_t update_utilization(void)
Updates utilization for most public functions.
void operator=(const BandwidthMonitor &rhs)
Assignment operator.
MADARA_Export utility::Refcounter< logger::Logger > global_logger
void clear(void)
Clears the bandwidth monitor.
BandwidthMonitor(time_t window_in_secs=10)
Default constructor.
uint64_t get_utilization(void)
Queries the monitor for the current bandwidth utilization.
BandwidthMessages messages_
Map of timestamps to messages.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
size_t get_number_of_messages(void)
Returns the number of messages in the past window.
void add(uint64_t size)
Adds a message to the monitor.
std::pair< time_t, uint64_t > BandwidthRecord
uint64_t utilization_
Utilization.
Provides monitoring capability of a transport's bandwidth.
virtual ~BandwidthMonitor()
Destructor.
void set_window(time_t window_in_secs)
Sets the window in seconds to measure bandwidth.
time_t window_
Time window for useful messages to bandwidth calculations.