CMS 3D CMS Logo

Public Member Functions | Static Private Member Functions

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)
virtual void setTimeout (unsigned int timeout)
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)

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 
) [inline, virtual]

Reimplemented from StorageMaker.

Definition at line 64 of file DCacheStorageMaker.cc.

References normalise(), findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

  {
    std::string testpath (normalise (proto, path));
    if (dc_access (testpath.c_str (), R_OK) != 0)
      return false;

    if (size)
    {
      struct stat64 buf;
      if (dc_stat64 (testpath.c_str (), &buf) != 0)
        return false;
        
      *size = buf.st_size;
    }

    return true;
  }
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 15 of file DCacheStorageMaker.cc.

References AlCaHLTBitMon_ParallelJobs::p.

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

  {
    size_t p = path.find("/pnfs");
    if (p < 3)
      return (proto == "gsidcap") ? proto + ':' + path.substr(p) : path.substr(p);

    // remove multiple "/"
    p = path.find_first_not_of('/');

    // it's url, return the full thing
    return proto + "://" + path.substr(p);
  }
virtual Storage* DCacheStorageMaker::open ( const std::string &  proto,
const std::string &  path,
int  mode 
) [inline, virtual]
virtual void DCacheStorageMaker::setTimeout ( unsigned int  timeout) [inline, virtual]

Reimplemented from StorageMaker.

Definition at line 84 of file DCacheStorageMaker.cc.

                                                {
    if (timeout != 0) dc_setOpenTimeout(timeout);
  }
virtual void DCacheStorageMaker::stagein ( const std::string &  proto,
const std::string &  path 
) [inline, virtual]

Reimplemented from StorageMaker.

Definition at line 50 of file DCacheStorageMaker.cc.

References cms::Exception::addContext(), normalise(), and AlCaHLTBitMon_QueryRunRegistry::string.

  {
    std::string npath = normalise(proto, path);
    if (dc_stage(npath.c_str(), 0, 0) != 0) {
      cms::Exception ex("FileStageInError");
      ex << "Cannot stage in file '" << npath
         << "', error was: " << dc_strerror(dc_errno)
         << " (dc_errno=" << dc_errno << ")";
      ex.addContext("Calling DCacheStorageMaker::stagein()");
      throw ex;
    }
  }