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