Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
NdmcClientService Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-04-10/NovaDAQMonitorClient/cxx/include/NdmcClientService.h"

Public Member Functions

bool isEnabled () const
 
Ganglia_pool_t getGlobalContext () const
 
Ganglia_udp_send_channels_t getSendChannels () const
 

Static Public Member Functions

static NdmcClientServiceinstance ()
 
static std::string getCONFIGFILE ()
 
static void setCONFIGFILE (std::string configfile)
 

Private Member Functions

 NdmcClientService ()
 
virtual ~NdmcClientService ()
 
bool _initGanglia ()
 
 NdmcClientService (const NdmcClientService &)
 
NdmcClientServiceoperator= (const NdmcClientService &)
 

Private Attributes

bool _enabled
 
Ganglia_pool_t _globalContext
 
Ganglia_gmond_config_t _gmondConfig
 
Ganglia_udp_send_channels_t _sendChannels
 

Static Private Attributes

static std::string _CONFIGFILE = "/etc/ganglia/gmond_nova.conf"
 

Detailed Description

NdmcClientService header file

Id
NdmcClientService.h,v 1.4 2017/08/08 20:21:09 dingpf Exp

NdmcClientService

This class implements the NdmcClientService singleton interface to the Ganglia global environment for initiating the Ganglia global context, udp send channels, and gmond configuration. An NdmcClient would use this service for access this Ganglia data, which should be common for all clients on this node.

Author
Susan Kasahara
schubert@physics.umn.edu
Date
May 5 2010

Definition at line 28 of file NdmcClientService.h.

Constructor & Destructor Documentation

NdmcClientService::NdmcClientService ( )
private

Constructor

Definition at line 15 of file NdmcClientService.cpp.

References _enabled, _initGanglia(), allTimeWatchdog::endl, and LOG_DEBUG.

