8 ((
std::string*)ptr)->append((
char*)contents, size * nmemb);
16 char errbuf[CURL_ERROR_SIZE];
18 curl = curl_easy_init();
21 struct curl_slist* chunk =
nullptr;
22 chunk = curl_slist_append(chunk,
"content-type:document/plain");
23 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
24 curl_easy_setopt(curl, CURLOPT_URL, urlString.c_str());
26 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &htmlBuffer);
27 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
28 res = curl_easy_perform(curl);
29 if (CURLE_OK == res) {
33 size_t len = strlen(errbuf);
34 fprintf(stderr,
"\nlibcurl: (%d) ", res);
36 fprintf(stderr,
"%s%s", errbuf, ((errbuf[len - 1] !=
'\n') ?
"\n" :
""));
38 fprintf(stderr,
"%s\n", curl_easy_strerror(res));
40 curl_easy_cleanup(curl);
51 lastLumiFile >> lastLumiProcessed;
55 return lastLumiProcessed;
62 throw Exception(
"Can't get data from OMS Service.");
63 std::istringstream sinfo(info);
65 if (!std::getline(sinfo, srun,
',')) {
66 throw Exception(
"Can't get run runmber info from OMS Service.");
69 if (!std::getline(sinfo, slumi,
',')) {
70 throw Exception(
"Can't get lumi id from OMS Service.");
72 unsigned int run = std::stoul(srun);
73 unsigned int lumi = std::stoul(slumi);
75 return lastLumiProcessed;
83 m_runNumber(iConfig.getUntrackedParameter<unsigned long long>(
"runNumber", 1)),
84 m_latencyInLumisections(iConfig.getUntrackedParameter<unsigned int>(
"latency", 1)),
85 m_omsServiceUrl(iConfig.getUntrackedParameter<std::
string>(
"omsServiceUrl",
"")),
86 m_preLoadConnectionString(iConfig.getUntrackedParameter<std::
string>(
"preLoadConnectionString",
"")),
87 m_frontierKey(iConfig.getUntrackedParameter<std::
string>(
"frontierKey",
"")),
88 m_debug(iConfig.getUntrackedParameter<bool>(
"debugLogging",
false)) {
99 if (!m_omsServiceUrl.empty()) {
101 logger().logInfo() <<
"Last lumi: " << lastLumiProcessed
105 if (!m_lastLumiFile.empty()) {
108 logger().logInfo() <<
"Last lumi: " << lastLumiProcessed <<
" Current run: " << upkTime.first
109 <<
" lumi id:" << upkTime.second;
114 return lastLumiProcessed;
120 transaction.
start(
true);
123 transaction.commit();
128 std::stringstream transId;
129 transId << targetTime;
130 if (!m_frontierKey.empty()) {
131 transId <<
"_" << m_frontierKey;
persistency::Exception Exception
T getUntrackedParameter(std::string const &, T const &) const
tuple ret
prodAgent to be discontinued
cond::Time_t getLastLumiFromOMS(const std::string &omsServiceUrl)
~OnlineDBOutputService() override
Transaction & transaction()
std::string tag(const std::string &recordName)
unsigned long long Time_t
Time_t lumiTime(unsigned int run, unsigned int lumiId)
std::string m_lastLumiFile
OnlineDBOutputService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
cond::Iov_t preLoadIov(const std::string &recordName, cond::Time_t targetTime)
cond::Time_t getLatestLumiFromFile(const std::string &fileName)
void start(bool readOnly=true)
cond::Iov_t getInterval(cond::Time_t time)
IOVProxy readIov(const std::string &tag)
bool getInfoFromService(const std::string &urlString, std::string &info)
std::string m_omsServiceUrl
cond::persistency::Session newReadOnlySession(const std::string &connectionString, const std::string &transactionId)
cond::persistency::Session getReadOnlyCache(cond::Time_t targetTime)
static size_t getHtmlCallback(void *contents, size_t size, size_t nmemb, void *ptr)
tuple size
Write out results.
cond::UnpackedTime unpack(cond::Time_t iValue)
cond::Time_t getLastLumiProcessed()