 |
Belle II Software
release-05-02-19
|
12 #include <framework/pcore/ProcHelper.h>
13 #include <framework/pcore/zmq/sockets/ZMQClient.h>
14 #include <framework/pcore/zmq/utils/StreamHelper.h>
30 class ProcessMonitor {
33 void subscribe(
const std::string& pubSocketAddress,
const std::string& subSocketAddress,
34 const std::string& controlSocketAddress);
45 void initialize(
unsigned int requestedNumberOfWorkers);
90 template <
class ASocket>
ProcType
Type of the process used for storing and mapping the child processes in the process handler.
bool m_hasEnded
Someone requested us to end the processing.
std::map< int, ProcType > m_processList
The current list of pid -> process types (to be compared to the proc handler)
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 initialize(unsigned int requestedNumberOfWorkers)
Init the processing with that many workers.
bool m_receivedStatistics
Did we already receive the statistics?
bool hasWorkers() const
Check if there is at least one running worker.
unsigned int m_requestedNumberOfWorkers
How many workers we should request to start.
void terminate()
Terminate the processing.
Helper class for data store serialization.
void waitForRunningInput(int timeout)
Block until either the input process is running or the timeout (in seconds) is raised.
void reset()
Reset the internal state.
unsigned int processesWithType(const ProcType &procType) const
Cound the number of processes with a certain type.
Abstract base class for different kinds of events.
void processMulticast(const ASocket &socket)
Process a message from the multicast.
void checkMulticast(int timeout=0)
check multicast for messages and kill workers if requested
unsigned int needMoreWorkers() const
Compare our current list of workers of how many we want to have.
void waitForRunningWorker(int timeout)
Block until either the worker process is running or the timeout (in seconds) is raised.
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.
void waitForRunningOutput(int timeout)
Block until either the output 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.
A helper class for communicating over ZMQ. Includes a multicast and (if needed) also a data socket.
ZMQClient m_client
The client used for message processing.
StreamHelper m_streamer
The data store streamer.
void checkChildProcesses()
check the child processes, if one has died