| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# DataListenerSvc.cpp

Go to the documentation of this file.

    00001 // $Id: DataListenerSvc.cpp,v 1.6 2008/10/27 19:22:21 marcocle Exp $
    00002 // Include files
    00003 #include "GaudiKernel/IAlgorithm.h"
    00004 #include "GaudiKernel/IAlgTool.h"
    00005 #include "GaudiKernel/Service.h"
    00006 #include "GaudiKernel/SvcFactory.h"
    00007 #include "GaudiKernel/MsgStream.h"
    00008 #include "GaudiKernel/IIncidentSvc.h"
    00009 #include "DataListenerSvc.h"
    00010 #include "ValueMap.h"
    00011 #include "XmlCode.h"
    00012 #ifdef _WIN32
    00013 #define NOMSG
    00014 #define NOGDI
    00015 #include <windows.h>
    00016 #include <winsock.h>
    00017 #include <process.h>
    00018 #undef NOMSG
    00019 #undef NOGDI
    00020 #else
    00021 #include <unistd.h>
    00022 #include <exception>
    00023 #endif
    00024 #include <sys/types.h>
    00025
    00026
    00027
    00028 /********************************************
    00029  *
    00030  * This program implements DataListenerSvc.h which supplies a handle method for the declareInfo service.
    00031  * Given options in the optsfile, txt and XML files containing the variable names and their values
    00032  * are written out for the last read record specified by the user.
    00033  *
    00034  * Currently there are no undeclare or getInfo methods
    00035  *
    00036  * Author: Ben King
    00037  *
    00038  ********************************************/
    00039
    00040
    00041 // Factory for instantiation of service objects
    00042 DECLARE_SERVICE_FACTORY(DataListenerSvc)
    00043
    00044 namespace  {
    00045   // num of Incidents counter
    00046   int numIncidents = 0;
    00047   int defaultMLFrequency = 100;
    00048   int defaultjobID = 0;
    00049   std::string defaultClusterName = "DataListenerSvc";
    00050   std::string defaultApMonSettingsFile = "http://ganga.web.cern.ch/ganga/monalisa.conf";
    00051   int defaultMonALISAMonitoring = 1;
    00052   int defaultXMLMonitoring = 1;
    00053   int defaultFileMonitoring = 1;
    00054
    00055   // fileNum counter
    00056   int fileCounter = 0;
    00057   int defaultFrequency = 100;
    00058 }
    00059
    00060 // UNIQUE Interface identifiers defined elsewhere
    00062 //extern const InterfaceID IID_IPublish;
    00063
    00064 // Constructor
    00065 DataListenerSvc::DataListenerSvc(const std::string& name, ISvcLocator* sl)
    00066   : Service(name, sl) {
    00067
    00068   declareProperty ("EventFrequency", m_EventFrequency=defaultFrequency);
    00069   declareProperty ("MLEventFrequency", m_MLEventFrequency=defaultMLFrequency);
    00070   declareProperty ("MLjobID", m_MLjobID=defaultjobID);
    00071   declareProperty ("MLClusterName", m_MLClusterName=defaultClusterName);
    00072   declareProperty ("MonALISAMonitoring", m_MonALISAMonitoring=defaultMonALISAMonitoring);
    00073   declareProperty ("ApMonSource", m_ApMonSettingsFile=defaultApMonSettingsFile);
    00074
    00075   declareProperty ("XMLMonitoring", m_XMLMonitoring=defaultXMLMonitoring);
    00076   declareProperty ("FileMonitoring", m_FileMonitoring=defaultFileMonitoring);
    00077
    00078 }
    00079
    00080
    00081 //Query interfaces of Interface
    00082 // @param riid       ID of Interface to be retrieved
    00083 // @param ppvUnknown Pointer to Location for interface pointer
    00084 StatusCode DataListenerSvc::queryInterface(const InterfaceID& riid,
    00085                                            void** ppvIF)
    00086 {
    00087   if(IID_IMonitorSvc == riid) {
    00088     *ppvIF = dynamic_cast<IMonitorSvc*> (this);
    00089   }
    00090   else {
    00091     return Service::queryInterface(riid, ppvIF);
    00092   }
    00093   addRef();
    00094   return StatusCode::SUCCESS;
    00095 }
    00096
    00097 // implement Service methods
    00098 StatusCode DataListenerSvc::initialize()
    00099 {
    00100
    00101   m_ApMonSettingsFile = defaultApMonSettingsFile;
    00102   StatusCode sc = Service::initialize();
    00103   MsgStream msg(msgSvc(),name());
    00104
    00105   jobIDString = "jobID: " + stringConverter(m_MLjobID);
    00106
    00107   if ( !sc.isSuccess() )   {
    00108     msg << MSG::ERROR << "Failed to initialize Service base class." << endmsg;
    00109     return StatusCode::FAILURE;
    00110   }
    00111
    00112   sc = service("IncidentSvc", m_incidentSvc, true);
    00113   if (!sc.isSuccess()) {
    00114     msg << MSG::ERROR << "Failed to access incident service." << endmsg;
    00115     return StatusCode::FAILURE;
    00116   }
    00117   m_incidentSvc->addListener(this, IncidentType::EndEvent);
    00118
    00119
    00120   if (m_MonALISAMonitoring){
    00121     // Initialise MonALISA
    00122     apm = new ApMon(const_cast<char*>(m_ApMonSettingsFile.c_str()));
    00123   }
    00124
    00125
    00126   // DEBUG info on job options specified in GAUDI
    00127   if (m_MLEventFrequency == defaultMLFrequency) {
    00128     msg << MSG::DEBUG
    00129         << "Frequency to send data to MonALISA not specified, taken as the default value: "
    00130         << defaultMLFrequency << endreq;
    00131   } else {
    00132     msg << MSG::INFO
    00133         << "Data sent to MonALISA every "
    00134         << m_MLEventFrequency << " events" << endreq;
    00135   }
    00136
    00137   if (m_MLjobID == defaultjobID){
    00138     msg << MSG::DEBUG
    00139         << "DataListenerSvc MonALISA Job ID not specified, taken as the default value: "
    00140         << defaultjobID << endreq;
    00141   }
    00142
    00143   if (m_MLClusterName == defaultClusterName){
    00144     msg << MSG::DEBUG
    00145         << "DataListenerSvc MonALISA cluster name not specified, taken as the default value: "
    00146         << defaultClusterName << endreq;
    00147   }
    00148
    00149   if (m_ApMonSettingsFile == defaultApMonSettingsFile){
    00150     msg << MSG::DEBUG
    00151         << "MonALISA ApMon configuration file destination not specified,  will be read from: "
    00152         << defaultClusterName << endreq;
    00153   }
    00154
    00155   if (m_EventFrequency == defaultFrequency){
    00156     msg << MSG::INFO
    00157         << "XML Log file frequency not specified, taken as the default value: "
    00158         << defaultFrequency << endreq;
    00159   } else {
    00160     msg << MSG::INFO
    00161         << "Frequency XML logs are written at: "
    00162         << m_EventFrequency << endreq;
    00163   }
    00164
    00165
    00166   if (m_MonALISAMonitoring) {
    00167     msg << MSG::INFO
    00168         << "Data will be published to a MonALISA server"
    00169         << endreq;
    00170   }
    00171
    00172   if (m_XMLMonitoring) {
    00173     msg << MSG::INFO
    00174         << "Data will be written to XML log files"
    00175         << endreq;
    00176   }
    00177   if (m_FileMonitoring) {
    00178     msg << MSG::INFO
    00179         << "Data will be updated in a Text log file"
    00180         << endreq;
    00181   }
    00182
    00183   return StatusCode::SUCCESS;
    00184
    00185 }
    00186
    00187
    00188 StatusCode DataListenerSvc::finalize()
    00189 {
    00190   MsgStream msg(msgSvc(),"DataListenerSvc");
    00191
    00192   m_infoDescriptions.clear();
    00193   m_ValNamesMap.clear();
    00194
    00195   if (m_MonALISAMonitoring){
    00196         if ( 0!= apm ) {
    00197                 delete apm;
    00198                 apm = 0 ;
    00199         }
    00200   }
    00201
    00202   msg << MSG::DEBUG << "ApMon deleted" << endreq;
    00203   msg << MSG::INFO << "finalized successfully" << endreq;
    00204
    00205  if( m_incidentSvc ) m_incidentSvc->release();
    00206
    00207   return Service::finalize();
    00208 }
    00209
    00210
    00211
    00212
    00213
    00214 void DataListenerSvc::declareInfo(const std::string& name, const double& var,
    00215                                   const std::string& /*desc*/,
    00216                                   const IInterface* /*owner*/)
    00217 {
    00218   ValueMap::m_type vartype;
    00219   vartype = ValueMap::m_double;
    00220
    00221   MsgStream msg(msgSvc(),"DataListenerSvc");
    00222
    00223   // In the ValueMap, store the pointer to the data (converted to void*)
    00224   // and also store the pointer type (with an enum) so it can be converted back
    00225   m_ValueMap.set_ptr(  static_cast <void*> (const_cast <double*> (&var) )  );
    00226   m_ValueMap.set_ptrType(vartype);
    00227
    00228   Entry p1(name, m_ValueMap);
    00229
    00230   // m_ValNamesMap is then composed of n (variable Name: ValueMap) pairs
    00231   m_ValNamesMap.insert(p1);
    00232
    00233 }
    00234
    00235
    00236
    00237 void DataListenerSvc::declareInfo(const std::string& name, const long& var,
    00238                                   const std::string& /*desc*/,
    00239                                   const IInterface* /*owner*/)
    00240 {
    00241
    00242   ValueMap::m_type vartype;
    00243   vartype = ValueMap::m_long;
    00244
    00245   MsgStream msg(msgSvc(),"DataListenerSvc");
    00246
    00247   m_ValueMap.set_ptr(  static_cast <void*> (const_cast <long*> (&var) )  );
    00248   m_ValueMap.set_ptrType(vartype);
    00249
    00250   Entry p1(name, m_ValueMap);
    00251
    00252   m_ValNamesMap.insert(p1);
    00253
    00254 }
    00255
    00256 void DataListenerSvc::declareInfo(const std::string& name, const int& var,
    00257                                   const std::string& /*desc*/,
    00258                                   const IInterface* /*owner*/)
    00259 {
    00260   ValueMap::m_type vartype;
    00261   vartype = ValueMap::m_int;
    00262
    00263   MsgStream msg(msgSvc(),"DataListenerSvc");
    00264
    00265   m_ValueMap.set_ptr(  static_cast <void*> (const_cast <int*> (&var) )  );
    00266   m_ValueMap.set_ptrType(vartype);
    00267
    00268   Entry p1(name, m_ValueMap);
    00269
    00270   m_ValNamesMap.insert(p1);
    00271
    00272 }
    00273
    00274 void DataListenerSvc::declareInfo(const std::string& name, const bool& var,
    00275                                   const std::string& /*desc*/,
    00276                                   const IInterface* /*owner*/)
    00277 {
    00278
    00279   ValueMap::m_type vartype;
    00280   vartype = ValueMap::m_bool;
    00281
    00282   MsgStream msg(msgSvc(),"DataListenerSvc");
    00283
    00284   m_ValueMap.set_ptr(  static_cast <void*> (const_cast <bool*> (&var) )  );
    00285   m_ValueMap.set_ptrType(vartype);
    00286
    00287   Entry p1(name, m_ValueMap);
    00288
    00289   m_ValNamesMap.insert(p1);
    00290
    00291 }
    00292
    00293 void DataListenerSvc::declareInfo(const std::string& name,
    00294                                   const std::string& var,
    00295                                   const std::string& /*desc*/,
    00296                                   const IInterface* /*owner*/)
    00297 {
    00298   ValueMap::m_type vartype;
    00299   vartype = ValueMap::m_string;
    00300
    00301   MsgStream msg(msgSvc(),"DataListenerSvc");
    00302
    00303   m_ValueMap.set_ptr(  static_cast <void*> (const_cast <std::string*> (&var) )  );  m_ValueMap.set_ptrType(vartype);
    00304
    00305   Entry p1(name, m_ValueMap);
    00306
    00307   m_ValNamesMap.insert(p1);
    00308
    00309 }
    00310
    00311
    00312 void DataListenerSvc::declareInfo(const std::string& /*name*/,
    00313                                   const std::pair<double,double>& /*var*/,
    00314                                   const std::string& /*desc*/,
    00315                                   const IInterface* /*owner*/)
    00316 {
    00317 }
    00318 void DataListenerSvc::declareInfo(const std::string& /*name*/,
    00319                                   const AIDA::IBaseHistogram* /*var*/,
    00320                                   const std::string& /*desc*/,
    00321                                   const IInterface* /*owner*/)
    00322 {
    00323 }
    00324
    00325 void DataListenerSvc::declareInfo(const std::string& /*name*/,
    00326                                   const std::string& /*format*/,
    00327                                   const void* /*var*/,
    00328                                   int /*size*/,
    00329                                   const std::string& /*desc*/,
    00330                                   const IInterface* /*owner*/)
    00331 {
    00332 }
    00333
    00334
    00335
    00336 void DataListenerSvc::undeclareInfo( const std::string& /*name*/,
    00337                                      const IInterface* /*owner*/ )
    00338 {
    00339 }
    00340
    00341 void DataListenerSvc::undeclareAll( const IInterface* /*owner*/ )
    00342 {
    00343 }
    00344
    00345 std::set<std::string> * DataListenerSvc::getInfos(const IInterface* /*owner*/ )
    00346 {
    00347   std::set<std::string> * returnData = NULL;
    00348   return returnData;
    00349 }
    00350
    00351 std::string DataListenerSvc::infoOwnerName( const IInterface* /*owner*/ )
    00352   {
    00353     std::string returnData = "";
    00354     return returnData;
    00355   }
    00356
    00357
    00358 void DataListenerSvc::handle (const Incident& Inc)
    00359 {
    00360
    00361   MsgStream msg(msgSvc(),"DataListenerSvc");
    00362   numIncidents++;
    00363
    00364
    00365   if (numIncidents % m_EventFrequency == 0){
    00366
    00367     try {
    00368       Log4.open("MonitorLog.txt", std::ios::trunc);
    00369       XMLLog.open(("./log" + stringConverter(fileCounter)  + ".xml").c_str() , std::ios::trunc);
    00370     } catch(std::exception /*&e*/) {
    00371       msg << MSG::INFO
    00372           << "Log File could not be opened, no monitoring available"
    00373           << endreq;
    00374     }
    00375
    00376     if (m_MonALISAMonitoring){
    00377       // Send Data to MonALISA
    00378       sendData(&m_ValNamesMap);
    00379     }
    00380
    00381     if (m_FileMonitoring){
    00382       // Write simple text log
    00383       writeMap(&m_ValNamesMap, Inc, &Log4 );
    00384       Log4.close();
    00385     }
    00386
    00387     if (m_XMLMonitoring){
    00388       // Write XML files
    00389       writeXML(&m_ValNamesMap, Inc, &XMLLog );
    00390       XMLLog.close();
    00391     }
    00392
    00393     fileCounter++;
    00394   }
    00395
    00396 }
    00397
    00398
    00399
    00400 // With a String as argument, resize with whitespace until specified length
    00401 std::string DataListenerSvc::resizeString ( const std::string text,
    00402                                             const unsigned int length)
    00403 {
    00404   std::string temp;
    00405   unsigned int counter=0;
    00406
    00407   do {
    00408
    00409     if (text.length() > length) {
    00410       temp = text.substr(0,(length-1));
    00411     } else {
    00412       if (counter==0) {
    00413         temp = text;
    00414         counter++;
    00415       }
    00416       temp.append(" ");
    00417     }
    00418
    00419   } while (temp.length() != length);
    00420
    00421   return temp;
    00422 }
    00423
    00424
    00425 // Convert argument to a string so that can format for text file
    00426 std::string DataListenerSvc::stringConverter (const int convertee)
    00427 {
    00428   std::stringstream s;
    00429   std::string temp;
    00430   s << convertee;
    00431   s >> temp;
    00432   s.flush();
    00433   return temp;
    00434 }
    00435
    00436 std::string DataListenerSvc::stringConverter (const double convertee)
    00437 {
    00438   std::stringstream s;
    00439   std::string temp;
    00440   s << convertee;
    00441   s >> temp;
    00442   s.flush();
    00443   return temp;
    00444 }
    00445 std::string DataListenerSvc::stringConverter (const long convertee)
    00446 {
    00447   std::stringstream s;
    00448   std::string temp;
    00449   s << convertee;
    00450   s >> temp;
    00451   s.flush();
    00452   return temp;
    00453 }
    00454
    00455 std::string DataListenerSvc::stringConverter (const bool convertee)
    00456 {
    00457   std::stringstream s;
    00458   std::string temp;
    00459   s << convertee;
    00460   s >> temp;
    00461   s.flush();
    00462   return temp;
    00463 }
    00464
    00465
    00466
    00467 void DataListenerSvc::writeXML(ValNamesMap* m_ValNamesMap,
    00468                                const Incident& Inc,
    00469                                std::ofstream* MyFile)
    00470 {
    00471
    00472   MsgStream msg(msgSvc(),"DataListenerSvc");
    00473
    00474   // prepare time ctime.h and remove trailing carriage return
    00475   time ( &rawTime );
    00476   sprintf (buffer, "%s", ctime(&rawTime));
    00477   timeDate = buffer;
    00478   timeDate.erase(timeDate.size()-1, 1);
    00479
    00480
    00481   msg << MSG::INFO << "XML written to file: " << MyFile << endreq;
    00482
    00483
    00484   *MyFile << xml.declaration("1.0", "ASCII", "yes") << std::endl;
    00485
    00486   *MyFile << xml.tagBegin("Results", 0, "Time", timeDate)
    00487           << xml.tagBegin("Run",1);
    00488
    00489
    00490   for (m_ValNamesMapIt = m_ValNamesMap->begin();
    00491        m_ValNamesMapIt != m_ValNamesMap->end();
    00492        ++m_ValNamesMapIt) {
    00493
    00494     m_ValueMapTemp = m_ValNamesMapIt->second;
    00495
    00496     *MyFile << xml.tagBegin("Incident",2);
    00497
    00498     *MyFile << xml.tagBegin("IncType", 3)
    00499             << xml.data(resizeString(Inc.type(),18))
    00500             << xml.tagEnd("IncType", 0);
    00501
    00502     *MyFile << xml.tagBegin("IncSource", 3)
    00503             << xml.data(resizeString(Inc.source(),18))
    00504             << xml.tagEnd("IncSource", 0);
    00505
    00506     *MyFile << xml.tagBegin("VarName", 3)
    00507             << xml.data(resizeString(m_ValNamesMapIt->first,20))
    00508             << xml.tagEnd("VarName", 0);
    00509
    00510     *MyFile << xml.tagBegin("Value", 3, "Result", stringConverter(numIncidents));
    00511     // Check the variable type and in each case, cast accordingly
    00512
    00513
    00514
    00515     // re-convert pointers to their original form and then to strings
    00516     // so that they can be written with XMLCode.h
    00517     if (m_ValueMapTemp.get_ptrType() == ValueMap::m_double){
    00518       valToWrite = stringConverter(*(double*)m_ValueMapTemp.get_ptr());
    00519     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_int){
    00520       valToWrite = stringConverter(*(int*)m_ValueMapTemp.get_ptr());
    00521     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_long){
    00522       valToWrite = stringConverter(*(long*)m_ValueMapTemp.get_ptr());
    00523     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_bool){
    00524       valToWrite = stringConverter(*(bool*)m_ValueMapTemp.get_ptr());
    00525     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_string){
    00526       valToWrite = *(std::string*)m_ValueMapTemp.get_ptr();
    00527     }
    00528
    00529
    00530     *MyFile << xml.data(valToWrite);
    00531     msg << MSG::DEBUG << "XML written: " << m_ValNamesMapIt->first << " , "
    00532         << valToWrite << endreq;
    00533
    00534     *MyFile << xml.tagEnd("Value", 0);
    00535     *MyFile << xml.tagEnd("Incident",2);
    00536   }
    00537
    00538
    00539   *MyFile << xml.tagEnd("Run",1)
    00540           << xml.tagEnd("Results", 0);
    00541
    00542 }
    00543
    00544
    00545 // Write the map to a standard text logfile
    00546 void DataListenerSvc::writeMap (ValNamesMap* m_ValNamesMap,
    00547                    const Incident& Inc, std::ofstream* MyFile)
    00548 {
    00549   // prepare time ctime.h and remove trailing carriage return
    00550   time ( &rawTime2 );
    00551   sprintf (buffer2, "%s", ctime(&rawTime2));
    00552   timeDate2 = buffer2;
    00553   timeDate2.erase(timeDate2.size()-1, 1);
    00554
    00555   // headings for the text file with spacing numbers
    00556   std::string space = "   ";
    00557   std::string heading0 = "Time                       "; // 27
    00558   std::string heading1 = "No      "; // 8 chars long
    00559   std::string heading2 = "Incident Type     "; // 18
    00560   std::string heading3 = "Incident Source   "; // 18
    00561   std::string heading4 = "Name            ";  // 16
    00562   std::string heading5 = "Value               "; // 20
    00563
    00564   *MyFile << heading0 + heading1 + heading2 + heading3 + heading4 + heading5
    00565           << std::endl;
    00566
    00567   for (m_ValNamesMapIt = m_ValNamesMap->begin();
    00568        m_ValNamesMapIt != m_ValNamesMap->end();
    00569        ++m_ValNamesMapIt){
    00570
    00571     m_ValueMapTemp = m_ValNamesMapIt->second;
    00572
    00573     *MyFile << timeDate2 << space
    00574
    00575             << resizeString(stringConverter(numIncidents),8) // Counts # incidents
    00576             << resizeString(Inc.type(),18)                 // Incident Type
    00577             << resizeString(Inc.source(),18)               // Source of the Incident
    00578             << resizeString(m_ValNamesMapIt->first,20);    // Variable Name
    00579
    00580     // Check the variable type and in each case, cast accordingly
    00581     if (m_ValueMapTemp.get_ptrType() == ValueMap::m_double){
    00582       *MyFile << resizeString(stringConverter(*(double*)m_ValueMapTemp.get_ptr()), 12)
    00583               << std::endl;
    00584     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_int){
    00585       *MyFile << resizeString(stringConverter(*(int*)m_ValueMapTemp.get_ptr()), 12)
    00586               << std::endl;
    00587     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_long){
    00588       *MyFile << resizeString(stringConverter(*(long*)m_ValueMapTemp.get_ptr()), 12)
    00589               << std::endl;
    00590     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_bool){
    00591       *MyFile << resizeString(stringConverter(*(bool*)m_ValueMapTemp.get_ptr()), 12)
    00592               << std::endl;
    00593     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_string){
    00594       *MyFile << resizeString((*(std::string*)m_ValueMapTemp.get_ptr()), 12)
    00595               << std::endl;
    00596       }
    00597
    00598       }
    00599
    00600 }
    00601
    00602
    00603 void DataListenerSvc::sendData(ValNamesMap* m_ValNamesMap)
    00604 {
    00605
    00606   for (m_ValNamesMapIt = m_ValNamesMap->begin();
    00607        m_ValNamesMapIt != m_ValNamesMap->end();
    00608        ++m_ValNamesMapIt){
    00609
    00610     m_ValueMapTemp = m_ValNamesMapIt->second;
    00611     keyToSend = const_cast<char*>((m_ValNamesMapIt->first).c_str());
    00612
    00613
    00614     if (m_ValueMapTemp.get_ptrType() == ValueMap::m_double){
    00615       apmSend(const_cast <char*>(m_MLClusterName.c_str()),
    00616               const_cast <char*> (jobIDString.c_str()),
    00617               keyToSend, *(double*)m_ValueMapTemp.get_ptr());
    00618     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_int){
    00619       apmSend(const_cast <char*>(m_MLClusterName.c_str()),
    00620               const_cast <char*> (jobIDString.c_str()),
    00621               keyToSend, *(int*)m_ValueMapTemp.get_ptr());
    00622     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_long){
    00623       apmSend(const_cast <char*>(m_MLClusterName.c_str()),
    00624               const_cast <char*> (jobIDString.c_str()),
    00625               keyToSend, *(long*)m_ValueMapTemp.get_ptr());
    00626     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_bool){
    00627       apmSend(const_cast <char*>(m_MLClusterName.c_str()),
    00628               const_cast <char*> (jobIDString.c_str()),
    00629               keyToSend, *(bool*)m_ValueMapTemp.get_ptr());
    00630     } else if (m_ValueMapTemp.get_ptrType() == ValueMap::m_string){
    00631       apmSend(const_cast <char*>(m_MLClusterName.c_str()),
    00632               const_cast <char*> (jobIDString.c_str()),
    00633               keyToSend, const_cast <char*>((*(std::string*)m_ValueMapTemp.get_ptr()).c_str()));
    00634     }
    00635   }
    00636
    00637 }
    00638
    00639
    00640
    00641 void DataListenerSvc::apmSend(char* clusterName, char* clusterNode,
    00642                               char* key, double val)
    00643 {
    00644   MsgStream msg(msgSvc(),"DataListenerSvc");
    00645   msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00646
    00647   try {
    00648     DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val);
    00649     msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00650     msg << MSG::INFO << "Sent parameters to MonALISA sever:"
    00651         << m_MLClusterName << "->"
    00652         << jobIDString.c_str() << "->"
    00653         << key << ":" << val << endreq;
    00654   } catch(std::runtime_error &e) {
    00655     msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endreq;
    00656   }
    00657 }
    00658
    00659 void DataListenerSvc::apmSend(char* clusterName, char* clusterNode,
    00660                               char* key, int val)
    00661 {
    00662   MsgStream msg(msgSvc(),"DataListenerSvc");
    00663   msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00664   try {
    00665     DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val);
    00666     msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00667     msg << MSG::INFO << "Sent parameters to MonALISA sever:"
    00668         << m_MLClusterName << "->"
    00669         << jobIDString.c_str() << "->"
    00670         << key << ":" << val << endreq;
    00671   } catch(std::runtime_error &e) {
    00672     msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endreq;
    00673   }
    00674 }
    00675
    00676 void DataListenerSvc::apmSend(char* clusterName, char* clusterNode,
    00677                               char* key, long val)
    00678 {
    00679   MsgStream msg(msgSvc(),"DataListenerSvc");
    00680   msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00681   double temp;
    00682   temp = *(double*)val;
    00683
    00684   try {
    00685     DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, temp);
    00686     msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00687     msg << MSG::INFO << "Sent parameters to MonALISA sever:"
    00688         << m_MLClusterName << "->"
    00689         << jobIDString.c_str() << "->"
    00690         << key << ":" << val << endreq;
    00691   } catch (std::runtime_error &e){
    00692     msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endreq;
    00693   }
    00694 }
    00695
    00696 void DataListenerSvc::apmSend(char* clusterName, char* clusterNode,
    00697                               char* key, bool val)
    00698 {
    00699   MsgStream msg(msgSvc(),"DataListenerSvc");
    00700   msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00701   try {
    00702     DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val);
    00703     msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00704     msg << MSG::INFO << "Sent parameters to MonALISA sever:"
    00705         << m_MLClusterName << "->"
    00706         << jobIDString.c_str() << "->"
    00707         << key << ":" << val << endreq;
    00708   } catch (std::runtime_error &e){
    00709     msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endreq;
    00710   }
    00711 }
    00712
    00713 void DataListenerSvc::apmSend(char* clusterName, char* clusterNode,
    00714                               char* key, char* val)
    00715 {
    00716   MsgStream msg(msgSvc(),"DataListenerSvc");
    00717   msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00718   try {
    00719     DataListenerSvc::apm->sendParameter( clusterName, clusterNode, key, val);
    00720     msg << MSG::DEBUG << "ApMon instantiated" << endreq;
    00721     msg << MSG::INFO << "Sent parameters to MonALISA sever:"
    00722         << m_MLClusterName << "->"
    00723         << jobIDString.c_str() << "->"
    00724         << key << ":" << val << endreq;
    00725   } catch (std::runtime_error &e){
    00726     msg << MSG::WARNING << "WARNING sending to ApMon:\t" << e.what() << endreq;
    00727   }
    00728 }
    00729