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

Constructor & Destructor Documentation

XrdStorageMaker::XrdStorageMaker ( )
inline

Definition at line 32 of file XrdStorageMaker.cc.

References web.browse_db::env.

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

References StorageMaker::AuxSettings::debugLevel, reco_skim_cfg_mod::fullpath, findQualityFiles::size, hgcalPlots::stat, AlCaHLTBitMon_QueryRunRegistry::string, StorageMaker::AuxSettings::timeout, util.rrClient::URL, and relmon_authenticated_wget::url.

90  {
91  setDebugLevel(aux.debugLevel);
92  setTimeout(aux.timeout);
93 
94  std::string fullpath(proto + ":" + path);
96  XrdCl::FileSystem fs(url);
97 
98  XrdCl::StatInfo *stat;
99  if (!(fs.Stat(url.GetPath(), stat)).IsOK() || (stat == nullptr)) {
100  return false;
101  }
102 
103  if (size)
104  *size = stat->GetSize();
105  return true;
106  }
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 50 of file XrdStorageMaker.cc.

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

53  {
54  setDebugLevel(aux.debugLevel);
55  setTimeout(aux.timeout);
56 
58  StorageFactory::ReadHint readHint = f->readHint();
59  StorageFactory::CacheHint cacheHint = f->cacheHint();
60 
63  else
65 
66  std::string fullpath(proto + ":" + path);
67  auto file = std::make_unique<XrdFile>(fullpath, mode);
68  return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
69  }
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 108 of file XrdStorageMaker.cc.

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

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

Definition at line 146 of file XrdStorageMaker.cc.

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

146  {
148 
149  auto oldTimeout = m_lastTimeout.load();
150  if (oldTimeout == timeout) {
151  return;
152  }
153 
154  std::lock_guard<std::mutex> guard(m_envMutex);
155  if (oldTimeout != m_lastTimeout) {
156  //Another thread beat us to changing the value
157  return;
158  }
159 
160  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
161  if (env) {
162  env->PutInt("StreamTimeout", timeout);
163  env->PutInt("RequestTimeout", timeout);
164  env->PutInt("ConnectionWindow", timeout);
165  env->PutInt("StreamErrorWindow", timeout);
166  // Crank down some of the connection defaults. We have more
167  // aggressive error recovery than the default client so we
168  // can error out sooner.
169  env->PutInt("ConnectionWindow", timeout / 6 + 1);
170  env->PutInt("ConnectionRetry", 2);
171  }
173  }
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 71 of file XrdStorageMaker.cc.

References StorageMaker::AuxSettings::debugLevel, reco_skim_cfg_mod::fullpath, mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, StorageMaker::AuxSettings::timeout, util.rrClient::URL, and relmon_authenticated_wget::url.

71  {
72  setDebugLevel(aux.debugLevel);
73  setTimeout(aux.timeout);
74 
75  std::string fullpath(proto + ":" + path);
77  XrdCl::FileSystem fs(url);
78  std::vector<std::string> fileList;
79  fileList.push_back(url.GetPath());
80  auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, &m_null_handler);
81  if (!status.IsOK()) {
82  edm::LogWarning("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status.ToStr()
83  << "' (errNo = " << status.errNo << ")";
84  }
85  }
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 177 of file XrdStorageMaker.cc.

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

Definition at line 178 of file XrdStorageMaker.cc.

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

Definition at line 179 of file XrdStorageMaker.cc.

MakerResponseHandler XrdStorageMaker::m_null_handler
mutableprivate

Definition at line 176 of file XrdStorageMaker.cc.

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

Definition at line 30 of file XrdStorageMaker.cc.