diff --git a/CCDB/src/CcdbApi.cxx b/CCDB/src/CcdbApi.cxx index d85843e11497d..02e6fc7feadc8 100644 --- a/CCDB/src/CcdbApi.cxx +++ b/CCDB/src/CcdbApi.cxx @@ -144,18 +144,19 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin long startValidityTimestamp, long endValidityTimestamp, std::vector::size_type maxSize) const { if (maxSize > 0 && size > maxSize) { + LOGP(alarm, "Object will not be uploaded to {} since its size {} exceeds max allowed {}", path, size, maxSize); return -1; } // Prepare URL long sanitizedStartValidityTimestamp = startValidityTimestamp; if (startValidityTimestamp == -1) { - cout << "Start of Validity not set, current timestamp used." << endl; + LOGP(info, "Start of Validity not set, current timestamp used."); sanitizedStartValidityTimestamp = getCurrentTimestamp(); } long sanitizedEndValidityTimestamp = endValidityTimestamp; if (endValidityTimestamp == -1) { - cout << "End of Validity not set, start of validity plus 1 day used." << endl; + LOGP(info, "End of Validity not set, start of validity plus 1 day used."); sanitizedEndValidityTimestamp = getFutureTimestamp(60 * 60 * 24 * 1); } @@ -200,8 +201,7 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin res = curl_easy_perform(curl); /* Check for errors */ if (res != CURLE_OK) { - fprintf(stderr, "curl_easy_perform() failed: %s\n", - curl_easy_strerror(res)); + LOGP(alarm, "curl_easy_perform() failed: {}", curl_easy_strerror(res)); returnValue = res; } } @@ -214,7 +214,7 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin /* free slist */ curl_slist_free_all(headerlist); } else { - cerr << "curl initialization failure" << endl; + LOGP(alarm, "curl initialization failure"); returnValue = -2; } return returnValue; @@ -485,8 +485,7 @@ bool CcdbApi::receiveObject(void* dataHolder, std::string const& path, std::map< curlResultCode = curl_easy_perform(curlHandle); if (curlResultCode != CURLE_OK) { - fprintf(stderr, "curl_easy_perform() failed: %s\n", - curl_easy_strerror(curlResultCode)); + LOGP(alarm, "curl_easy_perform() failed: {}", curl_easy_strerror(curlResultCode)); } else { curlResultCode = curl_easy_getinfo(curlHandle, CURLINFO_RESPONSE_CODE, &responseCode); if ((curlResultCode == CURLE_OK) && (responseCode < 300)) { @@ -494,9 +493,9 @@ bool CcdbApi::receiveObject(void* dataHolder, std::string const& path, std::map< return true; } else { if (curlResultCode != CURLE_OK) { - cerr << "invalid URL : " << fullUrl << endl; + LOGP(alarm, "invalid URL {}", fullUrl); } else { - cerr << "not found under link: " << fullUrl << endl; + LOGP(alarm, "not found under link {}", fullUrl); } } } @@ -526,7 +525,7 @@ TObject* CcdbApi::retrieve(std::string const& path, std::map diff --git a/Detectors/Calibration/workflow/CCDBPopulatorSpec.h b/Detectors/Calibration/workflow/CCDBPopulatorSpec.h index 2e458d8859a4c..39cefc8e4d806 100644 --- a/Detectors/Calibration/workflow/CCDBPopulatorSpec.h +++ b/Detectors/Calibration/workflow/CCDBPopulatorSpec.h @@ -48,6 +48,7 @@ class CCDBPopulator : public o2::framework::Task mCCDBpath = ic.options().get("ccdb-path"); mSSpecMin = ic.options().get("sspec-min"); mSSpecMax = ic.options().get("sspec-max"); + mFatalOnFailure = ic.options().get("no-fatal-on-failure"); auto& mgr = CcdbManager::instance(); mgr.setURL(mCCDBpath); mAPI.init(mgr.getURL()); @@ -84,13 +85,17 @@ class CCDBPopulator : public o2::framework::Task LOG(info) << "Storing in ccdb " << wrp->getPath() << "/" << wrp->getFileName() << " of size " << pld.size() << " Valid for " << wrp->getStartValidityTimestamp() << " : " << wrp->getEndValidityTimestamp(); - mAPI.storeAsBinaryFile(&pld[0], pld.size(), wrp->getFileName(), wrp->getObjectType(), wrp->getPath(), - *md, wrp->getStartValidityTimestamp(), wrp->getEndValidityTimestamp()); + int res = mAPI.storeAsBinaryFile(&pld[0], pld.size(), wrp->getFileName(), wrp->getObjectType(), wrp->getPath(), + *md, wrp->getStartValidityTimestamp(), wrp->getEndValidityTimestamp()); + if (res && mFatalOnFailure) { + LOGP(fatal, "failed on uploading to {} / {}", mAPI.getURL(), wrp->getPath()); + } } } private: CcdbApi mAPI; + bool mFatalOnFailure = true; // produce fatal on failed upload std::int64_t mSSpecMin = -1; // min subspec to accept std::int64_t mSSpecMax = -1; // max subspec to accept std::string mCCDBpath = "http://ccdb-test.cern.ch:8080"; // CCDB path @@ -115,7 +120,8 @@ DataProcessorSpec getCCDBPopulatorDeviceSpec(const std::string& defCCDB, const s Options{ {"ccdb-path", VariantType::String, defCCDB, {"Path to CCDB"}}, {"sspec-min", VariantType::Int64, -1L, {"min subspec to accept"}}, - {"sspec-max", VariantType::Int64, -1L, {"max subspec to accept"}}}}; + {"sspec-max", VariantType::Int64, -1L, {"max subspec to accept"}}, + {"no-fatal-on-failure", VariantType::Bool, false, {"do not produce fatal on failed upload"}}}}; } } // namespace framework