CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
edm::DuplicateTreeSentry Class Reference

Classes

struct  CloseBeforeDelete
 

Public Member Functions

 DuplicateTreeSentry (TTree *tree)
 
TTree * tree () const
 

Private Member Functions

void dup ()
 
 DuplicateTreeSentry (DuplicateTreeSentry const &)=delete
 
DuplicateTreeSentryoperator= (DuplicateTreeSentry const &)=delete
 

Private Attributes

std::unique_ptr< TFile, CloseBeforeDeletefile_
 
std::unique_ptr< TTree > mytree_ = nullptr
 
TTree * tree_ = nullptr
 

Detailed Description

Currently, ROOT doesn't use any latency-hiding optimizations for fast-cloning. This causes a significant slowdown when doing fast-cloning over a high-latency network (30ms latency makes this multiple factors slower).

Accordingly, we allow sites to provide a separate hint on how to treat fast- cloning. The DuplicateTreeSentry allows us to implement it - given a tree we are about to clone, with the appropriate configs, this will re-open the file with lazy-download and re-open the tree. The new tree is appropriate for cloning. When the object is destroyed, the new file and tree are cleaned up.

Definition at line 41 of file RootOutputTree.cc.

Constructor & Destructor Documentation

◆ DuplicateTreeSentry() [1/2]

edm::DuplicateTreeSentry::DuplicateTreeSentry ( TTree *  tree)
inline

Definition at line 43 of file RootOutputTree.cc.

43 : tree_(tree) { dup(); }

References dup().

◆ DuplicateTreeSentry() [2/2]

edm::DuplicateTreeSentry::DuplicateTreeSentry ( DuplicateTreeSentry const &  )
privatedelete

Member Function Documentation

◆ dup()

void edm::DuplicateTreeSentry::dup ( )
inlineprivate

Definition at line 59 of file RootOutputTree.cc.

59  {
61  if (!pSLC.isAvailable()) {
62  return;
63  }
64  if (pSLC->sourceCacheHint() && *(pSLC->sourceCacheHint()) == "lazy-download") {
65  return;
66  }
67  if (!pSLC->sourceCloneCacheHint() || *(pSLC->sourceCloneCacheHint()) != "lazy-download") {
68  return;
69  }
70  edm::LogWarning("DuplicateTreeSentry") << "Re-opening file for fast-cloning";
71 
72  TFile* file = tree_->GetCurrentFile();
73  const TUrl* url = file->GetEndpointUrl();
74  if (!url) {
75  return;
76  }
77  file_.reset(TFile::Open(url->GetUrl(), "READWRAP")); // May throw an exception.
78  if (!file_) {
79  return;
80  }
81  mytree_.reset(dynamic_cast<TTree*>(file_->Get(tree_->GetName())));
82  if (!mytree_) {
83  return;
84  }
85  }

References FrontierConditions_GlobalTag_cff::file, file_, edm::Service< T >::isAvailable(), mytree_, edm::SiteLocalConfig::sourceCacheHint(), edm::SiteLocalConfig::sourceCloneCacheHint(), tree_, and relmon_authenticated_wget::url.

Referenced by DuplicateTreeSentry().

◆ operator=()

DuplicateTreeSentry& edm::DuplicateTreeSentry::operator= ( DuplicateTreeSentry const &  )
privatedelete

◆ tree()

TTree* edm::DuplicateTreeSentry::tree ( ) const
inline

Member Data Documentation

◆ file_

std::unique_ptr<TFile, CloseBeforeDelete> edm::DuplicateTreeSentry::file_
private

Note this relies on the implicit delete ordering - mytree_ (if non-null) must be deleted before file_. Do not reorder the class members!

Definition at line 91 of file RootOutputTree.cc.

Referenced by dup().

◆ mytree_

std::unique_ptr<TTree> edm::DuplicateTreeSentry::mytree_ = nullptr
private

Definition at line 93 of file RootOutputTree.cc.

Referenced by dup(), and tree().

◆ tree_

TTree* edm::DuplicateTreeSentry::tree_ = nullptr
private

Definition at line 92 of file RootOutputTree.cc.

Referenced by dup(), and tree().

relmon_authenticated_wget.url
url
Definition: relmon_authenticated_wget.py:22
tree
Definition: tree.py:1
edm::DuplicateTreeSentry::tree_
TTree * tree_
Definition: RootOutputTree.cc:92
edm::DuplicateTreeSentry::file_
std::unique_ptr< TFile, CloseBeforeDelete > file_
Definition: RootOutputTree.cc:91
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::DuplicateTreeSentry::mytree_
std::unique_ptr< TTree > mytree_
Definition: RootOutputTree.cc:93
edm::SiteLocalConfig::sourceCloneCacheHint
virtual std::string const * sourceCloneCacheHint() const =0
edm::Service
Definition: Service.h:30
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
edm::SiteLocalConfig::sourceCacheHint
virtual std::string const * sourceCacheHint() const =0
edm::DuplicateTreeSentry::dup
void dup()
Definition: RootOutputTree.cc:59