ATLAS Offline Software
Loading...
Searching...
No Matches
PoolSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "PoolSvc.h"
11
12#include "GaudiKernel/IIoComponentMgr.h"
13#include "GaudiKernel/ConcurrencyFlags.h"
14
16
17#include "CoralKernel/Context.h"
18
21
23
30
31#include "StorageSvc/DbType.h"
32#include "StorageSvc/DbPrint.h"
33
34#include "RelationalAccess/ConnectionService.h"
35#include "RelationalAccess/IConnectionServiceConfiguration.h"
36#include "RelationalAccess/IWebCacheControl.h"
37#include "RelationalAccess/IWebCacheInfo.h"
38#include "RelationalAccess/ILookupService.h"
39#include "RelationalAccess/IDatabaseServiceSet.h"
40#include "RelationalAccess/IDatabaseServiceDescription.h"
41
43
44#include <cstdlib>
45#include <cstring>
46#include <algorithm>
47#include <cstdio>
48#include <cctype>
49#include <exception> // for runtime_error
50
51bool isNumber(const std::string& s) {
52 return !s.empty() && (std::isdigit(s[0]) || s[0] == '+' || s[0] == '-');
53}
54
55//__________________________________________________________________________
56StatusCode PoolSvc::initialize() {
57 ATH_CHECK(::AthService::initialize());
58
59 // Register this service for 'I/O' events
60 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
61 ATH_CHECK(iomgr.retrieve());
62 ATH_CHECK(iomgr->io_register(this));
63 // Register input file's names with the I/O manager, unless in SharedWrite mode, set by AthenaPoolCnvSvc
64 bool allGood = true;
65 for (const auto& catalog : m_readCatalog.value()) {
66 if (catalog.starts_with("xmlcatalog_file:")) {
67 const std::string fileName = catalog.substr(16);
68 if (!iomgr->io_register(this, IIoComponentMgr::IoMode::READ, fileName, fileName).isSuccess()) {
69 ATH_MSG_FATAL("could not register [" << catalog << "] for input !");
70 allGood = false;
71 } else {
72 ATH_MSG_INFO("io_register[" << this->name() << "](" << catalog << ") [ok]");
73 }
74 }
75 }
76 if (m_writeCatalog.value().starts_with("xmlcatalog_file:")) {
77 const std::string fileName = m_writeCatalog.value().substr(16);
78 if (!iomgr->io_register(this, IIoComponentMgr::IoMode::WRITE, fileName, fileName).isSuccess()) {
79 ATH_MSG_FATAL("could not register [" << m_writeCatalog.value() << "] for input !");
80 allGood = false;
81 } else {
82 ATH_MSG_INFO("io_register[" << this->name() << "](" << m_writeCatalog.value() << ") [ok]");
83 }
84 }
85 if (!allGood) {
86 return(StatusCode::FAILURE);
87 }
88 m_context = &coral::Context::instance();
89 if (m_context == nullptr) {
90 ATH_MSG_FATAL("Failed to access CORAL Context");
91 return(StatusCode::FAILURE);
92 }
93 coral::ConnectionService conSvcH;
94 coral::IConnectionServiceConfiguration& csConfig = conSvcH.configuration();
95 csConfig.setConnectionRetrialPeriod(m_retrialPeriod);
96 csConfig.setConnectionRetrialTimeOut(m_retrialTimeOut);
97 if (m_connClean) {
98 csConfig.enablePoolAutomaticCleanUp();
99 csConfig.setConnectionTimeOut(m_timeOut);
100 } else {
101 csConfig.disablePoolAutomaticCleanUp();
102 csConfig.setConnectionTimeOut(0);
103 }
104 ATH_MSG_INFO("Set connectionsvc retry/timeout/IDLE timeout to "
106 << "/"
108 << "/"
109 << m_timeOut
110 << " seconds with connection cleanup "
111 << (csConfig.isPoolAutomaticCleanUpEnabled() ? "enabled" : "disabled"));
112 // set Frontier web cache compression level
113 coral::IWebCacheControl& webCache = conSvcH.webCacheControl();
114 webCache.setCompressionLevel(m_frontierComp);
115 ATH_MSG_INFO("Frontier compression level set to " << webCache.compressionLevel());
116 if (m_sortReplicas) {
117 // set replica sorter - get service
118 ServiceHandle<IDBReplicaSvc> replicasvc("DBReplicaSvc", name());
119 if (replicasvc.retrieve().isSuccess()) {
120 csConfig.setReplicaSortingAlgorithm(*replicasvc);
121 ATH_MSG_INFO("Successfully setup replica sorting algorithm");
122 } else {
123 ATH_MSG_WARNING("Cannot setup replica sorting algorithm");
124 }
125 }
126 MSG::Level athLvl = msg().level();
127 ATH_MSG_DEBUG("OutputLevel is " << (int)athLvl);
129 return(setupPersistencySvc());
130}
131
132//__________________________________________________________________________
133StatusCode PoolSvc::io_reinit() {
134 ATH_MSG_INFO("I/O reinitialization...");
135 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
136 if (!iomgr.retrieve().isSuccess()) {
137 ATH_MSG_FATAL("Could not retrieve IoComponentMgr !");
138 return(StatusCode::FAILURE);
139 }
140 if (!iomgr->io_hasitem(this)) {
141 ATH_MSG_FATAL("IoComponentMgr does not know about myself !");
142 return(StatusCode::FAILURE);
143 }
144 std::vector<std::string> readcat = m_readCatalog.value();
145 for (std::size_t icat = 0, imax = readcat.size(); icat < imax; icat++) {
146 if (readcat[icat].compare(0, 16, "xmlcatalog_file:") == 0) {
147 std::string fileName = readcat[icat].substr(16);
148 if (iomgr->io_contains(this, fileName)) {
149 if (!iomgr->io_retrieve(this, fileName).isSuccess()) {
150 ATH_MSG_FATAL("Could not retrieve new value for [" << fileName << "] !");
151 return(StatusCode::FAILURE);
152 }
153 readcat[icat] = "xmlcatalog_file:" + fileName;
154 }
155 }
156 }
157 // all good... copy over.
158 m_readCatalog = readcat;
159 if (m_writeCatalog.value().compare(0, 16, "xmlcatalog_file:") == 0) {
160 std::string fileName = m_writeCatalog.value().substr(16);
161 if (iomgr->io_contains(this, fileName)) {
162 if (!iomgr->io_retrieve(this, fileName).isSuccess()) {
163 ATH_MSG_FATAL("Could not retrieve new value for [" << fileName << "] !");
164 return(StatusCode::FAILURE);
165 }
166 if (!m_shareCat) {
167 m_writeCatalog.setValue("xmlcatalog_file:" + fileName);
168 }
169 }
170 }
171 return(setupPersistencySvc());
172}
173//__________________________________________________________________________
175 clearState();
176 ATH_MSG_INFO("Setting up FileCatalog and Streams");
178 if (m_catalog != nullptr) {
179 m_catalog->start();
180 } else {
181 ATH_MSG_FATAL("Failed to setup POOL File Catalog.");
182 return(StatusCode::FAILURE);
183 }
184 // Setup a persistency services
185 m_dbSessionVec.push_back(pool::createSession(*m_catalog).release()); // Read Service
186 m_pers_mut.push_back(new CallMutex);
187 if (!m_dbSessionVec[IPoolSvc::kInputStream]->technologySpecificAttributes(pool::ROOT_StorageType.type()).setAttribute<bool>("ENABLE_THREADSAFETY", true)) {
188 ATH_MSG_FATAL("Failed to enable thread safety in ROOT via PersistencySvc.");
189 return(StatusCode::FAILURE);
190 }
191 m_contextMaxFile.insert(std::pair<unsigned int, int>(IPoolSvc::kInputStream, m_dbAgeLimit));
192 if (!connect(Io::READ, IPoolSvc::kInputStream).isSuccess()) {
193 ATH_MSG_FATAL("Failed to connect Input PersistencySvc.");
194 return(StatusCode::FAILURE);
195 }
196 m_dbSessionVec.push_back(pool::createSession(*m_catalog).release()); // Write Service
197 m_pers_mut.push_back(new CallMutex);
199 ATH_MSG_FATAL("Failed to set ROOT default container type via PersistencySvc.");
200 return(StatusCode::FAILURE);
201 }
202
203 return(StatusCode::SUCCESS);
204}
205//__________________________________________________________________________
206StatusCode PoolSvc::start() {
207 // Switiching on ROOT implicit multi threading for AthenaMT
208 if (m_useROOTIMT && Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
209 if (!m_dbSessionVec[IPoolSvc::kInputStream]->technologySpecificAttributes(pool::ROOT_StorageType.type()).setAttribute<int>("ENABLE_IMPLICITMT", Gaudi::Concurrency::ConcurrencyFlags::numThreads() - 1)) {
210 ATH_MSG_FATAL("Failed to enable implicit multithreading in ROOT via PersistencySvc.");
211 return(StatusCode::FAILURE);
212 }
213 ATH_MSG_INFO("Enabled implicit multithreading in ROOT via PersistencySvc to: " << Gaudi::Concurrency::ConcurrencyFlags::numThreads() - 1);
214 }
215 return(StatusCode::SUCCESS);
216}
217//__________________________________________________________________________
218StatusCode PoolSvc::stop() {
219 ATH_MSG_VERBOSE("stop()");
220 bool retError = false;
221 for (unsigned int contextId = 0, imax = m_dbSessionVec.size(); contextId < imax; contextId++) {
222 if (!disconnect(contextId).isSuccess()) {
223 ATH_MSG_FATAL("Cannot disconnect Stream: " << contextId);
224 retError = true;
225 }
226 }
227 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
228}
229
230//__________________________________________________________________________
232 std::lock_guard<CallMutex> lock(m_pool_mut);
233 // Cleanup persistency service
234 for (const auto& dbSession : m_dbSessionVec) {
235 delete dbSession;
236 }
237 m_dbSessionVec.clear();
238 for (const auto& persistencyMutex : m_pers_mut) {
239 delete persistencyMutex;
240 }
241 m_mainOutputLabel.clear();
242 m_inputContextLabel.clear();
243 m_outputContextLabel.clear();
244 m_pers_mut.clear();
245 if (m_catalog != nullptr) {
246 m_catalog->commit();
247 delete m_catalog; m_catalog = nullptr;
248 }
249}
250//__________________________________________________________________________
251StatusCode PoolSvc::finalize() {
252 clearState();
253 return(::AthService::finalize());
254}
255//__________________________________________________________________________
257 ATH_MSG_INFO("I/O finalization...");
258 for (size_t i = 0; i < m_dbSessionVec.size(); i++) {
259 if ((m_dbSessionVec[i]->transaction().type() == Io::WRITE || m_dbSessionVec[i]->transaction().type() == Io::APPEND) &&
260 !disconnect(i).isSuccess()) {
261 ATH_MSG_WARNING("Cannot disconnect output Stream " << i);
262 }
263 }
264 clearState();
265 return(StatusCode::SUCCESS);
266}
267//__________________________________________________________________________
269 const void* obj,
270 const RootType& classDesc) {
271 unsigned int contextId = IPoolSvc::kOutputStream;
272 const std::string& auxString = placement->auxString();
273 if (!auxString.empty()) {
274 if (auxString.compare(0, 6, "[CTXT=") == 0) {
275 ::sscanf(auxString.c_str(), "[CTXT=%08X]", &contextId);
276 } else if (auxString.compare(0, 8, "[CLABEL=") == 0) {
277 contextId = this->getOutputContext(auxString);
278 }
279 if (contextId >= m_dbSessionVec.size()) {
280 ATH_MSG_WARNING("registerForWrite: Using default output Stream instead of id = " << contextId);
281 contextId = IPoolSvc::kOutputStream;
282 }
283 }
284 std::lock_guard<CallMutex> lock(*m_pers_mut[contextId]);
285 Token* token = m_dbSessionVec[contextId]->registerForWrite(*placement, obj, classDesc);
286 if (token == nullptr) {
287 ATH_MSG_WARNING("Cannot write object: " << placement->containerName());
288 }
289 return(token);
290}
291//__________________________________________________________________________
292void PoolSvc::setObjPtr(void*& obj, const Token* token) {
293 unsigned int contextId = IPoolSvc::kInputStream;
294 const std::string& auxString = token->auxString();
295 if (!auxString.empty()) {
296 if (auxString.compare(0, 6, "[CTXT=") == 0) {
297 ::sscanf(auxString.c_str(), "[CTXT=%08X]", &contextId);
298 } else if (auxString.compare(0, 8, "[CLABEL=") == 0) {
299 contextId = this->getInputContext(auxString);
300 }
301 if (contextId >= m_dbSessionVec.size()) {
302 ATH_MSG_WARNING("setObjPtr: Using default input Stream instead of id = " << contextId);
303 contextId = IPoolSvc::kInputStream;
304 }
305 }
306 ATH_MSG_VERBOSE("setObjPtr: token=" << token->toString() << ", auxString=" << auxString << ", contextID=" << contextId);
307 // Get Context ID/label from Token
308 std::lock_guard<CallMutex> lock(*m_pers_mut[contextId]);
309 obj = m_dbSessionVec[contextId]->readObject(*token, obj);
310 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
311 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0) {
312 m_guidLists[contextId].remove(token->dbID());
313 m_guidLists[contextId].push_back(token->dbID());
314 while (m_guidLists[contextId].size() > maxFileIter->second) {
315 this->disconnectDb("FID:" + m_guidLists[contextId].begin()->toString(), contextId).ignore();
316 }
317 }
318}
319//__________________________________________________________________________
320unsigned int PoolSvc::getOutputContext(const std::string& label) {
321 std::lock_guard<CallMutex> lock(m_pool_mut);
322 if (m_mainOutputLabel.empty()) {
324 m_outputContextLabel.insert(std::pair<std::string, unsigned int>(label, IPoolSvc::kOutputStream));
325 }
326 if (label == m_mainOutputLabel || label.empty()) {
328 }
329 std::map<std::string, unsigned int>::const_iterator contextIter = m_outputContextLabel.find(label);
330 if (contextIter != m_outputContextLabel.end()) {
331 return(contextIter->second);
332 }
333 const unsigned int id = m_dbSessionVec.size();
334 m_dbSessionVec.push_back(pool::createSession(*m_catalog).release());
335 m_pers_mut.push_back(new CallMutex);
336 if (!m_dbSessionVec[id]->technologySpecificAttributes(pool::ROOT_StorageType.type()).setAttribute<int>("DEFAULT_CONTAINER_TYPE", pool::DbType::getType(m_defaultContainerType).type())) {
337 ATH_MSG_WARNING("Failed to set ROOT default container type via PersistencySvc for id " << id);
339 }
340 m_outputContextLabel.insert(std::pair<std::string, unsigned int>(label, id));
341 return(id);
342}
343//__________________________________________________________________________
344unsigned int PoolSvc::getInputContext(const std::string& label, unsigned int maxFile) {
345 std::lock_guard<CallMutex> lock(m_pool_mut);
346 if (!label.empty()) {
347 std::map<std::string, unsigned int>::const_iterator contextIter = m_inputContextLabel.find(label);
348 if (contextIter != m_inputContextLabel.end()) {
349 if (maxFile > 0) {
350 m_contextMaxFile[contextIter->second] = maxFile;
351 }
352 return(contextIter->second);
353 }
354 }
355 const unsigned int id = m_dbSessionVec.size();
356 m_dbSessionVec.push_back( pool::createSession(*m_catalog, maxFile).release() );
357 m_pers_mut.push_back(new CallMutex);
358 if (!connect(Io::READ, id).isSuccess()) {
359 ATH_MSG_WARNING("Failed to connect Input PersistencySvc: " << id);
361 }
362 if (!label.empty()) {
363 m_inputContextLabel.insert(std::pair<std::string, unsigned int>(label, id));
364 }
365 m_contextMaxFile.insert(std::pair<unsigned int, int>(id, maxFile));
366 return(id);
367}
368//__________________________________________________________________________
369std::map<std::string, unsigned int> PoolSvc::getInputContextMap() const {
370 std::lock_guard<CallMutex> lock(m_pool_mut);
371 return(m_inputContextLabel);
372}
373//__________________________________________________________________________
375 std::lock_guard<CallMutex> lock(m_pool_mut);
376 return(m_inputContextLabel.size());
377}
378//__________________________________________________________________________
379const coral::Context* PoolSvc::context() const {
380 return(m_context);
381}
382//__________________________________________________________________________
383void PoolSvc::loadComponent(const std::string& compName) {
384 m_context->loadComponent(compName);
385}
386//__________________________________________________________________________
387void PoolSvc::setShareMode(bool shareCat) {
388 m_shareCat = shareCat;
389}
390//__________________________________________________________________________
392 return(m_catalog);
393}
394//__________________________________________________________________________
395void PoolSvc::lookupBestPfn(const std::string& token, std::string& pfn, std::string& type) const {
396 std::string dbID;
397 if (token.compare(0, 4, "PFN:") == 0) {
398 m_catalog->lookupFileByPFN(token.substr(4), dbID, type); // PFN -> FID
399 } else if (token.compare(0, 4, "LFN:") == 0) {
400 m_catalog->lookupFileByLFN(token.substr(4), dbID); // LFN -> FID
401 } else if (token.compare(0, 4, "FID:") == 0) {
402 dbID = token.substr(4);
403 } else if (token.size() > Guid::stringSize()) { // full token
404 Token tok;
405 tok.fromString(token);
406 dbID = tok.dbID().toString();
407 } else { // guid only
408 dbID = token;
409 }
410 m_catalog->getFirstPFN(dbID, pfn, type); // FID -> best PFN
411}
412//__________________________________________________________________________
413void PoolSvc::renamePfn(const std::string& pf, const std::string& newpf) {
414 std::string dbID, type;
415 m_catalog->lookupFileByPFN(pf, dbID, type);
416 if (dbID.empty()) {
417 ATH_MSG_WARNING("Failed to lookup: " << pf << " in FileCatalog");
418 return;
419 }
420 m_catalog->lookupFileByPFN(newpf, dbID, type);
421 if (!dbID.empty()) {
422 ATH_MSG_INFO("Found: " << newpf << " in FileCatalog");
423 return;
424 }
425 m_catalog->renamePFN(pf, newpf);
426}
427//__________________________________________________________________________
428pool::ICollection* PoolSvc::createCollection(const std::string& connection,
429 const std::string& collectionName,
430 const pool::DbType& collectionType,
431 unsigned int contextId) const {
432 ATH_MSG_DEBUG("createCollection() type=" << collectionType.storageName() << ", connection=" << connection
433 << ", name=" << collectionName << ", contextID=" << contextId);
434 if (contextId >= m_dbSessionVec.size()) {
435 ATH_MSG_WARNING("createCollection: Using default input Stream instead of id = " << contextId);
436 contextId = IPoolSvc::kInputStream;
437 }
439 // Check POOL FileCatalog entry.
440 bool insertFile = false;
441 if (connection.compare(0, 4, "PFN:") == 0) {
442 std::string fid, fileType;
443 m_catalog->lookupFileByPFN(connection.substr(4), fid, fileType);
444 if (fid.empty()) { // No entry in file catalog
445 insertFile = true;
446 ATH_MSG_INFO("File is not in Catalog! Attempt to open it anyway.");
447 }
448 }
449 if (collectionType.majorType() == pool::POOL_StorageType.type()) {
450 // Check whether Collection Container exists.
451 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
452 if (dbH == nullptr) {
453 ATH_MSG_INFO("Failed to get Session/DatabaseHandle to create POOL collection.");
454 return(nullptr);
455 }
456 try {
457 if (dbH->openMode() == Io::INVALID) {
458 dbH->connectForRead();
459 }
460 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
461 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0 && !dbH->fid().empty()) {
462 const Guid guid(dbH->fid());
463 m_guidLists[contextId].remove(guid);
464 m_guidLists[contextId].push_back(guid);
465 while (m_guidLists[contextId].size() > maxFileIter->second + 1) {
466 this->disconnectDb("FID:" + m_guidLists[contextId].begin()->toString(), contextId).ignore();
467 }
468 }
469 } catch (std::exception& e) {
470 ATH_MSG_INFO("Failed to open container to check POOL collection - trying.");
471 }
472 }
473
474 // access to these variables is locked below:
476 pool::ICollection* collPtr ATLAS_THREAD_SAFE = nullptr;
477
478 // Try to open EventTags Collection in the input file
479 std::scoped_lock sc_lock(m_pool_mut);
480 std::string error_text;
481 try {
482 collPtr = collSvc.open(collectionName, collectionType, connection, m_dbSessionVec[contextId]);
483 } catch (std::exception &e) {
484 collPtr = nullptr;
485 error_text = e.what();
486 }
487 if( !collPtr ) {
488 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
489 if (dbH != nullptr && !dbH->fid().empty()) {
490 return(nullptr); // no events
491 }
492 throw std::runtime_error( "Failed to open Collection: " + error_text + ", PoolSvc::createCollection");
493 }
494 if (insertFile && m_attemptCatalogPatch.value()) {
495 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
496 if (dbH == nullptr) {
497 ATH_MSG_INFO("Failed to create FileCatalog entry.");
498 } else if (dbH->fid().empty()) {
499 ATH_MSG_INFO("Cannot retrieve the FID of an existing POOL database: '"
500 << connection << "' - FileCatalog will NOT be updated.");
501 } else {
502 patchCatalog(connection.substr(4), *dbH);
503 }
504 }
505 // For multithreaded processing (with multiple events in flight),
506 // increase virtual tree size to accomodate back reads
507 if (m_useROOTMaxTree && Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1) {
508 if (!this->setAttribute("TREE_MAX_VIRTUAL_SIZE", "-1", pool::ROOT_StorageType.type(), connection.substr(4), "CollectionTree", IPoolSvc::kInputStream).isSuccess()) {
509 ATH_MSG_WARNING("Failed to increase maximum virtual TTree size.");
510 }
511 }
512
513 return(collPtr);
514}
515//__________________________________________________________________________
516void PoolSvc::patchCatalog(const std::string& pfn, pool::IDatabase& dbH) const {
517 std::scoped_lock lock(m_pool_mut);
519 std::string fid = dbH.fid();
521 catalog_locked->registerPFN(pfn, "ROOT_All", fid);
522}
523//__________________________________________________________________________
524Token* PoolSvc::getToken(const std::string& connection,
525 const std::string& collection,
526 const unsigned long ientry) const {
527 std::lock_guard<CallMutex> lock(*m_pers_mut[IPoolSvc::kInputStream]);
528 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(IPoolSvc::kInputStream, connection);
529 if (dbH == nullptr) {
530 return(nullptr);
531 }
532 if (dbH->openMode() == Io::INVALID) {
533 dbH->connectForRead();
534 }
535 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), collection);
536 if (contH == nullptr) {
537 return(nullptr);
538 }
539 auto tokenIter = std::unique_ptr<pool::ITokenIterator>(contH->tokens());
540 // the Token returned by the iterator has the refCount already increased
541 return tokenIter->seek(ientry)? tokenIter->next() : nullptr;
542}
543//__________________________________________________________________________
544StatusCode PoolSvc::connect(Io::IoFlag type, unsigned int contextId) {
545 if (type != Io::READ) {
546 if (contextId >= m_dbSessionVec.size()) {
547 ATH_MSG_WARNING("connect: Using default output Stream instead of id = " << contextId);
548 contextId = IPoolSvc::kOutputStream;
549 }
550 } else {
551 if (contextId > m_dbSessionVec.size()) {
552 ATH_MSG_WARNING("connect: Using default input Stream instead of id = " << contextId);
553 contextId = IPoolSvc::kInputStream;
554 } else if (contextId == m_dbSessionVec.size()) {
555 ATH_MSG_INFO("Connecting to InputStream for: " << contextId);
556 contextId = this->getInputContext("");
557 }
558 }
559 if (contextId >= m_dbSessionVec.size()) {
560 return(StatusCode::FAILURE);
561 }
563 auto session = m_dbSessionVec[contextId];
564 // Connect to a logical database using the pre-defined technology and dbID
565 if (session->transaction().isActive()) {
566 return(StatusCode::SUCCESS);
567 }
568 if (!session->start(type)) {
569 ATH_MSG_ERROR("connect failed session = " << session << " type = " << type);
570 return(StatusCode::FAILURE);
571 }
572
573 return(StatusCode::SUCCESS);
574}
575//__________________________________________________________________________
576StatusCode PoolSvc::commit(unsigned int contextId) const {
577 if (contextId >= m_dbSessionVec.size()) {
578 return(StatusCode::FAILURE);
579 }
581 auto session = m_dbSessionVec[contextId];
582 if (session != nullptr && session->transaction().isActive()) {
583 if (!session->commit()) {
584 ATH_MSG_ERROR("POOL commit failed " << session);
585 return(StatusCode::FAILURE);
586 }
587 if (session->transaction().type() == Io::READ) {
588 session->disconnectAll();
589 }
590 }
591 return(StatusCode::SUCCESS);
592}
593//__________________________________________________________________________
594StatusCode PoolSvc::commitAndHold(unsigned int contextId) const {
595 if (contextId >= m_dbSessionVec.size()) {
596 return(StatusCode::FAILURE);
597 }
599 pool::ISession* session = m_dbSessionVec[contextId];
600 if (session != nullptr && session->transaction().isActive()) {
601 if (!session->commitAndHold()) {
602 ATH_MSG_ERROR("POOL commitAndHold failed " << session);
603 return(StatusCode::FAILURE);
604 }
605 }
606 return(StatusCode::SUCCESS);
607}
608//__________________________________________________________________________
609StatusCode PoolSvc::disconnect(unsigned int contextId) const {
610 ATH_MSG_DEBUG("Disconnect request for contextId=" << contextId);
611 if (contextId >= m_dbSessionVec.size()) {
612 return(StatusCode::SUCCESS);
613 }
615 pool::ISession* session = m_dbSessionVec[contextId];
616 if (session != nullptr && session->transaction().isActive()) {
617 if (!commit(contextId).isSuccess()) {
618 ATH_MSG_ERROR("disconnect failed to commit " << session);
619 return(StatusCode::FAILURE);
620 }
621 if (session->disconnectAll()) {
622 ATH_MSG_DEBUG("Disconnected PersistencySvc session");
623 } else {
624 ATH_MSG_ERROR("disconnect failed to diconnect PersistencySvc");
625 return(StatusCode::FAILURE);
626 }
627 }
628 return(StatusCode::SUCCESS);
629}
630//__________________________________________________________________________
631StatusCode PoolSvc::disconnectDb(const std::string& connection, unsigned int contextId) const {
632 if (contextId >= m_dbSessionVec.size()) {
633 return(StatusCode::SUCCESS);
634 }
636 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
637 if (dbH == nullptr) {
638 ATH_MSG_ERROR("Failed to get Session/DatabaseHandle.");
639 return(StatusCode::FAILURE);
640 }
641 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
642 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0) {
643 m_guidLists[contextId].remove(Guid(dbH->fid()));
644 }
645 dbH->disconnect();
646 return(StatusCode::SUCCESS);
647}
648//_______________________________________________________________________
649StatusCode PoolSvc::getAttribute(const std::string& optName,
650 std::string& data,
651 long tech,
652 unsigned int contextId) const {
653 if (contextId >= m_dbSessionVec.size()) {
654 ATH_MSG_WARNING("getAttribute: Using default input Stream instead of id = " << contextId);
655 contextId = IPoolSvc::kInputStream;
656 }
658 pool::ISession* sesH = m_dbSessionVec[contextId];
659 std::ostringstream oss;
660 if (data == "DbLonglong") {
661 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<long long int>(optName);
662 } else if (data == "double") {
663 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<double>(optName);
664 } else {
665 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<int>(optName);
666 }
667 data = oss.str();
668 ATH_MSG_INFO("Domain attribute [" << optName << "]" << ": " << data);
669 return(StatusCode::SUCCESS);
670}
671//_______________________________________________________________________
672StatusCode PoolSvc::getAttribute(const std::string& optName,
673 std::string& data,
674 long tech,
675 const std::string& dbName,
676 const std::string& contName,
677 unsigned int contextId) const {
679 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, dbName);
680 if (dbH == nullptr) {
681 ATH_MSG_DEBUG("getAttribute: Failed to get Session/DatabaseHandle to get POOL property.");
682 return(StatusCode::FAILURE);
683 }
684 if (dbH->openMode() == Io::INVALID) {
685 if (m_dbSessionVec[contextId]->transaction().type() == Io::WRITE || m_dbSessionVec[contextId]->transaction().type() == Io::APPEND) {
686 dbH->setTechnology(tech);
687 dbH->connectForWrite();
688 } else {
689 dbH->connectForRead();
690 }
691 }
692 std::ostringstream oss;
693 if (contName.empty()) {
694 if (data == "DbLonglong") {
695 oss << std::dec << dbH->technologySpecificAttributes().attribute<long long int>(optName);
696 } else if (data == "double") {
697 oss << std::dec << dbH->technologySpecificAttributes().attribute<double>(optName);
698 } else if (data == "string") {
699 oss << dbH->technologySpecificAttributes().attribute<char*>(optName);
700 } else {
701 oss << std::dec << dbH->technologySpecificAttributes().attribute<int>(optName);
702 }
703 ATH_MSG_INFO("Database (" << dbH->pfn() << ") attribute [" << optName << "]" << ": " << oss.str());
704 } else {
705 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), contName);
706 if (contH == nullptr) {
707 ATH_MSG_DEBUG("Failed to get ContainerHandle to get POOL property.");
708 return(StatusCode::FAILURE);
709 }
710 if (data == "DbLonglong") {
711 oss << std::dec << contH->technologySpecificAttributes().attribute<long long int>(optName);
712 } else if (data == "double") {
713 oss << std::dec << contH->technologySpecificAttributes().attribute<double>(optName);
714 } else {
715 oss << std::dec << contH->technologySpecificAttributes().attribute<int>(optName);
716 }
717 ATH_MSG_INFO("Container attribute [" << contName << "." << optName << "]: " << oss.str());
718 }
719 data = oss.str();
720 return(StatusCode::SUCCESS);
721}
722//_______________________________________________________________________
723StatusCode PoolSvc::setAttribute(const std::string& optName,
724 const std::string& data,
725 long tech,
726 unsigned int contextId) const {
727 if (contextId >= m_dbSessionVec.size()) {
728 ATH_MSG_WARNING("setAttribute: Using default output Stream instead of id = " << contextId);
729 contextId = IPoolSvc::kOutputStream;
730 }
732 pool::ISession* sesH = m_dbSessionVec[contextId];
733 if (data[data.size() - 1] == 'L') {
734 if (!sesH->technologySpecificAttributes(tech).setAttribute<long long int>(optName, atoll(data.c_str()))) {
735 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
736 return(StatusCode::FAILURE);
737 }
738 } else {
739 if (!sesH->technologySpecificAttributes(tech).setAttribute<int>(optName, atoi(data.c_str()))) {
740 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
741 return(StatusCode::FAILURE);
742 }
743 }
744 return(StatusCode::SUCCESS);
745}
746//_______________________________________________________________________
747StatusCode PoolSvc::setAttribute(const std::string& optName,
748 const std::string& data,
749 long tech,
750 const std::string& dbName,
751 const std::string& contName,
752 unsigned int contextId) const {
753 if (contextId >= m_dbSessionVec.size()) {
754 ATH_MSG_WARNING("setAttribute: Using default output Stream instead of id = " << contextId);
755 contextId = IPoolSvc::kOutputStream;
756 }
758 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, dbName);
759 if (dbH == nullptr) {
760 ATH_MSG_DEBUG("Failed to get Session/DatabaseHandle to set POOL property.");
761 return(StatusCode::FAILURE);
762 }
763 if (dbH->openMode() == Io::INVALID) {
764 if (m_dbSessionVec[contextId]->transaction().type() == Io::WRITE || m_dbSessionVec[contextId]->transaction().type() == Io::APPEND) {
765 dbH->setTechnology(tech);
766 dbH->connectForWrite();
767 } else {
768 dbH->connectForRead();
769 }
770 }
771 bool retError = false;
772 std::string objName;
773 bool hasTTreeName = (contName.length() > 6 && contName.compare(0, 6, "TTree=") == 0);
774 if (contName.empty() || hasTTreeName || m_dbSessionVec[contextId]->transaction().type() == Io::READ) {
775 objName = hasTTreeName ? contName.substr(6) : contName;
776 if( !isNumber(data) ) {
777 retError = dbH->technologySpecificAttributes().setAttribute(optName, data.c_str(), objName);
778 } else if( data[data.size() - 1] == 'L' ) {
779 retError = dbH->technologySpecificAttributes().setAttribute<long long int>(optName, atoll(data.c_str()), objName);
780 } else {
781 retError = dbH->technologySpecificAttributes().setAttribute<int>(optName, atoi(data.c_str()), objName);
782 }
783 if (!retError) {
784 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
785 return(StatusCode::FAILURE);
786 }
787 } else {
788 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), contName);
789 if (contH == nullptr) {
790 ATH_MSG_DEBUG("Failed to get ContainerHandle to set POOL property.");
791 return(StatusCode::FAILURE);
792 }
793 if (auto p = contName.find('('); p != std::string::npos) {
794 objName = contName.substr(p + 1); // Get BranchName between parenthesis
795 objName.erase(objName.find(')'));
796 } else if (auto p = contName.find("::"); p != std::string::npos) {
797 objName = contName.substr(p + 2); // Split off Tree name
798 } else if (auto p = contName.find('_'); p != std::string::npos) {
799 objName = contName.substr(p + 1); // Split off "POOLContainer"
800 objName.erase(objName.find('/')); // Split off key
801 }
802 std::string::size_type off = 0;
803 while ((off = objName.find_first_of("<>/")) != std::string::npos) {
804 objName[off] = '_'; // Replace special chars (e.g. templates)
805 }
806 if (data[data.size() - 1] == 'L') {
807 retError = contH->technologySpecificAttributes().setAttribute<long long int>(optName, atoll(data.c_str()), objName);
808 } else {
809 retError = contH->technologySpecificAttributes().setAttribute<int>(optName, atoi(data.c_str()), objName);
810 }
811 if (!retError) {
812 ATH_MSG_DEBUG("Failed to set POOL container property, " << optName << " for " << contName << " : " << objName << " to " << data);
813 return(StatusCode::FAILURE);
814 }
815 }
816 return(StatusCode::SUCCESS);
817}
818//__________________________________________________________________________
819StatusCode PoolSvc::setFrontierCache(const std::string& conn) {
820 std::lock_guard<CallMutex> lock(m_pool_mut);
821 ATH_MSG_VERBOSE("setFrontierCache called for connection:" << conn);
822 // setup the Frontier cache information for the given logical or physical connection string
823 // first determine if the connection is logical (no ':')
824 std::vector<std::string> physcons;
825 if (conn.find(':') == std::string::npos) {
826 // if logical, have to lookup list of physical replicas, and consider each
827 // need the CORAL ILookupSvc interface which must be loaded if needed
828 const std::string lookSvcStr("CORAL/Services/XMLLookupService");
829 coral::IHandle<coral::ILookupService> lookSvcH = m_context->query<coral::ILookupService>();
830 if (!lookSvcH.isValid()) {
831 m_context->loadComponent(lookSvcStr);
832 lookSvcH = m_context->query<coral::ILookupService>();
833 }
834 if (!lookSvcH.isValid()) {
835 ATH_MSG_ERROR("Cannot locate " << lookSvcStr);
836 return(StatusCode::FAILURE);
837 }
838 coral::IDatabaseServiceSet* dbset = lookSvcH->lookup(conn, coral::ReadOnly);
839 if (dbset != nullptr) {
840 for (int irep = 0, nrep = dbset->numberOfReplicas(); irep < nrep; ++irep) {
841 const std::string pcon = dbset->replica(irep).connectionString();
842 if (pcon.compare(0, 9, "frontier:") == 0) {
843 physcons.push_back(std::move(pcon));
844 }
845 }
846 delete dbset; dbset = nullptr;
847 } else {
848 ATH_MSG_DEBUG("setFrontierCache: Could not find any replicas for " << conn);
849 }
850 } else if (conn.compare(0, 9, "frontier:") == 0) {
851 physcons.push_back(conn);
852 }
853 // check if any replicas will try and use frontier
854 if (physcons.size() == 0) {
855 return(StatusCode::SUCCESS);
856 }
857 coral::ConnectionService conSvcH;
858 // for each frontier replica, define the web cache info
859 // get the WebCacheControl interface via ConnectionSvc
860 // note ConnectionSvc should already be loaded by initialize
861 coral::IWebCacheControl& webCache = conSvcH.webCacheControl();
862 for (const auto& physcon : physcons) {
863 const auto& refreshList = m_frontierRefresh.value();
864 if (std::find(refreshList.begin(), refreshList.end(), physcon) == refreshList.end()
865 && std::find(refreshList.begin(), refreshList.end(), conn) == refreshList.end()) {
866 // set that a table DUMMYTABLE should be refreshed - indicates that everything
867 // else in the schema should not be
868 webCache.refreshTable(physcon, "DUMMYTABLE");
869 } else {
870 // set the schema to be refreshed
871 webCache.refreshSchemaInfo(physcon);
872 }
873 ATH_MSG_DEBUG("Cache flag for connection " << physcon << " set to " << webCache.webCacheInfo(physcon).isSchemaInfoCached());
874 }
875 return(StatusCode::SUCCESS);
876}
877//__________________________________________________________________________
880 ctlg->removeCatalog("*");
881 for (auto& catalog : m_readCatalog.value()) {
882 ATH_MSG_DEBUG("POOL ReadCatalog is " << catalog);
883 if (catalog.compare(0, 8,"apcfile:") == 0 || catalog.compare(0, 7, "prfile:") == 0) {
884 std::string::size_type cpos = catalog.find(':');
885 // check for file accessed via ATLAS_POOLCOND_PATH
886 std::string file = poolCondPath(catalog.substr(cpos + 1));
887 if (!file.empty()) {
888 ATH_MSG_INFO("Resolved path (via ATLAS_POOLCOND_PATH) is " << file);
889 ctlg->addReadCatalog("file:" + file);
890 } else {
891 // As backup, check for file accessed via PathResolver
892 file = PathResolver::find_file(catalog.substr(cpos + 1), "DATAPATH");
893 if (!file.empty()) {
894 ATH_MSG_INFO("Resolved path (via DATAPATH) is " << file);
895 ctlg->addReadCatalog("file:" + file);
896 } else {
897 ATH_MSG_INFO("Unable find catalog "
898 << catalog
899 << " in $ATLAS_POOLCOND_PATH and $DATAPATH");
900 }
901 }
902 } else {
903 ctlg->addReadCatalog(catalog);
904 }
905 }
906 try {
907 ATH_MSG_INFO("POOL WriteCatalog is " << m_writeCatalog.value());
908 ctlg->setWriteCatalog(m_writeCatalog.value());
909 } catch(std::exception& e) {
910 ATH_MSG_ERROR("setWriteCatalog - caught exception: " << e.what());
911 return(nullptr); // This catalog is not setup properly!
912 }
913 return(ctlg);
914}
915
916//__________________________________________________________________________
919//__________________________________________________________________________
920std::unique_ptr<pool::IDatabase> PoolSvc::getDbHandle(unsigned int contextId, const std::string& dbName) const {
921 if (contextId >= m_dbSessionVec.size()) {
922 ATH_MSG_WARNING("getDbHandle: Using default input Stream instead of id = " << contextId);
923 contextId = IPoolSvc::kInputStream;
924 }
925 pool::ISession* sesH = m_dbSessionVec[contextId];
926 if (!sesH->transaction().isActive()) {
927 Io::IoFlag transMode = Io::READ;
928 ATH_MSG_DEBUG("Start transaction, type = " << transMode);
929 if (!sesH->transaction().start(transMode)) {
930 ATH_MSG_WARNING("Failed to start transaction, type = " << transMode);
931 return(nullptr);
932 }
933 }
934 if (dbName.compare(0, 4,"PFN:") == 0) {
935 return sesH->databaseHandle(dbName.substr(4), pool::DatabaseSpecification::PFN);
936 } else if (dbName.compare(0, 4, "LFN:") == 0) {
937 return sesH->databaseHandle(dbName.substr(4), pool::DatabaseSpecification::LFN);
938 } else if (dbName.compare(0, 4,"FID:") == 0) {
939 return sesH->databaseHandle(dbName.substr(4), pool::DatabaseSpecification::FID);
940 }
942}
943//__________________________________________________________________________
944std::unique_ptr<pool::IContainer> PoolSvc::getContainerHandle(pool::IDatabase* dbH, const std::string& contName) const {
945 pool::IContainer* contH = nullptr;
946 if (dbH == nullptr) {
947 ATH_MSG_DEBUG("No DatabaseHandle to get Container.");
948 return(nullptr);
949 }
950 if (contName.find("DataHeader") != std::string::npos) {
951 contH = dbH->containerHandle(contName.substr(0, contName.find("_p")));
952 } else {
953 contH = dbH->containerHandle(contName);
954 }
955 return(std::unique_ptr<pool::IContainer>(contH));
956}
957//__________________________________________________________________________
958std::string PoolSvc::poolCondPath(const std::string& leaf) {
959 // look for files at $ATLAS_POOLCOND_PATH/<leaf>
960 // return full filename if exists, or empty string if not
961 const char* cpath = std::getenv("ATLAS_POOLCOND_PATH");
962 if (cpath && strcmp(cpath, "") != 0) {
963 const std::string testpath = std::string(cpath) + "/" + leaf;
964
965 // Try to open file for reading. Note that a simple stat call may return
966 // a wrong result if the file is residing on an auto-mounted FS (ATR-28801).
967 if (FILE* fp = std::fopen(testpath.c_str(), "r")) {
968 std::fclose(fp);
969 return testpath;
970 }
971 }
972 return {};
973}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
This file contains the class definition for the Placement class (migrated from POOL).
bool isNumber(const std::string &s)
Definition PoolSvc.cxx:51
This file contains the class definition for the PoolSvc class.
TTypeAdapter RootType
Definition RootType.h:211
size_t size() const
Number of registered mappings.
int imax(int i, int j)
This file contains the class definition for the Token class (migrated from POOL).
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition Guid.h:25
constexpr void toString(std::span< char, StrLen > buf, bool uppercase=true) const noexcept
Automatic conversion to string representation.
static constexpr int stringSize()
Definition Guid.h:61
@ kOutputStream
Definition IPoolSvc.h:40
@ kInputStream
Definition IPoolSvc.h:40
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition Placement.h:19
const std::string & auxString() const
Access auxiliary string.
Definition Placement.h:40
const std::string & containerName() const
Access container name.
Definition Placement.h:32
virtual StatusCode io_reinit() override
Definition PoolSvc.cxx:133
pool::IFileCatalog * createCatalog()
Definition PoolSvc.cxx:878
virtual Token * registerForWrite(const Placement *placement, const void *obj, const RootType &classDesc) override
Definition PoolSvc.cxx:268
virtual ~PoolSvc()
Destructor.
Definition PoolSvc.cxx:917
Gaudi::Property< int > m_retrialTimeOut
ConnectionRetrialTimeOut, the retrial time out for CORAL Connection Service: default = 300 seconds.
Definition PoolSvc.h:251
Gaudi::Property< int > m_timeOut
ConnectionTimeOut, the time out for CORAL Connection Service: default = 5 seconds.
Definition PoolSvc.h:253
virtual void renamePfn(const std::string &pf, const std::string &newpf) override
Definition PoolSvc.cxx:413
Gaudi::Property< int > m_retrialPeriod
ConnectionRetrialPeriod, retry period for CORAL Connection Service: default = 30 seconds.
Definition PoolSvc.h:249
virtual const coral::Context * context() const override
Definition PoolSvc.cxx:379
pool::IFileCatalog * m_catalog
Definition PoolSvc.h:222
Gaudi::Property< std::vector< std::string > > m_frontierRefresh
Definition PoolSvc.h:258
virtual StatusCode connect(Io::IoFlag type, unsigned int contextId=IPoolSvc::kInputStream) override
Connect to a logical database unit; PersistencySvc is chosen according to transaction type (accessmod...
Definition PoolSvc.cxx:544
std::string poolCondPath(const std::string &leaf)
Resolve a file using ATLAS_POOLCOND_PATH.
Definition PoolSvc.cxx:958
virtual unsigned int getInputContextMapSize() const override
Definition PoolSvc.cxx:374
void patchCatalog(const std::string &pfn, pool::IDatabase &dbH) const
Definition PoolSvc.cxx:516
CallMutex m_pool_mut
Definition PoolSvc.h:219
virtual unsigned int getInputContext(const std::string &label, unsigned int maxFile=0) override
Definition PoolSvc.cxx:344
Gaudi::Property< bool > m_sortReplicas
Use DBReplicaSvc to sort database connections, default = true.
Definition PoolSvc.h:260
std::recursive_mutex CallMutex
Definition PoolSvc.h:205
virtual void lookupBestPfn(const std::string &token, std::string &pfn, std::string &type) const override
Definition PoolSvc.cxx:395
virtual StatusCode setAttribute(const std::string &optName, const std::string &data, long tech, unsigned int contextId=IPoolSvc::kOutputStream) const override
Set POOL attributes - domain.
Definition PoolSvc.cxx:723
std::vector< pool::ISession * > m_dbSessionVec
Definition PoolSvc.h:223
Gaudi::Property< std::string > m_defaultContainerType
Default ROOT container type.
Definition PoolSvc.h:262
Gaudi::Property< bool > m_connClean
ConnectionCleanUp - whether to use CORAL connection management thread: default = false.
Definition PoolSvc.h:255
Gaudi::Property< bool > m_useROOTIMT
Use ROOT Implicit MultiThreading, default = true.
Definition PoolSvc.h:242
virtual StatusCode commit(unsigned int contextId=IPoolSvc::kInputStream) const override
Commit data for a given contextId and flush buffer.
Definition PoolSvc.cxx:576
std::unique_ptr< pool::IContainer > getContainerHandle(pool::IDatabase *dbH, const std::string &contName) const
Get Container handle.
Definition PoolSvc.cxx:944
virtual Token * getToken(const std::string &connection, const std::string &collection, const unsigned long ientry) const override
Definition PoolSvc.cxx:524
virtual StatusCode start() override
Required of all Gaudi services:
Definition PoolSvc.cxx:206
Gaudi::Property< int > m_frontierComp
Frontier proprties, compression level and list of schemas to be refreshed: default = 5.
Definition PoolSvc.h:257
StatusCode setupPersistencySvc()
Definition PoolSvc.cxx:174
virtual StatusCode io_finalize() override
Definition PoolSvc.cxx:256
Gaudi::Property< int > m_dbAgeLimit
MaxFilesOpen, option to have PoolSvc limit the number of open Input Files: default = 0 (No files are ...
Definition PoolSvc.h:235
Gaudi::Property< bool > m_useROOTMaxTree
Increase virtual TTree size to avoid backreads in multithreading, default = false.
Definition PoolSvc.h:244
std::map< std::string, unsigned int > m_outputContextLabel
Definition PoolSvc.h:226
virtual StatusCode disconnectDb(const std::string &connection, unsigned int contextId=IPoolSvc::kInputStream) const override
Disconnect single Database.
Definition PoolSvc.cxx:631
std::vector< CallMutex * > m_pers_mut
Definition PoolSvc.h:224
std::map< std::string, unsigned int > m_inputContextLabel
Definition PoolSvc.h:225
virtual void setObjPtr(void *&obj, const Token *token) override
Definition PoolSvc.cxx:292
virtual void loadComponent(const std::string &compName) override
Definition PoolSvc.cxx:383
Gaudi::Property< std::vector< std::string > > m_readCatalog
ReadCatalog, the list of additional POOL input file catalogs to consult: default = empty vector.
Definition PoolSvc.h:240
std::string m_mainOutputLabel
Definition PoolSvc.h:227
virtual pool::ICollection * createCollection(const std::string &connection, const std::string &collectionName, const pool::DbType &collectionType=pool::POOL_StorageType.type(), unsigned int contextId=IPoolSvc::kInputStream) const override
Definition PoolSvc.cxx:428
virtual const pool::IFileCatalog * catalog() const override
Definition PoolSvc.cxx:391
void clearState()
Definition PoolSvc.cxx:231
std::map< unsigned int, unsigned int > m_contextMaxFile
Definition PoolSvc.h:228
virtual void setShareMode(bool shareCat) override
Definition PoolSvc.cxx:387
std::unique_ptr< pool::IDatabase > getDbHandle(unsigned int contextId, const std::string &dbName) const
Get Database handle.
Definition PoolSvc.cxx:920
coral::Context * m_context
Definition PoolSvc.h:220
virtual StatusCode commitAndHold(unsigned int contextId=IPoolSvc::kInputStream) const override
Commit data for a given contextId and hold buffer.
Definition PoolSvc.cxx:594
virtual StatusCode disconnect(unsigned int contextId=IPoolSvc::kInputStream) const override
Disconnect PersistencySvc associated with a contextId.
Definition PoolSvc.cxx:609
virtual StatusCode finalize() override
Required of all Gaudi services:
Definition PoolSvc.cxx:251
virtual StatusCode initialize() override
Required of all Gaudi services:
Definition PoolSvc.cxx:56
virtual StatusCode setFrontierCache(const std::string &conn) override
Setup Frontier cache for given logical or physical connection name.
Definition PoolSvc.cxx:819
virtual std::map< std::string, unsigned int > getInputContextMap() const override
Definition PoolSvc.cxx:369
virtual unsigned int getOutputContext(const std::string &label) override
Definition PoolSvc.cxx:320
Gaudi::Property< std::string > m_writeCatalog
WriteCatalog, the file catalog to be used to register output files (also default input catalog): defa...
Definition PoolSvc.h:238
virtual StatusCode stop() override
Definition PoolSvc.cxx:218
Gaudi::Property< bool > m_attemptCatalogPatch
AttemptCatalogPatch, option to create catalog: default = false.
Definition PoolSvc.h:247
std::map< unsigned int, std::list< Guid > > m_guidLists ATLAS_THREAD_SAFE
Definition PoolSvc.h:230
virtual StatusCode getAttribute(const std::string &optName, std::string &data, long tech, unsigned int contextId=IPoolSvc::kInputStream) const override
Get POOL attributes - domain.
Definition PoolSvc.cxx:649
bool m_shareCat
Definition PoolSvc.h:221
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:21
const std::string & auxString() const
Access auxiliary string.
Definition Token.h:91
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition Token.cxx:134
Token & fromString(const std::string_view from)
Build from the string representation of a token.
Definition Token.cxx:147
const Guid & dbID() const
Access database identifier.
Definition Token.h:64
A service for creating, accessing and managing an ensemble of collections of event references.
const std::string storageName() const
Human readable storage type.
int majorType() const
Access to major type.
Definition DbType.h:67
static DbType getType(const std::string &name)
Access known storage type object by name.
An interface to a storage technology specific collection of event references and attributes.
Definition ICollection.h:24
IContainer is the base class for container objects.
Definition IContainer.h:23
IDatabase is the base class for database objects.
Definition IDatabase.h:37
virtual bool setTechnology(long technology)=0
Sets the technology identifier for this database.
virtual const std::string & fid()=0
Returns the file identifier of this database.
virtual IContainer * containerHandle(const std::string &name)=0
Returns a pointer to a container object. The user acquires ownership of that object.
void addReadCatalog(const std::string &connect)
Add new catalog, identified by name, to the existing ones.
void removeCatalog(const std::string &connect)
Remove catalog identified by name from the existing ones. * or '' removes all.
void setWriteCatalog(const std::string &connect)
Establish the writable catalog, identified by name.
ISession is the interface class for user (macroscopic) sessions Every transaction and connection to a...
Definition ISession.h:37
virtual std::unique_ptr< IDatabase > databaseHandle(const std::string &dbName, DatabaseSpecification::NameType dbNameType)=0
Returns a pointer to a database object. The user acquires ownership of that object.
virtual ITransaction & transaction()=0
Returns the transaction interface.
virtual const ITechnologySpecificAttributes & technologySpecificAttributes(long technology) const =0
Returns the object holding the technology specific attributes for a given technology domain.
virtual bool disconnectAll()=0
Explicitly disconnects all the databases.
T attribute(const std::string &attributeName, const std::string &option="")
Templated method to retrieve an attribute.
bool setAttribute(const std::string &attributeName, const T &atttibuteValue, const std::string &option="")
Templated method to set an attribute.
virtual bool commitAndHold()=0
Commits the holds transaction.
virtual bool start(Io::IoFlag type=Io::READ)=0
Starts a new transaction. Returns the success of the operation.
virtual bool isActive() const =0
Checks if the transaction is active.
static std::string release
Definition computils.h:50
std::string label(const std::string &format, int i)
Definition label.h:19
std::unique_ptr< ISession > createSession(IFileCatalog &catalog, int ageLimit=-1)
static const DbType ROOT_StorageType
Definition DbType.h:85
static const DbType POOL_StorageType
Definition DbType.h:84
@ FID
Physical File Name.
Definition IDatabase.h:26
@ LFN
File IDentifier.
Definition IDatabase.h:27
static void setLevel(MSG::Level l)
Definition DbPrint.h:20
MsgStream & msg
Definition testRead.cxx:32
TFile * file