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 public:
14  virtual Storage *open (const std::string &proto,
15  const std::string &path,
16  int mode) override
17  {
18  // The important part here is not the cache size (which will get
19  // auto-adjusted), but the fact the cache is set to something non-zero.
20  // If we don't do this before creating the XrdFile object, caching will be
21  // completely disabled, resulting in poor performance.
22  EnvPutInt(NAME_READCACHESIZE, 20*1024*1024);
23 
25  StorageFactory::ReadHint readHint = f->readHint();
26  StorageFactory::CacheHint cacheHint = f->cacheHint();
27 
29  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
30  mode &= ~IOFlags::OpenUnbuffered;
31  else
33 
34  std::string fullpath(proto + ":" + path);
35  Storage *file = new XrdFile (fullpath, mode);
36  return f->wrapNonLocalFile(file, proto, std::string(), mode);
37  }
38 
39  virtual void stagein (const std::string &proto, const std::string &path) override
40  {
41  std::string fullpath(proto + ":" + path);
42  XrdClientAdmin admin(fullpath.c_str());
43  if (admin.Connect())
44  {
45  XrdOucString str(fullpath.c_str());
46  XrdClientUrlSet url(str);
47  admin.Prepare(url.GetFile().c_str(), kXR_stage | kXR_noerrs, 0);
48  }
49  }
50 
51  virtual bool check (const std::string &proto,
52  const std::string &path,
53  IOOffset *size = 0) override
54  {
55  std::string fullpath(proto + ":" + path);
56  XrdClientAdmin admin(fullpath.c_str());
57  if (! admin.Connect())
58  return false; // FIXME: Throw?
59 
60  long id;
61  long flags;
62  long modtime;
63  long long xrdsize;
64 
65  XrdOucString str(fullpath.c_str());
66  XrdClientUrlSet url(str);
67 
68  if (! admin.Stat(url.GetFile().c_str(), id, xrdsize, flags, modtime))
69  return false; // FIXME: Throw?
70 
71  *size = xrdsize;
72  return true;
73  }
74 
75  virtual void setDebugLevel (unsigned int level) override
76  {
77  EnvPutInt("DebugLevel", level);
78  }
79 };
80 
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
Storage * wrapNonLocalFile(Storage *s, const std::string &proto, const std::string &path, int mode)
static StorageFactory * get(void)
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.