#include <ParameterSetRetriever.h>
Public Member Functions | |
std::string | getAsString () const |
std::string | getHostString (const std::string &in, std::string modifier="") const |
std::string | getModuleTableAsString () const |
std::string | getPathTableAsString () const |
ParameterSetRetriever (const std::string &in) | |
Private Attributes | |
std::string | pathIndexTable |
std::string | pset |
Static Private Attributes | |
static const std::string | dbheading = "db:" |
static const std::string | fileheading = "file:" |
static const std::string | webheading = "https://" |
Definition at line 8 of file ParameterSetRetriever.h.
evf::ParameterSetRetriever::ParameterSetRetriever | ( | const std::string & | in | ) |
Definition at line 23 of file ParameterSetRetriever.cc.
References evf::SquidNet::check(), HDQMDatabaseProducer::configFile, dbheading, error, fileheading, lut2db_cfg::filename, getHostString(), recoMuon::in, geometryCSVtoXML::line, MatrixRunner::msg, NULL, pathIndexTable, pset, summarizeEdmComparisonLogfiles::success, webheading, and evf::write_data().
{ using std::string; using std::ostringstream; using std::ifstream; if (fileheading==in.substr(0,fileheading.size())) { string filename=in.substr(fileheading.size()); edm::LogInfo("psetRetriever")<<"filename is --> "<<filename<<" <--"; string line; ifstream configFile(filename.c_str()); while(std::getline(configFile,line)) { pset+=line; pset+="\n"; } } else if (webheading==in.substr(0,webheading.size())) { string hostname = getHostString(in); SquidNet sn(3128,"https://localhost:8000/RELEASE-NOTES.txt"); edm::LogInfo("psetRetriever")<<"Using cfg from " << in; CURL* han = curl_easy_init(); if(han==0) { XCEPT_RAISE(evf::Exception,"could not create handle for web ParameterSet"); } struct curl_slist *headers=NULL; /* init to NULL is important */ headers = curl_slist_append(headers, "Pragma:"); curl_easy_setopt(han, CURLOPT_HTTPHEADER, headers); char error[CURL_ERROR_SIZE]; if(sn.check()) curl_easy_setopt(han, CURLOPT_PROXY, "localhost:3128"); curl_easy_setopt(han, CURLOPT_URL, hostname.c_str()); curl_easy_setopt(han, CURLOPT_VERBOSE,""); curl_easy_setopt(han, CURLOPT_NOSIGNAL,""); // curl_easy_setopt(han, CURLOPT_TIMEOUT, 60.0L); curl_easy_setopt(han, CURLOPT_WRITEFUNCTION, &write_data); curl_easy_setopt(han, CURLOPT_WRITEDATA, &pset); curl_easy_setopt(han, CURLOPT_ERRORBUFFER, error); int success = curl_easy_perform(han); curl_slist_free_all(headers); /* free the header list */ curl_easy_cleanup(han); han = 0; if(success != 0) { ostringstream msg; msg << "could not get config from url " << in << " error #" << success << " " << error; XCEPT_RAISE(evf::Exception,msg.str().c_str()); } //now get path-index table han = curl_easy_init(); if(han==0) { XCEPT_RAISE(evf::Exception,"could not create handle for web ParameterSet"); } headers = NULL; headers = curl_slist_append(headers, "Pragma:"); curl_easy_setopt(han, CURLOPT_HTTPHEADER, headers); if(sn.check()) curl_easy_setopt(han, CURLOPT_PROXY, "localhost:3128"); hostname = getHostString(in,"path"); curl_easy_setopt(han, CURLOPT_URL, hostname.c_str()); curl_easy_setopt(han, CURLOPT_VERBOSE,""); curl_easy_setopt(han, CURLOPT_NOSIGNAL,""); // curl_easy_setopt(han, CURLOPT_TIMEOUT, 60.0L); curl_easy_setopt(han, CURLOPT_WRITEFUNCTION, &write_data); curl_easy_setopt(han, CURLOPT_WRITEDATA, &pathIndexTable); curl_easy_setopt(han, CURLOPT_ERRORBUFFER, error); success = curl_easy_perform(han); curl_slist_free_all(headers); /* free the header list */ curl_easy_cleanup(han); if(success != 0) { ostringstream msg; msg << "could not get pathindex table from url " << in << " error #" << success << " " << error; XCEPT_RAISE(evf::Exception,msg.str().c_str()); } } else if (dbheading==in.substr(0,dbheading.size())) { XCEPT_RAISE(evf::Exception,"db access for ParameterSet not yet implemented"); } else { edm::LogInfo("psetRetriever")<<"Using string cfg from RunControl or XML"; pset = in; } }
std::string evf::ParameterSetRetriever::getAsString | ( | ) | const |
Definition at line 128 of file ParameterSetRetriever.cc.
References pset.
Referenced by stor::Configuration::actionPerformed(), evf::FWEPWrapper::init(), and stor::Configuration::updateLocalDiskWritingData().
{ return pset; }
std::string evf::ParameterSetRetriever::getHostString | ( | const std::string & | in, |
std::string | modifier = "" |
||
) | const |
Definition at line 139 of file ParameterSetRetriever.cc.
References query::host, path(), pos, and webheading.
Referenced by ParameterSetRetriever().
{ using std::string; string innohttps = in.substr(webheading.size()); string::size_type pos = innohttps.find(':',0); string host = innohttps.substr(0,pos); string path = innohttps.substr(pos); if(modifier != "") { pos = path.find_last_of('.'); if(pos != string::npos) { string upath = path.substr(0,pos); path = upath + '.' + modifier; } } struct hostent *heb = gethostbyname(host.c_str()); struct hostent *he = gethostbyaddr(heb->h_addr_list[0], heb->h_length, heb->h_addrtype); string completehost = "https://"; completehost += he->h_name; completehost += path; return completehost; }
std::string evf::ParameterSetRetriever::getModuleTableAsString | ( | ) | const |
std::string evf::ParameterSetRetriever::getPathTableAsString | ( | ) | const |
Definition at line 133 of file ParameterSetRetriever.cc.
References pathIndexTable.
Referenced by evf::FWEPWrapper::init().
{ return pathIndexTable; }
const std::string evf::ParameterSetRetriever::dbheading = "db:" [static, private] |
Definition at line 20 of file ParameterSetRetriever.h.
Referenced by ParameterSetRetriever().
const std::string evf::ParameterSetRetriever::fileheading = "file:" [static, private] |
Definition at line 19 of file ParameterSetRetriever.h.
Referenced by ParameterSetRetriever().
std::string evf::ParameterSetRetriever::pathIndexTable [private] |
Definition at line 18 of file ParameterSetRetriever.h.
Referenced by getPathTableAsString(), and ParameterSetRetriever().
std::string evf::ParameterSetRetriever::pset [private] |
Definition at line 17 of file ParameterSetRetriever.h.
Referenced by getAsString(), and ParameterSetRetriever().
const std::string evf::ParameterSetRetriever::webheading = "https://" [static, private] |
Definition at line 21 of file ParameterSetRetriever.h.
Referenced by getHostString(), and ParameterSetRetriever().