|
5 | 5 | #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" |
6 | 6 | #include "FWCore/ParameterSet/interface/ParameterSet.h" |
7 | 7 | #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" |
| 8 | +#include "FWCore/ParameterSet/interface/PluginDescription.h" |
8 | 9 | #include "FWCore/Reflection/interface/SetClassParsing.h" |
9 | 10 | #include "FWCore/ServiceRegistry/interface/Service.h" |
10 | 11 | #include "FWCore/Utilities/interface/EDMException.h" |
11 | 12 | #include "Utilities/StorageFactory/interface/StorageAccount.h" |
12 | 13 | #include "Utilities/StorageFactory/interface/StorageFactory.h" |
| 14 | +#include "Utilities/StorageFactory/interface/StorageProxyMaker.h" |
| 15 | +#include "Utilities/StorageFactory/interface/StorageProxyMakerFactory.h" |
13 | 16 |
|
14 | 17 | #include <TROOT.h> |
15 | 18 | #include <TFile.h> |
@@ -68,32 +71,26 @@ bool TFileAdaptor::native(char const* proto) const { |
68 | 71 | } |
69 | 72 |
|
70 | 73 | TFileAdaptor::TFileAdaptor(edm::ParameterSet const& pset, edm::ActivityRegistry& ar) |
71 | | - : enabled_(true), |
72 | | - doStats_(true), |
| 74 | + : enabled_(pset.getUntrackedParameter<bool>("enable")), |
| 75 | + doStats_(pset.getUntrackedParameter<bool>("stats")), |
73 | 76 | enablePrefetching_(false), |
74 | | - cacheHint_("auto-detect"), |
75 | | - readHint_("auto-detect"), |
76 | | - tempDir_(), |
77 | | - minFree_(0), |
| 77 | + // values set in the site local config or in SiteLocalConfigService override |
| 78 | + // any values set here for this service. |
| 79 | + // These parameters here are needed only for backward compatibility |
| 80 | + // for WMDM tools until we switch to only using the site local config for this info. |
| 81 | + cacheHint_(pset.getUntrackedParameter<std::string>("cacheHint")), |
| 82 | + readHint_(pset.getUntrackedParameter<std::string>("readHint")), |
| 83 | + tempDir_(pset.getUntrackedParameter<std::string>("tempDir")), |
| 84 | + minFree_(pset.getUntrackedParameter<double>("tempMinFree")), |
| 85 | + native_(pset.getUntrackedParameter<std::vector<std::string>>("native")), |
| 86 | + // end of section of values overridden by SiteLocalConfigService |
78 | 87 | timeout_(0U), |
79 | | - debugLevel_(0U), |
80 | | - native_() { |
81 | | - if (!(enabled_ = pset.getUntrackedParameter<bool>("enable", enabled_))) |
| 88 | + debugLevel_(0U) { |
| 89 | + if (not enabled_) |
82 | 90 | return; |
83 | 91 |
|
84 | 92 | using namespace edm::storage; |
85 | 93 | StorageFactory* f = StorageFactory::getToModify(); |
86 | | - doStats_ = pset.getUntrackedParameter<bool>("stats", doStats_); |
87 | | - |
88 | | - // values set in the site local config or in SiteLocalConfigService override |
89 | | - // any values set here for this service. |
90 | | - // These parameters here are needed only for backward compatibility |
91 | | - // for WMDM tools until we switch to only using the site local config for this info. |
92 | | - cacheHint_ = pset.getUntrackedParameter<std::string>("cacheHint", cacheHint_); |
93 | | - readHint_ = pset.getUntrackedParameter<std::string>("readHint", readHint_); |
94 | | - tempDir_ = pset.getUntrackedParameter<std::string>("tempDir", f->tempPath()); |
95 | | - minFree_ = pset.getUntrackedParameter<double>("tempMinFree", f->tempMinFree()); |
96 | | - native_ = pset.getUntrackedParameter<std::vector<std::string> >("native", native_); |
97 | 94 |
|
98 | 95 | ar.watchPostEndJob(this, &TFileAdaptor::termination); |
99 | 96 |
|
@@ -161,6 +158,15 @@ TFileAdaptor::TFileAdaptor(edm::ParameterSet const& pset, edm::ActivityRegistry& |
161 | 158 | // tell where to save files. |
162 | 159 | f->setTempDir(tempDir_, minFree_); |
163 | 160 |
|
| 161 | + // forward generic storage proxy makers |
| 162 | + { |
| 163 | + std::vector<std::unique_ptr<StorageProxyMaker>> makers; |
| 164 | + for (auto const& pset : pset.getUntrackedParameter<std::vector<edm::ParameterSet>>("storageProxies")) { |
| 165 | + makers.push_back(StorageProxyMakerFactory::get()->create(pset.getUntrackedParameter<std::string>("type"), pset)); |
| 166 | + } |
| 167 | + f->setStorageProxyMakers(std::move(makers)); |
| 168 | + } |
| 169 | + |
164 | 170 | // set our own root plugins |
165 | 171 | TPluginManager* mgr = gROOT->GetPluginManager(); |
166 | 172 |
|
@@ -203,15 +209,49 @@ TFileAdaptor::TFileAdaptor(edm::ParameterSet const& pset, edm::ActivityRegistry& |
203 | 209 | } |
204 | 210 |
|
205 | 211 | void TFileAdaptor::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { |
| 212 | + using namespace edm::storage; |
206 | 213 | edm::ParameterSetDescription desc; |
207 | | - desc.addOptionalUntracked<bool>("enable"); |
208 | | - desc.addOptionalUntracked<bool>("stats"); |
209 | | - desc.addOptionalUntracked<std::string>("cacheHint"); |
210 | | - desc.addOptionalUntracked<std::string>("readHint"); |
211 | | - desc.addOptionalUntracked<std::string>("tempDir"); |
212 | | - desc.addOptionalUntracked<double>("tempMinFree"); |
213 | | - desc.addOptionalUntracked<std::vector<std::string> >("native"); |
| 214 | + desc.addUntracked<bool>("enable", true)->setComment("Enable or disable TFileAdaptor behavior"); |
| 215 | + desc.addUntracked<bool>("stats", true); |
| 216 | + desc.addUntracked<std::string>("cacheHint", "auto-detect") |
| 217 | + ->setComment( |
| 218 | + "Hint for read caching. Possible values: 'application-only', 'storage-only', 'lazy-download', 'auto-detect'. " |
| 219 | + "The value from the SiteLocalConfigService overrides the value set here. In addition, if the " |
| 220 | + "SiteLocalConfigService has prefetching enabled, the default hint is 'application-only'."); |
| 221 | + desc.addUntracked<std::string>("readHint", "auto-detect") |
| 222 | + ->setComment( |
| 223 | + "Hint for reading itself. Possible values: 'direct-unbuffered', 'read-ahead-buffered', 'auto-detect'. The " |
| 224 | + "value from SiteLocalConfigService overrides the value set here."); |
| 225 | + desc.addUntracked<std::string>("tempDir", StorageFactory::defaultTempDir()) |
| 226 | + ->setComment( |
| 227 | + "Colon-separated list of directories that storage implementations downloading the full file could place the " |
| 228 | + "file. The value from SiteLocalConfigService overrides the value set here."); |
| 229 | + desc.addUntracked<double>("tempMinFree", StorageFactory::defaultMinTempFree()) |
| 230 | + ->setComment( |
| 231 | + "Minimum amount of space in GB required for a temporary data directory specified in tempDir. The value from " |
| 232 | + "SiteLocalConfigService overrides the value set here."); |
| 233 | + desc.addUntracked<std::vector<std::string>>("native", {}) |
| 234 | + ->setComment( |
| 235 | + "Set of protocols for which to use a native ROOT storage implementation instead of CMSSW's StorageFactory. " |
| 236 | + "Valid " |
| 237 | + "values are 'file', 'http', 'ftp', 'dcache', 'dcap', 'gsidcap', 'root', or 'all' to prefer ROOT for all " |
| 238 | + "protocols. The value from SiteLocalConfigService overrides the value set here."); |
| 239 | + |
| 240 | + edm::ParameterSetDescription proxyMakerDesc; |
| 241 | + proxyMakerDesc.addNode(edm::PluginDescription<edm::storage::StorageProxyMakerFactory>("type", false)); |
| 242 | + std::vector<edm::ParameterSet> proxyMakerDefaults; |
| 243 | + desc.addVPSetUntracked("storageProxies", proxyMakerDesc, proxyMakerDefaults) |
| 244 | + ->setComment( |
| 245 | + "Ordered list of Storage proxies the real Storage object is wrapped into. The real Storage is wrapped into " |
| 246 | + "the first element of the list, then that proxy is wrapped into the second element of the list and so on. " |
| 247 | + "Only after this wrapping are the LocalCacheFile (lazy-download) and statistics accounting ('stats' " |
| 248 | + "parameter) proxies applied."); |
| 249 | + |
214 | 250 | descriptions.add("AdaptorConfig", desc); |
| 251 | + descriptions.setComment( |
| 252 | + "AdaptorConfig Service is used to configure the TFileAdaptor. If enabled, the TFileAdaptor registers " |
| 253 | + "TStorageFactoryFile as a handler for various protocols. The StorageFactory facility provides custom storage " |
| 254 | + "access implementations for these protocols, as well as statistics accounting."); |
215 | 255 | } |
216 | 256 |
|
217 | 257 | // Write current Storage statistics on a ostream |
|
0 commit comments