AnyCollect  1.1.2
AnyCollect::SnapInterface Class Referencefinal

#include <SnapInterface.h>

Inheritance diagram for AnyCollect::SnapInterface:
Collaboration diagram for AnyCollect::SnapInterface:

Public Member Functions

 SnapInterface ()
 Construct a new Snap Interface object. More...
 
const Plugin::ConfigPolicy get_config_policy () override final
 Returns the plugin configuration keys and default values to Snap. More...
 
std::vector< Plugin::Metric > get_metric_types (Plugin::Config cfg) override final
 Returns all metrics that can be fetched by the plugin to Snap. More...
 
void get_metrics_in (std::vector< Plugin::Metric > &metsIn) override final
 Gets the user's requested metrics from Snap. More...
 
void stream_metrics () override final
 Stream metrics to Snap. More...
 
void contollerCollectedMetrics (const Controller &controller, const std::vector< const Metric *> &metrics) override final
 Function called every time the Controller has collected metrics. More...
 
bool contollerShouldStopCollectingMetrics (const Controller &controller) override final
 Function called after each iteration to ask the delegate whether the controller should stop collecting metrics. More...
 

Static Public Attributes

static constexpr int appVersion = 1
 Snap plugin version. More...
 
static constexpr std::string_view appName = "anycollect"sv
 Snap plugin name. More...
 

Protected Member Functions

void insertAppPrefixToNamespace (std::vector< std::string > &ns)
 Inserts plugin name prefix into Snap namespace. More...
 
void setConfig (const Plugin::Config &cfg)
 Configures the plugin and the controller accordingly, unspecified values are reset to default. More...
 
void formatName (std::vector< std::string > &name)
 Formats a metric name to be compatible with Snap requirements. More...
 
size_t computeNameKey (const Metric &m)
 Computes a key based solely on a metric's name. More...
 
size_t computeNameKey (const Plugin::Metric &m)
 Computes a key based solely on a metric's name. More...
 
Plugin::Metric convertToSnapMetric (const Metric &metric)
 Converts a metric object into a Snap metric object. More...
 

Protected Attributes

AnyCollect::Controller controller_
 Controller used to collect statistics. More...
 
std::map< size_t, Plugin::Metric > metrics_
 Map associating keys to their metric. More...
 
std::set< size_t > requestedMetrics_
 Array of keys of requested metrics. More...
 
std::set< size_t > unwantedMetrics_
 Array of keys of non requested metrics. More...
 
bool sendAllMetrics_
 Whether to send all metrics, regardless of which are requested. More...
 
std::vector< Plugin::Metric * > metricsToSend_
 Array of pointers to Snap metrics to be sent. More...
 

Static Protected Attributes

static constexpr std::array appPrefix = {"cfm"sv, "anycollect"sv}
 Snap metric name prefix. More...
 
static constexpr std::string_view configKeyConfigFile = "ConfigFile"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeySamplingInterval = "SamplingInterval"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeySendAllMetrics = "SendAllMetrics"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyMaxCollectDuration = "MaxCollectDuration"sv
 Snap plugin configuration key. More...
 
static constexpr std::string_view configKeyMaxMetricsBuffer = "MaxMetricsBuffer"sv
 Snap plugin configuration key. More...
 
static constexpr std::array configKeysInt = {configKeySamplingInterval, configKeyMaxCollectDuration, configKeyMaxMetricsBuffer}
 Array of integer-valued configuration keys. More...
 
static constexpr std::array configKeysBool = {configKeySendAllMetrics}
 Array of boolean-valued configuration keys. More...
 
static constexpr bool defaultSendAllMetrics = false
 Snap plugin configuration default value. More...
 
static constexpr std::chrono::seconds defaultMaxCollectDuration = 0s
 Snap plugin configuration default value. More...
 
static constexpr size_t defaultMaxMetricsBuffer = 0
 Snap plugin configuration default value. More...
 
static constexpr std::array< int, configKeysInt.size()> configValuesInt = {AnyCollect::Controller::defaultSamplingInterval.count(), SnapInterface::defaultMaxCollectDuration.count(), SnapInterface::defaultMaxMetricsBuffer}
 Array of integer-valued configuration default values. More...
 
static constexpr std::array< int, configKeysBool.size()> configValuesBool = {SnapInterface::defaultSendAllMetrics}
 Array of boolean-valued configuration default values. More...
 
static std::hash< std::string > hasher {}
 Object used to compute keys (string hashes) More...
 

Detailed Description

Definition at line 36 of file SnapInterface.h.

Constructor & Destructor Documentation

◆ SnapInterface()

AnyCollect::SnapInterface::SnapInterface ( )

