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
 

Detailed Description

Definition at line 52 of file XrdStorageMaker.cc.

Constructor & Destructor Documentation

XrdStorageMaker::XrdStorageMaker ( )
inline

Definition at line 56 of file XrdStorageMaker.cc.

References web.browse_db::env.

56  :
57  m_lastDebugLevel(1),//so that 0 will trigger change
58  m_lastTimeout(0)
59  {
60  // When CMSSW loads, both XrdCl and XrdClient end up being loaded
61  // (ROOT loads XrdClient). XrdClient forces IPv4-only. Accordingly,
62  // we must explicitly set the default network stack in XrdCl to
63  // whatever is available on the node (IPv4 or IPv6).
64  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
65  if (env)
66  {
67  env->PutString("NetworkStack", "IPAuto");
68  }
69  XrdNetUtils::SetAuto(XrdNetUtils::prefAuto);
71  setDebugLevel(0);
72  }
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 112 of file XrdStorageMaker.cc.

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

116  {
117  setDebugLevel(aux.debugLevel);
118  setTimeout(aux.timeout);
119 
120  std::string fullpath(proto + ":" + path);
121  XrdCl::URL url(fullpath);
122  XrdCl::FileSystem fs(url);
123 
124  XrdCl::StatInfo *stat;
125  if (!(fs.Stat(url.GetPath(), stat)).IsOK() || (stat == nullptr))
126  {
127  return false;
128  }
129 
130  if (size) *size = stat->GetSize();
131  return true;
132  }
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 76 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().

80  {
81  setDebugLevel(aux.debugLevel);
82  setTimeout(aux.timeout);
83 
85  StorageFactory::ReadHint readHint = f->readHint();
86  StorageFactory::CacheHint cacheHint = f->cacheHint();
87 
89  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
91  else
93 
94  std::string fullpath(proto + ":" + path);
95  auto file = std::make_unique<XrdFile>(fullpath, mode);
96  return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
97  }
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 134 of file XrdStorageMaker.cc.

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

135  {
136  auto oldLevel = m_lastDebugLevel.load();
137  if(level == oldLevel) {
138  return;
139  }
140  std::lock_guard<std::mutex> guard(m_envMutex);
141  if(oldLevel != m_lastDebugLevel) {
142  //another thread just changed this value
143  return;
144  }
145 
146  // 'Error' is way too low of debug level - we have interest
147  // in warning in the default
148  switch (level)
149  {
150  case 0:
151  XrdCl::DefaultEnv::SetLogLevel("Warning");
152  break;
153  case 1:
154  XrdCl::DefaultEnv::SetLogLevel("Info");
155  break;
156  case 2:
157  XrdCl::DefaultEnv::SetLogLevel("Debug");
158  break;
159  case 3:
160  XrdCl::DefaultEnv::SetLogLevel("Dump");
161  break;
162  case 4:
163  XrdCl::DefaultEnv::SetLogLevel("Dump");
164  break;
165  default:
167  ex << "Invalid log level specified " << level;
168  ex.addContext("Calling XrdStorageMaker::setDebugLevel()");
169  throw ex;
170  }
172  }
std::atomic< unsigned int > m_lastDebugLevel
std::mutex m_envMutex
void XrdStorageMaker::setTimeout ( unsigned int  timeout) const
inline

Definition at line 174 of file XrdStorageMaker.cc.

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

175  {
177 
178  auto oldTimeout = m_lastTimeout.load();
179  if (oldTimeout == timeout) {
180  return;
181  }
182 
183  std::lock_guard<std::mutex> guard(m_envMutex);
184  if (oldTimeout != m_lastTimeout) {
185  //Another thread beat us to changing the value
186  return;
187  }
188 
189  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
190  if (env)
191  {
192  env->PutInt("StreamTimeout", timeout);
193  env->PutInt("RequestTimeout", timeout);
194  env->PutInt("ConnectionWindow", timeout);
195  env->PutInt("StreamErrorWindow", timeout);
196  // Crank down some of the connection defaults. We have more
197  // aggressive error recovery than the default client so we
198  // can error out sooner.
199  env->PutInt("ConnectionWindow", timeout/6+1);
200  env->PutInt("ConnectionRetry", 2);
201  }
203  }
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 99 of file XrdStorageMaker.cc.

References StorageMaker::AuxSettings::debugLevel, 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 
108  auto prep_handler = new PrepareHandler(url);
109  prep_handler->callAsyncPrepare();
110  }
void setTimeout(unsigned int timeout) const
void setDebugLevel(unsigned int level) const

Member Data Documentation

std::mutex XrdStorageMaker::m_envMutex
mutableprivate

Definition at line 206 of file XrdStorageMaker.cc.

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

Definition at line 207 of file XrdStorageMaker.cc.

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

Definition at line 208 of file XrdStorageMaker.cc.

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

Definition at line 54 of file XrdStorageMaker.cc.