CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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 //#include <iostream>
00007 //
00008 // Package: CondCore/DBCommon   
00009 // Class  : Logger    
00010 // 
00013 //
00014 // Author:      Zhen Xie
00015 //
00016 //#include "UserLogInfo.h"
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     bool getWriteLock() throw ();
00030     bool releaseWriteLock() throw ();
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& iovtag,
00041                          const std::string& iovtimetype,
00042                          unsigned int payloadIdx,
00043                          unsigned long long lastSince
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                                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 cond::UserLogInfo& userLogInfo,
00094                          const std::string& iovtag,
00095                          const std::string& iovtimetype,
00096                          unsigned int payloadIdx,
00097                          unsigned long long lastSince,
00098                          const std::string& exceptionMessage);
00099     
00100     mutable DbSession m_sessionHandle;
00101     //coral::ISchema& m_schema;
00102     bool m_locked;
00103     coral::IQuery* m_statusEditorHandle;
00104     SequenceManager* m_sequenceManager;
00105     bool m_logTableExists;
00106   };
00107 }//ns cond
00108 #endif