CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual bool check (const std::string &proto, const std::string &path, const AuxSettings &aux, IOOffset *size=0) const override
 
virtual std::unique_ptr< Storageopen (const std::string &proto, const std::string &path, int mode, AuxSettings const &aux) const override
 
virtual void stagein (const std::string &proto, const std::string &path, const AuxSettings &aux) const override
 
- Public Member Functions inherited from StorageMaker
 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

virtual 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 68 of file DCacheStorageMaker.cc.

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

72  {
73  setTimeout(aux.timeout);
74  std::string testpath (normalise (proto, path));
75  if (dc_access (testpath.c_str (), R_OK) != 0)
76  return false;
77 
78  if (size)
79  {
80  struct stat64 buf;
81  if (dc_stat64 (testpath.c_str (), &buf) != 0)
82  return false;
83 
84  *size = buf.st_size;
85  }
86 
87  return true;
88  }
void setTimeout(unsigned int timeout) const
static std::string normalise(const std::string &proto, const std::string &path)
tuple size
Write out results.
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 15 of file DCacheStorageMaker.cc.

References AlCaHLTBitMon_ParallelJobs::p.

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

16  {
17  size_t p = path.find("/pnfs");
18  if (p < 3)
19  return (proto == "gsidcap") ? proto + ':' + path.substr(p) : path.substr(p);
20 
21  // remove multiple "/"
22  p = path.find_first_not_of('/');
23 
24  // it's url, return the full thing
25  return proto + "://" + path.substr(p);
26  }
virtual std::unique_ptr<Storage> DCacheStorageMaker::open ( const std::string &  proto,
const std::string &  path,
int  mode,
AuxSettings const &  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 32 of file DCacheStorageMaker.cc.

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

36  {
37  setTimeout(aux.timeout);
39  StorageFactory::ReadHint readHint = f->readHint();
40  StorageFactory::CacheHint cacheHint = f->cacheHint();
41 
43  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
44  mode &= ~IOFlags::OpenUnbuffered;
45  else
47 
48  auto file = std::make_unique<DCacheFile>(normalise(proto, path), mode);
49  return f->wrapNonLocalFile(std::move(file), proto, std::string(), mode);
50  }
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
static const StorageFactory * get(void)
def move
Definition: eostools.py:510
double f[11][100]
ReadHint readHint(void) const
static std::string normalise(const std::string &proto, const std::string &path)
void DCacheStorageMaker::setTimeout ( unsigned int  timeout) const
inlineprivate

Definition at line 92 of file DCacheStorageMaker.cc.

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

92  {
93  if (timeout != 0) dc_setOpenTimeout(timeout);
94  }
int timeout
Definition: mps_check.py:51
virtual void DCacheStorageMaker::stagein ( const std::string &  proto,
const std::string &  path,
const AuxSettings aux 
) const
inlineoverridevirtual

Reimplemented from StorageMaker.

Definition at line 52 of file DCacheStorageMaker.cc.

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

55  {
56  setTimeout(aux.timeout);
57  std::string npath = normalise(proto, path);
58  if (dc_stage(npath.c_str(), 0, 0) != 0) {
59  cms::Exception ex("FileStageInError");
60  ex << "Cannot stage in file '" << npath
61  << "', error was: " << dc_strerror(dc_errno)
62  << " (dc_errno=" << dc_errno << ")";
63  ex.addContext("Calling DCacheStorageMaker::stagein()");
64  throw ex;
65  }
66  }
void setTimeout(unsigned int timeout) const
static std::string normalise(const std::string &proto, const std::string &path)