Construct a new Snap Interface object.

Definition at line 29 of file SnapInterface.cc.

Member Function Documentation

◆ computeNameKey() [1/2]

size_t AnyCollect::SnapInterface::computeNameKey ( const Metric m)
protected

Computes a key based solely on a metric's name.

Parameters
mthe metric to compute the name key
Returns
the computed name key

Definition at line 87 of file SnapInterface.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeNameKey() [2/2]

size_t AnyCollect::SnapInterface::computeNameKey ( const Plugin::Metric &  m)
protected

Computes a key based solely on a metric's name.

Parameters
mthe Snap metric to compute the name key
Returns
the computed name key

Definition at line 96 of file SnapInterface.cc.

◆ contollerCollectedMetrics()

void AnyCollect::SnapInterface::contollerCollectedMetrics ( const Controller controller,
const std::vector< const Metric *> &  metrics 
)
finaloverridevirtual

Function called every time the Controller has collected metrics.

Parameters
controllerthe calling Controller
metricslatest collected metrics

Implements AnyCollect::ControllerDelegate.

Definition at line 190 of file SnapInterface.cc.

Here is the call graph for this function:

◆ contollerShouldStopCollectingMetrics()

bool AnyCollect::SnapInterface::contollerShouldStopCollectingMetrics ( const Controller controller)
finaloverridevirtual

Function called after each iteration to ask the delegate whether the controller should stop collecting metrics.

Parameters
controllerthe calling Controller
Returns
true if the controller should stop
false otherwise

Implements AnyCollect::ControllerDelegate.

Definition at line 216 of file SnapInterface.cc.

◆ convertToSnapMetric()

Plugin::Metric AnyCollect::SnapInterface::convertToSnapMetric ( const Metric metric)
protected

Converts a metric object into a Snap metric object.

Parameters
metricthe metric to convert
Returns
the converted metric

Definition at line 103 of file SnapInterface.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatName()

void AnyCollect::SnapInterface::formatName ( std::vector< std::string > &  name)
protected

Formats a metric name to be compatible with Snap requirements.

Parameters
namename to format

Definition at line 58 of file SnapInterface.cc.

Here is the caller graph for this function:

◆ get_config_policy()

const Plugin::ConfigPolicy AnyCollect::SnapInterface::get_config_policy ( )
finaloverride

Returns the plugin configuration keys and default values to Snap.

Returns
The plugin default configuration

Definition at line 117 of file SnapInterface.cc.

Here is the call graph for this function:

◆ get_metric_types()

std::vector< Plugin::Metric > AnyCollect::SnapInterface::get_metric_types ( Plugin::Config  cfg)
finaloverride

Returns all metrics that can be fetched by the plugin to Snap.

Parameters
cfgincomming Snap configuration values
Returns
metrics that can be fetched

Definition at line 140 of file SnapInterface.cc.

Here is the call graph for this function:

◆ get_metrics_in()

void AnyCollect::SnapInterface::get_metrics_in ( std::vector< Plugin::Metric > &  metsIn)
finaloverride

Gets the user's requested metrics from Snap.

Parameters
metsInthe user's requested metrics array

Definition at line 156 of file SnapInterface.cc.

Here is the call graph for this function:

◆ insertAppPrefixToNamespace()

void AnyCollect::SnapInterface::insertAppPrefixToNamespace ( std::vector< std::string > &  ns)
protected

Inserts plugin name prefix into Snap namespace.

Parameters
nsSnap namespace to modify

Definition at line 35 of file SnapInterface.cc.

Here is the caller graph for this function:

◆ setConfig()

void AnyCollect::SnapInterface::setConfig ( const Plugin::Config &  cfg)
protected

Configures the plugin and the controller accordingly, unspecified values are reset to default.

Parameters
cfgconfiguration options to use

Definition at line 41 of file SnapInterface.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stream_metrics()

void AnyCollect::SnapInterface::stream_metrics ( )
finaloverride

Stream metrics to Snap.

Definition at line 182 of file SnapInterface.cc.

Here is the call graph for this function:

Member Data Documentation

◆ appName

constexpr std::string_view AnyCollect::SnapInterface::appName = "anycollect"sv
static

Snap plugin name.

Definition at line 39 of file SnapInterface.h.

◆ appPrefix

constexpr std::array AnyCollect::SnapInterface::appPrefix = {"cfm"sv, "anycollect"sv}
staticprotected

Snap metric name prefix.

Definition at line 42 of file SnapInterface.h.

◆ appVersion

constexpr int AnyCollect::SnapInterface::appVersion = 1
static

Snap plugin version.

Definition at line 38 of file SnapInterface.h.

