Public Member Functions | |
virtual bool | check (const std::string &proto, const std::string &path, IOOffset *size=0) |
virtual Storage * | open (const std::string &proto, const std::string &surl, int mode) |
Private Member Functions | |
std::string | getTURL (const std::string &surl) |
Definition at line 12 of file StormStorageMaker.cc.
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.
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] |
Implements StorageMaker.
Definition at line 57 of file StormStorageMaker.cc.
References StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), f, reco_application_tbsim_DetSim-Digi_cfg::File, dbtoweb::file, reco::get(), getTURL(), IOFlags::OpenUnbuffered, path(), StorageFactory::READ_HINT_UNBUFFERED, StorageFactory::readHint(), and StorageFactory::wrapNonLocalFile().
{ 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 path = getTURL(surl); File *file = new File (path, mode); return f->wrapNonLocalFile (file, proto, path, mode); }