00001 #include "CondTools/L1Trigger/interface/DataManager.h" 00002 00003 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00004 00005 #include "CondCore/DBCommon/interface/SessionConfiguration.h" 00006 #include "CondCore/DBCommon/interface/ConnectionConfiguration.h" 00007 00008 00009 namespace l1t 00010 { 00011 00012 DataManager::DataManager (const std::string & connect, 00013 const std::string & authenticationPath, 00014 bool isOMDS ) 00015 { 00016 // // Initialize session used with this object 00017 // poolSession = new cond::DBSession (); 00018 // poolSession->configuration ().setAuthenticationMethod (cond::Env); 00019 // // poolSession->sessionConfiguration ().setMessageLevel (cond::Info); 00020 // poolSession->configuration ().connectionConfiguration ()->enableConnectionSharing (); 00021 // poolSession->configuration ().connectionConfiguration ()->enableReadOnlySessionOnUpdateConnections (); 00022 00023 // coralSession = new cond::DBSession (); 00024 // coralSession->configuration ().setAuthenticationMethod (cond::Env); 00025 // // coralSession->sessionConfiguration ().setMessageLevel (cond::Info); 00026 // coralSession->configuration ().connectionConfiguration ()->enableConnectionSharing (); 00027 // coralSession->configuration ().connectionConfiguration ()->enableReadOnlySessionOnUpdateConnections (); 00028 00029 session = new cond::DBSession(); 00030 setDebug( false ) ; 00031 00032 if( isOMDS ) 00033 { 00034 session->configuration().setAuthenticationMethod(cond::XML); 00035 } 00036 else 00037 { 00038 // session->configuration().setAuthenticationMethod(cond::Env); 00039 session->configuration().setAuthenticationMethod(cond::XML); 00040 session->configuration().connectionConfiguration() 00041 ->enableConnectionSharing (); 00042 session->configuration().connectionConfiguration() 00043 ->enableReadOnlySessionOnUpdateConnections (); 00044 } 00045 session->configuration().setAuthenticationPath( authenticationPath ) ; 00046 session->configuration().setBlobStreamer("COND/Services/TBufferBlobStreamingService") ; 00047 session->open() ; 00048 00049 00050 // create Coral connection and pool. This ones should be connected on required basis 00051 // coral = new cond::CoralTransaction (connect, coralSession); 00052 // pool = new cond::PoolTransaction (connect, catalog, poolSession); 00053 00054 connection = new cond::Connection( connect ) ; 00055 connection->connect( session ) ; 00056 cond::CoralTransaction& coral = connection->coralTransaction() ; 00057 // coral = &( connection->coralTransaction() ) ; 00058 // pool = &( connection->poolTransaction() ) ; 00059 00060 // and data object 00061 metadata = new cond::MetaData (coral); 00062 00063 // wsun: need to disconnect? 00064 // connection->disconnect() ; 00065 00066 // can I use two sessions? One for pool and one for coral? So that I could connect to one and another.... 00067 // will sqlite will be happy with transactions? 00068 } 00069 00070 DataManager::~DataManager () 00071 { 00072 connection->disconnect() ; 00073 00074 // detele all in reverse direction 00075 // closing and comminting may be a good idea here 00076 // in case we have exception in some other part between connect/close pairs 00077 00078 delete metadata; 00079 // delete pool; 00080 // delete coral; 00081 delete connection ; 00082 // delete coralSession; 00083 // delete poolSession; 00084 delete session ; 00085 } 00086 00087 edm::eventsetup::TypeTag DataManager::findType (const std::string & type) const 00088 { 00089 static edm::eventsetup::TypeTag defaultType; 00090 edm::eventsetup::TypeTag typeTag = edm::eventsetup::TypeTag::findType (type); 00091 00092 if (typeTag == defaultType) 00093 //throw cond::Exception ("l1t::DataManager::findType") 00094 edm::LogError("L1TriggerDB") << "DataManager::findType() : " << type << " was not found"; 00095 00096 return typeTag; 00097 } 00098 00099 void 00100 DataManager::setDebug( bool debug ) 00101 { 00102 if( debug ) 00103 { 00104 session->configuration().setMessageLevel( cond::Debug ) ; 00105 } 00106 else 00107 { 00108 session->configuration().setMessageLevel( cond::Error ) ; 00109 } 00110 } 00111 }