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.
1 
4 
10 
11 #include "XrdCl/XrdClDefaultEnv.hh"
12 #include "XrdNet/XrdNetUtils.hh"
13 
14 class MakerResponseHandler : public XrdCl::ResponseHandler
15 {
16 public:
17  virtual void HandleResponse( XrdCl::XRootDStatus *status,
18  XrdCl::AnyObject *response )
19  {
20  if (response) delete response;
21  }
22 
23 };
24 
26 {
27 public:
28  static const unsigned int XRD_DEFAULT_TIMEOUT = 3*60;
29 
31  {
32  // When CMSSW loads, both XrdCl and XrdClient end up being loaded
33  // (ROOT loads XrdClient). XrdClient forces IPv4-only. Accordingly,
34  // we must explicitly set the default network stack in XrdCl to
35  // whatever is available on the node (IPv4 or IPv6).
36  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
37  if (env)
38  {
39  env->PutString("NetworkStack", "IPAuto");
40  }
41  XrdNetUtils::SetAuto(XrdNetUtils::prefAuto);
43  }
44 
47  virtual Storage *open (const std::string &proto,
48  const std::string &path,
49  int mode) override
50  {
51 
53  StorageFactory::ReadHint readHint = f->readHint();
54  StorageFactory::CacheHint cacheHint = f->cacheHint();
55 
57  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
58  mode &= ~IOFlags::OpenUnbuffered;
59  else
61 
62  std::string fullpath(proto + ":" + path);
63  Storage *file = new XrdFile (fullpath, mode);
64  return f->wrapNonLocalFile(file, proto, std::string(), mode);
65  }
66 
67  virtual void stagein (const std::string &proto, const std::string &path) override
68  {
69  std::string fullpath(proto + ":" + path);
70  XrdCl::URL url(fullpath);
71  XrdCl::FileSystem fs(url);
72  std::vector<std::string> fileList; fileList.push_back(url.GetPath());
73  fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, &m_null_handler);
74  }
75 
76  virtual bool check (const std::string &proto,
77  const std::string &path,
78  IOOffset *size = 0) override
79  {
80  std::string fullpath(proto + ":" + path);
81  XrdCl::URL url(fullpath);
82  XrdCl::FileSystem fs(url);
83 
84  XrdCl::StatInfo *stat;
85  if (!(fs.Stat(url.GetPath(), stat)).IsOK() || (stat == nullptr))
86  {
87  return false;
88  }
89 
90  if (size) *size = stat->GetSize();
91  return true;
92  }
93 
94  virtual void setDebugLevel (unsigned int level) override
95  {
96  // 'Error' is way too low of debug level - we have interest
97  // in warning in the default
98  switch (level)
99  {
100  case 0:
101  XrdCl::DefaultEnv::SetLogLevel("Warning");
102  break;
103  case 1:
104  XrdCl::DefaultEnv::SetLogLevel("Info");
105  break;
106  case 2:
107  XrdCl::DefaultEnv::SetLogLevel("Debug");
108  break;
109  case 3:
110  XrdCl::DefaultEnv::SetLogLevel("Dump");
111  break;
112  case 4:
113  XrdCl::DefaultEnv::SetLogLevel("Dump");
114  break;
115  default:
117  ex << "Invalid log level specified " << level;
118  ex.addContext("Calling XrdStorageMaker::setDebugLevel()");
119  throw ex;
120  }
121  }
122 
123  virtual void setTimeout(unsigned int timeout) override
124  {
125  timeout = timeout ? timeout : XRD_DEFAULT_TIMEOUT;
126  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
127  if (env)
128  {
129  env->PutInt("StreamTimeout", timeout);
130  env->PutInt("RequestTimeout", timeout);
131  env->PutInt("ConnectionWindow", timeout);
132  env->PutInt("StreamErrorWindow", timeout);
133  // Crank down some of the connection defaults. We have more
134  // aggressive error recovery than the default client so we
135  // can error out sooner.
136  env->PutInt("ConnectionWindow", timeout/6+1);
137  env->PutInt("ConnectionRetry", 2);
138  }
139  }
140 
141 private:
143 };
144 
147 
CacheHint cacheHint(void) const
MakerResponseHandler m_null_handler
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)
static StorageFactory * get(void)
tuple path
else: Piece not in the list, fine.
virtual void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response)
double f[11][100]
virtual void stagein(const std::string &proto, const std::string &path) override
#define DEFINE_FWK_SERVICE(type)
Definition: ServiceMaker.h:113
static const unsigned int XRD_DEFAULT_TIMEOUT
ReadHint readHint(void) const
void addContext(std::string const &context)
Definition: Exception.cc:227
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
tuple status
Definition: ntuplemaker.py:245
virtual void setDebugLevel(unsigned int level) override
tuple size
Write out results.