Belle II Software development
|
EventProcessor to be used on the HLT with all specialities of the HLT processing: More...
#include <HLTEventProcessor.h>
Public Member Functions | |
HLTEventProcessor (const std::vector< std::string > &outputAddresses) | |
Create a new event processor and store the ZMQ addresses where to unregister workers. | |
void | process (PathPtr spath, bool restartFailedWorkers, bool appendProcessNumberToModuleName=false) |
Process the given path. | |
void | process (const PathPtr &startPath, long maxEvent=0) |
Processes the full module chain, starting with the first module in the given path. | |
void | setProfileModuleName (const std::string &name) |
Set the name of the module we want to profile. | |
Static Public Member Functions | |
static void | writeToStdErr (const char msg[]) |
async-safe method to write something to STDERR. | |
static void | installSignalHandler (int sig, void(*fn)(int)) |
Install a signal handler 'fn' for given signal. | |
static void | installMainSignalHandlers (void(*fn)(int)=nullptr) |
Install signal handler for INT, TERM and QUIT signals. | |
Protected Member Functions | |
void | processInitialize (const ModulePtrList &modulePathList, bool setEventInfo=true) |
Initializes the modules. | |
void | processCore (const PathPtr &startPath, const ModulePtrList &modulePathList, long maxEvent=0, bool isInputProcess=true) |
Processes the full module chain consisting of an arbitrary number of connected paths, starting with the first module in the specified path. | |
void | callEvent (Module *module) |
Calls event() on one single module, setting up logging and statistics as needed. | |
void | processTerminate (const ModulePtrList &modulePathList) |
Terminates the modules. | |
void | processBeginRun (bool skipDB=false) |
Calls the begin run methods of all modules. | |
void | processEndRun () |
Calls the end run methods of all modules. | |
long | getMaximumEventNumber (long maxEvent) const |
Calculate the maximum event number out of the argument from command line and the environment. | |
Protected Attributes | |
const Module * | m_master |
The master module that determines the experiment/run/event number. | |
ModulePtrList | m_moduleList |
List of all modules in order initialized. | |
std::string | m_profileModuleName |
Name of the module which should be profiled, empty if no profiling is requested. | |
Module * | m_profileModule = nullptr |
Adress of the module which we want to profile, nullptr if no profiling is requested. | |
StoreObjPtr< EventMetaData > | m_eventMetaDataPtr |
EventMetaData is used by processEvent()/processCore(). | |
EventMetaData | m_previousEventMetaData |
Stores state of EventMetaData before it was last changed. | |
StoreObjPtr< ProcessStatistics > | m_processStatisticsPtr |
Also used in a number of places. | |
bool | m_inRun |
Are we currently in a run? If yes, processEndRun() needs to do something. | |
double | m_lastMetadataUpdate |
Time in seconds of last call for metadata update in event loop. | |
double | m_metadataUpdateInterval |
Minimal time difference in seconds for metadata updates in event loop. | |
bool | m_steerRootInputModuleOn = false |
True if the SteerRootInputModule is in charge for event processing. | |
Private Member Functions | |
void | sendTerminatedMessage (unsigned int pid, bool waitForConfirmation) |
Send an unregister message to all sockets if the given PID died. Wait at max 10s for the confirmation (if requested) | |
void | runWorkers (PathPtr path, unsigned int numProcesses, bool appendProcessNumberToModuleName=false) |
Fork out as much workers as requested and in each run the given path using processCore. | |
void | processCore (PathPtr path) |
Process the path by basically calling processEvent until a termination is requested. | |
bool | processEvent (PathIterator moduleIter, bool firstRound) |
Process a single event by iterating through the module path once. | |
std::pair< unsigned int, unsigned int > | checkChildProcesses () |
Check if one of the started processes has died. | |
void | release () |
Release the parent resource, which is needed after forking to not close it twice. | |
bool | forkOut () |
Helper function to fork out. Sets the Python state correctly and adds the process to the internal state. | |
Private Attributes | |
ZMQParent | m_parent |
An instance of a ZMQParent to create sockets for unregistering workers. | |
std::vector< int > | m_processList |
The current list of running processes (with their PIDs) | |
std::vector< std::unique_ptr< zmq::socket_t > > | m_sockets |
The created sockets for unregistering workers. TODO: use connections. | |
EventProcessor to be used on the HLT with all specialities of the HLT processing:
This event processor is specialies to the HLT and should not be used apart from that. The event processor is exported as a python module. It can be called with
import hbasf2 hbasf2.process(path, [address, ...], True)
Definition at line 37 of file HLTEventProcessor.h.
HLTEventProcessor | ( | const std::vector< std::string > & | outputAddresses | ) |
Create a new event processor and store the ZMQ addresses where to unregister workers.
Definition at line 76 of file HLTEventProcessor.cc.
|
protectedinherited |
Calls event() on one single module, setting up logging and statistics as needed.
module | Module to call the event() function |
Definition at line 226 of file EventProcessor.cc.
|
private |
Check if one of the started processes has died.
If it has died with a non-zero exit code, increase the counter of workers to restart.
Returns the number of still alive workers and the number of workers needed to restart (aka the number of workers that died with a non-zero exit code) as a pair.
Definition at line 396 of file HLTEventProcessor.cc.
|
private |
Helper function to fork out. Sets the Python state correctly and adds the process to the internal state.
Definition at line 449 of file HLTEventProcessor.cc.
|
protectedinherited |
Calculate the maximum event number out of the argument from command line and the environment.
Definition at line 113 of file EventProcessor.cc.
|
staticinherited |
Install signal handler for INT, TERM and QUIT signals.
If argument is NULL, EventProcessor's own signal handler will be installed.
Definition at line 312 of file EventProcessor.cc.
|
staticinherited |
Install a signal handler 'fn' for given signal.
Definition at line 297 of file EventProcessor.cc.
|
inherited |
Processes the full module chain, starting with the first module in the given path.
Processes all events for the given run number and for events from 0 to maxEvent. If maxEvent is smaller or equal 0 the maximum number check is disabled and all events are processed. If runNumber is smaller than 0, the run number has to be set externally by a module and not the given number is used.
startPath | The processing starts with the first module of this path. |
maxEvent | Optional: The maximum number of events that will be processed. If the number is smaller or equal 0, all events will be processed. |
Definition at line 123 of file EventProcessor.cc.
void process | ( | PathPtr | spath, |
bool | restartFailedWorkers, | ||
bool | appendProcessNumberToModuleName = false |
||
) |
Process the given path.
If requested, restart failed workers (or not) For this,
Definition at line 84 of file HLTEventProcessor.cc.
|
protectedinherited |
Calls the begin run methods of all modules.
Loops over all module instances specified in a list and calls their beginRun() method. Please note: the beginRun() method of the module which triggered the beginRun() loop will also be called.
Definition at line 467 of file EventProcessor.cc.
|
protectedinherited |
Processes the full module chain consisting of an arbitrary number of connected paths, starting with the first module in the specified path.
startPath | The processing starts with the first module of this path. |
modulePathList | A list of all modules which could be executed during the data processing (used for calling the beginRun() and endRun() method). |
maxEvent | The maximum number of events that will be processed. If the number is smaller or equal 0, all events are processed. |
isInputProcess | true when this is either the only or the input process |
Definition at line 406 of file EventProcessor.cc.
|
private |
Process the path by basically calling processEvent until a termination is requested.
# Will not any initialization - it is assumed this has already happened before. In the end, terminate is called.
Definition at line 249 of file HLTEventProcessor.cc.
|
protectedinherited |
Calls the end run methods of all modules.
Loops over all module instances specified in a list and calls their endRun() method. Please note: the endRun() method of the module which triggered the endRun() loop will also be called.
Definition at line 501 of file EventProcessor.cc.
|
private |
Process a single event by iterating through the module path once.
In principle very similar to the EventProcessor::processEvent function, but has different assumptions for the run changes happening induced by the master module (which is always the ZMQ2Ds module in the HLT case).
The logic happening after the master module is the following:
The rest (e.g. module conditions, db store) is the same as the EventProcessor case.
Definition at line 286 of file HLTEventProcessor.cc.
|
protectedinherited |
Initializes the modules.
Loops over all module instances specified in a list and calls their initialize() method.
modulePathList | A list of all modules which could be executed during the data processing. |
setEventInfo | if true the first event call of the master module will be called immidiately to load the event info right away so that it's available for subsequent modules |
Definition at line 242 of file EventProcessor.cc.
|
protectedinherited |
Terminates the modules.
Loops over all module instances in reverse order specified in a list and calls their terminate() method.
modulePathList | A list of all modules which could be executed during the data processing. |
Definition at line 440 of file EventProcessor.cc.
|
private |
Release the parent resource, which is needed after forking to not close it twice.
Definition at line 441 of file HLTEventProcessor.cc.
|
private |
Fork out as much workers as requested and in each run the given path using processCore.
Definition at line 208 of file HLTEventProcessor.cc.
|
private |
Send an unregister message to all sockets if the given PID died. Wait at max 10s for the confirmation (if requested)
Definition at line 57 of file HLTEventProcessor.cc.
|
inlineinherited |
Set the name of the module we want to profile.
name | Name of the module as returned by getName() |
Definition at line 57 of file EventProcessor.h.
|
staticinherited |
async-safe method to write something to STDERR.
Definition at line 72 of file EventProcessor.cc.
|
protectedinherited |
EventMetaData is used by processEvent()/processCore().
Definition at line 163 of file EventProcessor.h.
|
protectedinherited |
Are we currently in a run? If yes, processEndRun() needs to do something.
Definition at line 172 of file EventProcessor.h.
|
protectedinherited |
Time in seconds of last call for metadata update in event loop.
Definition at line 175 of file EventProcessor.h.
|
protectedinherited |
The master module that determines the experiment/run/event number.
Definition at line 153 of file EventProcessor.h.
|
protectedinherited |
Minimal time difference in seconds for metadata updates in event loop.
Definition at line 178 of file EventProcessor.h.
|
protectedinherited |
List of all modules in order initialized.
Definition at line 154 of file EventProcessor.h.
|
private |
An instance of a ZMQParent to create sockets for unregistering workers.
Definition at line 55 of file HLTEventProcessor.h.
|
protectedinherited |
Stores state of EventMetaData before it was last changed.
Useful since processEndRun() needs info about which run it needs to end.
Definition at line 166 of file EventProcessor.h.
|
private |
The current list of running processes (with their PIDs)
Definition at line 57 of file HLTEventProcessor.h.
|
protectedinherited |
Also used in a number of places.
Definition at line 169 of file EventProcessor.h.
|
protectedinherited |
Adress of the module which we want to profile, nullptr if no profiling is requested.
Definition at line 160 of file EventProcessor.h.
|
protectedinherited |
Name of the module which should be profiled, empty if no profiling is requested.
Definition at line 157 of file EventProcessor.h.
|
private |
The created sockets for unregistering workers. TODO: use connections.
Definition at line 59 of file HLTEventProcessor.h.
|
protectedinherited |
True if the SteerRootInputModule is in charge for event processing.
Definition at line 181 of file EventProcessor.h.