![]() |
Belle II Software development
|
This class provides the core event processing loop for parallel processing with ZMQ. More...
#include <ZMQEventProcessor.h>
Public Member Functions | |
ZMQEventProcessor () | |
Init the socket cleaning at exit. | |
virtual | ~ZMQEventProcessor () |
Make sure we remove all sockets cleanly. | |
void | process (const PathPtr &spath, long maxEvent) |
Processes the full module chain using parallel processing, starting with the first module in the given path. | |
void | cleanup () |
clean up IPC resources (should only be called in one process). | |
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. | |
bool | processEvent (PathIterator moduleIter, bool skipMasterModule) |
Calls event() functions on all modules for the current event. | |
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. | |
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 |
Address of the module which we want to profile, nullptr if no profiling is requested. | |
StoreObjPtr< EventMetaData > | m_eventMetaDataPtr |
EventMetaData is used by processEvent()/processCore(). | |
StoreObjPtr< EventExtraInfo > | m_eventExtraInfo |
event extra info object pointer | |
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 | initialize (const ModulePtrList &moduleList, const ModulePtr &histogramManager) |
First step in the process: init the module in the list. | |
void | forkAndRun (long maxEvent, const PathPtr &inputPath, const PathPtr &mainPath, const PathPtr &outputPath, const ModulePtrList &terminateGlobally) |
Second step in the process: fork out the processes we need to have and call the event loop. | |
void | terminateAndCleanup (const ModulePtr &histogramManager) |
Last step in the process: run the termination and cleanup (kill all remaining processes) | |
void | runMonitoring (const PathPtr &inputPath, const PathPtr &mainPath, const ModulePtrList &terminateGlobally, long maxEvent) |
Start the monitoring (without forking) | |
void | runInput (const PathPtr &inputPath, const ModulePtrList &terminateGlobally, long maxEvent) |
Fork out the input process. | |
void | runOutput (const PathPtr &outputPath, const ModulePtrList &terminateGlobally, long maxEvent) |
Fork out the output process. | |
void | runWorker (unsigned int numProcesses, const PathPtr &inputPath, const PathPtr &mainPath, const ModulePtrList &terminateGlobally, long maxEvent) |
Fork out the N worker process. | |
void | processPath (const PathPtr &localPath, const ModulePtrList &terminateGlobally, long maxEvent) |
Basic function run in every process: process the event loop of the given path. | |
void | processCore (const PathPtr &startPath, const ModulePtrList &modulePathList, long maxEvent=0, bool isInputProcess=true, bool isWorkerProcess=false, bool isOutputProcess=false) |
Process modules in the path. | |
bool | processEvent (PathIterator moduleIter, bool skipMasterModule, bool Worker=false, bool output=false) |
Calls Event function. | |
void | processBeginRun (bool skipDB=false) |
Calls BeginRun function. | |
void | processEndRun () |
Calls EndRun function. | |
Private Attributes | |
ProcessMonitor | m_processMonitor |
Instance of the process monitor. | |
EventMetaData | m_previousEventMetaData |
Stores previous eventMetaData. | |
This class provides the core event processing loop for parallel processing with ZMQ.
Definition at line 23 of file ZMQEventProcessor.h.
Init the socket cleaning at exit.
Definition at line 101 of file ZMQEventProcessor.cc.
|
virtual |
Make sure we remove all sockets cleanly.
Definition at line 112 of file ZMQEventProcessor.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.
void cleanup | ( | ) |
clean up IPC resources (should only be called in one process).
Definition at line 422 of file ZMQEventProcessor.cc.
|
private |
Second step in the process: fork out the processes we need to have and call the event loop.
Definition at line 400 of file ZMQEventProcessor.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.
|
private |
First step in the process: init the module in the list.
TFiles are stored in a global list and cleaned up by root since this will happen in all forked processes, these will be corrupted if we don't clean the list!
needs to be called at the end of every process.
Definition at line 170 of file ZMQEventProcessor.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 315 of file EventProcessor.cc.
|
staticinherited |
Install a signal handler 'fn' for given signal.
Definition at line 300 of file EventProcessor.cc.
void process | ( | const PathPtr & | spath, |
long | maxEvent | ||
) |
Processes the full module chain using parallel processing, starting with the first module in the given path.
Definition at line 118 of file ZMQEventProcessor.cc.
|
private |
Calls BeginRun function.
Definition at line 622 of file ZMQEventProcessor.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 409 of file EventProcessor.cc.
|
private |
Process modules in the path.
Definition at line 434 of file ZMQEventProcessor.cc.
|
private |
Calls EndRun function.
Definition at line 655 of file ZMQEventProcessor.cc.
|
protectedinherited |
Calls event() functions on all modules for the current event.
Used by processCore.
moduleIter | iterator of the path containing all the modules |
skipMasterModule | skip the execution of the master module, presumably because this is the first event and it's already been done in initialize() |
Definition at line 324 of file EventProcessor.cc.
|
private |
Calls Event function.
Definition at line 483 of file ZMQEventProcessor.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 immediately to load the event info right away so that it's available for subsequent modules |
Definition at line 242 of file EventProcessor.cc.
|
private |
Basic function run in every process: process the event loop of the given path.
Definition at line 318 of file ZMQEventProcessor.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 443 of file EventProcessor.cc.
|
private |
Fork out the input process.
Definition at line 226 of file ZMQEventProcessor.cc.
|
private |
Start the monitoring (without forking)
Definition at line 333 of file ZMQEventProcessor.cc.
|
private |
Fork out the output process.
Definition at line 249 of file ZMQEventProcessor.cc.
|
private |
Fork out the N worker process.
Definition at line 289 of file ZMQEventProcessor.cc.
|
inlineinherited |
Set the name of the module we want to profile.
name | Name of the module as returned by getName() |
Definition at line 58 of file EventProcessor.h.
|
private |
Last step in the process: run the termination and cleanup (kill all remaining processes)
Definition at line 202 of file ZMQEventProcessor.cc.
|
staticinherited |
async-safe method to write something to STDERR.
Definition at line 72 of file EventProcessor.cc.
|
protectedinherited |
event extra info object pointer
Definition at line 170 of file EventProcessor.h.
|
protectedinherited |
EventMetaData is used by processEvent()/processCore().
Definition at line 164 of file EventProcessor.h.
|
protectedinherited |
Are we currently in a run? If yes, processEndRun() needs to do something.
Definition at line 176 of file EventProcessor.h.
|
protectedinherited |
Time in seconds of last call for metadata update in event loop.
Definition at line 179 of file EventProcessor.h.
|
protectedinherited |
The master module that determines the experiment/run/event number.
Definition at line 154 of file EventProcessor.h.
|
protectedinherited |
Minimal time difference in seconds for metadata updates in event loop.
Definition at line 182 of file EventProcessor.h.
|
protectedinherited |
List of all modules in order initialized.
Definition at line 155 of file EventProcessor.h.
|
private |
Stores previous eventMetaData.
Definition at line 82 of file ZMQEventProcessor.h.
|
private |
Instance of the process monitor.
Definition at line 79 of file ZMQEventProcessor.h.
|
protectedinherited |
Also used in a number of places.
Definition at line 173 of file EventProcessor.h.
|
protectedinherited |
Address of the module which we want to profile, nullptr if no profiling is requested.
Definition at line 161 of file EventProcessor.h.
|
protectedinherited |
Name of the module which should be profiled, empty if no profiling is requested.
Definition at line 158 of file EventProcessor.h.
|
protectedinherited |
True if the SteerRootInputModule is in charge for event processing.
Definition at line 185 of file EventProcessor.h.