CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CondCore/DBCommon/interface/Logger.h

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