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

Public Member Functions

void stats (std::ostream &o) const
 
void statsXML (std::map< std::string, std::string > &data) const
 
void termination (void) const
 
 TFileAdaptor (const edm::ParameterSet &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 22 of file TFileAdaptor.cc.

Constructor & Destructor Documentation

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

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

54  : enabled_(true),
55  doStats_(true),
56  cacheHint_("application-only"),
57  readHint_("auto-detect"),
58  tempDir_(),
59  minFree_(0),
60  timeout_(0U),
61  native_() {
62  if (!(enabled_ = p.getUntrackedParameter<bool> ("enable", enabled_)))
63  return;
64 
66  doStats_ = p.getUntrackedParameter<bool> ("stats", doStats_);
67 
68  // values set in the site local config or in SiteLocalConfigService override
69  // any values set here for this service.
70  // These parameters here are needed only for backward compatibility
71  // for WMDM tools until we switch to only using the site local config for this info.
72  cacheHint_ = p.getUntrackedParameter<std::string> ("cacheHint", cacheHint_);
73  readHint_ = p.getUntrackedParameter<std::string> ("readHint", readHint_);
74  tempDir_ = p.getUntrackedParameter<std::string> ("tempDir", f->tempPath());
75  minFree_ = p.getUntrackedParameter<double> ("tempMinFree", f->tempMinFree());
76  native_ = p.getUntrackedParameter<std::vector<std::string> >("native", native_);
77 
79 
80  // Retrieve values from SiteLocalConfigService.
81  // Any such values will override values set above.
83  if (pSLC.isAvailable()) {
84  if (std::string const* p = pSLC->sourceCacheTempDir()) {
85  tempDir_ = *p;
86  }
87  if (double const* p = pSLC->sourceCacheMinFree()) {
88  minFree_ = *p;
89  }
90  if (std::string const* p = pSLC->sourceCacheHint()) {
91  cacheHint_ = *p;
92  }
93  if (std::string const* p = pSLC->sourceReadHint()) {
94  readHint_ = *p;
95  }
96  if (unsigned int const* p = pSLC->sourceTimeout()) {
97  timeout_ = *p;
98  }
99  if (std::vector<std::string> const* p = pSLC->sourceNativeProtocols()) {
100  native_ = *p;
101  }
102  }
103 
104  // tell factory how clients should access files
105  if (cacheHint_ == "application-only")
107  else if (cacheHint_ == "storage-only")
109  else if (cacheHint_ == "lazy-download")
111  else if (cacheHint_ == "auto-detect")
113  else
114  throw cms::Exception("TFileAdaptor")
115  << "Unrecognised 'cacheHint' value '" << cacheHint_
116  << "', recognised values are 'application-only',"
117  << " 'storage-only', 'lazy-download', 'auto-detect'";
118 
119  if (readHint_ == "direct-unbuffered")
121  else if (readHint_ == "read-ahead-buffered")
123  else if (readHint_ == "auto-detect")
125  else
126  throw cms::Exception("TFileAdaptor")
127  << "Unrecognised 'readHint' value '" << readHint_
128  << "', recognised values are 'direct-unbuffered',"
129  << " 'read-ahead-buffered', 'auto-detect'";
130 
131  f->setTimeout(timeout_);
132 
133  // enable file access stats accounting if requested
135 
136  // tell where to save files.
137  f->setTempDir(tempDir_, minFree_);
138 
139  // set our own root plugins
140  TPluginManager *mgr = gROOT->GetPluginManager();
141  mgr->LoadHandlersFromPluginDirs();
142 
143  if (!native("file")) addType(mgr, "^file:");
144  if (!native("http")) addType(mgr, "^http:");
145  if (!native("ftp")) addType(mgr, "^ftp:");
146  /* always */ addType(mgr, "^web:");
147  /* always */ addType(mgr, "^gsiftp:");
148  /* always */ addType(mgr, "^sfn:");
149  if (!native("rfio")) addType(mgr, "^rfio:");
150  if (!native("dcache")) addType(mgr, "^dcache:");
151  if (!native("dcap")) addType(mgr, "^dcap:");
152  if (!native("gsidcap")) addType(mgr, "^gsidcap:");
153  if (!native("storm")) addType(mgr, "^storm:");
154  if (!native("storm-lcg")) addType(mgr, "^storm-lcg:");
155  }
T getUntrackedParameter(std::string const &, T const &) const
unsigned int timeout_
Definition: TFileAdaptor.cc:30
bool enableAccounting(bool enabled)
bool native(char const *proto) const
Definition: TFileAdaptor.cc:47
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.cc:26
std::string readHint_
Definition: TFileAdaptor.cc:27
double tempMinFree(void) const
double minFree_
Definition: TFileAdaptor.cc:29
std::string tempDir_
Definition: TFileAdaptor.cc:28
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
static void addType(TPluginManager *mgr, char const *type)
Definition: TFileAdaptor.cc:33
double f[11][100]
std::vector< std::string > native_
Definition: TFileAdaptor.cc:31
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

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

Definition at line 33 of file TFileAdaptor.cc.

Referenced by TFileAdaptor().

33  {
34  mgr->AddHandler("TFile",
35  type,
36  "TStorageFactoryFile",
37  "IOPoolTFileAdaptor",
38  "TStorageFactoryFile(char const*,Option_t*,char const*,Int_t)");
39 
40  mgr->AddHandler("TSystem",
41  type,
42  "TStorageFactorySystem",
43  "IOPoolTFileAdaptor",
44  "TStorageFactorySystem()");
45  }
type
Definition: HCALResponse.h:22
static void TFileAdaptor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 157 of file TFileAdaptor.cc.

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

157  {
159  desc.addOptionalUntracked<bool>("enable");
160  desc.addOptionalUntracked<bool>("stats");
161  desc.addOptionalUntracked<std::string>("cacheHint");
162  desc.addOptionalUntracked<std::string>("readHint");
163  desc.addOptionalUntracked<std::string>("tempDir");
164  desc.addOptionalUntracked<double>("tempMinFree");
165  desc.addOptionalUntracked<std::vector<std::string> >("native");
166  descriptions.add("AdaptorConfig", desc);
167  }
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
bool TFileAdaptor::native ( char const *  proto) const
inlineprivate

Definition at line 47 of file TFileAdaptor.cc.

References spr::find(), and native_.

Referenced by TFileAdaptor().

47  {
48  return std::find(native_.begin(), native_.end(), "all") != native_.end()
49  || std::find(native_.begin(), native_.end(), proto) != native_.end();
50  }
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.cc:31
void TFileAdaptor::stats ( std::ostream &  o) const
inline

Definition at line 179 of file TFileAdaptor.cc.

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

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

Definition at line 194 of file TFileAdaptor.cc.

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

Referenced by termination().

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

Definition at line 170 of file TFileAdaptor.cc.

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

Referenced by TFileAdaptor().

170  {
171  std::map<std::string, std::string> data;
172  statsXML(data);
173  if (!data.empty()) {
175  reportSvc->reportPerformanceSummary("StorageStatistics", data);
176  }
177  }
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 26 of file TFileAdaptor.cc.

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

bool TFileAdaptor::doStats_
private

Definition at line 25 of file TFileAdaptor.cc.

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

bool TFileAdaptor::enabled_
private

Definition at line 24 of file TFileAdaptor.cc.

Referenced by TFileAdaptor().

double TFileAdaptor::minFree_
private

Definition at line 29 of file TFileAdaptor.cc.

Referenced by TFileAdaptor().

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

Definition at line 31 of file TFileAdaptor.cc.

Referenced by native(), and TFileAdaptor().

std::string TFileAdaptor::readHint_
private

Definition at line 27 of file TFileAdaptor.cc.

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

std::string TFileAdaptor::tempDir_
private

Definition at line 28 of file TFileAdaptor.cc.

Referenced by TFileAdaptor().

unsigned int TFileAdaptor::timeout_
private

Definition at line 30 of file TFileAdaptor.cc.

Referenced by TFileAdaptor().