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=nullptr) 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
 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

◆ check()

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

Reimplemented from StorageMaker.

Definition at line 59 of file DCacheStorageMaker.cc.

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  }

References printConversionInfo::aux, visDQMUpload::buf, normalise(), castor_dqm_sourceclient_file_cfg::path, setTimeout(), findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ normalise()

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.

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  }

References AlCaHLTBitMon_ParallelJobs::p, and castor_dqm_sourceclient_file_cfg::path.

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

◆ open()

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

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  }

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

◆ setTimeout()

void DCacheStorageMaker::setTimeout ( unsigned int  timeout) const
inlineprivate

Definition at line 80 of file DCacheStorageMaker.cc.

80  {
81  if (timeout != 0)
82  dc_setOpenTimeout(timeout);
83  }

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

◆ stagein()

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.

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  }

References cms::Exception::addContext(), printConversionInfo::aux, normalise(), castor_dqm_sourceclient_file_cfg::path, setTimeout(), and AlCaHLTBitMon_QueryRunRegistry::string.

DCacheStorageMaker::normalise
static std::string normalise(const std::string &proto, const std::string &path)
Definition: DCacheStorageMaker.cc:14
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
StorageFactory::CacheHint
CacheHint
Definition: StorageFactory.h:15
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
StorageFactory::READ_HINT_UNBUFFERED
Definition: StorageFactory.h:17
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
DCacheStorageMaker::setTimeout
void setTimeout(unsigned int timeout) const
Definition: DCacheStorageMaker.cc:80
StorageFactory::get
static const StorageFactory * get(void)
Definition: StorageFactory.cc:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IOFlags
Definition: IOFlags.h:4
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
timeout
Definition: timeout.py:1
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
StorageFactory
Definition: StorageFactory.h:13
eostools.move
def move(src, dest)
Definition: eostools.py:511
IOFlags::OpenUnbuffered
Definition: IOFlags.h:20
StorageFactory::CACHE_HINT_STORAGE
Definition: StorageFactory.h:15
cms::Exception
Definition: Exception.h:70
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
StorageFactory::ReadHint
ReadHint
Definition: StorageFactory.h:17
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443