CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XrdStorageMaker.cc
Go to the documentation of this file.
5 #include "XrdClient/XrdClientAdmin.hh"
6 #include "XrdClient/XrdClientUrlSet.hh"
7 #include "XrdClient/XrdClientEnv.hh"
8 
10 {
11 private:
12  unsigned int timeout_ = 0;
13 
14 public:
17  virtual Storage *open (const std::string &proto,
18  const std::string &path,
19  int mode) override
20  {
21  // The important part here is not the cache size (which will get
22  // auto-adjusted), but the fact the cache is set to something non-zero.
23  // If we don't do this before creating the XrdFile object, caching will be
24  // completely disabled, resulting in poor performance.
25  EnvPutInt(NAME_READCACHESIZE, 20*1024*1024);
26 
27  // XrdClient has various timeouts which vary from 3 minutes to 8 hours.
28  // This enforces an even default (10 minutes) more appropriate for the
29  // cmsRun case.
30  if (timeout_ <= 0) {setTimeout(600);}
31 
33  StorageFactory::ReadHint readHint = f->readHint();
34  StorageFactory::CacheHint cacheHint = f->cacheHint();
35 
37  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
38  mode &= ~IOFlags::OpenUnbuffered;
39  else
41 
42  std::string fullpath(proto + ":" + path);
43  Storage *file = new XrdFile (fullpath, mode);
44  return f->wrapNonLocalFile(file, proto, std::string(), mode);
45  }
46 
47  virtual void stagein (const std::string &proto, const std::string &path) override
48  {
49  std::string fullpath(proto + ":" + path);
50  XrdClientAdmin admin(fullpath.c_str());
51  if (admin.Connect())
52  {
53  XrdOucString str(fullpath.c_str());
54  XrdClientUrlSet url(str);
55  admin.Prepare(url.GetFile().c_str(), kXR_stage | kXR_noerrs, 0);
56  }
57  }
58 
59  virtual bool check (const std::string &proto,
60  const std::string &path,
61  IOOffset *size = 0) override
62  {
63  std::string fullpath(proto + ":" + path);
64  XrdClientAdmin admin(fullpath.c_str());
65  if (! admin.Connect())
66  return false; // FIXME: Throw?
67 
68  long id;
69  long flags;
70  long modtime;
71  long long xrdsize;
72 
73  XrdOucString str(fullpath.c_str());
74  XrdClientUrlSet url(str);
75 
76  if (! admin.Stat(url.GetFile().c_str(), id, xrdsize, flags, modtime))
77  return false; // FIXME: Throw?
78 
79  *size = xrdsize;
80  return true;
81  }
82 
83  virtual void setDebugLevel (unsigned int level) override
84  {
85  EnvPutInt("DebugLevel", level);
86  }
87 
88  virtual void setTimeout(unsigned int timeout) override
89  {
90  timeout_ = timeout;
91  if (timeout == 0) {return;}
92  EnvPutInt("ConnectTimeout", timeout/3+1); // Default 120. This should allow multiple connections to timeout before the open fails.
93  EnvPutInt("RequestTimeout", timeout/3+1); // Default 300. This should allow almost three requests to be performed before the transaction times out.
94  EnvPutInt("TransactionTimeout", timeout); // Default 28800
95 
96  // Safety mechanism - if client is redirected more than 255 times in 600
97  // seconds, then we abort the interaction.
98  EnvPutInt("RedirCntTimeout", 600); // Default 36000
99 
100  // Enforce some CMS defaults.
101  EnvPutInt("MaxRedirectcount", 32); // Default 16
102  EnvPutInt("ReconnectWait", 5); // Default 5
103  }
104 };
105 
CacheHint cacheHint(void) const
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
virtual Storage * open(const std::string &proto, const std::string &path, int mode) override
virtual void setTimeout(unsigned int timeout) override
Storage * wrapNonLocalFile(Storage *s, const std::string &proto, const std::string &path, int mode)
unsigned int timeout_
static StorageFactory * get(void)
tuple path
else: Piece not in the list, fine.
double f[11][100]
virtual void stagein(const std::string &proto, const std::string &path) override
ReadHint readHint(void) const
int64_t IOOffset
Definition: IOTypes.h:19
virtual bool check(const std::string &proto, const std::string &path, IOOffset *size=0) override
#define DEFINE_EDM_PLUGIN(factory, type, name)
tuple level
Definition: testEve_cfg.py:34
virtual void setDebugLevel(unsigned int level) override
tuple size
Write out results.