CMS 3D CMS Logo

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

#include <TFileAdaptor.h>

Public Member Functions

void stats (std::ostream &o) const
 
void statsXML (std::map< std::string, std::string > &data) const
 
void termination (void) const
 
 TFileAdaptor (edm::ParameterSet const &p, edm::ActivityRegistry &ar)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

bool native (char const *proto) const
 

Static Private Member Functions

static void addType (TPluginManager *mgr, char const *type)
 

Private Attributes

std::string cacheHint_
 
bool doStats_
 
bool enabled_
 
double minFree_
 
std::vector< std::string > native_
 
std::string readHint_
 
std::string tempDir_
 
unsigned int timeout_
 

Detailed Description

Definition at line 17 of file TFileAdaptor.h.

Constructor & Destructor Documentation

TFileAdaptor::TFileAdaptor ( edm::ParameterSet const &  p,
edm::ActivityRegistry ar 
)

Definition at line 45 of file TFileAdaptor.cc.

References addType(), StorageFactory::CACHE_HINT_APPLICATION, StorageFactory::CACHE_HINT_AUTO_DETECT, StorageFactory::CACHE_HINT_LAZY_DOWNLOAD, StorageFactory::CACHE_HINT_STORAGE, cacheHint_, doStats_, StorageFactory::enableAccounting(), enabled_, edm::hlt::Exception, f, StorageFactory::get(), edm::ParameterSet::getUntrackedParameter(), edm::Service< T >::isAvailable(), minFree_, native(), native_, L1TEmulatorMonitor_cff::p, StorageFactory::READ_HINT_AUTO, StorageFactory::READ_HINT_READAHEAD, StorageFactory::READ_HINT_UNBUFFERED, readHint_, StorageFactory::setCacheHint(), StorageFactory::setReadHint(), StorageFactory::setTempDir(), StorageFactory::setTimeout(), edm::SiteLocalConfig::sourceCacheHint(), edm::SiteLocalConfig::sourceCacheMinFree(), edm::SiteLocalConfig::sourceCacheTempDir(), edm::SiteLocalConfig::sourceNativeProtocols(), edm::SiteLocalConfig::sourceReadHint(), edm::SiteLocalConfig::sourceTimeout(), tempDir_, StorageFactory::tempMinFree(), StorageFactory::tempPath(), termination(), timeout_, and edm::ActivityRegistry::watchPostEndJob().