15  : _enabled(false) {
16 
17  LOG_DEBUG("NdmcClientService") << "NdmcClientService::ctor @" << this << std::endl;
18 
19  if ( _initGanglia() ) _enabled = true; // initialize Ganglia
20 
21 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
NdmcClientService::~NdmcClientService ( )
privatevirtual

Destructor

Definition at line 26 of file NdmcClientService.cpp.

References _globalContext, allTimeWatchdog::endl, and LOG_DEBUG.

26  {
27 
28  LOG_DEBUG("NdmcClientService") << "NdmcClientService::dtor @" << this << std::endl;
29 
30  Ganglia_pool_destroy(_globalContext);
31 
32 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
Ganglia_pool_t _globalContext
NdmcClientService::NdmcClientService ( const NdmcClientService )
private

Disabled

Member Function Documentation

bool NdmcClientService::_initGanglia ( )
private

Initialize Ganglia. Return true if success, else false.

Definition at line 47 of file NdmcClientService.cpp.

References _globalContext, _gmondConfig, _sendChannels, allTimeWatchdog::endl, getCONFIGFILE(), LOG_DEBUG, LogError, and LogInfo.

Referenced by NdmcClientService().

47  {
48 
49  // Create the Ganglia global context
50  _globalContext = Ganglia_pool_create(NULL);
51  if ( !_globalContext ) {
52  ::mf::LogError("NdmcClientService")
53  << "NdmcClientService::_initGanglia - Unable to create global context." << std::endl;
54  return false;
55  }
56  else {
57  LOG_DEBUG("NdmcClientService")
58  << "NdmcClientService::_initGanglia - Successfully created global context." << std::endl;
59  }
60 
61  // Parse the configuration file.
62  const char* configFile = getCONFIGFILE().c_str();
63  ::mf::LogInfo("NdmcClientService") << "NdmcClientService::_initGanglia - Using gmond config "
64  << configFile << "." << std::endl;
65  int fall_back_to_default = 0; // use default location for configuration, not.
66  _gmondConfig = Ganglia_gmond_config_create((char*)configFile,fall_back_to_default);
67  if ( !_gmondConfig ) {
68  ::mf::LogError("NdmcClientService") << "NdmcClientService::_initGanglia - Unable to open "
69  << configFile << "." << std::endl;;
70  return false;
71  }
72  else {
73  LOG_DEBUG("NdmcClientService")
74  << "NdmcClientService::_initGanglia - Successfully opened "
75  << configFile << "." << std::endl;
76  }
77 
78  // Build the udp send channels
79  _sendChannels = Ganglia_udp_send_channels_create(_globalContext, _gmondConfig);
80  if ( !_sendChannels ) {
81  ::mf::LogError("NdmcClientService")
82  << "NdmcClientService::_initGanglia - Unable to create ganglia send channels." << std::endl;
83  return false;
84  }
85  else {
86  LOG_DEBUG("NdmcClientService")
87  << "NdmcClientService::_initGanglia - Successfully created ganglia send channels."
88  << std::endl;;
89  }
90 
91  return true;
92 
93 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
Ganglia_udp_send_channels_t _sendChannels
static std::string getCONFIGFILE()
Ganglia_gmond_config_t _gmondConfig
Ganglia_pool_t _globalContext
static std::string NdmcClientService::getCONFIGFILE ( )
inlinestatic

Definition at line 39 of file NdmcClientService.h.

References _CONFIGFILE.

Referenced by _initGanglia().

39 { return _CONFIGFILE; }
static std::string _CONFIGFILE
Ganglia_pool_t NdmcClientService::getGlobalContext ( ) const
inline

Definition at line 46 of file NdmcClientService.h.

References _globalContext.

Referenced by NdmcMetric< T >::NdmcMetric().

46 { return _globalContext; }
Ganglia_pool_t _globalContext
Ganglia_udp_send_channels_t NdmcClientService::getSendChannels ( ) const
inline

Definition at line 47 of file NdmcClientService.h.

References _sendChannels.

Referenced by NdmcMetric< T >::send().

47 { return _sendChannels; }
Ganglia_udp_send_channels_t _sendChannels
NdmcClientService & NdmcClientService::instance ( )
static

Access the singleton instance

Definition at line 37 of file NdmcClientService.cpp.

Referenced by NdmcMetric< T >::NdmcMetric(), NdmcMetric< T >::send(), and NdmcClientServiceTest::testInstance().

37  {
38 
39  static NdmcClientService ndmc;
40  return ndmc;
41 
42 }
bool NdmcClientService::isEnabled ( ) const
inline

Definition at line 45 of file NdmcClientService.h.

References _enabled.

Referenced by NdmcClientServiceTest::testInstance().

45 { return _enabled; }
NdmcClientService& NdmcClientService::operator= ( const NdmcClientService )
private

Disabled

static void NdmcClientService::setCONFIGFILE ( std::string  configfile)
inlinestatic

Definition at line 40 of file NdmcClientService.h.

References _CONFIGFILE.

Referenced by NdmcClientTest::setUp(), NdmcMetricTest::setUp(), and NdmcClientServiceTest::testInstance().

40 { _CONFIGFILE = configfile; }
static std::string _CONFIGFILE

Member Data Documentation

std::string NdmcClientService::_CONFIGFILE = "/etc/ganglia/gmond_nova.conf"
staticprivate

Definition at line 62 of file NdmcClientService.h.

Referenced by getCONFIGFILE(), and setCONFIGFILE().

bool NdmcClientService::_enabled
private

NdmcClientService has been initialized

Definition at line 51 of file NdmcClientService.h.

Referenced by isEnabled(), and NdmcClientService().

Ganglia_pool_t NdmcClientService::_globalContext
private

Ganglia global context

Definition at line 52 of file NdmcClientService.h.

Referenced by _initGanglia(), getGlobalContext(), and ~NdmcClientService().

Ganglia_gmond_config_t NdmcClientService::_gmondConfig
private

Ganglia gmond configuration

Definition at line 53 of file NdmcClientService.h.

Referenced by _initGanglia().

Ganglia_udp_send_channels_t NdmcClientService::_sendChannels
private

Ganglia send channels

Definition at line 54 of file NdmcClientService.h.

Referenced by _initGanglia(), and getSendChannels().


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