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 Attributes | Private Attributes
XrdStorageMaker Class Referencefinal
Inheritance diagram for XrdStorageMaker:
StorageMaker

Public Member Functions

virtual bool check (const std::string &proto, const std::string &path, const AuxSettings &aux, IOOffset *size=0) const override
 
virtual std::unique_ptr< Storageopen (const std::string &proto, const std::string &path, int mode, const AuxSettings &aux) const override
 
void setDebugLevel (unsigned int level) const
 
void setTimeout (unsigned int timeout) const
 
virtual void stagein (const std::string &proto, const std::string &path, const AuxSettings &aux) const override
 
 XrdStorageMaker ()
 
- Public Member Functions inherited from StorageMaker
 StorageMaker ()=default
 
virtual ~StorageMaker ()=default
 

Static Public Attributes

static const unsigned int XRD_DEFAULT_TIMEOUT = 3*60
 

Private Attributes

std::mutex m_envMutex
 
std::atomic< unsigned int > m_lastDebugLevel
 
std::atomic< unsigned int > m_lastTimeout
 
MakerResponseHandler m_null_handler
 

Detailed Description

Definition at line 28 of file XrdStorageMaker.cc.

Constructor & Destructor Documentation

XrdStorageMaker::XrdStorageMaker ( )
inline

Definition at line 33 of file XrdStorageMaker.cc.

References web.browse_db::env, setDebugLevel(), setTimeout(), and XRD_DEFAULT_TIMEOUT.

33  :
34  m_lastDebugLevel(1),//so that 0 will trigger change
35  m_lastTimeout(0)
36  {
37  // When CMSSW loads, both XrdCl and XrdClient end up being loaded
38  // (ROOT loads XrdClient). XrdClient forces IPv4-only. Accordingly,
39  // we must explicitly set the default network stack in XrdCl to
40  // whatever is available on the node (IPv4 or IPv6).
41  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
42  if (env)
43  {
44  env->PutString("NetworkStack", "IPAuto");
45  }
46  XrdNetUtils::SetAuto(XrdNetUtils::prefAuto);
48  setDebugLevel(0);
49  }
std::atomic< unsigned int > m_lastDebugLevel
void setTimeout(unsigned int timeout) const
std::atomic< unsigned int > m_lastTimeout
static const unsigned int XRD_DEFAULT_TIMEOUT
void setDebugLevel(unsigned int level) const

Member Function Documentation

virtual bool XrdStorageMaker::check ( const std::string &  proto,
const std::string &  path,
const AuxSettings aux,
IOOffset size = 0 
) const
inlineoverridevirtual

Reimplemented from StorageMaker.

Definition at line 89 of file XrdStorageMaker.cc.

References StorageMaker::AuxSettings::debugLevel, setDebugLevel(), setTimeout(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, StorageMaker::AuxSettings::timeout, and relmon_authenticated_wget::url.

93  {
94  setDebugLevel(aux.debugLevel);
95  setTimeout(aux.timeout);
96 
97  std::string fullpath(proto + ":" + path);
98  XrdCl::URL url(fullpath);
99  XrdCl::FileSystem fs(url);
100 
101  XrdCl::StatInfo *stat;
102  if (!(fs.Stat(url.GetPath(), stat)).IsOK() || (stat == nullptr))
103  {
104  return false;
105  }
106 
107  if (size) *size = stat->GetSize();
108  return true;
109  }
void setTimeout(unsigned int timeout) const
tuple size
Write out results.
void setDebugLevel(unsigned int level) const
virtual std::unique_ptr<Storage> XrdStorageMaker::open ( const std::string &  proto,
const std::string &  path,
int  mode,
const AuxSettings aux 
) const
inlineoverridevirtual

Open a storage object for the given URL (protocol + path), using the mode bits. No temporary files are downloaded.

Implements StorageMaker.

Definition at line 53 of file XrdStorageMaker.cc.

References StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), StorageMaker::AuxSettings::debugLevel, f, mergeVDriftHistosByStation::file, StorageFactory::get(), alignBH_cfg::mode, eostools::move(), IOFlags::OpenUnbuffered, StorageFactory::READ_HINT_UNBUFFERED, StorageFactory::readHint(), setDebugLevel(), setTimeout(), AlCaHLTBitMon_QueryRunRegistry::string, StorageMaker::AuxSettings::timeout, and StorageFactory::wrapNonLocalFile().

57  {
58  setDebugLevel(aux.debugLevel);
59  setTimeout(aux.timeout);
60 
62  StorageFactory::ReadHint readHint = f->readHint();
63  StorageFactory::CacheHint cacheHint = f->cacheHint();
64 
66  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
67  mode &= ~IOFlags::OpenUnbuffered;
68  else
70 
71  std::string fullpath(proto + ":" + path);
72  auto file = std::make_unique<XrdFile>(fullpath, mode);
73  return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
74  }
CacheHint cacheHint(void) const
std::unique_ptr< Storage > wrapNonLocalFile(std::unique_ptr< Storage > s, const std::string &proto, const std::string &path, int mode) const
static const StorageFactory * get(void)
void setTimeout(unsigned int timeout) const
def move
Definition: eostools.py:510
double f[11][100]
ReadHint readHint(void) const
void setDebugLevel(unsigned int level) const
void XrdStorageMaker::setDebugLevel ( unsigned int  level) const
inline

