|
Gaudi Framework, version v21r7 |
| Home | Generated: 22 Jan 2010 |
#include <bking/DataListenerSvc.h>


Public Member Functions | |
| DataListenerSvc (const std::string &name, ISvcLocator *sl) | |
| virtual | ~DataListenerSvc () |
| StatusCode | initialize () |
| StatusCode | finalize () |
| void | declareInfo (const std::string &name, const bool &var, const std::string &desc, const IInterface *owner) |
| Declare monitoring information. | |
| void | declareInfo (const std::string &name, const int &var, const std::string &desc, const IInterface *owner) |
| void | declareInfo (const std::string &name, const long &var, const std::string &desc, const IInterface *owner) |
| void | declareInfo (const std::string &name, const double &var, const std::string &desc, const IInterface *owner) |
| void | declareInfo (const std::string &name, const std::string &var, const std::string &desc, const IInterface *owner) |
| void | declareInfo (const std::string &name, const std::pair< double, double > &var, const std::string &desc, const IInterface *owner) |
| void | declareInfo (const std::string &name, const AIDA::IBaseHistogram *var, const std::string &desc, const IInterface *owner) |
| void | declareInfo (const std::string &name, const StatEntity &var, const std::string &desc, const IInterface *owner) |
| void | declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc, const IInterface *owner) |
| void | undeclareInfo (const std::string &name, const IInterface *owner) |
| Undeclare monitoring information. | |
| void | undeclareAll (const IInterface *owner) |
| Undeclare monitoring information. | |
| virtual void | handle (const Incident &) |
| Implementation of the IIncidentListener.h virtual method. | |
| std::set< std::string > * | getInfos (const IInterface *owner=0) |
| Get the names for all declared monitoring informations for a given owner. | |
| void | apmSend (char *clusterName, char *moduleName, char *key, double val) |
| Send (key,value) pairs to MonALISA server. | |
| void | apmSend (char *clusterName, char *moduleName, char *key, int val) |
| Send a (char*,int) pair to MonALISA. | |
| void | apmSend (char *clusterName, char *moduleName, char *key, long val) |
| Send a (char*,long) pair to MonALISA. | |
| void | apmSend (char *clusterName, char *moduleName, char *key, bool val) |
| Send a (char*,bool) pair to MonALISA. | |
| void | apmSend (char *clusterName, char *moduleName, char *key, char *val) |
| Send a (char*,char*) pair to MonALISA. | |
Private Types | |
| typedef std::pair< std::string, ValueMap > | Entry |
| typedef std::map< const IInterface *, std::set < std::string > > | InfoNamesMap |
| typedef std::map< std::string, ValueMap > | ValNamesMap |
Private Member Functions | |
| void | writeMap (ValNamesMap *, const Incident &, std::ofstream *) |
| void | writeXML (ValNamesMap *, const Incident &, std::ofstream *) |
| std::string | resizeString (const std::string, const unsigned int) |
| std::string | stringConverter (const int convertee) |
| std::string | stringConverter (const double convertee) |
| std::string | stringConverter (const bool convertee) |
| std::string | stringConverter (const long convertee) |
| void | sendData (ValNamesMap *) |
| MonALISA sender method to send Data to MonALISA server. | |
| std::string | infoOwnerName (const IInterface *owner) |
Private Attributes | |
| ApMon * | apm |
| ValueMap | m_ValueMap |
| ValueMap | m_ValueMapTemp |
| time_t | rawTime |
| time_t | rawTime2 |
| char | buffer [50] |
| char | buffer2 [50] |
| std::string | timeDate |
| std::string | timeDate2 |
| std::string | valToWrite |
| InfoNamesMap | m_InfoNamesMap |
| InfoNamesMap::iterator | m_InfoNamesMapIt |
| ValNamesMap | m_ValNamesMap |
| ValNamesMap::iterator | m_ValNamesMapIt |
| XmlCode | xml |
| IIncidentSvc * | m_incidentSvc |
| FILE * | MonitorLog |
| std::ofstream | Log4 |
| std::ofstream | XMLLog |
| int | FreqCriterion |
| int | m_EventFrequency |
| std::map< std::string, std::string > | m_infoDescriptions |
| int | m_MLjobID |
| int | m_MLEventFrequency |
| std::string | m_MLClusterName |
| std::string | m_ApMonSettingsFile |
| std::string | jobIDString |
| int | m_MonALISAMonitoring |
| int | m_XMLMonitoring |
| int | m_FileMonitoring |
| char * | keyToSend |
DataListenerSvc generates XML files on the individual machines where the algorithm is run, which can then be parsed by e.g. GANGA and sent to a monitoring server such as MonALISA. XML files are written at a frequency specified by the user and are consumed as they are created when used within GANGA.
Usage
include DataListenerSvc/DataListenerSvc.h IMonitorSvc *m_DataListenerSvcSvc; sc = service("DataListenerSvc", m_DataListenerSvcSvc, true); m_DataListenerSvcSvc->declareInfo("Psi ID", m_jPsiID, "The Psi ID", this); (for variable m_jPsiID) int, long, bool, double, string
DataListenerSvc DataListenerSvc/DataListenerSvc DataListenerSvc.EventFrequency = 50 | EventFrequency | How data is sent to - default is every 100 events |
Opening parent tags of the form:
<?xml version="1.0" encoding="ASCII" standalone="yes"?>
<Results Time="Tue Aug 22 10:17:22 2006">
<Run> |
With then an entry for each monitored variable of the form:
<Incident> | ||
<IncType>EndEvent </IncType> <IncSource>EventLoopMgr </IncSource> <VarName>Psi ID </VarName> <Value Result="8">443</Value> | ||
</Incident> |
| IncType | What type of incident triggered the handle method | |
| IncSource | What triggered the IIncident handle method | |
| VarName | Name of the variable monitored | |
| Value | Value of the variable | |
| Result | Number of times the variable already read |
Definition at line 112 of file DataListenerSvc.h.
typedef std::pair< std::string, ValueMap > DataListenerSvc::Entry [private] |
Definition at line 213 of file DataListenerSvc.h.
typedef std::map<const IInterface*, std::set<std::string> > DataListenerSvc::InfoNamesMap [private] |
Definition at line 214 of file DataListenerSvc.h.
typedef std::map< std::string, ValueMap > DataListenerSvc::ValNamesMap [private] |
Definition at line 216 of file DataListenerSvc.h.
| DataListenerSvc::DataListenerSvc | ( | const std::string & | name, | |
| ISvcLocator * | sl | |||
| ) |
Definition at line 59 of file DataListenerSvc.cpp.
00060 : base_class(name, sl) { 00061 00062 declareProperty ("EventFrequency", m_EventFrequency=defaultFrequency); 00063 declareProperty ("MLEventFrequency", m_MLEventFrequency=defaultMLFrequency); 00064 declareProperty ("MLjobID", m_MLjobID=defaultjobID); 00065 declareProperty ("MLClusterName", m_MLClusterName=defaultClusterName); 00066 declareProperty ("MonALISAMonitoring", m_MonALISAMonitoring=defaultMonALISAMonitoring); 00067 declareProperty ("ApMonSource", m_ApMonSettingsFile=defaultApMonSettingsFile); 00068 00069 declareProperty ("XMLMonitoring", m_XMLMonitoring=defaultXMLMonitoring); 00070 declareProperty ("FileMonitoring", m_FileMonitoring=defaultFileMonitoring); 00071 00072 }
| virtual DataListenerSvc::~DataListenerSvc | ( | ) | [inline, virtual] |
| StatusCode DataListenerSvc::initialize | ( | ) | [virtual] |
Reimplemented from Service.
Definition at line 75 of file DataListenerSvc.cpp.
00076 { 00077 00078 m_ApMonSettingsFile = defaultApMonSettingsFile; 00079 StatusCode sc = Service::initialize(); 00080 MsgStream msg(msgSvc(),name()); 00081 00082 jobIDString = "jobID: " + stringConverter(m_MLjobID); 00083 00084 if ( !sc.isSuccess() ) { 00085 msg << MSG::ERROR << "Failed to initialize Service base class." << endmsg; 00086 return StatusCode::FAILURE; 00087 } 00088 00089 sc = service("IncidentSvc", m_incidentSvc, true); 00090 if (!sc.isSuccess()) { 00091 msg << MSG::ERROR << "Failed to access incident service." << endmsg; 00092 return StatusCode::FAILURE; 00093 } 00094 m_incidentSvc->addListener(this, IncidentType::EndEvent); 00095 00096 if (m_MonALISAMonitoring){ 00097 // Initialise MonALISA 00098 apm = new ApMon(const_cast<char*>(m_ApMonSettingsFile.c_str())); 00099 } 00100 00101 // DEBUG info on job options specified in GAUDI 00102 if (m_MLEventFrequency == defaultMLFrequency) { 00103 msg << MSG::DEBUG 00104 << "Frequency to send data to MonALISA not specified, taken as the default value: " 00105 << defaultMLFrequency << endmsg; 00106 } else { 00107 msg << MSG::INFO 00108 << "Data sent to MonALISA every " 00109 << m_MLEventFrequency << " events" << endmsg; 00110 } 00111 00112 if (m_MLjobID == defaultjobID){ 00113 msg << MSG::DEBUG 00114 << "DataListenerSvc MonALISA Job ID not specified, taken as the default value: " 00115 << defaultjobID << endmsg; 00116 } 00117 00118 if (m_MLClusterName == defaultClusterName){ 00119 msg << MSG::DEBUG 00120 << "DataListenerSvc MonALISA cluster name not specified, taken as the default value: " 00121 << defaultClusterName << endmsg; 00122 } 00123 00124 if (m_ApMonSettingsFile == defaultApMonSettingsFile){ 00125 msg << MSG::DEBUG 00126 << "MonALISA ApMon configuration file destination not specified, will be read from: " 00127 << defaultClusterName << endmsg; 00128 } 00129 00130 if (m_EventFrequency == defaultFrequency){ 00131 msg << MSG::INFO 00132 << "XML Log file frequency not specified, taken as the default value: " 00133 << defaultFrequency << endmsg; 00134 } else { 00135 msg << MSG::INFO 00136 << "Frequency XML logs are written at: " 00137 << m_EventFrequency << endmsg; 00138 } 00139 00140 if (m_MonALISAMonitoring) { 00141 msg << MSG::INFO 00142 << "Data will be published to a MonALISA server" 00143 << endmsg; 00144 } 00145 00146 if (m_XMLMonitoring) { 00147 msg << MSG::INFO 00148 << "Data will be written to XML log files" 00149 << endmsg; 00150 } 00151 if (m_FileMonitoring) { 00152 msg << MSG::INFO 00153 << "Data will be updated in a Text log file" 00154 << endmsg; 00155 } 00156 00157 return StatusCode::SUCCESS; 00158 }
| StatusCode DataListenerSvc::finalize | ( | void | ) | [virtual] |
Reimplemented from Service.
Definition at line 161 of file DataListenerSvc.cpp.
00162 { 00163 MsgStream msg(msgSvc(),"DataListenerSvc"); 00164 00165 m_infoDescriptions.clear(); 00166 m_ValNamesMap.clear(); 00167 00168 if (m_MonALISAMonitoring){ 00169 if ( 0!= apm ) { 00170 delete apm; 00171 apm = 0 ; 00172 } 00173 } 00174 00175 msg << MSG::DEBUG << "ApMon deleted" << endmsg; 00176 msg << MSG::INFO << "finalized successfully" << endmsg; 00177 00178 if( m_incidentSvc ) m_incidentSvc->release(); 00179 00180 return Service::finalize(); 00181 }
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const bool & | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
Declare monitoring information.
| name | Monitoring information name known to the external system | |
| var | Monitoring Listener address | |
| desc | Textual description | |
| owner | Owner identifier of the monitoring information (needed to perform clean up |
Definition at line 241 of file DataListenerSvc.cpp.
00244 { 00245 00246 ValueMap::m_type vartype; 00247 vartype = ValueMap::m_bool; 00248 00249 MsgStream msg(msgSvc(),"DataListenerSvc"); 00250 00251 m_ValueMap.set_ptr( static_cast <void*> (const_cast <bool*> (&var) ) ); 00252 m_ValueMap.set_ptrType(vartype); 00253 00254 Entry p1(name, m_ValueMap); 00255 00256 m_ValNamesMap.insert(p1); 00257 00258 }
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const int & | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
Definition at line 223 of file DataListenerSvc.cpp.
00226 { 00227 ValueMap::m_type vartype; 00228 vartype = ValueMap::m_int; 00229 00230 MsgStream msg(msgSvc(),"DataListenerSvc"); 00231 00232 m_ValueMap.set_ptr( static_cast <void*> (const_cast <int*> (&var) ) ); 00233 m_ValueMap.set_ptrType(vartype); 00234 00235 Entry p1(name, m_ValueMap); 00236 00237 m_ValNamesMap.insert(p1); 00238 00239 }
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const long & | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
Definition at line 204 of file DataListenerSvc.cpp.
00207 { 00208 00209 ValueMap::m_type vartype; 00210 vartype = ValueMap::m_long; 00211 00212 MsgStream msg(msgSvc(),"DataListenerSvc"); 00213 00214 m_ValueMap.set_ptr( static_cast <void*> (const_cast <long*> (&var) ) ); 00215 m_ValueMap.set_ptrType(vartype); 00216 00217 Entry p1(name, m_ValueMap); 00218 00219 m_ValNamesMap.insert(p1); 00220 00221 }
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const double & | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
Definition at line 183 of file DataListenerSvc.cpp.
00186 { 00187 ValueMap::m_type vartype; 00188 vartype = ValueMap::m_double; 00189 00190 MsgStream msg(msgSvc(),"DataListenerSvc"); 00191 00192 // In the ValueMap, store the pointer to the data (converted to void*) 00193 // and also store the pointer type (with an enum) so it can be converted back 00194 m_ValueMap.set_ptr( static_cast <void*> (const_cast <double*> (&var) ) ); 00195 m_ValueMap.set_ptrType(vartype); 00196 00197 Entry p1(name, m_ValueMap); 00198 00199 // m_ValNamesMap is then composed of n (variable Name: ValueMap) pairs 00200 m_ValNamesMap.insert(p1); 00201 00202 }
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const std::string & | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
Definition at line 260 of file DataListenerSvc.cpp.
00264 { 00265 ValueMap::m_type vartype; 00266 vartype = ValueMap::m_string; 00267 00268 MsgStream msg(msgSvc(),"DataListenerSvc"); 00269 00270 m_ValueMap.set_ptr( static_cast <void*> (const_cast <std::string*> (&var) ) ); m_ValueMap.set_ptrType(vartype); 00271 00272 Entry p1(name, m_ValueMap); 00273 00274 m_ValNamesMap.insert(p1); 00275 00276 }
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const std::pair< double, double > & | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const AIDA::IBaseHistogram * | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const StatEntity & | var, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
| void DataListenerSvc::declareInfo | ( | const std::string & | name, | |
| const std::string & | format, | |||
| const void * | var, | |||
| int | size, | |||
| const std::string & | desc, | |||
| const IInterface * | owner | |||
| ) |
| void DataListenerSvc::undeclareInfo | ( | const std::string & | name, | |
| const IInterface * | owner | |||
| ) |
Undeclare monitoring information.
| name | Monitoring information name known to the external system | |
| owner | Owner identifier of the monitoring information |
Definition at line 308 of file DataListenerSvc.cpp.
| void DataListenerSvc::undeclareAll | ( | const IInterface * | owner | ) |
Undeclare monitoring information.
| owner | Owner identifier of the monitoring information |
Definition at line 313 of file DataListenerSvc.cpp.
| void DataListenerSvc::handle | ( | const Incident & | Inc | ) | [virtual] |
Implementation of the IIncidentListener.h virtual method.
Definition at line 329 of file DataListenerSvc.cpp.
00330 { 00331 00332 MsgStream msg(msgSvc(),"DataListenerSvc"); 00333 numIncidents++; 00334 00335 00336 if (numIncidents % m_EventFrequency == 0){ 00337 00338 try { 00339 Log4.open("MonitorLog.txt", std::ios::trunc); 00340 XMLLog.open(("./log" + stringConverter(fileCounter) + ".xml").c_str() , std::ios::trunc); 00341 } catch(std::exception /*&e*/) { 00342 msg << MSG::INFO 00343 << "Log File could not be opened, no monitoring available" 00344 << endmsg; 00345 } 00346 00347 if (m_MonALISAMonitoring){ 00348 // Send Data to MonALISA 00349 sendData(&m_ValNamesMap); 00350 } 00351 00352 if (m_FileMonitoring){ 00353 // Write simple text log 00354 writeMap(&m_ValNamesMap, Inc, &Log4 ); 00355 Log4.close(); 00356 } 00357 00358 if (m_XMLMonitoring){ 00359 // Write XML files 00360 writeXML(&m_ValNamesMap, Inc, &XMLLog ); 00361 XMLLog.close(); 00362 } 00363 00364 fileCounter++; 00365 } 00366 00367 }
| std::set< std::string > * DataListenerSvc::getInfos | ( | const IInterface * | owner = 0 |
) |
Get the names for all declared monitoring informations for a given owner.
If the owner is NULL, then it returns for all owners
Definition at line 317 of file DataListenerSvc.cpp.
00318 { 00319 std::set<std::string> * returnData = NULL; 00320 return returnData; 00321 }
| void DataListenerSvc::apmSend | ( | char * | clusterName, | |
| char * | moduleName, | |||
| char * | key, | |||
| double | val | |||
| ) |
Send (key,value) pairs to MonALISA server.
| clusterName | Name of cluster where information will be stored | |
| moduleName | Name of module where information will be stored | |
| key | Key of the (key,value) pair sent to MonALISA | |
| value | Value of the (key,value) pair sent to MonALISA Send a (char*,double) pair to MonALISA |
Definition at line 608 of file DataListenerSvc.cpp.
00610 { 00611 MsgStream msg(msgSvc(),"DataListenerSvc"); 00612 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00613 00614 try { 00615 DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val); 00616 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00617 msg << MSG::INFO << "Sent parameters to MonALISA sever:" 00618 << m_MLClusterName << "->" 00619 << jobIDString.c_str() << "->" 00620 << key << ":" << val << endmsg; 00621 } catch(std::runtime_error &e) { 00622 msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endmsg; 00623 } 00624 }
| void DataListenerSvc::apmSend | ( | char * | clusterName, | |
| char * | moduleName, | |||
| char * | key, | |||
| int | val | |||
| ) |
Send a (char*,int) pair to MonALISA.
Definition at line 626 of file DataListenerSvc.cpp.
00628 { 00629 MsgStream msg(msgSvc(),"DataListenerSvc"); 00630 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00631 try { 00632 DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val); 00633 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00634 msg << MSG::INFO << "Sent parameters to MonALISA sever:" 00635 << m_MLClusterName << "->" 00636 << jobIDString.c_str() << "->" 00637 << key << ":" << val << endmsg; 00638 } catch(std::runtime_error &e) { 00639 msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endmsg; 00640 } 00641 }
| void DataListenerSvc::apmSend | ( | char * | clusterName, | |
| char * | moduleName, | |||
| char * | key, | |||
| long | val | |||
| ) |
Send a (char*,long) pair to MonALISA.
Definition at line 643 of file DataListenerSvc.cpp.
00645 { 00646 MsgStream msg(msgSvc(),"DataListenerSvc"); 00647 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00648 double temp; 00649 temp = *(double*)val; 00650 00651 try { 00652 DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, temp); 00653 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00654 msg << MSG::INFO << "Sent parameters to MonALISA sever:" 00655 << m_MLClusterName << "->" 00656 << jobIDString.c_str() << "->" 00657 << key << ":" << val << endmsg; 00658 } catch (std::runtime_error &e){ 00659 msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endmsg; 00660 } 00661 }
| void DataListenerSvc::apmSend | ( | char * | clusterName, | |
| char * | moduleName, | |||
| char * | key, | |||
| bool | val | |||
| ) |
Send a (char*,bool) pair to MonALISA.
Definition at line 663 of file DataListenerSvc.cpp.
00665 { 00666 MsgStream msg(msgSvc(),"DataListenerSvc"); 00667 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00668 try { 00669 DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val); 00670 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00671 msg << MSG::INFO << "Sent parameters to MonALISA sever:" 00672 << m_MLClusterName << "->" 00673 << jobIDString.c_str() << "->" 00674 << key << ":" << val << endmsg; 00675 } catch (std::runtime_error &e){ 00676 msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endmsg; 00677 } 00678 }
| void DataListenerSvc::apmSend | ( | char * | clusterName, | |
| char * | moduleName, | |||
| char * | key, | |||
| char * | val | |||
| ) |
Send a (char*,char*) pair to MonALISA.
Definition at line 680 of file DataListenerSvc.cpp.
00682 { 00683 MsgStream msg(msgSvc(),"DataListenerSvc"); 00684 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00685 try { 00686 DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val); 00687 msg << MSG::DEBUG << "ApMon instantiated" << endmsg; 00688 msg << MSG::INFO << "Sent parameters to MonALISA sever:" 00689 << m_MLClusterName << "->" 00690 << jobIDString.c_str() << "->" 00691 << key << ":" << val << endmsg; 00692 } catch (std::runtime_error &e){ 00693 msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endmsg; 00694 } 00695 }
| void DataListenerSvc::writeMap | ( | ValNamesMap * | m_ValNamesMap, | |
| const Incident & | Inc, | |||
| std::ofstream * | MyFile | |||
| ) | [private] |
Definition at line 514 of file DataListenerSvc.cpp.
00516 { 00517 // prepare time ctime.h and remove trailing carriage return 00518 time ( &rawTime2 ); 00519 sprintf (buffer2, "%s", ctime(&rawTime2)); 00520 timeDate2 = buffer2; 00521 timeDate2.erase(timeDate2.size()-1, 1); 00522 00523 // headings for the text file with spacing numbers 00524 std::string space = " "; 00525 std::string heading0 = "Time "; // 27 00526 std::string heading1 = "No "; // 8 chars long 00527 std::string heading2 = "Incident Type "; // 18 00528 std::string heading3 = "Incident Source "; // 18 00529 std::string heading4 = "Name "; // 16 00530 std::string heading5 = "Value "; // 20 00531 00532 *MyFile << heading0 + heading1 + heading2 + heading3 + heading4 + heading5 00533 << std::endl; 00534 00535 for (m_ValNamesMapIt = m_ValNamesMap->begin(); 00536 m_ValNamesMapIt != m_ValNamesMap->end(); 00537 ++m_ValNamesMapIt){ 00538 00539 m_ValueMapTemp = m_ValNamesMapIt->second; 00540 00541 *MyFile << timeDate2 << space 00542 00543 << resizeString(stringConverter(numIncidents),8) // Counts # incidents 00544 << resizeString(Inc.type(),18) // Incident Type 00545 << resizeString(Inc.source(),18) // Source of the Incident 00546 << resizeString(m_ValNamesMapIt->first,20); // Variable Name 00547 00548 // Check the variable type and in each case, cast accordingly 00549 if (m_ValueMapTemp.get_ptrType() == ValueMap::m_double){ 00550 *MyFile << resizeString(stringConverter(*(double*)m_ValueMapTemp.get_ptr()), 12) 00551 << std::endl; 00552 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_int){ 00553 *MyFile << resizeString(stringConverter(*(int*)m_ValueMapTemp.get_ptr()), 12) 00554 << std::endl; 00555 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_long){ 00556 *MyFile << resizeString(stringConverter(*(long*)m_ValueMapTemp.get_ptr()), 12) 00557 << std::endl; 00558 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_bool){ 00559 *MyFile << resizeString(stringConverter(*(bool*)m_ValueMapTemp.get_ptr()), 12) 00560 << std::endl; 00561 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_string){ 00562 *MyFile << resizeString((*(std::string*)m_ValueMapTemp.get_ptr()), 12) 00563 << std::endl; 00564 } 00565 00566 } 00567 00568 }
| void DataListenerSvc::writeXML | ( | ValNamesMap * | m_ValNamesMap, | |
| const Incident & | Inc, | |||
| std::ofstream * | MyFile | |||
| ) | [private] |
Definition at line 435 of file DataListenerSvc.cpp.
00438 { 00439 00440 MsgStream msg(msgSvc(),"DataListenerSvc"); 00441 00442 // prepare time ctime.h and remove trailing carriage return 00443 time ( &rawTime ); 00444 sprintf (buffer, "%s", ctime(&rawTime)); 00445 timeDate = buffer; 00446 timeDate.erase(timeDate.size()-1, 1); 00447 00448 00449 msg << MSG::INFO << "XML written to file: " << MyFile << endmsg; 00450 00451 00452 *MyFile << xml.declaration("1.0", "ASCII", "yes") << std::endl; 00453 00454 *MyFile << xml.tagBegin("Results", 0, "Time", timeDate) 00455 << xml.tagBegin("Run",1); 00456 00457 00458 for (m_ValNamesMapIt = m_ValNamesMap->begin(); 00459 m_ValNamesMapIt != m_ValNamesMap->end(); 00460 ++m_ValNamesMapIt) { 00461 00462 m_ValueMapTemp = m_ValNamesMapIt->second; 00463 00464 *MyFile << xml.tagBegin("Incident",2); 00465 00466 *MyFile << xml.tagBegin("IncType", 3) 00467 << xml.data(resizeString(Inc.type(),18)) 00468 << xml.tagEnd("IncType", 0); 00469 00470 *MyFile << xml.tagBegin("IncSource", 3) 00471 << xml.data(resizeString(Inc.source(),18)) 00472 << xml.tagEnd("IncSource", 0); 00473 00474 *MyFile << xml.tagBegin("VarName", 3) 00475 << xml.data(resizeString(m_ValNamesMapIt->first,20)) 00476 << xml.tagEnd("VarName", 0); 00477 00478 *MyFile << xml.tagBegin("Value", 3, "Result", stringConverter(numIncidents)); 00479 // Check the variable type and in each case, cast accordingly 00480 00481 00482 00483 // re-convert pointers to their original form and then to strings 00484 // so that they can be written with XMLCode.h 00485 if (m_ValueMapTemp.get_ptrType() == ValueMap::m_double){ 00486 valToWrite = stringConverter(*(double*)m_ValueMapTemp.get_ptr()); 00487 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_int){ 00488 valToWrite = stringConverter(*(int*)m_ValueMapTemp.get_ptr()); 00489 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_long){ 00490 valToWrite = stringConverter(*(long*)m_ValueMapTemp.get_ptr()); 00491 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_bool){ 00492 valToWrite = stringConverter(*(bool*)m_ValueMapTemp.get_ptr()); 00493 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_string){ 00494 valToWrite = *(std::string*)m_ValueMapTemp.get_ptr(); 00495 } 00496 00497 00498 *MyFile << xml.data(valToWrite); 00499 msg << MSG::DEBUG << "XML written: " << m_ValNamesMapIt->first << " , " 00500 << valToWrite << endmsg; 00501 00502 *MyFile << xml.tagEnd("Value", 0); 00503 *MyFile << xml.tagEnd("Incident",2); 00504 } 00505 00506 00507 *MyFile << xml.tagEnd("Run",1) 00508 << xml.tagEnd("Results", 0); 00509 00510 }
| std::string DataListenerSvc::resizeString | ( | const std::string | text, | |
| const unsigned int | length | |||
| ) | [private] |
Definition at line 370 of file DataListenerSvc.cpp.
00372 { 00373 std::string temp; 00374 unsigned int counter=0; 00375 00376 do { 00377 00378 if (text.length() > length) { 00379 temp = text.substr(0,(length-1)); 00380 } else { 00381 if (counter==0) { 00382 temp = text; 00383 counter++; 00384 } 00385 temp.append(" "); 00386 } 00387 00388 } while (temp.length() != length); 00389 00390 return temp; 00391 }
| std::string DataListenerSvc::stringConverter | ( | const int | convertee | ) | [private] |
Definition at line 394 of file DataListenerSvc.cpp.
00395 { 00396 std::stringstream s; 00397 std::string temp; 00398 s << convertee; 00399 s >> temp; 00400 s.flush(); 00401 return temp; 00402 }
| std::string DataListenerSvc::stringConverter | ( | const double | convertee | ) | [private] |
Definition at line 404 of file DataListenerSvc.cpp.
00405 { 00406 std::stringstream s; 00407 std::string temp; 00408 s << convertee; 00409 s >> temp; 00410 s.flush(); 00411 return temp; 00412 }
| std::string DataListenerSvc::stringConverter | ( | const bool | convertee | ) | [private] |
Definition at line 424 of file DataListenerSvc.cpp.
00425 { 00426 std::stringstream s; 00427 std::string temp; 00428 s << convertee; 00429 s >> temp; 00430 s.flush(); 00431 return temp; 00432 }
| std::string DataListenerSvc::stringConverter | ( | const long | convertee | ) | [private] |
Definition at line 414 of file DataListenerSvc.cpp.
00415 { 00416 std::stringstream s; 00417 std::string temp; 00418 s << convertee; 00419 s >> temp; 00420 s.flush(); 00421 return temp; 00422 }
| void DataListenerSvc::sendData | ( | ValNamesMap * | m_ValNamesMap | ) | [private] |
MonALISA sender method to send Data to MonALISA server.
Definition at line 571 of file DataListenerSvc.cpp.
00572 { 00573 00574 for (m_ValNamesMapIt = m_ValNamesMap->begin(); 00575 m_ValNamesMapIt != m_ValNamesMap->end(); 00576 ++m_ValNamesMapIt){ 00577 00578 m_ValueMapTemp = m_ValNamesMapIt->second; 00579 keyToSend = const_cast<char*>((m_ValNamesMapIt->first).c_str()); 00580 00581 00582 if (m_ValueMapTemp.get_ptrType() == ValueMap::m_double){ 00583 apmSend(const_cast <char*>(m_MLClusterName.c_str()), 00584 const_cast <char*> (jobIDString.c_str()), 00585 keyToSend, *(double*)m_ValueMapTemp.get_ptr()); 00586 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_int){ 00587 apmSend(const_cast <char*>(m_MLClusterName.c_str()), 00588 const_cast <char*> (jobIDString.c_str()), 00589 keyToSend, *(int*)m_ValueMapTemp.get_ptr()); 00590 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_long){ 00591 apmSend(const_cast <char*>(m_MLClusterName.c_str()), 00592 const_cast <char*> (jobIDString.c_str()), 00593 keyToSend, *(long*)m_ValueMapTemp.get_ptr()); 00594 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_bool){ 00595 apmSend(const_cast <char*>(m_MLClusterName.c_str()), 00596 const_cast <char*> (jobIDString.c_str()), 00597 keyToSend, *(bool*)m_ValueMapTemp.get_ptr()); 00598 } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_string){ 00599 apmSend(const_cast <char*>(m_MLClusterName.c_str()), 00600 const_cast <char*> (jobIDString.c_str()), 00601 keyToSend, const_cast <char*>((*(std::string*)m_ValueMapTemp.get_ptr()).c_str())); 00602 } 00603 } 00604 00605 }
| std::string DataListenerSvc::infoOwnerName | ( | const IInterface * | owner | ) | [private] |
Definition at line 323 of file DataListenerSvc.cpp.
00324 { 00325 std::string returnData = ""; 00326 return returnData; 00327 }
ApMon* DataListenerSvc::apm [private] |
Definition at line 195 of file DataListenerSvc.h.
ValueMap DataListenerSvc::m_ValueMap [private] |
Definition at line 199 of file DataListenerSvc.h.
ValueMap DataListenerSvc::m_ValueMapTemp [private] |
Definition at line 200 of file DataListenerSvc.h.
time_t DataListenerSvc::rawTime [private] |
Definition at line 202 of file DataListenerSvc.h.
time_t DataListenerSvc::rawTime2 [private] |
Definition at line 203 of file DataListenerSvc.h.
char DataListenerSvc::buffer[50] [private] |
Definition at line 205 of file DataListenerSvc.h.
char DataListenerSvc::buffer2[50] [private] |
Definition at line 206 of file DataListenerSvc.h.
std::string DataListenerSvc::timeDate [private] |
Definition at line 207 of file DataListenerSvc.h.
std::string DataListenerSvc::timeDate2 [private] |
Definition at line 208 of file DataListenerSvc.h.
std::string DataListenerSvc::valToWrite [private] |
Definition at line 209 of file DataListenerSvc.h.
InfoNamesMap DataListenerSvc::m_InfoNamesMap [private] |
Definition at line 230 of file DataListenerSvc.h.
Definition at line 231 of file DataListenerSvc.h.
ValNamesMap DataListenerSvc::m_ValNamesMap [private] |
Definition at line 233 of file DataListenerSvc.h.
Definition at line 234 of file DataListenerSvc.h.
XmlCode DataListenerSvc::xml [private] |
Definition at line 235 of file DataListenerSvc.h.
IIncidentSvc* DataListenerSvc::m_incidentSvc [private] |
Definition at line 240 of file DataListenerSvc.h.
FILE* DataListenerSvc::MonitorLog [private] |
Definition at line 241 of file DataListenerSvc.h.
std::ofstream DataListenerSvc::Log4 [private] |
Definition at line 242 of file DataListenerSvc.h.
std::ofstream DataListenerSvc::XMLLog [private] |
Definition at line 243 of file DataListenerSvc.h.
int DataListenerSvc::FreqCriterion [private] |
Definition at line 246 of file DataListenerSvc.h.
int DataListenerSvc::m_EventFrequency [private] |
Definition at line 247 of file DataListenerSvc.h.
Definition at line 257 of file DataListenerSvc.h.
int DataListenerSvc::m_MLjobID [private] |
Definition at line 261 of file DataListenerSvc.h.
int DataListenerSvc::m_MLEventFrequency [private] |
Definition at line 262 of file DataListenerSvc.h.
std::string DataListenerSvc::m_MLClusterName [private] |
Definition at line 263 of file DataListenerSvc.h.
Definition at line 264 of file DataListenerSvc.h.
std::string DataListenerSvc::jobIDString [private] |
Definition at line 265 of file DataListenerSvc.h.
int DataListenerSvc::m_MonALISAMonitoring [private] |
Definition at line 266 of file DataListenerSvc.h.
int DataListenerSvc::m_XMLMonitoring [private] |
Definition at line 267 of file DataListenerSvc.h.
int DataListenerSvc::m_FileMonitoring [private] |
Definition at line 268 of file DataListenerSvc.h.
char* DataListenerSvc::keyToSend [private] |
Definition at line 271 of file DataListenerSvc.h.