| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- File List
- File Members

# DataListenerSvc.cpp

Go to the documentation of this file.

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