CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/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 
00030     void connect( const std::string& logConnectionString, bool readOnly=false );
00031     //NB. for oracle only schema owner can do this 
00032     void createLogDBIfNonExist();
00033     //
00034     //the current local time will be registered as execution time
00035     // payloadName and containerName are also logged but they are deduced from payloadToken
00036     void logOperationNow(
00037                          const cond::UserLogInfo& userlogInfo,
00038                          const std::string& destDB,
00039                          const std::string& payloadToken,
00040                          const std::string& payloadClass,
00041                          const std::string& iovtag,
00042                          const std::string& iovtimetype,
00043                          unsigned int payloadIdx,
00044                          unsigned long long lastSince
00045                          );
00046     //
00047     //the current local time will be registered as execution time
00048     //
00049     // payloadName and containerName are also logged but they are deduced from payloadToken
00050     void logFailedOperationNow(
00051                                const cond::UserLogInfo& userlogInfo,
00052                                const std::string& destDB,
00053                                const std::string& payloadToken,
00054                                const std::string& payloadClass,
00055                                const std::string& iovtag,
00056                                const std::string& iovtimetype,
00057                                unsigned int payloadIdx,
00058                                unsigned long long lastSince,
00059                                const std::string& exceptionMessage
00060                                );
00061     //
00062     // Here we query the log for the last entry for these payloads.
00063     // Parameter  LogDBEntry& result is both input and output
00064     // As input, it defines query condition. 
00065     // Last: in the sense of max rowid satisfies the requirement
00066     // Note: if empty logentry is given, the absolute max is returned which
00067     // normally is useless. 
00068     // return empty struct is no result found
00069     //
00070     void LookupLastEntryByProvenance( const std::string& provenance,
00071                                       LogDBEntry& logentry,
00072                                       bool filterFailedOp=true) const;
00073     //
00074     // Here we query the log for the last entry for these payloads.
00075     // Parameter  LogDBEntry& result is both input and output
00076     // As input, it defines query condition. 
00077     // Last: in the sense of max rowid satisfies the requirement
00078     // Note: if empty logentry is given, the absolute max is returned which
00079     // normally is useless.
00080     //
00081     void LookupLastEntryByTag( const std::string& iovtag,
00082                                LogDBEntry& logentry,
00083                                bool filterFailedOp=true) const;
00084     
00085     void LookupLastEntryByTag( const std::string& iovtag,
00086                                const std::string & connectionStr,
00087                                LogDBEntry& logentry,
00088                                bool filterFailedOp=true) const;
00089 
00090   private:
00091     void insertLogRecord(unsigned long long logId,
00092                          const std::string& utctime,
00093                          const std::string& destDB,
00094                          const std::string& payloadToken,
00095                          const std::string& payloadClass,
00096                          const cond::UserLogInfo& userLogInfo,
00097                          const std::string& iovtag,
00098                          const std::string& iovtimetype,
00099                          unsigned int payloadIdx,
00100                          unsigned long long lastSince,
00101                          const std::string& exceptionMessage);
00102     
00103     mutable DbSession m_sessionHandle;
00104     //coral::ISchema& m_schema;
00105     bool m_locked;
00106     coral::IQuery* m_statusEditorHandle;
00107     SequenceManager* m_sequenceManager;
00108     bool m_logTableExists;
00109   };
00110 }//ns cond
00111 #endif