@@ -126,8 +126,10 @@ TriggerFcn Periodic(double seconds, const Activity& activity, std::string config
126126{
127127 AliceO2::Common::Timer timer;
128128 timer.reset (static_cast <int >(seconds * 1000000 ));
129+ auto resultActivity = activity;
130+ resultActivity.mValidity = gInvalidValidityInterval ;
129131
130- return [timer, activity , config]() mutable -> Trigger {
132+ return [timer, resultActivity , config]() mutable -> Trigger {
131133 if (timer.isTimeout ()) {
132134 // We calculate the exact time when timer has passed
133135 uint64_t timestamp = Trigger::msSinceEpoch () + static_cast <int >(timer.getRemainingTime () * 1000 );
@@ -136,9 +138,10 @@ TriggerFcn Periodic(double seconds, const Activity& activity, std::string config
136138 while (timer.isTimeout ()) {
137139 timer.increment ();
138140 }
139- return { TriggerType::Periodic, false , activity, timestamp, config };
141+ resultActivity.mValidity .update (timestamp);
142+ return { TriggerType::Periodic, false , resultActivity, timestamp, config };
140143 } else {
141- return { TriggerType::No, false , activity , Trigger::msSinceEpoch (), config };
144+ return { TriggerType::No, false , resultActivity , Trigger::msSinceEpoch (), config };
142145 }
143146 };
144147}
@@ -149,26 +152,27 @@ TriggerFcn NewObject(const std::string& databaseUrl, const std::string& database
149152 constexpr auto timestampKey = metadata_keys::validFrom;
150153 auto fullObjectPath = (databaseType == " qcdb" ? activity.mProvenance + " /" : " " ) + objectPath;
151154 auto metadata = databaseType == " qcdb" ? activity_helpers::asDatabaseMetadata (activity, false ) : std::map<std::string, std::string>();
155+ auto objectActivity = activity;
152156
153157 ILOG (Debug, Support) << " Initializing newObject trigger for the object '" << fullObjectPath << " ' and Activity '" << activity << " '" << ENDM ;
154158 // We support only CCDB here.
155159 auto db = std::make_shared<repository::CcdbDatabase>();
156160 db->connect (databaseUrl, " " , " " , " " );
157161
158162 // Returns "Valid-From" of an object if there is a new one, otherwise 0.
159- auto newObjectValidityStart = [db, fullObjectPath, metadata, databaseUrl, activity, lastModified = validity_time_t { 0 }]() mutable -> validity_time_t {
163+ auto newObjectValidity = [db, fullObjectPath, metadata, databaseUrl, activity, lastModified = validity_time_t { 0 }]() mutable -> ValidityInterval {
160164 const auto listing = db->getListingAsPtree (fullObjectPath, metadata, true );
161165 if (listing.count (" objects" ) == 0 ) {
162166 ILOG (Warning, Support) << " Could not get a valid listing from db '" << databaseUrl << " ' for object '" << fullObjectPath << " '" << ENDM ;
163- return 0 ;
167+ return gInvalidValidityInterval ;
164168 }
165169 const auto & objects = listing.get_child (" objects" );
166170 if (objects.empty ()) {
167171 // We don't make a fuss over it, because we might be just waiting for the first version of such object.
168172 // It should not happen often though, so having a warning makes sense.
169173 ILOG (Warning, Support) << " Could not find the file '" << fullObjectPath << " ' in the db '"
170174 << databaseUrl << " ' for given Activity settings (" << activity << " ). Zeroes and empty strings are treated as wildcards." << ENDM ;
171- return 0 ;
175+ return gInvalidValidityInterval ;
172176 } else if (objects.size () > 1 ) {
173177 ILOG (Warning, Support) << " Expected just one metadata entry for object '" << fullObjectPath << " '. Trying to continue by using the first." << ENDM ;
174178 }
@@ -177,18 +181,20 @@ TriggerFcn NewObject(const std::string& databaseUrl, const std::string& database
177181 validity_time_t newLastModified = object.get <uint64_t >(metadata_keys::lastModified, 0 );
178182 if (newLastModified > lastModified) {
179183 lastModified = newLastModified;
180- return object.get <uint64_t >(metadata_keys::validFrom, 0 );
184+ return { object.get <uint64_t >(metadata_keys::validFrom, 0 ), object. get < uint64_t >(metadata_keys::validUntil) } ;
181185 }
182- return 0 ;
186+ return gInvalidValidityInterval ;
183187 };
184188 // we execute it once before in order to know about the latest existing object.
185- newObjectValidityStart ();
189+ newObjectValidity ();
186190
187- return [activity, config, newObjectValidityStart]() mutable -> Trigger {
188- if (auto validFrom = newObjectValidityStart ()) {
189- return { TriggerType::NewObject, false , activity, validFrom, config };
191+ return [objectActivity, config, newObjectValidity]() mutable -> Trigger {
192+ if (auto validity = newObjectValidity (); validity.isValid ()) {
193+ objectActivity.mValidity = validity;
194+ return { TriggerType::NewObject, false , objectActivity, validity.getMax (), config };
190195 }
191- return { TriggerType::No, false , activity, Trigger::msSinceEpoch (), config };
196+ objectActivity.mValidity = gInvalidValidityInterval ;
197+ return { TriggerType::No, false , objectActivity, Trigger::msSinceEpoch (), config };
192198 };
193199}
194200
0 commit comments