MADARA  3.1.8
madara::transport::BandwidthMonitor Class Reference

Provides monitoring capability of a transport's bandwidth. More...

#include <BandwidthMonitor.h>

Collaboration diagram for madara::transport::BandwidthMonitor:

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...
 

Detailed Description

Provides monitoring capability of a transport's bandwidth.

Definition at line 35 of file BandwidthMonitor.h.

Constructor & Destructor Documentation

madara::transport::BandwidthMonitor::BandwidthMonitor ( time_t  window_in_secs = 10)

Default constructor.

Parameters
window_in_secsTime window to measure bandwidth usage

Definition at line 7 of file BandwidthMonitor.cpp.

madara::transport::BandwidthMonitor::BandwidthMonitor ( const BandwidthMonitor rhs)

Copy constructor.

Parameters
rhsthe value to be copied into this class

Definition at line 13 of file BandwidthMonitor.cpp.

madara::transport::BandwidthMonitor::~BandwidthMonitor ( )
virtual

Destructor.

Definition at line 20 of file BandwidthMonitor.cpp.

Member Function Documentation

void madara::transport::BandwidthMonitor::add ( uint64_t  size)

Adds a message to the monitor.

Parameters
sizethe 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.

Parameters
timestampthe time the message occured
sizethe 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.

Returns
current bandwidth utilization in bytes/s

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.

Returns
the number of types that have filters

Definition at line 130 of file BandwidthMonitor.cpp.

uint64_t madara::transport::BandwidthMonitor::get_utilization ( void  )

Queries the monitor for the current bandwidth utilization.

Returns
current bandwidth utilization in bytes over the entire window (this is not bytes/s)

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.

Parameters
limitif -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.

Parameters
rhsthe 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.

Parameters
window_in_secsTime window to measure bandwidth usage

Definition at line 38 of file BandwidthMonitor.cpp.

time_t madara::transport::BandwidthMonitor::update_utilization ( void  )
inlineprotected

Updates utilization for most public functions.

Returns
current time

if we have an old message, remove it from utilization and schedule a deletion

Definition at line 8 of file BandwidthMonitor.inl.

Member Data Documentation

BandwidthMessages madara::transport::BandwidthMonitor::messages_
protected

Map of timestamps to messages.

Definition at line 132 of file BandwidthMonitor.h.

MADARA_LOCK_TYPE madara::transport::BandwidthMonitor::mutex_
mutableprotected

Mutex for supporting multithreaded monitor calls.

Definition at line 127 of file BandwidthMonitor.h.

uint64_t madara::transport::BandwidthMonitor::utilization_
protected

Utilization.

Definition at line 137 of file BandwidthMonitor.h.

time_t madara::transport::BandwidthMonitor::window_
protected

Time window for useful messages to bandwidth calculations.

Definition at line 142 of file BandwidthMonitor.h.


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