0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Hypertable::MetricsCollectorGanglia Class Reference

Ganglia metrics collector. More...

#include <MetricsCollectorGanglia.h>

Inheritance diagram for Hypertable::MetricsCollectorGanglia:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::MetricsCollectorGanglia:
Collaboration graph
[legend]

Public Member Functions

 MetricsCollectorGanglia (const std::string &component, PropertiesPtr &props)
 Constructor. More...
 
 ~MetricsCollectorGanglia ()
 Destructor. More...
 
void update (const std::string &name, const std::string &value) override
 Updates string metric value. More...
 
void update (const std::string &name, int16_t value) override
 Updates short integer metric value. More...
 
void update (const std::string &name, int32_t value) override
 Updates integer metric value. More...
 
void update (const std::string &name, float value) override
 Updates float metric value. More...
 
void update (const std::string &name, double value) override
 Updates double metric value. More...
 
void publish () override
 Publishes metric values to Ganglia hypertable extension. More...
 

Private Member Functions

void connect ()
 Connects to Ganglia hypertable extension receive port. More...
 

Private Attributes

std::mutex m_mutex
 Mutex for serializing access to members More...
 
std::string m_prefix
 Metric name prefix ("ht." + component + ".") More...
 
uint16_t m_port
 Ganglia hypertable extension listen port. More...
 
int m_sd {}
 Datagram send socket. More...
 
std::string m_message
 Persistent string for holding JSON string. More...
 
std::unordered_map
< std::string, std::string > 
m_values_string
 Map holding string metric values. More...
 
std::unordered_map
< std::string, int32_t > 
m_values_int
 Map holding integer metric values. More...
 
std::unordered_map
< std::string, double > 
m_values_double
 Map holding floating point metric values. More...
 
bool m_connected {}
 Flag indicating if socket is connected. More...
 
bool m_disabled {}
 Flag indicating if publishing is disabled. More...
 

Detailed Description

Ganglia metrics collector.

Definition at line 45 of file MetricsCollectorGanglia.h.

Constructor & Destructor Documentation

MetricsCollectorGanglia::MetricsCollectorGanglia ( const std::string &  component,
PropertiesPtr props 
)

Constructor.

Creates a datagram send socket and binds it to an arbitrary interface and ephemeral port. Initializes m_prefix to "ht." + component + ".".

Parameters
componentHypertable component ("fsbroker", "hyperspace, "master", "rangeserver", or "thriftbroker")
propsProperties object

Definition at line 55 of file MetricsCollectorGanglia.cc.

MetricsCollectorGanglia::~MetricsCollectorGanglia ( )

Destructor.

Closes datagram socket (m_sd).

Definition at line 86 of file MetricsCollectorGanglia.cc.

Member Function Documentation

void MetricsCollectorGanglia::connect ( )
private

Connects to Ganglia hypertable extension receive port.

Connects m_sd to "localhost", port m_port. Throws an exception on error, otherwise sets m_connected to true.

Exceptions
Exceptionwith code set to Error::COMM_CONNECT_ERROR

Definition at line 176 of file MetricsCollectorGanglia.cc.

void MetricsCollectorGanglia::publish ( )
overridevirtual

Publishes metric values to Ganglia hypertable extension.

Constructs a JSON object containing the metrics key/value pairs constructed from the m_values_string, m_values_int, and m_values_double maps. The JSON string is sent to the the Ganglia hyperspace extension by sending it in the form of a datagram packet over m_sd.

Implements Hypertable::MetricsCollector.

Definition at line 115 of file MetricsCollectorGanglia.cc.

void MetricsCollectorGanglia::update ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Updates string metric value.

Inserts value into m_values_string map using a key that is formulated as m_prefix + name.

Parameters
nameRelative name of metric
valueMetric value

Implements Hypertable::MetricsCollector.

Definition at line 90 of file MetricsCollectorGanglia.cc.

void MetricsCollectorGanglia::update ( const std::string &  name,
int16_t  value 
)
overridevirtual

Updates short integer metric value.

Inserts value into m_values_int map using a key that is formulated as m_prefix + name.

Parameters
nameRelative name of metric
valueMetric value

Implements Hypertable::MetricsCollector.

Definition at line 95 of file MetricsCollectorGanglia.cc.

void MetricsCollectorGanglia::update ( const std::string &  name,
int32_t  value 
)
overridevirtual

Updates integer metric value.

Inserts value into m_values_int map using a key that is formulated as m_prefix + name.

Parameters
nameRelative name of metric
valueMetric value

Implements Hypertable::MetricsCollector.

Definition at line 100 of file MetricsCollectorGanglia.cc.

void MetricsCollectorGanglia::update ( const std::string &  name,
float  value 
)
overridevirtual

Updates float metric value.

Inserts value into m_values_double map using a key that is formulated as m_prefix + name.

Parameters
nameRelative name of metric
valueMetric value

Implements Hypertable::MetricsCollector.

Definition at line 105 of file MetricsCollectorGanglia.cc.

void MetricsCollectorGanglia::update ( const std::string &  name,
double  value 
)
overridevirtual

Updates double metric value.

Inserts value into m_values_double map using a key that is formulated as m_prefix + name.

Parameters
nameRelative name of metric
valueMetric value

Implements Hypertable::MetricsCollector.

Definition at line 110 of file MetricsCollectorGanglia.cc.

Member Data Documentation

bool Hypertable::MetricsCollectorGanglia::m_connected {}
private

Flag indicating if socket is connected.

Definition at line 137 of file MetricsCollectorGanglia.h.

bool Hypertable::MetricsCollectorGanglia::m_disabled {}
private

Flag indicating if publishing is disabled.

Definition at line 140 of file MetricsCollectorGanglia.h.

std::string Hypertable::MetricsCollectorGanglia::m_message
private

Persistent string for holding JSON string.

Definition at line 125 of file MetricsCollectorGanglia.h.

std::mutex Hypertable::MetricsCollectorGanglia::m_mutex
private

Mutex for serializing access to members

Definition at line 113 of file MetricsCollectorGanglia.h.

uint16_t Hypertable::MetricsCollectorGanglia::m_port
private

Ganglia hypertable extension listen port.

Definition at line 119 of file MetricsCollectorGanglia.h.

std::string Hypertable::MetricsCollectorGanglia::m_prefix
private

Metric name prefix ("ht." + component + ".")

Definition at line 116 of file MetricsCollectorGanglia.h.

int Hypertable::MetricsCollectorGanglia::m_sd {}
private

Datagram send socket.

Definition at line 122 of file MetricsCollectorGanglia.h.

std::unordered_map<std::string, double> Hypertable::MetricsCollectorGanglia::m_values_double
private

Map holding floating point metric values.

Definition at line 134 of file MetricsCollectorGanglia.h.

std::unordered_map<std::string, int32_t> Hypertable::MetricsCollectorGanglia::m_values_int
private

Map holding integer metric values.

Definition at line 131 of file MetricsCollectorGanglia.h.

std::unordered_map<std::string, std::string> Hypertable::MetricsCollectorGanglia::m_values_string
private

Map holding string metric values.

Definition at line 128 of file MetricsCollectorGanglia.h.


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