CMS 3D CMS Logo

Logger.h

Go to the documentation of this file.
00001 #ifndef CONDCORE_DBCOMMON_LOGGER_H
00002 #define CONDCORE_DBCOMMON_LOGGER_H
00003 
00004 #include <string>
00005 //#include <iostream>
00006 //
00007 // Package: CondCore/DBCommon   
00008 // Class  : Logger    
00009 // 
00012 //
00013 // Author:      Zhen Xie
00014 //
00015 //#include "UserLogInfo.h"
00016 namespace coral{
00017   //class ISchema;  
00018   class IQuery;
00019 }
00020 namespace cond{
00021   class UserLogInfo;
00022   class LogDBEntry;
00023   class CoralTransaction;
00024   class Connection;
00025   class SequenceManager;
00026   class Logger{
00027   public:
00028     explicit Logger(Connection* connectionHandle);
00029     ~Logger();
00030     bool getWriteLock() throw ();
00031     bool releaseWriteLock() throw ();
00032     //NB. for oracle only schema owner can do this 
00033     void createLogDBIfNonExist();
00034     //
00035     //the current local time will be registered as execution time
00036     // payloadName and containerName are also logged but they are deduced from payloadToken
00037     void logOperationNow(
00038                          const cond::UserLogInfo& userlogInfo,
00039                          const std::string& destDB,
00040                          const std::string& payloadToken,
00041                          const std::string& iovtag,
00042                          const std::string& iovtimetype,
00043                          unsigned int payloadIdx
00044                          );
00045     //
00046     //the current local time will be registered as execution time
00047     //
00048     // payloadName and containerName are also logged but they are deduced from payloadToken
00049     void logFailedOperationNow(
00050                                const cond::UserLogInfo& userlogInfo,
00051                                const std::string& destDB,
00052                                const std::string& payloadToken,
00053                                const std::string& iovtag,
00054                                const std::string& iovtimetype,
00055                                unsigned int payloadIdx,
00056                                const std::string& exceptionMessage
00057                                );
00058     //
00059     // Here we query the log for the last entry for these payloads.
00060     // Parameter  LogDBEntry& result is both input and output
00061     // As input, it defines query condition. 
00062     // Last: in the sense of max rowid satisfies the requirement
00063     // Note: if empty logentry is given, the absolute max is returned which
00064     // normally is useless. 
00065     // return empty struct is no result found
00066     //
00067     void LookupLastEntryByProvenance( const std::string& provenance,
00068                                       LogDBEntry& logentry,
00069                                       bool filterFailedOp=true) const;
00070     //
00071     // Here we query the log for the last entry for these payloads.
00072     // Parameter  LogDBEntry& result is both input and output
00073     // As input, it defines query condition. 
00074     // Last: in the sense of max rowid satisfies the requirement
00075     // Note: if empty logentry is given, the absolute max is returned which
00076     // normally is useless.
00077     //
00078     void LookupLastEntryByTag( const std::string& iovtag,
00079                                LogDBEntry& logentry,
00080                                bool filterFailedOp=true) const;
00081     
00082     void LookupLastEntryByTag( const std::string& iovtag,
00083                                const std::string & connectionStr,
00084                                LogDBEntry& logentry,
00085                                bool filterFailedOp=true) const;
00086 
00087   private:
00088     void insertLogRecord(unsigned long long logId,
00089                          const std::string& localtime,
00090                          const std::string& destDB,
00091                          const std::string& payloadToken,
00092                          const cond::UserLogInfo& userLogInfo,
00093                          const std::string& iovtag,
00094                          const std::string& iovtimetype,
00095                          unsigned int payloadIdx,
00096                          const std::string& exceptionMessage);
00097     
00098     Connection* m_connectionHandle;
00099     CoralTransaction& m_coraldb;
00100     //coral::ISchema& m_schema;
00101     bool m_locked;
00102     coral::IQuery* m_statusEditorHandle;
00103     SequenceManager* m_sequenceManager;
00104     bool m_logTableExists;
00105   };
00106 }//ns cond
00107 #endif

Generated on Tue Jun 9 17:26:04 2009 for CMSSW by  doxygen 1.5.4