CMS 3D CMS Logo

DCacheStorageMaker Class Reference

Inheritance diagram for DCacheStorageMaker:

StorageMaker

List of all members.

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, const std::string &tmpdir)
 Open a storage object for the given URL (protocol + path), using the mode bits.
virtual void stagein (const std::string &proto, const std::string &path)

Static Private Member Functions

static std::string normalise (const std::string &proto, const std::string &path)
 Return appropriate path for use with dcap library.


Detailed Description

Definition at line 10 of file DCacheStorageMaker.cc.


Member Function Documentation

virtual bool DCacheStorageMaker::check ( const std::string &  proto,
const std::string &  path,
IOOffset size = 0 
) [inline, virtual]

Reimplemented from StorageMaker.

Definition at line 70 of file DCacheStorageMaker.cc.

References normalise(), and size.

00073   {
00074     std::string testpath (normalise (proto, path));
00075     if (dc_access (testpath.c_str (), R_OK) != 0)
00076       return false;
00077 
00078     if (size)
00079     {
00080       struct stat64 buf;
00081       if (dc_stat64 (testpath.c_str (), &buf) != 0)
00082         return false;
00083         
00084       *size = buf.st_size;
00085     }
00086 
00087     return true;
00088   }

static std::string DCacheStorageMaker::normalise ( const std::string &  proto,
const std::string &  path 
) [inline, static, private]

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

References p.

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

00017   {
00018     size_t p = path.find("/pnfs");
00019     if (p < 3)
00020       return (proto == "gsidcap") ? proto + ':' + path.substr(p) : path.substr(p);
00021 
00022     // remove multiple "/"
00023     p = path.find_first_not_of('/');
00024 
00025     // it's url, return the full thing
00026     return proto + "://" + path.substr(p);
00027   }

virtual Storage* DCacheStorageMaker::open ( const std::string &  proto,
const std::string &  path,
int  mode,
const std::string &  tmpdir 
) [inline, virtual]

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::accounting(), StorageFactory::CACHE_HINT_AUTO_DETECT, StorageFactory::CACHE_HINT_LAZY_DOWNLOAD, StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), f, file, StorageFactory::get(), normalise(), IOFlags::OpenUnbuffered, IOFlags::OpenWrite, StorageFactory::READ_HINT_UNBUFFERED, StorageFactory::readHint(), and StorageFactory::tempDir().

00036   {
00037     StorageFactory *f = StorageFactory::get();
00038     StorageFactory::ReadHint readHint = f->readHint();
00039     StorageFactory::CacheHint cacheHint = f->cacheHint();
00040 
00041     if (readHint != StorageFactory::READ_HINT_UNBUFFERED
00042         || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
00043       mode &= ~IOFlags::OpenUnbuffered;
00044     else
00045       mode |= IOFlags::OpenUnbuffered;
00046 
00047     Storage *file = new DCacheFile(normalise(proto, path), mode);
00048     if ((cacheHint == StorageFactory::CACHE_HINT_LAZY_DOWNLOAD
00049          || cacheHint == StorageFactory::CACHE_HINT_AUTO_DETECT)
00050         && ! (mode & IOFlags::OpenWrite))
00051     {
00052       if (f->accounting())
00053         file = new StorageAccountProxy(proto, file);
00054       file = new LocalCacheFile(file, f->tempDir());
00055     }
00056     return file;
00057   }

virtual void DCacheStorageMaker::stagein ( const std::string &  proto,
const std::string &  path 
) [inline, virtual]

Reimplemented from StorageMaker.

Definition at line 59 of file DCacheStorageMaker.cc.

References Exception, and normalise().

00061   {
00062     std::string npath = normalise(proto, path);
00063     if (dc_stage(npath.c_str(), 0, 0) != 0)
00064       throw cms::Exception("DCacheStorageMaker::stagein()")
00065         << "Cannot stage in file '" << npath
00066         << "', error was: " << dc_strerror(dc_errno)
00067         << " (dc_errno=" << dc_errno << ")";
00068   }


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:17:41 2009 for CMSSW by  doxygen 1.5.4