46  : enabled_(true),
47  doStats_(true),
48  cacheHint_("application-only"),
49  readHint_("auto-detect"),
50  tempDir_(),
51  minFree_(0),
52  timeout_(0U),
53  native_() {
54  if (!(enabled_ = p.getUntrackedParameter<bool> ("enable", enabled_)))
55  return;
56 
58  doStats_ = p.getUntrackedParameter<bool> ("stats", doStats_);
59 
60  // values set in the site local config or in SiteLocalConfigService override
61  // any values set here for this service.
62  // These parameters here are needed only for backward compatibility
63  // for WMDM tools until we switch to only using the site local config for this info.
64  cacheHint_ = p.getUntrackedParameter<std::string> ("cacheHint", cacheHint_);
65  readHint_ = p.getUntrackedParameter<std::string> ("readHint", readHint_);
66  tempDir_ = p.getUntrackedParameter<std::string> ("tempDir", f->tempPath());
67  minFree_ = p.getUntrackedParameter<double> ("tempMinFree", f->tempMinFree());
68  native_ = p.getUntrackedParameter<std::vector<std::string> >("native", native_);
69 
71 
72  // Retrieve values from SiteLocalConfigService.
73  // Any such values will override values set above.
75  if (pSLC.isAvailable()) {
76  if (std::string const* p = pSLC->sourceCacheTempDir()) {
77  tempDir_ = *p;
78  }
79  if (double const* p = pSLC->sourceCacheMinFree()) {
80  minFree_ = *p;
81  }
82  if (std::string const* p = pSLC->sourceCacheHint()) {
83  cacheHint_ = *p;
84  }
85  if (std::string const* p = pSLC->sourceReadHint()) {
86  readHint_ = *p;
87  }
88  if (unsigned int const* p = pSLC->sourceTimeout()) {
89  timeout_ = *p;
90  }
91  if (std::vector<std::string> const* p = pSLC->sourceNativeProtocols()) {
92  native_ = *p;
93  }
94  }
95 
96  // tell factory how clients should access files
97  if (cacheHint_ == "application-only")
99  else if (cacheHint_ == "storage-only")
101  else if (cacheHint_ == "lazy-download")
103  else if (cacheHint_ == "auto-detect")
105  else
106  throw cms::Exception("TFileAdaptor")
107  << "Unrecognised 'cacheHint' value '" << cacheHint_
108  << "', recognised values are 'application-only',"
109  << " 'storage-only', 'lazy-download', 'auto-detect'";
110 
111  if (readHint_ == "direct-unbuffered")
113  else if (readHint_ == "read-ahead-buffered")
115  else if (readHint_ == "auto-detect")
117  else
118  throw cms::Exception("TFileAdaptor")
119  << "Unrecognised 'readHint' value '" << readHint_
120  << "', recognised values are 'direct-unbuffered',"
121  << " 'read-ahead-buffered', 'auto-detect'";
122 
123  f->setTimeout(timeout_);
124 
125  // enable file access stats accounting if requested
127 
128  // tell where to save files.
129  f->setTempDir(tempDir_, minFree_);
130 
131  // set our own root plugins
132  TPluginManager* mgr = gROOT->GetPluginManager();
133  mgr->LoadHandlersFromPluginDirs();
134 
135  if (!native("file")) addType(mgr, "^file:");
136  if (!native("http")) addType(mgr, "^http:");
137  if (!native("ftp")) addType(mgr, "^ftp:");
138  /* always */ addType(mgr, "^web:");
139  /* always */ addType(mgr, "^gsiftp:");
140  /* always */ addType(mgr, "^sfn:");
141  if (!native("rfio")) addType(mgr, "^rfio:");
142  if (!native("dcache")) addType(mgr, "^dcache:");
143  if (!native("dcap")) addType(mgr, "^dcap:");
144  if (!native("gsidcap")) addType(mgr, "^gsidcap:");
145  if (!native("storm")) addType(mgr, "^storm:");
146  if (!native("storm-lcg")) addType(mgr, "^storm-lcg:");
147  if (!native("lstore")) addType(mgr, "^lstore:");
148  }
unsigned int timeout_
Definition: TFileAdaptor.h:40
bool enableAccounting(bool enabled)
static void addType(TPluginManager *mgr, char const *type)
Definition: TFileAdaptor.cc:25
bool native(char const *proto) const
Definition: TFileAdaptor.cc:40
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
std::string tempPath(void) const
void setTimeout(unsigned int timeout)
void setReadHint(ReadHint value)
std::string cacheHint_
Definition: TFileAdaptor.h:36
std::string readHint_
Definition: TFileAdaptor.h:37
double tempMinFree(void) const
double minFree_
Definition: TFileAdaptor.h:39
std::string tempDir_
Definition: TFileAdaptor.h:38
static StorageFactory * get(void)
virtual std::string const * sourceCacheTempDir() const =0
virtual unsigned int const * sourceTimeout() const =0
bool isAvailable() const
Definition: Service.h:47
double f[11][100]
std::vector< std::string > native_
Definition: TFileAdaptor.h:41
virtual std::vector< std::string > const * sourceNativeProtocols() const =0
void setTempDir(const std::string &s, double minFreeSpace)
void setCacheHint(CacheHint value)
virtual double const * sourceCacheMinFree() const =0
virtual std::string const * sourceCacheHint() const =0
virtual std::string const * sourceReadHint() const =0
void termination(void) const

Member Function Documentation

void TFileAdaptor::addType ( TPluginManager *  mgr,
char const *  type 
)
staticprivate

Definition at line 25 of file TFileAdaptor.cc.

Referenced by TFileAdaptor().

25  {
26  mgr->AddHandler("TFile",
27  type,
28  "TStorageFactoryFile",
29  "IOPoolTFileAdaptor",
30  "TStorageFactoryFile(char const*,Option_t*,char const*,Int_t)");
31 
32  mgr->AddHandler("TSystem",
33  type,
34  "TStorageFactorySystem",
35  "IOPoolTFileAdaptor",
36  "TStorageFactorySystem()");
37  }
type
Definition: HCALResponse.h:22
void TFileAdaptor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 151 of file TFileAdaptor.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::addOptionalUntracked().

151  {
153  desc.addOptionalUntracked<bool>("enable");
154  desc.addOptionalUntracked<bool>("stats");
155  desc.addOptionalUntracked<std::string>("cacheHint");
156  desc.addOptionalUntracked<std::string>("readHint");
157  desc.addOptionalUntracked<std::string>("tempDir");
158  desc.addOptionalUntracked<double>("tempMinFree");
159  desc.addOptionalUntracked<std::vector<std::string> >("native");
160  descriptions.add("AdaptorConfig", desc);
161  }
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
bool TFileAdaptor::native ( char const *  proto) const
private

