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=nullptr) 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::XrdStorageMaker ( )
inline

Definition at line 32 of file XrdStorageMaker.cc.

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  }

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

Member Function Documentation

◆ check()

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

Reimplemented from StorageMaker.

Definition at line 87 of file XrdStorageMaker.cc.

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  }

References printConversionInfo::aux, reco_skim_cfg_mod::fullpath, castor_dqm_sourceclient_file_cfg::path, setDebugLevel(), setTimeout(), findQualityFiles::size, edm_modernize_messagelogger::stat, AlCaHLTBitMon_QueryRunRegistry::string, hcal_runs::URL, and relmon_authenticated_wget::url.

◆ open()

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.

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  }

References printConversionInfo::aux, StorageFactory::CACHE_HINT_STORAGE, f, geometryDiff::file, reco_skim_cfg_mod::fullpath, StorageFactory::get(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, eostools::move(), IOFlags::OpenUnbuffered, castor_dqm_sourceclient_file_cfg::path, StorageFactory::READ_HINT_UNBUFFERED, setDebugLevel(), setTimeout(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ setDebugLevel()

void XrdStorageMaker::setDebugLevel ( unsigned int  level) const
inline

Definition at line 108 of file XrdStorageMaker.cc.

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  }

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

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

◆ setTimeout()

void XrdStorageMaker::setTimeout ( unsigned int  timeout) const
inline

Definition at line 146 of file XrdStorageMaker.cc.

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  }

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

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

◆ stagein()

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.

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  }

References printConversionInfo::aux, reco_skim_cfg_mod::fullpath, m_null_handler, castor_dqm_sourceclient_file_cfg::path, setDebugLevel(), setTimeout(), mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, hcal_runs::URL, and relmon_authenticated_wget::url.

Member Data Documentation

◆ m_envMutex

std::mutex XrdStorageMaker::m_envMutex
mutableprivate

Definition at line 177 of file XrdStorageMaker.cc.

Referenced by setDebugLevel(), and setTimeout().

◆ m_lastDebugLevel

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

Definition at line 178 of file XrdStorageMaker.cc.

Referenced by setDebugLevel().

◆ m_lastTimeout

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

Definition at line 179 of file XrdStorageMaker.cc.

Referenced by setTimeout().

◆ m_null_handler

MakerResponseHandler XrdStorageMaker::m_null_handler
mutableprivate

Definition at line 176 of file XrdStorageMaker.cc.

Referenced by stagein().

◆ XRD_DEFAULT_TIMEOUT

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

Definition at line 30 of file XrdStorageMaker.cc.

Referenced by setTimeout(), and XrdStorageMaker().

personalPlayback.level
level
Definition: personalPlayback.py:22
relmon_authenticated_wget.url
url
Definition: relmon_authenticated_wget.py:22
reco_skim_cfg_mod.fullpath
fullpath
Definition: reco_skim_cfg_mod.py:202
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
StorageFactory::CacheHint
CacheHint
Definition: StorageFactory.h:15
mps_update.status
status
Definition: mps_update.py:68
StorageFactory::READ_HINT_UNBUFFERED
Definition: StorageFactory.h:17
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::Exception
Definition: EDMException.h:77
XrdStorageMaker::XRD_DEFAULT_TIMEOUT
static const unsigned int XRD_DEFAULT_TIMEOUT
Definition: XrdStorageMaker.cc:30
XrdStorageMaker::m_lastTimeout
std::atomic< unsigned int > m_lastTimeout
Definition: XrdStorageMaker.cc:179
StorageFactory::get
static const StorageFactory * get(void)
Definition: StorageFactory.cc:28
XrdStorageMaker::m_lastDebugLevel
std::atomic< unsigned int > m_lastDebugLevel
Definition: XrdStorageMaker.cc:178
web.browse_db.env
env
Definition: browse_db.py:18
geometryDiff.file
file
Definition: geometryDiff.py:13
IOFlags
Definition: IOFlags.h:4
mps_check.timeout
int timeout
Definition: mps_check.py:53
XrdStorageMaker::setDebugLevel
void setDebugLevel(unsigned int level) const
Definition: XrdStorageMaker.cc:108
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19
timeout
Definition: timeout.py:1
XrdStorageMaker::m_null_handler
MakerResponseHandler m_null_handler
Definition: XrdStorageMaker.cc:176
StorageFactory
Definition: StorageFactory.h:13
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
XrdStorageMaker::setTimeout
void setTimeout(unsigned int timeout) const
Definition: XrdStorageMaker.cc:146
eostools.move
def move(src, dest)
Definition: eostools.py:511
IOFlags::OpenUnbuffered
Definition: IOFlags.h:20
StorageFactory::CACHE_HINT_STORAGE
Definition: StorageFactory.h:15
hcal_runs.URL
URL
Definition: hcal_runs.py:4
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
StorageFactory::ReadHint
ReadHint
Definition: StorageFactory.h:17
XrdStorageMaker::m_envMutex
std::mutex m_envMutex
Definition: XrdStorageMaker.cc:177
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
edm::errors::Configuration
Definition: EDMException.h:36
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443