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

Constructor & Destructor Documentation

XrdStorageMaker::XrdStorageMaker ( )
inline

Definition at line 36 of file XrdStorageMaker.cc.

References web.browse_db::env.

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

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

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

60  {
61  setDebugLevel(aux.debugLevel);
62  setTimeout(aux.timeout);
63 
65  StorageFactory::ReadHint readHint = f->readHint();
66  StorageFactory::CacheHint cacheHint = f->cacheHint();
67 
69  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
71  else
73 
74  std::string fullpath(proto + ":" + path);
75  auto file = std::make_unique<XrdFile>(fullpath, mode);
76  return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
77  }
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:510
void setDebugLevel(unsigned int level) const
void XrdStorageMaker::setDebugLevel ( unsigned int  level) const
inline

Definition at line 119 of file XrdStorageMaker.cc.

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

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

Definition at line 159 of file XrdStorageMaker.cc.

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

160  {
162 
163  auto oldTimeout = m_lastTimeout.load();
164  if (oldTimeout == timeout) {
165  return;
166  }
167 
168  std::lock_guard<std::mutex> guard(m_envMutex);
169  if (oldTimeout != m_lastTimeout) {
170  //Another thread beat us to changing the value
171  return;
172  }
173 
174  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
175  if (env)
176  {
177  env->PutInt("StreamTimeout", timeout);
178  env->PutInt("RequestTimeout", timeout);
179  env->PutInt("ConnectionWindow", timeout);
180  env->PutInt("StreamErrorWindow", timeout);
181  // Crank down some of the connection defaults. We have more
182  // aggressive error recovery than the default client so we
183  // can error out sooner.
184  env->PutInt("ConnectionWindow", timeout/6+1);
185  env->PutInt("ConnectionRetry", 2);
186  }
188  }
std::mutex m_envMutex
int timeout
Definition: mps_check.py:51
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 79 of file XrdStorageMaker.cc.

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

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

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

Definition at line 193 of file XrdStorageMaker.cc.

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

Definition at line 194 of file XrdStorageMaker.cc.

MakerResponseHandler XrdStorageMaker::m_null_handler
mutableprivate

Definition at line 191 of file XrdStorageMaker.cc.

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

Definition at line 34 of file XrdStorageMaker.cc.