Definition at line 40 of file TFileAdaptor.cc.

References spr::find(), and native_.

Referenced by TFileAdaptor().

40  {
41  return std::find(native_.begin(), native_.end(), "all") != native_.end()
42  || std::find(native_.begin(), native_.end(), proto) != native_.end();
43  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< std::string > native_
Definition: TFileAdaptor.h:41
void TFileAdaptor::stats ( std::ostream &  o) const

Definition at line 175 of file TFileAdaptor.cc.

References cacheHint_, doStats_, readHint_, and StorageAccount::summaryText().

175  {
176  if (!doStats_) {
177  return;
178  }
179  float const oneMeg = 1048576.0;
180  o << "Storage parameters: adaptor: true"
181  << " Stats:" << (doStats_ ? "true" : "false") << '\n'
182  << " Cache hint:" << cacheHint_ << '\n'
183  << " Read hint:" << readHint_ << '\n'
184  << "Storage statistics: "
186  << "; tfile/read=?/?/" << (TFile::GetFileBytesRead() / oneMeg) << "MB/?ms/?ms/?ms"
187  << "; tfile/write=?/?/" << (TFile::GetFileBytesWritten() / oneMeg) << "MB/?ms/?ms/?ms";
188  }
std::string cacheHint_
Definition: TFileAdaptor.h:36
std::string readHint_
Definition: TFileAdaptor.h:37
static std::string summaryText(bool banner=false)
void TFileAdaptor::statsXML ( std::map< std::string, std::string > &  data) const

Definition at line 191 of file TFileAdaptor.cc.

References cacheHint_, doStats_, StorageAccount::fillSummary(), csvReporter::r, and readHint_.

Referenced by termination().

191  {
192  if (!doStats_) {
193  return;
194  }
195  float const oneMeg = 1048576.0;
196  data.insert(std::make_pair("Parameter-untracked-bool-enabled", "true"));
197  data.insert(std::make_pair("Parameter-untracked-bool-stats", (doStats_ ? "true" : "false")));
198  data.insert(std::make_pair("Parameter-untracked-string-cacheHint", cacheHint_));
199  data.insert(std::make_pair("Parameter-untracked-string-readHint", readHint_));
201  std::ostringstream r;
202  std::ostringstream w;
203  r << (TFile::GetFileBytesRead() / oneMeg);
204  w << (TFile::GetFileBytesWritten() / oneMeg);
205  data.insert(std::make_pair("ROOT-tfile-read-totalMegabytes", r.str()));
206  data.insert(std::make_pair("ROOT-tfile-write-totalMegabytes", w.str()));
207  }
static void fillSummary(std::map< std::string, std::string > &summary)
std::string cacheHint_
Definition: TFileAdaptor.h:36
std::string readHint_
Definition: TFileAdaptor.h:37
void TFileAdaptor::termination ( void  ) const

Definition at line 165 of file TFileAdaptor.cc.

References runTheMatrix::data, edm::JobReport::reportPerformanceSummary(), and statsXML().

Referenced by TFileAdaptor().

165  {
166  std::map<std::string, std::string> data;
167  statsXML(data);
168  if (!data.empty()) {
170  reportSvc->reportPerformanceSummary("StorageStatistics", data);
171  }
172  }
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:761
void statsXML(std::map< std::string, std::string > &data) const

Member Data Documentation

std::string TFileAdaptor::cacheHint_
private

Definition at line 36 of file TFileAdaptor.h.

Referenced by stats(), statsXML(), and TFileAdaptor().

bool TFileAdaptor::doStats_
private

Definition at line 35 of file TFileAdaptor.h.

Referenced by stats(), statsXML(), and TFileAdaptor().

bool TFileAdaptor::enabled_
private

Definition at line 34 of file TFileAdaptor.h.

Referenced by TFileAdaptor().

double TFileAdaptor::minFree_
private

Definition at line 39 of file TFileAdaptor.h.

Referenced by TFileAdaptor().

std::vector<std::string> TFileAdaptor::native_
private

Definition at line 41 of file TFileAdaptor.h.

Referenced by native(), and TFileAdaptor().

std::string TFileAdaptor::readHint_
private

Definition at line 37 of file TFileAdaptor.h.

Referenced by stats(), statsXML(), and TFileAdaptor().

std::string TFileAdaptor::tempDir_
private

Definition at line 38 of file TFileAdaptor.h.

Referenced by TFileAdaptor().

unsigned int TFileAdaptor::timeout_
private

Definition at line 40 of file TFileAdaptor.h.

Referenced by TFileAdaptor().