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

Constructor & Destructor Documentation

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

Definition at line 42 of file RootOutputTree.cc.

References dup().

Referenced by tree().

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

Member Function Documentation

void edm::DuplicateTreeSentry::dup ( )
inlineprivate

Definition at line 55 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().

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

Referenced by dup().

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

Definition at line 84 of file RootOutputTree.cc.

Referenced by dup(), and tree().

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

Definition at line 83 of file RootOutputTree.cc.

Referenced by dup(), and tree().