CMS 3D CMS Logo

Public Member Functions | Private Member Functions

StormStorageMaker Class Reference

Inheritance diagram for StormStorageMaker:
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 &surl, int mode)

Private Member Functions

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

Detailed Description

Definition at line 12 of file StormStorageMaker.cc.


Member Function Documentation

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

Reimplemented from StorageMaker.

Definition at line 76 of file StormStorageMaker.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 StormStorageMaker::getTURL ( const std::string &  surl) [inline, private]

Definition at line 15 of file StormStorageMaker.cc.

References python::OfflineClient_cff::client, Exception, LogDebug, convertSQLitetoXML_cfg::output, L1TEmulatorMonitor_cff::p, and pipe::pipe().

Referenced by check(), and open().

  {
    std::string client;
    if (char *p = getenv("CMS_STORM_PTG_CLIENT"))
      client = p;
    else
      throw cms::Exception("StormStorageMaker")
        << "$CMS_STORM_PTG_CLIENT has no value";

    // Command
    std::string comm(client + " srm:" + surl + " 2>&1"); 
    LogDebug("StormStorageMaker") << "command: " << comm << std::endl;

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

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

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

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