Belle II Software development
|
Send the histograms as compressed byte stream via a ZMQConfirmedOutput connection after merging with all the properties of a normal confirmed output. More...
#include <ZMQHistogramConnection.h>
Public Types | |
using | ReactorFunction = std::function< void(void)> |
Typedef of a function which will be called if a connection has a message. | |
Public Member Functions | |
ZMQHistoServerToZMQOutput (const std::string &outputAddress, const std::shared_ptr< ZMQParent > &parent) | |
Initialize the ZMQConfirmedOutput with the given address. | |
void | mergeAndSend (const std::map< std::string, HistogramMapping > &storedMessages, const std::optional< unsigned int > &experiment, const std::optional< unsigned int > &run, EMessageTypes messageType) |
Merge the histograms and send them via the connection. Stop/Terminate messages are sent after that. | |
void | clear () |
Nothing to do on clear. | |
std::string | getMonitoringJSON () const final |
The monitoring JSON is just passed from the ZMQConfirmedOutput. | |
void | handleIncomingData () |
The input data handling is passed from the ZMQConfirmedOutput. | |
bool | isReady () const override |
The is ready is passed from the ZMQConfirmedOutput. | |
std::vector< zmq::socket_t * > | getSockets () const final |
The sockets are passed from ZMQConfirmedOutput. | |
std::string | getEndPoint () const |
Return the connection string. | |
template<class AClass > | |
void | log (const std::string &key, const AClass &value) |
Store a value under a certain key. Different types of values can be stored, namely long, double or string. Mixtures are not allowed for a given key. | |
void | increment (const std::string &key) |
Increment the value with the given key (only numerical values). If not present, set to 1. | |
void | decrement (const std::string &key) |
Decrement the value with the given key (only numerical values). If not present, set to -1. | |
template<size_t MAX_SIZE = 100> | |
void | average (const std::string &key, double value) |
Instead of storeing the double value directly under the given key, store the average of the last MAX_SIZE values. | |
template<size_t AVERAGE_SIZE = 2000> | |
void | timeit (const std::string &key) |
Measure the rate of calls with the same key every AVERAGE_SIZE calls (and also display the last time AVERAGE_SIZE was reached under <key>_last_measurement) | |
void | logTime (const std::string &key) |
Store the current time as a string under the given key. | |
Static Public Member Functions | |
static bool | poll (const std::map< const ZMQConnection *, ReactorFunction > &connectionList, int timeout) |
Poll on the given connections and call the attached function if a messages comes in. | |
static bool | hasMessage (const ZMQConnection *connection) |
Check if the given connection as an incoming message (right now, no waiting). | |
Private Attributes | |
ZMQConfirmedOutput | m_output |
The output connection used for sending the histograms. | |
std::vector< char > | m_outputBuffer |
Buffer used for compression. | |
unsigned int | m_maximalCompressedSize = 100'000'000 |
Maximal size of the compression buffer. | |
std::map< std::string, std::variant< long, double, std::string > > | m_monitoring |
Internal storage of all stored values. | |
std::unordered_map< std::string, std::tuple< std::vector< double >, size_t > > | m_averages |
Internal storage of the previous values when calculating averages. | |
std::unordered_map< std::string, std::tuple< unsigned long, std::chrono::system_clock::time_point > > | m_timeCounters |
Internal storage how often the timeit function for a given key was called and when it has last reached MAX_SIZE. | |
Send the histograms as compressed byte stream via a ZMQConfirmedOutput connection after merging with all the properties of a normal confirmed output.
Stop and terminate messages are sent as normal (after performing a last merge and sending it). As additional message the event meta data is passed.
This connection allows to built hierarchies of histogram servers with ZMQ.
Definition at line 88 of file ZMQHistogramConnection.h.
|
inherited |
Typedef of a function which will be called if a connection has a message.
Definition at line 34 of file ZMQConnection.h.
ZMQHistoServerToZMQOutput | ( | const std::string & | outputAddress, |
const std::shared_ptr< ZMQParent > & | parent | ||
) |
Initialize the ZMQConfirmedOutput with the given address.
Definition at line 116 of file ZMQHistogramConnection.cc.
|
inline |
|
inherited |
Decrement the value with the given key (only numerical values). If not present, set to -1.
Definition at line 37 of file ZMQLogger.cc.
|
inline |
Return the connection string.
Definition at line 109 of file ZMQHistogramConnection.h.
|
inlinefinalvirtual |
The monitoring JSON is just passed from the ZMQConfirmedOutput.
Reimplemented from ZMQLogger.
Definition at line 101 of file ZMQHistogramConnection.h.
|
inlinefinalvirtual |
The sockets are passed from ZMQConfirmedOutput.
Implements ZMQConnection.
Definition at line 107 of file ZMQHistogramConnection.h.
|
inline |
The input data handling is passed from the ZMQConfirmedOutput.
Definition at line 103 of file ZMQHistogramConnection.h.
|
staticinherited |
Check if the given connection as an incoming message (right now, no waiting).
Definition at line 20 of file ZMQConnection.cc.
|
inherited |
Increment the value with the given key (only numerical values). If not present, set to 1.
Definition at line 32 of file ZMQLogger.cc.
|
inlineoverridevirtual |
The is ready is passed from the ZMQConfirmedOutput.
Reimplemented from ZMQConnection.
Definition at line 105 of file ZMQHistogramConnection.h.
|
inherited |
Store the current time as a string under the given key.
Definition at line 42 of file ZMQLogger.cc.
void mergeAndSend | ( | const std::map< std::string, HistogramMapping > & | storedMessages, |
const std::optional< unsigned int > & | experiment, | ||
const std::optional< unsigned int > & | run, | ||
EMessageTypes | messageType | ||
) |
Merge the histograms and send them via the connection. Stop/Terminate messages are sent after that.
Definition at line 127 of file ZMQHistogramConnection.cc.
|
staticinherited |
Poll on the given connections and call the attached function if a messages comes in.
If after timeout milliseconds still no message is received, return anyways. If timeout is 0, do not wait. If timeout is -1, wait infinitely.
Returns true if a message was received on any socket, false otherwise. Attention: in case of an interrupted system call (e.g. because a signal was received) the function might return anyways with a negative result even before the timeout!
Definition at line 27 of file ZMQConnection.cc.
|
privateinherited |
Internal storage of the previous values when calculating averages.
Definition at line 60 of file ZMQLogger.h.
|
private |
Maximal size of the compression buffer.
Definition at line 117 of file ZMQHistogramConnection.h.
|
privateinherited |
Internal storage of all stored values.
Definition at line 58 of file ZMQLogger.h.
|
private |
The output connection used for sending the histograms.
Definition at line 112 of file ZMQHistogramConnection.h.
|
private |
Buffer used for compression.
Definition at line 115 of file ZMQHistogramConnection.h.
|
privateinherited |
Internal storage how often the timeit function for a given key was called and when it has last reached MAX_SIZE.
Definition at line 62 of file ZMQLogger.h.