CMS 3D CMS Logo

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)
 
 DuplicateTreeSentry (DuplicateTreeSentry const &)=delete
 
DuplicateTreeSentryoperator= (DuplicateTreeSentry const &)=delete
 
TTree * tree () const
 

Private Member Functions

void dup ()
 

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.

References dup().

◆ DuplicateTreeSentry() [2/2]

edm::DuplicateTreeSentry::DuplicateTreeSentry ( DuplicateTreeSentry const &  )
delete

Member Function Documentation

◆ dup()

void edm::DuplicateTreeSentry::dup ( )
inlineprivate

Definition at line 59 of file RootOutputTree.cc.

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

Referenced by DuplicateTreeSentry().

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  }
std::unique_ptr< TTree > mytree_
virtual std::string const * sourceCloneCacheHint() const =0
virtual std::string const * sourceCacheHint() const =0
bool isAvailable() const
Definition: Service.h:40
Log< level::Warning, false > LogWarning
std::unique_ptr< TFile, CloseBeforeDelete > file_

◆ operator=()

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

◆ 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().