CMS 3D CMS Logo

DCacheStorageMaker.cc
Go to the documentation of this file.
6 #include <unistd.h>
7 #include <dcap.h>
8 
14  static std::string normalise(const std::string &proto, const std::string &path) {
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  }
25 
26 public:
29  std::unique_ptr<Storage> open(const std::string &proto,
30  const std::string &path,
31  int mode,
32  AuxSettings const &aux) const override {
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  }
46 
47  void stagein(const std::string &proto, const std::string &path, const AuxSettings &aux) const override {
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  }
58 
59  bool check(const std::string &proto,
60  const std::string &path,
61  const AuxSettings &aux,
62  IOOffset *size = nullptr) const override {
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  }
78 
79 private:
80  void setTimeout(unsigned int timeout) const {
81  if (timeout != 0)
82  dc_setOpenTimeout(timeout);
83  }
84 };
85 
DCacheStorageMaker::normalise
static std::string normalise(const std::string &proto, const std::string &path)
Definition: DCacheStorageMaker.cc:14
DCacheStorageMaker::check
bool check(const std::string &proto, const std::string &path, const AuxSettings &aux, IOOffset *size=nullptr) const override
Definition: DCacheStorageMaker.cc:59
DCacheStorageMaker
Definition: DCacheStorageMaker.cc:9
cms::Exception::addContext
void addContext(std::string const &context)
Definition: Exception.cc:165
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
StorageMaker
Definition: StorageMaker.h:9
DCacheStorageMaker::setTimeout
void setTimeout(unsigned int timeout) const
Definition: DCacheStorageMaker.cc:80
StorageFactory::get
static const StorageFactory * get(void)
Definition: StorageFactory.cc:28
StorageMaker.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DCacheFile.h
IOFlags
Definition: IOFlags.h:4
DCacheStorageMaker::open
std::unique_ptr< Storage > open(const std::string &proto, const std::string &path, int mode, AuxSettings const &aux) const override
Definition: DCacheStorageMaker.cc:29
edmplugin::PluginFactory
Definition: PluginFactory.h:34
IOOffset
int64_t IOOffset
Definition: IOTypes.h:19
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19
StorageFactory.h
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
DCacheStorageMaker::stagein
void stagein(const std::string &proto, const std::string &path, const AuxSettings &aux) const override
Definition: DCacheStorageMaker.cc:47
timeout
Definition: timeout.py:1
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
StorageFactory
Definition: StorageFactory.h:13
StorageMakerFactory.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception.h
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
StorageMaker::AuxSettings
Definition: StorageMaker.h:11
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443