CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions
DCacheStorageMaker Class Reference
Inheritance diagram for DCacheStorageMaker:
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, AuxSettings const &aux) const override
 
void stagein (const std::string &proto, const std::string &path, const AuxSettings &aux) const override
 
- Public Member Functions inherited from StorageMaker
virtual std::unique_ptr< Storageopen (const std::string &proto, const std::string &path, int mode, const AuxSettings &aux) const =0
 
 StorageMaker ()=default
 
virtual ~StorageMaker ()=default
 

Private Member Functions

void setTimeout (unsigned int timeout) const
 

Static Private Member Functions

static std::string normalise (const std::string &proto, const std::string &path)
 

Detailed Description

Definition at line 9 of file DCacheStorageMaker.cc.

Member Function Documentation

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

Reimplemented from StorageMaker.

Definition at line 59 of file DCacheStorageMaker.cc.

References normalise(), setTimeout(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and StorageMaker::AuxSettings::timeout.

62  {
63  setTimeout(aux.timeout);
64  std::string testpath(normalise(proto, path));
65  if (dc_access(testpath.c_str(), R_OK) != 0)
66  return false;
67 
68  if (size) {
69  struct stat64 buf;
70  if (dc_stat64(testpath.c_str(), &buf) != 0)
71  return false;
72 
73  *size = buf.st_size;
74  }
75 
76  return true;
77  }
size
Write out results.
void setTimeout(unsigned int timeout) const
static std::string normalise(const std::string &proto, const std::string &path)
static std::string DCacheStorageMaker::normalise ( const std::string &  proto,
const std::string &  path 
)
inlinestaticprivate

Return appropriate path for use with dcap library. If the path is in the URL form ([gsi]dcap://host:port/path), return the full URL as it is. If the path is /pnfs form (dcap:/pnfs/path), return only the path part, unless the protocol is 'gsidcap', in which case return the whole thing.

Definition at line 14 of file DCacheStorageMaker.cc.

References AlCaHLTBitMon_ParallelJobs::p.

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

14  {
15  size_t p = path.find("/pnfs");
16  if (p < 3)
17  return (proto == "gsidcap") ? proto + ':' + path.substr(p) : path.substr(p);
18 
19  // remove multiple "/"
20  p = path.find_first_not_of('/');
21 
22  // it's url, return the full thing
23  return proto + "://" + path.substr(p);
24  }
std::unique_ptr<Storage> DCacheStorageMaker::open ( const std::string &  proto,
const std::string &  path,
int  mode,
AuxSettings const &  aux 
) const
inlineoverride

Open a storage object for the given URL (protocol + path), using the mode bits. No temporary files are downloaded.

Definition at line 29 of file DCacheStorageMaker.cc.

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

32  {
33  setTimeout(aux.timeout);
35  StorageFactory::ReadHint readHint = f->readHint();
36  StorageFactory::CacheHint cacheHint = f->cacheHint();
37 
40  else
42 
43  auto file = std::make_unique<DCacheFile>(normalise(proto, path), mode);
44  return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
45  }
void setTimeout(unsigned int timeout) const
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)
double f[11][100]
ReadHint readHint(void) const
static std::string normalise(const std::string &proto, const std::string &path)
def move(src, dest)
Definition: eostools.py:511
void DCacheStorageMaker::setTimeout ( unsigned int  timeout) const
inlineprivate

Definition at line 80 of file DCacheStorageMaker.cc.

References DEFINE_EDM_PLUGIN.

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

80  {
81  if (timeout != 0)
82  dc_setOpenTimeout(timeout);
83  }
void DCacheStorageMaker::stagein ( const std::string &  proto,
const std::string &  path,
const AuxSettings aux 
) const
inlineoverridevirtual

Reimplemented from StorageMaker.

Definition at line 47 of file DCacheStorageMaker.cc.

References cms::Exception::addContext(), normalise(), setTimeout(), AlCaHLTBitMon_QueryRunRegistry::string, and StorageMaker::AuxSettings::timeout.

47  {
48  setTimeout(aux.timeout);
49  std::string npath = normalise(proto, path);
50  if (dc_stage(npath.c_str(), 0, nullptr) != 0) {
51  cms::Exception ex("FileStageInError");
52  ex << "Cannot stage in file '" << npath << "', error was: " << dc_strerror(dc_errno) << " (dc_errno=" << dc_errno
53  << ")";
54  ex.addContext("Calling DCacheStorageMaker::stagein()");
55  throw ex;
56  }
57  }
void setTimeout(unsigned int timeout) const
static std::string normalise(const std::string &proto, const std::string &path)