Definition at line 111 of file XrdStorageMaker.cc.

References cms::Exception::addContext(), edm::errors::Configuration, testEve_cfg::level, m_envMutex, and m_lastDebugLevel.

Referenced by check(), open(), stagein(), and XrdStorageMaker().

112  {
113  auto oldLevel = m_lastDebugLevel.load();
114  if(level == oldLevel) {
115  return;
116  }
117  std::lock_guard<std::mutex> guard(m_envMutex);
118  if(oldLevel != m_lastDebugLevel) {
119  //another thread just changed this value
120  return;
121  }
122 
123  // 'Error' is way too low of debug level - we have interest
124  // in warning in the default
125  switch (level)
126  {
127  case 0:
128  XrdCl::DefaultEnv::SetLogLevel("Warning");
129  break;
130  case 1:
131  XrdCl::DefaultEnv::SetLogLevel("Info");
132  break;
133  case 2:
134  XrdCl::DefaultEnv::SetLogLevel("Debug");
135  break;
136  case 3:
137  XrdCl::DefaultEnv::SetLogLevel("Dump");
138  break;
139  case 4:
140  XrdCl::DefaultEnv::SetLogLevel("Dump");
141  break;
142  default:
144  ex << "Invalid log level specified " << level;
145  ex.addContext("Calling XrdStorageMaker::setDebugLevel()");
146  throw ex;
147  }
149  }
std::atomic< unsigned int > m_lastDebugLevel
std::mutex m_envMutex
tuple level
Definition: testEve_cfg.py:34
void XrdStorageMaker::setTimeout ( unsigned int  timeout) const
inline

Definition at line 151 of file XrdStorageMaker.cc.

References web.browse_db::env, m_envMutex, m_lastTimeout, and XRD_DEFAULT_TIMEOUT.

Referenced by check(), open(), stagein(), and XrdStorageMaker().

152  {
153  timeout = timeout ? timeout : XRD_DEFAULT_TIMEOUT;
154 
155  auto oldTimeout = m_lastTimeout.load();
156  if (oldTimeout == timeout) {
157  return;
158  }
159 
160  std::lock_guard<std::mutex> guard(m_envMutex);
161  if (oldTimeout != m_lastTimeout) {
162  //Another thread beat us to changing the value
163  return;
164  }
165 
166  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
167  if (env)
168  {
169  env->PutInt("StreamTimeout", timeout);
170  env->PutInt("RequestTimeout", timeout);
171  env->PutInt("ConnectionWindow", timeout);
172  env->PutInt("StreamErrorWindow", timeout);
173  // Crank down some of the connection defaults. We have more
174  // aggressive error recovery than the default client so we
175  // can error out sooner.
176  env->PutInt("ConnectionWindow", timeout/6+1);
177  env->PutInt("ConnectionRetry", 2);
178  }
179  m_lastTimeout = timeout;
180  }
std::mutex m_envMutex
std::atomic< unsigned int > m_lastTimeout
static const unsigned int XRD_DEFAULT_TIMEOUT
virtual void XrdStorageMaker::stagein ( const std::string &  proto,
const std::string &  path,
const AuxSettings aux 
) const
inlineoverridevirtual

Reimplemented from StorageMaker.

Definition at line 76 of file XrdStorageMaker.cc.

References StorageMaker::AuxSettings::debugLevel, m_null_handler, setDebugLevel(), setTimeout(), AlCaHLTBitMon_QueryRunRegistry::string, StorageMaker::AuxSettings::timeout, and relmon_authenticated_wget::url.

78  {
79  setDebugLevel(aux.debugLevel);
80  setTimeout(aux.timeout);
81 
82  std::string fullpath(proto + ":" + path);
83  XrdCl::URL url(fullpath);
84  XrdCl::FileSystem fs(url);
85  std::vector<std::string> fileList; fileList.push_back(url.GetPath());
86  fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, &m_null_handler);
87  }
MakerResponseHandler m_null_handler
void setTimeout(unsigned int timeout) const
void setDebugLevel(unsigned int level) const

Member Data Documentation

std::mutex XrdStorageMaker::m_envMutex
mutableprivate

Definition at line 184 of file XrdStorageMaker.cc.

Referenced by setDebugLevel(), and setTimeout().

std::atomic<unsigned int> XrdStorageMaker::m_lastDebugLevel
mutableprivate

Definition at line 185 of file XrdStorageMaker.cc.

Referenced by setDebugLevel().

std::atomic<unsigned int> XrdStorageMaker::m_lastTimeout
mutableprivate

Definition at line 186 of file XrdStorageMaker.cc.

Referenced by setTimeout().

MakerResponseHandler XrdStorageMaker::m_null_handler
mutableprivate

Definition at line 183 of file XrdStorageMaker.cc.

Referenced by stagein().

const unsigned int XrdStorageMaker::XRD_DEFAULT_TIMEOUT = 3*60
static

Definition at line 31 of file XrdStorageMaker.cc.

Referenced by setTimeout(), and XrdStorageMaker().