XRootD
Loading...
Searching...
No Matches
XrdMonitor Class Reference

#include <XrdMonitor.hh>

+ Collaboration diagram for XrdMonitor:

Classes

struct  RegInfo.Json
 
struct  RegInfo.Xml
 

Public Types

enum  Mopts {
  F_JSON = 0x10000000 ,
  X_PLUG = 0x00000001 ,
  X_ADON = 0x00000002
}
 

Public Member Functions

 XrdMonitor ()
 
 ~XrdMonitor ()
 
int Format (char *buff, int bsize, const char *setName, int opts=0)
 
int Format (char *buff, int bsize, int &item, int opts=0)
 
bool Register (XrdMonRoll::rollType setType, const char *setName, XrdMonRoll::setMember setVec[])
 
bool Registered ()
 

Detailed Description

Definition at line 39 of file XrdMonitor.hh.


Class Documentation

◆ XrdMonitor::RegInfo.Json

struct XrdMonitor::RegInfo.Json

Definition at line 65 of file XrdMonitor.hh.

+ Collaboration diagram for XrdMonitor::RegInfo.Json:
Class Members
char * hdr
vector< char * > key

◆ XrdMonitor::RegInfo.Xml

struct XrdMonitor::RegInfo.Xml

Definition at line 68 of file XrdMonitor.hh.

+ Collaboration diagram for XrdMonitor::RegInfo.Xml:
Class Members
char * hdr
vector< char * > keyBeg
vector< char * > keyEnd

Member Enumeration Documentation

◆ Mopts

Enumerator
F_JSON 
X_PLUG 
X_ADON 

Definition at line 45 of file XrdMonitor.hh.

45{F_JSON = 0x10000000, X_PLUG = 0x00000001, X_ADON = 0x00000002};

Constructor & Destructor Documentation

◆ XrdMonitor()

XrdMonitor::XrdMonitor ( )
inline

Definition at line 56 of file XrdMonitor.hh.

56{}

◆ ~XrdMonitor()

XrdMonitor::~XrdMonitor ( )
inline

Definition at line 57 of file XrdMonitor.hh.

57{}

Member Function Documentation

◆ Format() [1/2]

int XrdMonitor::Format ( char * buff,
int bsize,
const char * setName,
int opts = 0 )

Definition at line 87 of file XrdMonitor.cc.

88{
89// Find the set and format it
90//
91 RegInfo* regInfo = FindSet(setName, opts);
92 if (!regInfo) return 0;
93 if (opts & F_JSON) bsize = FormJSON(*regInfo, buff, bsize);
94 else bsize = FormXML (*regInfo, buff, bsize);
95 return bsize;
96}
struct myOpts opts

References F_JSON, and opts.

◆ Format() [2/2]

int XrdMonitor::Format ( char * buff,
int bsize,
int & item,
int opts = 0 )

Definition at line 64 of file XrdMonitor.cc.

65{
66// Make sure we are in the range of things to format
67//
68 if (item < 0 || item >= (int)regVec.size()) return 0;
69
70// Skip over types that are not wanted
71//
72 while((regVec[item]->setType & opts) == 0)
73 {item++;
74 if (item >= (int)regVec.size()) return 0;
75 }
76
77// Format the item
78//
79 if (opts & F_JSON) bsize = FormJSON(*regVec[item], buff, bsize);
80 else bsize = FormXML (*regVec[item], buff, bsize);
81 item++;
82 return bsize;
83}

References F_JSON, and opts.

◆ Register()

bool XrdMonitor::Register ( XrdMonRoll::rollType setType,
const char * setName,
XrdMonRoll::setMember setVec[] )

Definition at line 163 of file XrdMonitor.cc.

165{ char buff[512];
166 int numE = 0;
167
168// Make sure this map has not been previously defined
169//
170 if (FindSet(setName,-1)) return false;
171
172// Count the number of elements
173//
174 for(int i = 0; setVec[i].varName; i++) numE++;
175 if (!numE) return true;
176
177// Determine type of set
178//
179 int sType;
180 switch(setType)
181 {case XrdMonRoll::AddOn: sType = isAdon; break;
182 case XrdMonRoll::Misc: sType = isAdon; break; // Deprecated
183 case XrdMonRoll::Plugin: sType = isPlug; break;
184 case XrdMonRoll::Protocol: sType = isPlug; break; // Deprecated
185 default: sType = isPlug; break;
186 }
187
188// Allocate a regInfo object
189//
190 RegInfo* regInfo = new RegInfo(setName, sType);
191 regInfo->Json.key.reserve(numE);
192 regInfo->Xml.keyBeg.reserve(numE);
193 regInfo->Xml.keyEnd.reserve(numE);
194 regInfo->keyVal = new RAtomic_uint*[numE]();
195
196// Create the registry
197//
198 for(int i = 0;i < numE; i++)
199 {snprintf(buff, sizeof(buff), ",\"%s\":", setVec[i].varName);
200 regInfo->Json.key.push_back(strdup(buff));
201 snprintf(buff, sizeof(buff), "<%s>", setVec[i].varName);
202 regInfo->Xml.keyBeg.push_back(strdup(buff));
203 snprintf(buff, sizeof(buff), "</%s>", setVec[i].varName);
204 regInfo->Xml.keyEnd.push_back(strdup(buff));
205 regInfo->keyVal[i] = &setVec[i].varValu;
206 }
207 regInfo->Json.key[0]++;
208
209// Complete the registry
210//
211 snprintf(buff, sizeof(buff), "\"stats_%s\":{", setName);
212 regInfo->Json.hdr = strdup(buff);
213 snprintf(buff, sizeof(buff), "<stats id=\"%s\">", setName);
214 regInfo->Xml.hdr = strdup(buff);
215
216// Insert registry into the map
217//
218 regVec.push_back(regInfo);
219
220// Display information
221//
222 char etxt[256];
223 snprintf(etxt, sizeof(etxt), "%s set %s registered with %d variable(s)",
224 (setType == XrdMonRoll::Misc ? "plugin" : "protocol"),setName,numE);
225 Log.Say("Config monitor: ", etxt);
226 return true;
227}
XrdSys::RAtomic< unsigned int > RAtomic_uint
const char * varName
Definition XrdMonRoll.hh:60
RAtomic_uint & varValu
Definition XrdMonRoll.hh:60
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
XrdSysError Log
Definition XrdConfig.cc:113

References XrdMonRoll::AddOn, XrdGlobal::Log, XrdMonRoll::Misc, XrdMonRoll::Plugin, XrdMonRoll::Protocol, XrdMonRoll::setMember::varName, and XrdMonRoll::setMember::varValu.

◆ Registered()

bool XrdMonitor::Registered ( )
inline

Definition at line 54 of file XrdMonitor.hh.

54{return !regVec.empty();}

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