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)
 
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_ = 0
 
TTree * tree_ = 0
 

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 44 of file RootOutputTree.cc.

References dup().

Referenced by tree().

45  : tree_(tree)
46  {
47  dup();
48  }
Definition: tree.py:1
edm::DuplicateTreeSentry::DuplicateTreeSentry ( DuplicateTreeSentry const &  )
privatedelete

Member Function Documentation

void edm::DuplicateTreeSentry::dup ( )
inlineprivate

Definition at line 57 of file RootOutputTree.cc.

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

58  {
60  if (!pSLC.isAvailable()) {return;}
61  if (pSLC->sourceCacheHint() && *(pSLC->sourceCacheHint()) == "lazy-download") {return;}
62  if (!pSLC->sourceCloneCacheHint() || *(pSLC->sourceCloneCacheHint()) != "lazy-download") {return;}
63  edm::LogWarning("DuplicateTreeSentry") << "Re-opening file for fast-cloning";
64 
65  TFile *file = tree_->GetCurrentFile();
66  const TUrl *url = file->GetEndpointUrl();
67  if (!url)
68  {
69  return;
70  }
71  file_.reset(TFile::Open(url->GetUrl(), "READWRAP")); // May throw an exception.
72  if (!file_)
73  {
74  return;
75  }
76  mytree_.reset(dynamic_cast<TTree*>(file_->Get(tree_->GetName())));
77  if (!mytree_) {return;}
78  }
virtual std::string const * sourceCacheHint() const =0
std::unique_ptr< TTree > mytree_
bool isAvailable() const
Definition: Service.h:46
virtual std::string const * sourceCloneCacheHint() const =0
std::unique_ptr< TFile, CloseBeforeDelete > file_
DuplicateTreeSentry& edm::DuplicateTreeSentry::operator= ( DuplicateTreeSentry const &  )
privatedelete

Referenced by tree().

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 84 of file RootOutputTree.cc.

Referenced by dup().

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

Definition at line 86 of file RootOutputTree.cc.

Referenced by dup(), and tree().

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

Definition at line 85 of file RootOutputTree.cc.

Referenced by dup(), and tree().