◆ configKeyConfigFile

constexpr std::string_view AnyCollect::SnapInterface::configKeyConfigFile = "ConfigFile"sv
staticprotected

Snap plugin configuration key.

Definition at line 43 of file SnapInterface.h.

◆ configKeyMaxCollectDuration

constexpr std::string_view AnyCollect::SnapInterface::configKeyMaxCollectDuration = "MaxCollectDuration"sv
staticprotected

Snap plugin configuration key.

Definition at line 46 of file SnapInterface.h.

◆ configKeyMaxMetricsBuffer

constexpr std::string_view AnyCollect::SnapInterface::configKeyMaxMetricsBuffer = "MaxMetricsBuffer"sv
staticprotected

Snap plugin configuration key.

Definition at line 47 of file SnapInterface.h.

◆ configKeySamplingInterval

constexpr std::string_view AnyCollect::SnapInterface::configKeySamplingInterval = "SamplingInterval"sv
staticprotected

Snap plugin configuration key.

Definition at line 44 of file SnapInterface.h.

◆ configKeysBool

constexpr std::array AnyCollect::SnapInterface::configKeysBool = {configKeySendAllMetrics}
staticprotected

Array of boolean-valued configuration keys.

Definition at line 49 of file SnapInterface.h.

◆ configKeySendAllMetrics

constexpr std::string_view AnyCollect::SnapInterface::configKeySendAllMetrics = "SendAllMetrics"sv
staticprotected

Snap plugin configuration key.

Definition at line 45 of file SnapInterface.h.

◆ configKeysInt

constexpr std::array AnyCollect::SnapInterface::configKeysInt = {configKeySamplingInterval, configKeyMaxCollectDuration, configKeyMaxMetricsBuffer}
staticprotected

Array of integer-valued configuration keys.

Definition at line 48 of file SnapInterface.h.

◆ configValuesBool

constexpr std::array<int, configKeysBool.size()> AnyCollect::SnapInterface::configValuesBool = {SnapInterface::defaultSendAllMetrics}
staticprotected

Array of boolean-valued configuration default values.

Definition at line 54 of file SnapInterface.h.

◆ configValuesInt

constexpr std::array<int, configKeysInt.size()> AnyCollect::SnapInterface::configValuesInt = {AnyCollect::Controller::defaultSamplingInterval.count(), SnapInterface::defaultMaxCollectDuration.count(), SnapInterface::defaultMaxMetricsBuffer}
staticprotected

Array of integer-valued configuration default values.

Definition at line 53 of file SnapInterface.h.

◆ controller_

AnyCollect::Controller AnyCollect::SnapInterface::controller_
protected

Controller used to collect statistics.

Definition at line 57 of file SnapInterface.h.

◆ defaultMaxCollectDuration

constexpr std::chrono::seconds AnyCollect::SnapInterface::defaultMaxCollectDuration = 0s
staticprotected

Snap plugin configuration default value.

Definition at line 51 of file SnapInterface.h.

◆ defaultMaxMetricsBuffer

constexpr size_t AnyCollect::SnapInterface::defaultMaxMetricsBuffer = 0
staticprotected

Snap plugin configuration default value.

Definition at line 52 of file SnapInterface.h.

◆ defaultSendAllMetrics

constexpr bool AnyCollect::SnapInterface::defaultSendAllMetrics = false
staticprotected

Snap plugin configuration default value.

Definition at line 50 of file SnapInterface.h.

◆ hasher

std::hash< std::string > AnyCollect::SnapInterface::hasher {}
staticprotected

Object used to compute keys (string hashes)

Definition at line 55 of file SnapInterface.h.

◆ metrics_

std::map<size_t, Plugin::Metric> AnyCollect::SnapInterface::metrics_
protected

Map associating keys to their metric.

Definition at line 58 of file SnapInterface.h.

◆ metricsToSend_

std::vector<Plugin::Metric*> AnyCollect::SnapInterface::metricsToSend_
protected

Array of pointers to Snap metrics to be sent.

Definition at line 62 of file SnapInterface.h.

◆ requestedMetrics_

std::set<size_t> AnyCollect::SnapInterface::requestedMetrics_
protected

Array of keys of requested metrics.

Definition at line 59 of file SnapInterface.h.

◆ sendAllMetrics_

bool AnyCollect::SnapInterface::sendAllMetrics_
protected

Whether to send all metrics, regardless of which are requested.

Definition at line 61 of file SnapInterface.h.

◆ unwantedMetrics_

std::set<size_t> AnyCollect::SnapInterface::unwantedMetrics_
protected

Array of keys of non requested metrics.

Definition at line 60 of file SnapInterface.h.


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