Belle II Software development
|
Class to monitor all started framework processes (input, workers, output), kill them if requested and handle the signals from the OS. More...
#include <ProcessMonitor.h>
Public Member Functions | |
void | subscribe (const std::string &pubSocketAddress, const std::string &subSocketAddress, const std::string &controlSocketAddress) |
Start listening for process management information on the given address. | |
void | waitForRunningInput (int timeout) |
Block until either the input process is running or the timeout (in seconds) is raised. | |
void | waitForRunningOutput (int timeout) |
Block until either the output process is running or the timeout (in seconds) is raised. | |
void | waitForRunningWorker (int timeout) |
Block until either the worker process is running or the timeout (in seconds) is raised. | |
void | killProcesses (unsigned int timeout) |
Ask all processes to terminate. If not, kill them after timeout seconds. | |
void | initialize (unsigned int requestedNumberOfWorkers) |
Init the processing with that many workers. | |
void | terminate () |
Terminate the processing. | |
void | reset () |
Reset the internal state. | |
void | checkMulticast (int timeout=0) |
check multicast for messages and kill workers if requested | |
void | checkChildProcesses () |
check the child processes, if one has died | |
void | checkSignals (int g_signalReceived) |
check if we have received any signal from the user or OS. Kill the processes if not SIGINT. | |
bool | hasEnded () const |
If we have received a SIGINT signal or the last process is gone, we can end smoothly. | |
unsigned int | needMoreWorkers () const |
Compare our current list of workers of how many we want to have. | |
bool | hasWorkers () const |
Check if there is at least one running worker. | |
Private Member Functions | |
unsigned int | processesWithType (const ProcType &procType) const |
Cound the number of processes with a certain type. | |
template<class ASocket > | |
void | processMulticast (const ASocket &socket) |
Process a message from the multicast. | |
Private Attributes | |
ZMQClient | m_client |
The client used for message processing. | |
unsigned int | m_requestedNumberOfWorkers = 0 |
How many workers we should request to start. | |
std::map< int, ProcType > | m_processList |
The current list of pid -> process types (to be compared to the proc handler) | |
bool | m_hasEnded = false |
Someone requested us to end the processing. | |
StreamHelper | m_streamer |
The data store streamer. | |
bool | m_receivedStatistics = false |
Did we already receive the statistics? | |
Class to monitor all started framework processes (input, workers, output), kill them if requested and handle the signals from the OS.
Is used in the ZMQ event processor and can only be used together with ZMQ.
Definition at line 28 of file ProcessMonitor.h.
void checkChildProcesses | ( | ) |
check the child processes, if one has died
Definition at line 266 of file ProcessMonitor.cc.
void checkMulticast | ( | int | timeout = 0 | ) |
check multicast for messages and kill workers if requested
Definition at line 210 of file ProcessMonitor.cc.
void checkSignals | ( | int | g_signalReceived | ) |
check if we have received any signal from the user or OS. Kill the processes if not SIGINT.
Definition at line 335 of file ProcessMonitor.cc.
bool hasEnded | ( | ) | const |
If we have received a SIGINT signal or the last process is gone, we can end smoothly.
Definition at line 343 of file ProcessMonitor.cc.
bool hasWorkers | ( | ) | const |
Check if there is at least one running worker.
Definition at line 348 of file ProcessMonitor.cc.
void initialize | ( | unsigned int | requestedNumberOfWorkers | ) |
Init the processing with that many workers.
Definition at line 205 of file ProcessMonitor.cc.
void killProcesses | ( | unsigned int | timeout | ) |
Ask all processes to terminate. If not, kill them after timeout seconds.
Definition at line 106 of file ProcessMonitor.cc.
unsigned int needMoreWorkers | ( | ) | const |
Compare our current list of workers of how many we want to have.
Definition at line 353 of file ProcessMonitor.cc.
|
private |
Cound the number of processes with a certain type.
Definition at line 365 of file ProcessMonitor.cc.
|
private |
Process a message from the multicast.
Definition at line 224 of file ProcessMonitor.cc.
void reset | ( | ) |
Reset the internal state.
Definition at line 101 of file ProcessMonitor.cc.
void subscribe | ( | const std::string & | pubSocketAddress, |
const std::string & | subSocketAddress, | ||
const std::string & | controlSocketAddress | ||
) |
Start listening for process management information on the given address.
Definition at line 24 of file ProcessMonitor.cc.
void terminate | ( | ) |
Terminate the processing.
Definition at line 96 of file ProcessMonitor.cc.
void waitForRunningInput | ( | int | timeout | ) |
Block until either the input process is running or the timeout (in seconds) is raised.
Definition at line 157 of file ProcessMonitor.cc.
void waitForRunningOutput | ( | int | timeout | ) |
Block until either the output process is running or the timeout (in seconds) is raised.
Definition at line 189 of file ProcessMonitor.cc.
void waitForRunningWorker | ( | int | timeout | ) |
Block until either the worker process is running or the timeout (in seconds) is raised.
Definition at line 173 of file ProcessMonitor.cc.
|
private |
The client used for message processing.
Definition at line 69 of file ProcessMonitor.h.
|
private |
Someone requested us to end the processing.
Definition at line 76 of file ProcessMonitor.h.
|
private |
The current list of pid -> process types (to be compared to the proc handler)
Definition at line 74 of file ProcessMonitor.h.
|
private |
Did we already receive the statistics?
Definition at line 82 of file ProcessMonitor.h.
|
private |
How many workers we should request to start.
Definition at line 72 of file ProcessMonitor.h.
|
private |
The data store streamer.
Definition at line 79 of file ProcessMonitor.h.