CMS 3D CMS Logo

Public Member Functions | Private Member Functions

StormLcgGtStorageMaker Class Reference

Inheritance diagram for StormLcgGtStorageMaker:
StorageMaker

List of all members.

Public Member Functions

virtual bool check (const std::string &, const std::string &path, IOOffset *size=0)
virtual Storageopen (const std::string &proto, const std::string &surl, int mode)

Private Member Functions

std::string getTURL (const std::string &surl)

Detailed Description

Definition at line 12 of file StormLCGStorageMaker.cc.


Member Function Documentation

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

Reimplemented from StorageMaker.

Definition at line 77 of file StormLCGStorageMaker.cc.

References getTURL(), and findQualityFiles::size.

  {
    struct stat st;
    if (stat (getTURL(path).c_str(), &st) != 0)
      return false;

    if (size)
      *size = st.st_size;

    return true;
  }
std::string StormLcgGtStorageMaker::getTURL ( const std::string &  surl) [inline, private]

Definition at line 15 of file StormLCGStorageMaker.cc.

References Exception, LogDebug, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, pipe::pipe(), and errorMatrix2Lands_multiChannel::start.

Referenced by check(), and open().

  {
    // PrepareToGet timeout  
    std::string timeout("300");
    if(char *p = getenv("CMS_STORM_LCG_GT_TIMEOUT"))
      timeout = p;

    /* Build the command line:
        -b => no BDII contacted
        -T srmv2 => necessary with -b 
        -t timeout */
    std::string comm("lcg-gt -b -T srmv2 -t " + timeout + " srm:" + surl + " file 2>&1"); 
    LogDebug("StormLCGStorageMaker") << "command: " << comm << std::endl;

    FILE *pipe = popen(comm.c_str(), "r");
    if(! pipe)
      throw cms::Exception("StormLCGStorageMaker")
        << "failed to execute lcg-gt command: "
        << comm;

    // Get output
    int ch;
    std::string output;
    while ((ch = getc(pipe)) != EOF)
      output.push_back(ch);
    pclose(pipe);

    LogDebug("StormLCGStorageMaker") << "output: " << output << std::endl;
 
    // Extract TURL if possible.
    size_t start = output.find("file:", 0);
    if (start == std::string::npos)
      throw cms::Exception("StormLCGStorageMaker")
        << "no turl found in command '" << comm << "' output:\n" << output;

    start += 5;
    std::string turl(output, start, output.find_first_of("\n", start) - start); 
    LogDebug("StormLCGStorageMaker") << "file to open: " << turl << std::endl;
    return turl;
  }
virtual Storage* StormLcgGtStorageMaker::open ( const std::string &  proto,
const std::string &  surl,
int  mode 
) [inline, virtual]