Belle II Software light-2406-ragdoll
ProcessedEventsBackupList.h
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#pragma once
9
10#include <framework/pcore/zmq/processModules/ProcessedEventBackup.h>
11#include <framework/dataobjects/EventMetaData.h>
12#include <framework/pcore/EvtMessage.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <memory>
15#include <chrono>
16
17
18namespace Belle2 {
26 using Duration = std::chrono::milliseconds;
27
28 public:
30 void storeEvent(std::unique_ptr<EvtMessage> evtMsg, const StoreObjPtr<EventMetaData>& evtMetaData, const unsigned int workerId);
31
33 void removeEvent(const EventMetaData& evtMetaData);
34
36 int checkForTimeout(const Duration& timeout) const;
37
39 template <class AZMQClient>
40 void sendWorkerBackupEvents(unsigned int worker, const AZMQClient& socket);
41
43 unsigned int size() const;
44
45 private:
47 std::vector<ProcessedEventBackup> m_evtBackupVector;
48 };
49
50 template <class AZMQClient>
51 void ProcessedEventsBackupList::sendWorkerBackupEvents(unsigned int worker, const AZMQClient& socket)
52 {
53 for (auto it = m_evtBackupVector.begin(); it != m_evtBackupVector.end();) {
54 if (it->getWorkerId() == worker) {
55 B2DEBUG(100, "Delete event: " << it->getEventMetaData().getEvent());
56 it->sendToSocket(socket);
57 // TODO: better: delete backup on confirmation message
58 m_evtBackupVector.erase(it);
59 B2DEBUG(100, "new backup list size: " << m_evtBackupVector.size());
60 } else {
61 it++;
62 }
63 }
64 }
66}
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
List-like structure for storing and retaining event backups.
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
void sendWorkerBackupEvents(unsigned int worker, const AZMQClient &socket)
Send all backups of a given worker directly to the multicast and delete them.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24