CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public 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, IOOffset *size=0)
 
virtual Storageopen (const std::string &proto, const std::string &path, int mode)
 
virtual void setTimeout (unsigned int timeout)
 
virtual void stagein (const std::string &proto, const std::string &path)
 
- Public Member Functions inherited from StorageMaker
 StorageMaker (void)
 
virtual ~StorageMaker (void)
 

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,
IOOffset size = 0 
)
inlinevirtual

Reimplemented from StorageMaker.

Definition at line 61 of file DCacheStorageMaker.cc.

References normalise(), and findQualityFiles::size.

64  {
65  std::string testpath (normalise (proto, path));
66  if (dc_access (testpath.c_str (), R_OK) != 0)
67  return false;
68 
69  if (size)
70  {
71  struct stat64 buf;
72  if (dc_stat64 (testpath.c_str (), &buf) != 0)
73  return false;
74 
75  *size = buf.st_size;
76  }
77 
78  return true;
79  }
int path() const
Definition: HLTadd.h:3
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 L1TEmulatorMonitor_cff::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  }
int path() const
Definition: HLTadd.h:3
virtual Storage* DCacheStorageMaker::open ( const std::string &  proto,
const std::string &  path,
int  mode 
)
inlinevirtual

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(), normalise(), IOFlags::OpenUnbuffered, StorageFactory::READ_HINT_UNBUFFERED, StorageFactory::readHint(), and StorageFactory::wrapNonLocalFile().

35  {
37  StorageFactory::ReadHint readHint = f->readHint();
38  StorageFactory::CacheHint cacheHint = f->cacheHint();
39 
41  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
42  mode &= ~IOFlags::OpenUnbuffered;
43  else
45 
46  Storage *file = new DCacheFile(normalise(proto, path), mode);
47  return f->wrapNonLocalFile(file, proto, std::string(), mode);
48  }
CacheHint cacheHint(void) const
Definition: Storage.h:8
Storage * wrapNonLocalFile(Storage *s, const std::string &proto, const std::string &path, int mode)
int path() const
Definition: HLTadd.h:3
static StorageFactory * get(void)
double f[11][100]
ReadHint readHint(void) const
int mode
Definition: AMPTWrapper.h:139
static std::string normalise(const std::string &proto, const std::string &path)
virtual void DCacheStorageMaker::setTimeout ( unsigned int  timeout)
inlinevirtual

Reimplemented from StorageMaker.

Definition at line 81 of file DCacheStorageMaker.cc.

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

Reimplemented from StorageMaker.

Definition at line 50 of file DCacheStorageMaker.cc.

References edm::hlt::Exception, and normalise().

52  {
53  std::string npath = normalise(proto, path);
54  if (dc_stage(npath.c_str(), 0, 0) != 0)
55  throw cms::Exception("DCacheStorageMaker::stagein()")
56  << "Cannot stage in file '" << npath
57  << "', error was: " << dc_strerror(dc_errno)
58  << " (dc_errno=" << dc_errno << ")";
59  }
int path() const
Definition: HLTadd.h:3
static std::string normalise(const std::string &proto, const std::string &path)