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