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