@@ -198,6 +198,7 @@ auto populateCacheWith(std::shared_ptr<CCDBFetcherHelper> const& helper,
198198 auto sid = _o2_signpost_id_t {(int64_t )timingInfo.timeslice };
199199 O2_SIGNPOST_START (ccdb, sid, " populateCacheWith" , " Starting to populate cache with CCDB objects" );
200200 for (auto & route : helper->routes ) {
201+ int64_t timestampToUse = timestamp;
201202 O2_SIGNPOST_EVENT_EMIT (ccdb, sid, " populateCacheWith" , " Fetching object for route %{public}s" , DataSpecUtils::describe (route.matcher ).data ());
202203 objCnt++;
203204 auto concrete = DataSpecUtils::asConcreteDataMatcher (route.matcher );
@@ -212,8 +213,14 @@ auto populateCacheWith(std::shared_ptr<CCDBFetcherHelper> const& helper,
212213 for (auto & meta : route.matcher .metadata ) {
213214 if (meta.name == " ccdb-path" ) {
214215 path = meta.defaultValue .get <std::string>();
215- } else if (meta.name == " ccdb-run-dependent" && meta.defaultValue .get <bool >() == true ) {
216- metadata[" runNumber" ] = dtc.runNumber ;
216+ } else if (meta.name == " ccdb-run-dependent" && meta.defaultValue .get <int >() > 0 ) {
217+ if (meta.defaultValue .get <int >() == 1 ) {
218+ metadata[" runNumber" ] = dtc.runNumber ;
219+ } else if (meta.defaultValue .get <int >() == 2 ) {
220+ timestampToUse = std::stoi (dtc.runNumber );
221+ } else {
222+ LOGP (fatal, " Undefined run-dependent option {} for spec {}/{}/{}" , meta.defaultValue .get <int >(), concrete.origin .as <std::string>(), concrete.description .as <std::string>(), int (concrete.subSpec ));
223+ }
217224 } else if (isPrefix (ccdbMetadataPrefix, meta.name )) {
218225 std::string key = meta.name .substr (ccdbMetadataPrefix.size ());
219226 auto value = meta.defaultValue .get <std::string>();
@@ -232,7 +239,7 @@ auto populateCacheWith(std::shared_ptr<CCDBFetcherHelper> const& helper,
232239 uint64_t cachePopulatedAt = url2uuid->second .cachePopulatedAt ;
233240 // If timestamp is before the time the element was cached or after the claimed validity, we need to check validity, again
234241 // when online.
235- bool cacheExpired = (validUntil <= timestamp ) || (timestamp <= cachePopulatedAt);
242+ bool cacheExpired = (validUntil <= timestampToUse ) || (timestamp < cachePopulatedAt);
236243 checkValidity = (std::abs (int (timingInfo.tfCounter - url2uuid->second .lastCheckedTF )) >= chRate) && (isOnline || cacheExpired);
237244 } else {
238245 checkValidity = true ; // never skip check if the cache is empty
@@ -242,10 +249,10 @@ auto populateCacheWith(std::shared_ptr<CCDBFetcherHelper> const& helper,
242249
243250 const auto & api = helper->getAPI (path);
244251 if (checkValidity && (!api.isSnapshotMode () || etag.empty ())) { // in the snapshot mode the object needs to be fetched only once
245- LOGP (detail, " Loading {} for timestamp {}" , path, timestamp );
246- api.loadFileToMemory (v, path, metadata, timestamp , &headers, etag, helper->createdNotAfter , helper->createdNotBefore );
252+ LOGP (detail, " Loading {} for timestamp {}" , path, timestampToUse );
253+ api.loadFileToMemory (v, path, metadata, timestampToUse , &headers, etag, helper->createdNotAfter , helper->createdNotBefore );
247254 if ((headers.count (" Error" ) != 0 ) || (etag.empty () && v.empty ())) {
248- LOGP (fatal, " Unable to find object {}/{}" , path, timestamp );
255+ LOGP (fatal, " Unable to find object {}/{}" , path, timestampToUse );
249256 // FIXME: I should send a dummy message.
250257 continue ;
251258 }
@@ -256,7 +263,7 @@ auto populateCacheWith(std::shared_ptr<CCDBFetcherHelper> const& helper,
256263 helper->mapURL2UUID [path].lastCheckedTF = timingInfo.tfCounter ;
257264 if (etag.empty ()) {
258265 helper->mapURL2UUID [path].etag = headers[" ETag" ]; // update uuid
259- helper->mapURL2UUID [path].cachePopulatedAt = timestamp ;
266+ helper->mapURL2UUID [path].cachePopulatedAt = timestampToUse ;
260267 helper->mapURL2UUID [path].cacheMiss ++;
261268 helper->mapURL2UUID [path].minSize = std::min (v.size (), helper->mapURL2UUID [path].minSize );
262269 helper->mapURL2UUID [path].maxSize = std::max (v.size (), helper->mapURL2UUID [path].maxSize );
@@ -269,7 +276,7 @@ auto populateCacheWith(std::shared_ptr<CCDBFetcherHelper> const& helper,
269276 if (v.size ()) { // but should be overridden by fresh object
270277 // somewhere here pruneFromCache should be called
271278 helper->mapURL2UUID [path].etag = headers[" ETag" ]; // update uuid
272- helper->mapURL2UUID [path].cachePopulatedAt = timestamp ;
279+ helper->mapURL2UUID [path].cachePopulatedAt = timestampToUse ;
273280 helper->mapURL2UUID [path].cacheValidUntil = headers[" Cache-Valid-Until" ].empty () ? 0 : std::stoul (headers[" Cache-Valid-Until" ]);
274281 helper->mapURL2UUID [path].cacheMiss ++;
275282 helper->mapURL2UUID [path].minSize = std::min (v.size (), helper->mapURL2UUID [path].minSize );
0 commit comments