Belle II Software light-2406-ragdoll
ProcessedEventsBackupList.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <framework/pcore/zmq/processModules/ProcessedEventsBackupList.h>
9
10using namespace Belle2;
11
12void ProcessedEventsBackupList::storeEvent(std::unique_ptr<EvtMessage> evtMsg, const StoreObjPtr<EventMetaData>& evtMetaData,
13 const unsigned int workerId)
14{
15 EventMetaData eventMetaData(evtMetaData->getEvent(), evtMetaData->getRun(), evtMetaData->getExperiment());
16 m_evtBackupVector.emplace_back(std::move(evtMsg), eventMetaData, workerId);
17}
18
20{
21 const auto oldSize = m_evtBackupVector.size();
22
23 m_evtBackupVector.erase(std::remove(m_evtBackupVector.begin(), m_evtBackupVector.end(), evtMetaData),
24 m_evtBackupVector.end());
25
26 if (oldSize == m_evtBackupVector.size()) {
27 B2WARNING("Event: " << evtMetaData.getEvent() << ", no matching event backup found in backup list");
28 }
29}
30
32{
33 if (m_evtBackupVector.empty()) {
34 return -1;
35 }
36 if (std::chrono::system_clock::now() - m_evtBackupVector[0].getTimestamp() > timeout) {
37 return m_evtBackupVector[0].getWorkerId();
38 } else {
39 return -1;
40 }
41}
42
44{
45 return m_evtBackupVector.size();
46}
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
unsigned int getEvent() const
Event Getter.
unsigned int size() const
Check the size.
void storeEvent(std::unique_ptr< EvtMessage > evtMsg, const StoreObjPtr< EventMetaData > &evtMetaData, const unsigned int workerId)
Add a new event backup with the given information. Takes ownership of the evt message.
std::vector< ProcessedEventBackup > m_evtBackupVector
The vector where the event backups are stored.
int checkForTimeout(const Duration &timeout) const
Check the items for timeout. Returns -1 if no timeout happened and the worker id, if it did.
std::chrono::milliseconds Duration
Short for the class of a duration (always measured in milliseconds)
void removeEvent(const EventMetaData &evtMetaData)
Remove all backups with the given event meta data (on confirmation)
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24