CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Attributes
XrdStorageMaker Class Referencefinal
Inheritance diagram for XrdStorageMaker:
StorageMaker

Public Member Functions

bool check (const std::string &proto, const std::string &path, const AuxSettings &aux, IOOffset *size=0) const override
 
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
 
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 32 of file XrdStorageMaker.cc.

Constructor & Destructor Documentation

XrdStorageMaker::XrdStorageMaker ( )
inline

Definition at line 37 of file XrdStorageMaker.cc.

References web.browse_db::env.

37  :
38  m_lastDebugLevel(1),//so that 0 will trigger change
39  m_lastTimeout(0)
40  {
41  // When CMSSW loads, both XrdCl and XrdClient end up being loaded
42  // (ROOT loads XrdClient). XrdClient forces IPv4-only. Accordingly,
43  // we must explicitly set the default network stack in XrdCl to
44  // whatever is available on the node (IPv4 or IPv6).
45  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
46  if (env)
47  {
48  env->PutString("NetworkStack", "IPAuto");
49  }
50  XrdNetUtils::SetAuto(XrdNetUtils::prefAuto);
52  setDebugLevel(0);
53  }
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

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 98 of file XrdStorageMaker.cc.

References StorageMaker::AuxSettings::debugLevel, findQualityFiles::size, trackingPlots::stat, AlCaHLTBitMon_QueryRunRegistry::string, StorageMaker::AuxSettings::timeout, and relmon_authenticated_wget::url.

102  {
103  setDebugLevel(aux.debugLevel);
104  setTimeout(aux.timeout);
105 
106  std::string fullpath(proto + ":" + path);
107  XrdCl::URL url(fullpath);
108  XrdCl::FileSystem fs(url);
109 
110  XrdCl::StatInfo *stat;
111  if (!(fs.Stat(url.GetPath(), stat)).IsOK() || (stat == nullptr))
112  {
113  return false;
114  }
115 
116  if (size) *size = stat->GetSize();
117  return true;
118  }
size
Write out results.
void setTimeout(unsigned int timeout) const
void setDebugLevel(unsigned int level) const
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 57 of file XrdStorageMaker.cc.

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

61  {
62  setDebugLevel(aux.debugLevel);
63  setTimeout(aux.timeout);
64 
66  StorageFactory::ReadHint readHint = f->readHint();
67  StorageFactory::CacheHint cacheHint = f->cacheHint();
68 
70  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
72  else
74 
75  std::string fullpath(proto + ":" + path);
76  auto file = std::make_unique<XrdFile>(fullpath, mode);
77  return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
78  }
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
Definition: IOFlags.h:4
static const StorageFactory * get(void)
void setTimeout(unsigned int timeout) const
double f[11][100]
ReadHint readHint(void) const
def move(src, dest)
Definition: eostools.py:511
void setDebugLevel(unsigned int level) const
void XrdStorageMaker::setDebugLevel ( unsigned int  level) const
inline

Definition at line 120 of file XrdStorageMaker.cc.

References cms::Exception::addContext(), edm::errors::Configuration, and hcalDigis_cfi::level.

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

Definition at line 160 of file XrdStorageMaker.cc.

References web.browse_db::env, and mps_check::timeout.

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

Reimplemented from StorageMaker.

Definition at line 80 of file XrdStorageMaker.cc.

References StorageMaker::AuxSettings::debugLevel, mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, StorageMaker::AuxSettings::timeout, and relmon_authenticated_wget::url.

82  {
83  setDebugLevel(aux.debugLevel);
84  setTimeout(aux.timeout);
85 
86  std::string fullpath(proto + ":" + path);
87  XrdCl::URL url(fullpath);
88  XrdCl::FileSystem fs(url);
89  std::vector<std::string> fileList; fileList.push_back(url.GetPath());
90  auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, &m_null_handler);
91  if (!status.IsOK())
92  {
93  edm::LogWarning("StageInError") << "XrdCl::FileSystem::Prepare failed with error '"
94  << status.ToStr() << "' (errNo = " << status.errNo << ")";
95  }
96  }
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 193 of file XrdStorageMaker.cc.

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

Definition at line 194 of file XrdStorageMaker.cc.

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

Definition at line 195 of file XrdStorageMaker.cc.

MakerResponseHandler XrdStorageMaker::m_null_handler
mutableprivate

Definition at line 192 of file XrdStorageMaker.cc.

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

Definition at line 35 of file XrdStorageMaker.cc.