CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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)
 
 DuplicateTreeSentry (DuplicateTreeSentry const &)=delete
 
DuplicateTreeSentryoperator= (DuplicateTreeSentry const &)=delete
 
TTree * tree () const
 

Private Member Functions

void dup ()
 

Private Attributes

std::unique_ptr< TFile,
CloseBeforeDelete
file_
 
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

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

Definition at line 43 of file RootOutputTree.cc.

References dup().

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

Member Function Documentation

void edm::DuplicateTreeSentry::dup ( )
inlineprivate

Definition at line 59 of file RootOutputTree.cc.

References mergeVDriftHistosByStation::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_
bool isAvailable() const
Definition: Service.h:40
virtual std::string const * sourceCloneCacheHint() const =0
virtual std::string const * sourceCacheHint() const =0
Log< level::Warning, false > LogWarning
std::unique_ptr< TFile, CloseBeforeDelete > file_
DuplicateTreeSentry& edm::DuplicateTreeSentry::operator= ( DuplicateTreeSentry const &  )
delete
TTree* edm::DuplicateTreeSentry::tree ( ) const
inline

Member Data Documentation

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

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

Definition at line 93 of file RootOutputTree.cc.

Referenced by dup(), and tree().

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

Definition at line 92 of file RootOutputTree.cc.

Referenced by dup(), and tree().