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);
198
199 return(StatusCode::SUCCESS);
200}
201//__________________________________________________________________________
202StatusCode PoolSvc::start() {
203 // Switiching on ROOT implicit multi threading for AthenaMT
204 if (m_useROOTIMT && Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
205 if (!m_dbSessionVec[IPoolSvc::kInputStream]->technologySpecificAttributes(pool::ROOT_StorageType.type()).setAttribute<int>("ENABLE_IMPLICITMT", Gaudi::Concurrency::ConcurrencyFlags::numThreads() - 1)) {
206 ATH_MSG_FATAL("Failed to enable implicit multithreading in ROOT via PersistencySvc.");
207 return(StatusCode::FAILURE);
208 }
209 ATH_MSG_INFO("Enabled implicit multithreading in ROOT via PersistencySvc to: " << Gaudi::Concurrency::ConcurrencyFlags::numThreads() - 1);
210 }
211 return(StatusCode::SUCCESS);
212}
213//__________________________________________________________________________
214StatusCode PoolSvc::stop() {
215 ATH_MSG_VERBOSE("stop()");
216 bool retError = false;
217 for (unsigned int contextId = 0, imax = m_dbSessionVec.size(); contextId < imax; contextId++) {
218 if (!disconnect(contextId).isSuccess()) {
219 ATH_MSG_FATAL("Cannot disconnect Stream: " << contextId);
220 retError = true;
221 }
222 }
223 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
224}
225
226//__________________________________________________________________________
228 std::lock_guard<CallMutex> lock(m_pool_mut);
229 // Cleanup persistency service
230 for (const auto& dbSession : m_dbSessionVec) {
231 delete dbSession;
232 }
233 m_dbSessionVec.clear();
234 for (const auto& persistencyMutex : m_pers_mut) {
235 delete persistencyMutex;
236 }
237 m_mainOutputLabel.clear();
238 m_inputContextLabel.clear();
239 m_outputContextLabel.clear();
240 m_pers_mut.clear();
241 if (m_catalog != nullptr) {
242 m_catalog->commit();
243 delete m_catalog; m_catalog = nullptr;
244 }
245}
246//__________________________________________________________________________
247StatusCode PoolSvc::finalize() {
248 clearState();
249 return(::AthService::finalize());
250}
251//__________________________________________________________________________
253 ATH_MSG_INFO("I/O finalization...");
254 for (size_t i = 0; i < m_dbSessionVec.size(); i++) {
255 if ((m_dbSessionVec[i]->transaction().type() == Io::WRITE || m_dbSessionVec[i]->transaction().type() == Io::APPEND) &&
256 !disconnect(i).isSuccess()) {
257 ATH_MSG_WARNING("Cannot disconnect output Stream " << i);
258 }
259 }
260 clearState();
261 return(StatusCode::SUCCESS);
262}
263//__________________________________________________________________________
265 const void* obj,
266 const RootType& classDesc) {
267 unsigned int contextId = IPoolSvc::kOutputStream;
268 const std::string& auxString = placement->auxString();
269 if (!auxString.empty()) {
270 if (auxString.compare(0, 6, "[CTXT=") == 0) {
271 ::sscanf(auxString.c_str(), "[CTXT=%08X]", &contextId);
272 } else if (auxString.compare(0, 8, "[CLABEL=") == 0) {
273 contextId = this->getOutputContext(auxString);
274 }
275 if (contextId >= m_dbSessionVec.size()) {
276 ATH_MSG_WARNING("registerForWrite: Using default output Stream instead of id = " << contextId);
277 contextId = IPoolSvc::kOutputStream;
278 }
279 }
280 std::lock_guard<CallMutex> lock(*m_pers_mut[contextId]);
281 Token* token = m_dbSessionVec[contextId]->registerForWrite(*placement, obj, classDesc);
282 if (token == nullptr) {
283 ATH_MSG_WARNING("Cannot write object: " << placement->containerName());
284 }
285 return(token);
286}
287//__________________________________________________________________________
288void PoolSvc::setObjPtr(void*& obj, const Token* token) {
289 unsigned int contextId = IPoolSvc::kInputStream;
290 const std::string& auxString = token->auxString();
291 if (!auxString.empty()) {
292 if (auxString.compare(0, 6, "[CTXT=") == 0) {
293 ::sscanf(auxString.c_str(), "[CTXT=%08X]", &contextId);
294 } else if (auxString.compare(0, 8, "[CLABEL=") == 0) {
295 contextId = this->getInputContext(auxString);
296 }
297 if (contextId >= m_dbSessionVec.size()) {
298 ATH_MSG_WARNING("setObjPtr: Using default input Stream instead of id = " << contextId);
299 contextId = IPoolSvc::kInputStream;
300 }
301 }
302 ATH_MSG_VERBOSE("setObjPtr: token=" << token->toString() << ", auxString=" << auxString << ", contextID=" << contextId);
303 // Get Context ID/label from Token
304 std::lock_guard<CallMutex> lock(*m_pers_mut[contextId]);
305 obj = m_dbSessionVec[contextId]->readObject(*token, obj);
306 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
307 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0) {
308 m_guidLists[contextId].remove(token->dbID());
309 m_guidLists[contextId].push_back(token->dbID());
310 while (m_guidLists[contextId].size() > maxFileIter->second) {
311 this->disconnectDb("FID:" + m_guidLists[contextId].begin()->toString(), contextId).ignore();
312 }
313 }
314}
315//__________________________________________________________________________
316unsigned int PoolSvc::getOutputContext(const std::string& label) {
317 std::lock_guard<CallMutex> lock(m_pool_mut);
318 if (m_mainOutputLabel.empty()) {
320 m_outputContextLabel.insert(std::pair<std::string, unsigned int>(label, IPoolSvc::kOutputStream));
321 }
322 if (label == m_mainOutputLabel || label.empty()) {
324 }
325 std::map<std::string, unsigned int>::const_iterator contextIter = m_outputContextLabel.find(label);
326 if (contextIter != m_outputContextLabel.end()) {
327 return(contextIter->second);
328 }
329 const unsigned int id = m_dbSessionVec.size();
330 m_dbSessionVec.push_back(pool::createSession(*m_catalog).release());
331 m_pers_mut.push_back(new CallMutex);
332 m_outputContextLabel.insert(std::pair<std::string, unsigned int>(label, id));
333 return(id);
334}
335//__________________________________________________________________________
336unsigned int PoolSvc::getInputContext(const std::string& label, unsigned int maxFile) {
337 std::lock_guard<CallMutex> lock(m_pool_mut);
338 if (!label.empty()) {
339 std::map<std::string, unsigned int>::const_iterator contextIter = m_inputContextLabel.find(label);
340 if (contextIter != m_inputContextLabel.end()) {
341 if (maxFile > 0) {
342 m_contextMaxFile[contextIter->second] = maxFile;
343 }
344 return(contextIter->second);
345 }
346 }
347 const unsigned int id = m_dbSessionVec.size();
348 m_dbSessionVec.push_back( pool::createSession(*m_catalog, maxFile).release() );
349 m_pers_mut.push_back(new CallMutex);
350 if (!connect(Io::READ, id).isSuccess()) {
351 ATH_MSG_WARNING("Failed to connect Input PersistencySvc: " << id);
353 }
354 if (!label.empty()) {
355 m_inputContextLabel.insert(std::pair<std::string, unsigned int>(label, id));
356 }
357 m_contextMaxFile.insert(std::pair<unsigned int, int>(id, maxFile));
358 return(id);
359}
360//__________________________________________________________________________
361std::map<std::string, unsigned int> PoolSvc::getInputContextMap() const {
362 std::lock_guard<CallMutex> lock(m_pool_mut);
363 return(m_inputContextLabel);
364}
365//__________________________________________________________________________
367 std::lock_guard<CallMutex> lock(m_pool_mut);
368 return(m_inputContextLabel.size());
369}
370//__________________________________________________________________________
371const coral::Context* PoolSvc::context() const {
372 return(m_context);
373}
374//__________________________________________________________________________
375void PoolSvc::loadComponent(const std::string& compName) {
376 m_context->loadComponent(compName);
377}
378//__________________________________________________________________________
379void PoolSvc::setShareMode(bool shareCat) {
380 m_shareCat = shareCat;
381}
382//__________________________________________________________________________
384 return(m_catalog);
385}
386//__________________________________________________________________________
387void PoolSvc::lookupBestPfn(const std::string& token, std::string& pfn, std::string& type) const {
388 std::string dbID;
389 if (token.compare(0, 4, "PFN:") == 0) {
390 m_catalog->lookupFileByPFN(token.substr(4), dbID, type); // PFN -> FID
391 } else if (token.compare(0, 4, "LFN:") == 0) {
392 m_catalog->lookupFileByLFN(token.substr(4), dbID); // LFN -> FID
393 } else if (token.compare(0, 4, "FID:") == 0) {
394 dbID = token.substr(4);
395 } else if (token.size() > Guid::stringSize()) { // full token
396 Token tok;
397 tok.fromString(token);
398 dbID = tok.dbID().toString();
399 } else { // guid only
400 dbID = token;
401 }
402 m_catalog->getFirstPFN(dbID, pfn, type); // FID -> best PFN
403}
404//__________________________________________________________________________
405void PoolSvc::renamePfn(const std::string& pf, const std::string& newpf) {
406 std::string dbID, type;
407 m_catalog->lookupFileByPFN(pf, dbID, type);
408 if (dbID.empty()) {
409 ATH_MSG_WARNING("Failed to lookup: " << pf << " in FileCatalog");
410 return;
411 }
412 m_catalog->lookupFileByPFN(newpf, dbID, type);
413 if (!dbID.empty()) {
414 ATH_MSG_INFO("Found: " << newpf << " in FileCatalog");
415 return;
416 }
417 m_catalog->renamePFN(pf, newpf);
418}
419//__________________________________________________________________________
420pool::ICollection* PoolSvc::createCollection(const std::string& connection,
421 const std::string& collectionName,
422 const pool::DbType& collectionType,
423 unsigned int contextId) const {
424 ATH_MSG_DEBUG("createCollection() type=" << collectionType.storageName() << ", connection=" << connection
425 << ", name=" << collectionName << ", contextID=" << contextId);
426 if (contextId >= m_dbSessionVec.size()) {
427 ATH_MSG_WARNING("createCollection: Using default input Stream instead of id = " << contextId);
428 contextId = IPoolSvc::kInputStream;
429 }
431 // Check POOL FileCatalog entry.
432 bool insertFile = false;
433 if (connection.compare(0, 4, "PFN:") == 0) {
434 std::string fid, fileType;
435 m_catalog->lookupFileByPFN(connection.substr(4), fid, fileType);
436 if (fid.empty()) { // No entry in file catalog
437 insertFile = true;
438 ATH_MSG_INFO("File is not in Catalog! Attempt to open it anyway.");
439 }
440 }
441 if (collectionType.majorType() == pool::POOL_StorageType.type()) {
442 // Check whether Collection Container exists.
443 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
444 if (dbH == nullptr) {
445 ATH_MSG_INFO("Failed to get Session/DatabaseHandle to create POOL collection.");
446 return(nullptr);
447 }
448 try {
449 if (dbH->openMode() == Io::INVALID) {
450 dbH->connectForRead();
451 }
452 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
453 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0 && !dbH->fid().empty()) {
454 const Guid guid(dbH->fid());
455 m_guidLists[contextId].remove(guid);
456 m_guidLists[contextId].push_back(guid);
457 while (m_guidLists[contextId].size() > maxFileIter->second + 1) {
458 this->disconnectDb("FID:" + m_guidLists[contextId].begin()->toString(), contextId).ignore();
459 }
460 }
461 } catch (std::exception& e) {
462 ATH_MSG_INFO("Failed to open container to check POOL collection - trying.");
463 }
464 }
465
466 // access to these variables is locked below:
468 pool::ICollection* collPtr ATLAS_THREAD_SAFE = nullptr;
469
470 // Try to open EventTags Collection in the input file
471 std::scoped_lock sc_lock(m_pool_mut);
472 std::string error_text;
473 try {
474 collPtr = collSvc.open(collectionName, collectionType, connection, m_dbSessionVec[contextId]);
475 } catch (std::exception &e) {
476 collPtr = nullptr;
477 error_text = e.what();
478 }
479 if( !collPtr ) {
480 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
481 if (dbH != nullptr && !dbH->fid().empty()) {
482 return(nullptr); // no events
483 }
484 throw std::runtime_error( "Failed to open Collection: " + error_text + ", PoolSvc::createCollection");
485 }
486 if (insertFile && m_attemptCatalogPatch.value()) {
487 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
488 if (dbH == nullptr) {
489 ATH_MSG_INFO("Failed to create FileCatalog entry.");
490 } else if (dbH->fid().empty()) {
491 ATH_MSG_INFO("Cannot retrieve the FID of an existing POOL database: '"
492 << connection << "' - FileCatalog will NOT be updated.");
493 } else {
494 patchCatalog(connection.substr(4), *dbH);
495 }
496 }
497 // For multithreaded processing (with multiple events in flight),
498 // increase virtual tree size to accomodate back reads
499 if (m_useROOTMaxTree && Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1) {
500 if (!this->setAttribute("TREE_MAX_VIRTUAL_SIZE", "-1", pool::ROOT_StorageType.type(), connection.substr(4), "CollectionTree", IPoolSvc::kInputStream).isSuccess()) {
501 ATH_MSG_WARNING("Failed to increase maximum virtual TTree size.");
502 }
503 }
504
505 return(collPtr);
506}
507//__________________________________________________________________________
508void PoolSvc::patchCatalog(const std::string& pfn, pool::IDatabase& dbH) const {
509 std::scoped_lock lock(m_pool_mut);
511 std::string fid = dbH.fid();
513 catalog_locked->registerPFN(pfn, "ROOT_All", fid);
514}
515//__________________________________________________________________________
516Token* PoolSvc::getToken(const std::string& connection,
517 const std::string& collection,
518 const unsigned long ientry) const {
519 std::lock_guard<CallMutex> lock(*m_pers_mut[IPoolSvc::kInputStream]);
520 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(IPoolSvc::kInputStream, connection);
521 if (dbH == nullptr) {
522 return(nullptr);
523 }
524 if (dbH->openMode() == Io::INVALID) {
525 dbH->connectForRead();
526 }
527 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), collection);
528 if (contH == nullptr) {
529 return(nullptr);
530 }
531 auto tokenIter = std::unique_ptr<pool::ITokenIterator>(contH->tokens());
532 // the Token returned by the iterator has the refCount already increased
533 return tokenIter->seek(ientry)? tokenIter->next() : nullptr;
534}
535//__________________________________________________________________________
536StatusCode PoolSvc::connect(Io::IoFlag type, unsigned int contextId) {
537 if (type != Io::READ) {
538 if (contextId >= m_dbSessionVec.size()) {
539 ATH_MSG_WARNING("connect: Using default output Stream instead of id = " << contextId);
540 contextId = IPoolSvc::kOutputStream;
541 }
542 } else {
543 if (contextId > m_dbSessionVec.size()) {
544 ATH_MSG_WARNING("connect: Using default input Stream instead of id = " << contextId);
545 contextId = IPoolSvc::kInputStream;
546 } else if (contextId == m_dbSessionVec.size()) {
547 ATH_MSG_INFO("Connecting to InputStream for: " << contextId);
548 contextId = this->getInputContext("");
549 }
550 }
551 if (contextId >= m_dbSessionVec.size()) {
552 return(StatusCode::FAILURE);
553 }
555 auto session = m_dbSessionVec[contextId];
556 // Connect to a logical database using the pre-defined technology and dbID
557 if (session->transaction().isActive()) {
558 return(StatusCode::SUCCESS);
559 }
560 if (!session->start(type)) {
561 ATH_MSG_ERROR("connect failed session = " << session << " type = " << type);
562 return(StatusCode::FAILURE);
563 }
564
565 return(StatusCode::SUCCESS);
566}
567//__________________________________________________________________________
568StatusCode PoolSvc::commit(unsigned int contextId) const {
569 if (contextId >= m_dbSessionVec.size()) {
570 return(StatusCode::FAILURE);
571 }
573 auto session = m_dbSessionVec[contextId];
574 if (session != nullptr && session->transaction().isActive()) {
575 if (!session->commit()) {
576 ATH_MSG_ERROR("POOL commit failed " << session);
577 return(StatusCode::FAILURE);
578 }
579 if (session->transaction().type() == Io::READ) {
580 session->disconnectAll();
581 }
582 }
583 return(StatusCode::SUCCESS);
584}
585//__________________________________________________________________________
586StatusCode PoolSvc::commitAndHold(unsigned int contextId) const {
587 if (contextId >= m_dbSessionVec.size()) {
588 return(StatusCode::FAILURE);
589 }
591 pool::ISession* session = m_dbSessionVec[contextId];
592 if (session != nullptr && session->transaction().isActive()) {
593 if (!session->commitAndHold()) {
594 ATH_MSG_ERROR("POOL commitAndHold failed " << session);
595 return(StatusCode::FAILURE);
596 }
597 }
598 return(StatusCode::SUCCESS);
599}
600//__________________________________________________________________________
601StatusCode PoolSvc::disconnect(unsigned int contextId) const {
602 ATH_MSG_DEBUG("Disconnect request for contextId=" << contextId);
603 if (contextId >= m_dbSessionVec.size()) {
604 return(StatusCode::SUCCESS);
605 }
607 pool::ISession* session = m_dbSessionVec[contextId];
608 if (session != nullptr && session->transaction().isActive()) {
609 if (!commit(contextId).isSuccess()) {
610 ATH_MSG_ERROR("disconnect failed to commit " << session);
611 return(StatusCode::FAILURE);
612 }
613 if (session->disconnectAll()) {
614 ATH_MSG_DEBUG("Disconnected PersistencySvc session");
615 } else {
616 ATH_MSG_ERROR("disconnect failed to diconnect PersistencySvc");
617 return(StatusCode::FAILURE);
618 }
619 }
620 return(StatusCode::SUCCESS);
621}
622//__________________________________________________________________________
623StatusCode PoolSvc::disconnectDb(const std::string& connection, unsigned int contextId) const {
624 if (contextId >= m_dbSessionVec.size()) {
625 return(StatusCode::SUCCESS);
626 }
628 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
629 if (dbH == nullptr) {
630 ATH_MSG_ERROR("Failed to get Session/DatabaseHandle.");
631 return(StatusCode::FAILURE);
632 }
633 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
634 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0) {
635 m_guidLists[contextId].remove(Guid(dbH->fid()));
636 }
637 dbH->disconnect();
638 return(StatusCode::SUCCESS);
639}
640//_______________________________________________________________________
641StatusCode PoolSvc::getAttribute(const std::string& optName,
642 std::string& data,
643 long tech,
644 unsigned int contextId) const {
645 if (contextId >= m_dbSessionVec.size()) {
646 ATH_MSG_WARNING("getAttribute: Using default input Stream instead of id = " << contextId);
647 contextId = IPoolSvc::kInputStream;
648 }
650 pool::ISession* sesH = m_dbSessionVec[contextId];
651 std::ostringstream oss;
652 if (data == "DbLonglong") {
653 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<long long int>(optName);
654 } else if (data == "double") {
655 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<double>(optName);
656 } else {
657 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<int>(optName);
658 }
659 data = oss.str();
660 ATH_MSG_INFO("Domain attribute [" << optName << "]" << ": " << data);
661 return(StatusCode::SUCCESS);
662}
663//_______________________________________________________________________
664StatusCode PoolSvc::getAttribute(const std::string& optName,
665 std::string& data,
666 long tech,
667 const std::string& dbName,
668 const std::string& contName,
669 unsigned int contextId) const {
671 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, dbName);
672 if (dbH == nullptr) {
673 ATH_MSG_DEBUG("getAttribute: Failed to get Session/DatabaseHandle to get POOL property.");
674 return(StatusCode::FAILURE);
675 }
676 if (dbH->openMode() == Io::INVALID) {
677 if (m_dbSessionVec[contextId]->transaction().type() == Io::WRITE || m_dbSessionVec[contextId]->transaction().type() == Io::APPEND) {
678 dbH->setTechnology(tech);
679 dbH->connectForWrite();
680 } else {
681 dbH->connectForRead();
682 }
683 }
684 std::ostringstream oss;
685 if (contName.empty()) {
686 if (data == "DbLonglong") {
687 oss << std::dec << dbH->technologySpecificAttributes().attribute<long long int>(optName);
688 } else if (data == "double") {
689 oss << std::dec << dbH->technologySpecificAttributes().attribute<double>(optName);
690 } else if (data == "string") {
691 oss << dbH->technologySpecificAttributes().attribute<char*>(optName);
692 } else {
693 oss << std::dec << dbH->technologySpecificAttributes().attribute<int>(optName);
694 }
695 ATH_MSG_INFO("Database (" << dbH->pfn() << ") attribute [" << optName << "]" << ": " << oss.str());
696 } else {
697 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), contName);
698 if (contH == nullptr) {
699 ATH_MSG_DEBUG("Failed to get ContainerHandle to get POOL property.");
700 return(StatusCode::FAILURE);
701 }
702 if (data == "DbLonglong") {
703 oss << std::dec << contH->technologySpecificAttributes().attribute<long long int>(optName);
704 } else if (data == "double") {
705 oss << std::dec << contH->technologySpecificAttributes().attribute<double>(optName);
706 } else {
707 oss << std::dec << contH->technologySpecificAttributes().attribute<int>(optName);
708 }
709 ATH_MSG_INFO("Container attribute [" << contName << "." << optName << "]: " << oss.str());
710 }
711 data = oss.str();
712 return(StatusCode::SUCCESS);
713}
714//_______________________________________________________________________
715StatusCode PoolSvc::setAttribute(const std::string& optName,
716 const std::string& data,
717 long tech,
718 unsigned int contextId) const {
719 if (contextId >= m_dbSessionVec.size()) {
720 ATH_MSG_WARNING("setAttribute: Using default output Stream instead of id = " << contextId);
721 contextId = IPoolSvc::kOutputStream;
722 }
724 pool::ISession* sesH = m_dbSessionVec[contextId];
725 if (data[data.size() - 1] == 'L') {
726 if (!sesH->technologySpecificAttributes(tech).setAttribute<long long int>(optName, atoll(data.c_str()))) {
727 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
728 return(StatusCode::FAILURE);
729 }
730 } else {
731 if (!sesH->technologySpecificAttributes(tech).setAttribute<int>(optName, atoi(data.c_str()))) {
732 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
733 return(StatusCode::FAILURE);
734 }
735 }
736 return(StatusCode::SUCCESS);
737}
738//_______________________________________________________________________
739StatusCode PoolSvc::setAttribute(const std::string& optName,
740 const std::string& data,
741 long tech,
742 const std::string& dbName,
743 const std::string& contName,
744 unsigned int contextId) const {
745 if (contextId >= m_dbSessionVec.size()) {
746 ATH_MSG_WARNING("setAttribute: Using default output Stream instead of id = " << contextId);
747 contextId = IPoolSvc::kOutputStream;
748 }
750 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, dbName);
751 if (dbH == nullptr) {
752 ATH_MSG_DEBUG("Failed to get Session/DatabaseHandle to set POOL property.");
753 return(StatusCode::FAILURE);
754 }
755 if (dbH->openMode() == Io::INVALID) {
756 if (m_dbSessionVec[contextId]->transaction().type() == Io::WRITE || m_dbSessionVec[contextId]->transaction().type() == Io::APPEND) {
757 dbH->setTechnology(tech);
758 dbH->connectForWrite();
759 } else {
760 dbH->connectForRead();
761 }
762 }
763 bool retError = false;
764 std::string objName;
765 bool hasTTreeName = (contName.length() > 6 && contName.compare(0, 6, "TTree=") == 0);
766 if (contName.empty() || hasTTreeName || m_dbSessionVec[contextId]->transaction().type() == Io::READ) {
767 objName = hasTTreeName ? contName.substr(6) : contName;
768 if( !isNumber(data) ) {
769 retError = dbH->technologySpecificAttributes().setAttribute(optName, data.c_str(), objName);
770 } else if( data[data.size() - 1] == 'L' ) {
771 retError = dbH->technologySpecificAttributes().setAttribute<long long int>(optName, atoll(data.c_str()), objName);
772 } else {
773 retError = dbH->technologySpecificAttributes().setAttribute<int>(optName, atoi(data.c_str()), objName);
774 }
775 if (!retError) {
776 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
777 return(StatusCode::FAILURE);
778 }
779 } else {
780 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), contName);
781 if (contH == nullptr) {
782 ATH_MSG_DEBUG("Failed to get ContainerHandle to set POOL property.");
783 return(StatusCode::FAILURE);
784 }
785 if (auto p = contName.find('('); p != std::string::npos) {
786 objName = contName.substr(p + 1); // Get BranchName between parenthesis
787 objName.erase(objName.find(')'));
788 } else if (auto p = contName.find("::"); p != std::string::npos) {
789 objName = contName.substr(p + 2); // Split off Tree name
790 } else if (auto p = contName.find('_'); p != std::string::npos) {
791 objName = contName.substr(p + 1); // Split off "POOLContainer"
792 objName.erase(objName.find('/')); // Split off key
793 }
794 std::string::size_type off = 0;
795 while ((off = objName.find_first_of("<>/")) != std::string::npos) {
796 objName[off] = '_'; // Replace special chars (e.g. templates)
797 }
798 if (data[data.size() - 1] == 'L') {
799 retError = contH->technologySpecificAttributes().setAttribute<long long int>(optName, atoll(data.c_str()), objName);
800 } else {
801 retError = contH->technologySpecificAttributes().setAttribute<int>(optName, atoi(data.c_str()), objName);
802 }
803 if (!retError) {
804 ATH_MSG_DEBUG("Failed to set POOL container property, " << optName << " for " << contName << " : " << objName << " to " << data);
805 return(StatusCode::FAILURE);
806 }
807 }
808 return(StatusCode::SUCCESS);
809}
810//__________________________________________________________________________
811StatusCode PoolSvc::setFrontierCache(const std::string& conn) {
812 std::lock_guard<CallMutex> lock(m_pool_mut);
813 ATH_MSG_VERBOSE("setFrontierCache called for connection:" << conn);
814 // setup the Frontier cache information for the given logical or physical connection string
815 // first determine if the connection is logical (no ':')
816 std::vector<std::string> physcons;
817 if (conn.find(':') == std::string::npos) {
818 // if logical, have to lookup list of physical replicas, and consider each
819 // need the CORAL ILookupSvc interface which must be loaded if needed
820 const std::string lookSvcStr("CORAL/Services/XMLLookupService");
821 coral::IHandle<coral::ILookupService> lookSvcH = m_context->query<coral::ILookupService>();
822 if (!lookSvcH.isValid()) {
823 m_context->loadComponent(lookSvcStr);
824 lookSvcH = m_context->query<coral::ILookupService>();
825 }
826 if (!lookSvcH.isValid()) {
827 ATH_MSG_ERROR("Cannot locate " << lookSvcStr);
828 return(StatusCode::FAILURE);
829 }
830 coral::IDatabaseServiceSet* dbset = lookSvcH->lookup(conn, coral::ReadOnly);
831 if (dbset != nullptr) {
832 for (int irep = 0, nrep = dbset->numberOfReplicas(); irep < nrep; ++irep) {
833 const std::string pcon = dbset->replica(irep).connectionString();
834 if (pcon.compare(0, 9, "frontier:") == 0) {
835 physcons.push_back(std::move(pcon));
836 }
837 }
838 delete dbset; dbset = nullptr;
839 } else {
840 ATH_MSG_DEBUG("setFrontierCache: Could not find any replicas for " << conn);
841 }
842 } else if (conn.compare(0, 9, "frontier:") == 0) {
843 physcons.push_back(conn);
844 }
845 // check if any replicas will try and use frontier
846 if (physcons.size() == 0) {
847 return(StatusCode::SUCCESS);
848 }
849 coral::ConnectionService conSvcH;
850 // for each frontier replica, define the web cache info
851 // get the WebCacheControl interface via ConnectionSvc
852 // note ConnectionSvc should already be loaded by initialize
853 coral::IWebCacheControl& webCache = conSvcH.webCacheControl();
854 for (const auto& physcon : physcons) {
855 const auto& refreshList = m_frontierRefresh.value();
856 if (std::find(refreshList.begin(), refreshList.end(), physcon) == refreshList.end()
857 && std::find(refreshList.begin(), refreshList.end(), conn) == refreshList.end()) {
858 // set that a table DUMMYTABLE should be refreshed - indicates that everything
859 // else in the schema should not be
860 webCache.refreshTable(physcon, "DUMMYTABLE");
861 } else {
862 // set the schema to be refreshed
863 webCache.refreshSchemaInfo(physcon);
864 }
865 ATH_MSG_DEBUG("Cache flag for connection " << physcon << " set to " << webCache.webCacheInfo(physcon).isSchemaInfoCached());
866 }
867 return(StatusCode::SUCCESS);
868}
869//__________________________________________________________________________
872 ctlg->removeCatalog("*");
873 for (auto& catalog : m_readCatalog.value()) {
874 ATH_MSG_DEBUG("POOL ReadCatalog is " << catalog);
875 if (catalog.compare(0, 8,"apcfile:") == 0 || catalog.compare(0, 7, "prfile:") == 0) {
876 std::string::size_type cpos = catalog.find(':');
877 // check for file accessed via ATLAS_POOLCOND_PATH
878 std::string file = poolCondPath(catalog.substr(cpos + 1));
879 if (!file.empty()) {
880 ATH_MSG_INFO("Resolved path (via ATLAS_POOLCOND_PATH) is " << file);
881 ctlg->addReadCatalog("file:" + file);
882 } else {
883 // As backup, check for file accessed via PathResolver
884 file = PathResolver::find_file(catalog.substr(cpos + 1), "DATAPATH");
885 if (!file.empty()) {
886 ATH_MSG_INFO("Resolved path (via DATAPATH) is " << file);
887 ctlg->addReadCatalog("file:" + file);
888 } else {
889 ATH_MSG_INFO("Unable find catalog "
890 << catalog
891 << " in $ATLAS_POOLCOND_PATH and $DATAPATH");
892 }
893 }
894 } else {
895 ctlg->addReadCatalog(catalog);
896 }
897 }
898 try {
899 ATH_MSG_INFO("POOL WriteCatalog is " << m_writeCatalog.value());
900 ctlg->setWriteCatalog(m_writeCatalog.value());
901 } catch(std::exception& e) {
902 ATH_MSG_ERROR("setWriteCatalog - caught exception: " << e.what());
903 return(nullptr); // This catalog is not setup properly!
904 }
905 return(ctlg);
906}
907
908//__________________________________________________________________________
911//__________________________________________________________________________
912std::unique_ptr<pool::IDatabase> PoolSvc::getDbHandle(unsigned int contextId, const std::string& dbName) const {
913 if (contextId >= m_dbSessionVec.size()) {
914 ATH_MSG_WARNING("getDbHandle: Using default input Stream instead of id = " << contextId);
915 contextId = IPoolSvc::kInputStream;
916 }
917 pool::ISession* sesH = m_dbSessionVec[contextId];
918 if (!sesH->transaction().isActive()) {
919 Io::IoFlag transMode = Io::READ;
920 ATH_MSG_DEBUG("Start transaction, type = " << transMode);
921 if (!sesH->transaction().start(transMode)) {
922 ATH_MSG_WARNING("Failed to start transaction, type = " << transMode);
923 return(nullptr);
924 }
925 }
926 if (dbName.compare(0, 4,"PFN:") == 0) {
927 return sesH->databaseHandle(dbName.substr(4), pool::DatabaseSpecification::PFN);
928 } else if (dbName.compare(0, 4, "LFN:") == 0) {
929 return sesH->databaseHandle(dbName.substr(4), pool::DatabaseSpecification::LFN);
930 } else if (dbName.compare(0, 4,"FID:") == 0) {
931 return sesH->databaseHandle(dbName.substr(4), pool::DatabaseSpecification::FID);
932 }
934}
935//__________________________________________________________________________
936std::unique_ptr<pool::IContainer> PoolSvc::getContainerHandle(pool::IDatabase* dbH, const std::string& contName) const {
937 pool::IContainer* contH = nullptr;
938 if (dbH == nullptr) {
939 ATH_MSG_DEBUG("No DatabaseHandle to get Container.");
940 return(nullptr);
941 }
942 if (contName.find("DataHeader") != std::string::npos) {
943 contH = dbH->containerHandle(contName.substr(0, contName.find("_p")));
944 } else {
945 contH = dbH->containerHandle(contName);
946 }
947 return(std::unique_ptr<pool::IContainer>(contH));
948}
949//__________________________________________________________________________
950std::string PoolSvc::poolCondPath(const std::string& leaf) {
951 // look for files at $ATLAS_POOLCOND_PATH/<leaf>
952 // return full filename if exists, or empty string if not
953 const char* cpath = std::getenv("ATLAS_POOLCOND_PATH");
954 if (cpath && strcmp(cpath, "") != 0) {
955 const std::string testpath = std::string(cpath) + "/" + leaf;
956
957 // Try to open file for reading. Note that a simple stat call may return
958 // a wrong result if the file is residing on an auto-mounted FS (ATR-28801).
959 if (FILE* fp = std::fopen(testpath.c_str(), "r")) {
960 std::fclose(fp);
961 return testpath;
962 }
963 }
964 return {};
965}
#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)
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:41
@ kInputStream
Definition IPoolSvc.h:41
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:20
const std::string & auxString() const
Access auxiliary string.
Definition Placement.h:41
const std::string & containerName() const
Access container name.
Definition Placement.h:33
virtual StatusCode io_reinit() override
Definition PoolSvc.cxx:133
pool::IFileCatalog * createCatalog()
Definition PoolSvc.cxx:870
virtual Token * registerForWrite(const Placement *placement, const void *obj, const RootType &classDesc) override
Definition PoolSvc.cxx:264
virtual ~PoolSvc()
Destructor.
Definition PoolSvc.cxx:909
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:405
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:371
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:536
std::string poolCondPath(const std::string &leaf)
Resolve a file using ATLAS_POOLCOND_PATH.
Definition PoolSvc.cxx:950
virtual unsigned int getInputContextMapSize() const override
Definition PoolSvc.cxx:366
void patchCatalog(const std::string &pfn, pool::IDatabase &dbH) const
Definition PoolSvc.cxx:508
CallMutex m_pool_mut
Definition PoolSvc.h:219
virtual unsigned int getInputContext(const std::string &label, unsigned int maxFile=0) override
Definition PoolSvc.cxx:336
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:387
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:715
std::vector< pool::ISession * > m_dbSessionVec
Definition PoolSvc.h:223
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:568
std::unique_ptr< pool::IContainer > getContainerHandle(pool::IDatabase *dbH, const std::string &contName) const
Get Container handle.
Definition PoolSvc.cxx:936
virtual Token * getToken(const std::string &connection, const std::string &collection, const unsigned long ientry) const override
Definition PoolSvc.cxx:516
virtual StatusCode start() override
Required of all Gaudi services:
Definition PoolSvc.cxx:202
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:252
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:623
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:288
virtual void loadComponent(const std::string &compName) override
Definition PoolSvc.cxx:375
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:420
virtual const pool::IFileCatalog * catalog() const override
Definition PoolSvc.cxx:383
void clearState()
Definition PoolSvc.cxx:227
std::map< unsigned int, unsigned int > m_contextMaxFile
Definition PoolSvc.h:228
virtual void setShareMode(bool shareCat) override
Definition PoolSvc.cxx:379
std::unique_ptr< pool::IDatabase > getDbHandle(unsigned int contextId, const std::string &dbName) const
Get Database handle.
Definition PoolSvc.cxx:912
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:586
virtual StatusCode disconnect(unsigned int contextId=IPoolSvc::kInputStream) const override
Disconnect PersistencySvc associated with a contextId.
Definition PoolSvc.cxx:601
virtual StatusCode finalize() override
Required of all Gaudi services:
Definition PoolSvc.cxx:247
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:811
virtual std::map< std::string, unsigned int > getInputContextMap() const override
Definition PoolSvc.cxx:361
virtual unsigned int getOutputContext(const std::string &label) override
Definition PoolSvc.cxx:316
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:214
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:641
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:22
const std::string & auxString() const
Access auxiliary string.
Definition Token.h:92
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition Token.cxx:135
Token & fromString(const std::string_view from)
Build from the string representation of a token.
Definition Token.cxx:169
const Guid & dbID() const
Access database identifier.
Definition Token.h:65
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
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