CMS 3D CMS Logo

Public Member Functions

XrdStorageMaker Class Reference

Inheritance diagram for XrdStorageMaker:
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)
virtual void setDebugLevel (unsigned int level)
virtual void stagein (const std::string &proto, const std::string &path)

Detailed Description

Definition at line 9 of file XrdStorageMaker.cc.


Member Function Documentation

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

Reimplemented from StorageMaker.

Definition at line 51 of file XrdStorageMaker.cc.

References flags, and findQualityFiles::size.

  {
    std::string fullpath(proto + ":" + path);
    XrdClientAdmin admin(fullpath.c_str());
    if (! admin.Connect())
      return false; // FIXME: Throw?

    long      id;
    long      flags;
    long      modtime;
    long long xrdsize;

    XrdOucString str(fullpath.c_str());
    XrdClientUrlSet url(str);

    if (! admin.Stat(url.GetFile().c_str(), id, xrdsize, flags, modtime))
      return false; // FIXME: Throw?

    *size = xrdsize;
    return true;
  }
virtual Storage* XrdStorageMaker::open ( const std::string &  proto,
const std::string &  path,
int  mode 
) [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 14 of file XrdStorageMaker.cc.

References StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), f, mergeVDriftHistosByStation::file, reco::get(), IOFlags::OpenUnbuffered, StorageFactory::READ_HINT_UNBUFFERED, StorageFactory::readHint(), and StorageFactory::wrapNonLocalFile().

  {
    // The important part here is not the cache size (which will get
    // auto-adjusted), but the fact the cache is set to something non-zero.
    // If we don't do this before creating the XrdFile object, caching will be
    // completely disabled, resulting in poor performance.
    EnvPutInt(NAME_READCACHESIZE, 20*1024*1024);

    StorageFactory *f = StorageFactory::get();
    StorageFactory::ReadHint readHint = f->readHint();
    StorageFactory::CacheHint cacheHint = f->cacheHint();

    if (readHint != StorageFactory::READ_HINT_UNBUFFERED
        || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
      mode &= ~IOFlags::OpenUnbuffered;
    else
      mode |=  IOFlags::OpenUnbuffered;

    std::string fullpath(proto + ":" + path);
    Storage *file = new XrdFile (fullpath, mode);
    return f->wrapNonLocalFile(file, proto, std::string(), mode);
  }
virtual void XrdStorageMaker::setDebugLevel ( unsigned int  level) [inline, virtual]

Reimplemented from StorageMaker.

Definition at line 75 of file XrdStorageMaker.cc.

  {
    EnvPutInt("DebugLevel", level);
  }
virtual void XrdStorageMaker::stagein ( const std::string &  proto,
const std::string &  path 
) [inline, virtual]

Reimplemented from StorageMaker.

Definition at line 39 of file XrdStorageMaker.cc.

  {
    std::string fullpath(proto + ":" + path);
    XrdClientAdmin admin(fullpath.c_str());
    if (admin.Connect())
    {
      XrdOucString str(fullpath.c_str());
      XrdClientUrlSet url(str);
      admin.Prepare(url.GetFile().c_str(), kXR_stage | kXR_noerrs, 0);
    }
  }