|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
EventBuilder fed by inbound libfabric server links from the contributors (DRPs). More...
#include <EbAppBase.hh>
Inherits Pds::Eb::EventBuilder.
Public Types | |
| using | u64arr_t = std::array< uint64_t, NUM_READOUT_GROUPS > |
| Array of NUM_READOUT_GROUPS uint64_t values (contributor bit lists per readout group). | |
| using | PromHisto_t = std::shared_ptr< Pds::PromHistogram > |
| Shared pointer to a Pds::PromHistogram. | |
| using | MetricExporter_t = std::shared_ptr< Pds::MetricExporter > |
| Shared pointer to a Pds::MetricExporter. | |
Public Types inherited from Pds::Eb::EventBuilder | |
| using | time_point_t = std::chrono::time_point< fast_monotonic_clock > |
| Time point of fast_monotonic_clock. | |
| using | ns_t = std::chrono::nanoseconds |
| Alias for std::chrono::nanoseconds. | |
Public Member Functions | |
| EbAppBase (EbParams &prms, const std::string &pfx) | |
| Construct the EventBuilder with the timeout from the eb_timeout entry of prms.kwargs (inserted as EB_TMO_MS if absent), create the server transport and connect a ZMQ PUSH socket to tcp://collSrv:(CollectionApp::zmq_base_port + partition) for asynchronous error messages. | |
| virtual | ~EbAppBase () |
| Free the per-contributor regions. | |
| int | resetCounters () |
| Reset the buffer counter and the notification pulse ID, clear the histograms if present and reset the EventBuilder counters; returns 0. | |
| int | startConnection (const std::string &ifAddr, std::string &port, unsigned nLinks) |
| Listen for nLinks contributor connections on ifAddr:port with EbLfServer::listen(); if port is empty, the bound ephemeral port is written back into port. | |
| int | connect (unsigned maxEvBuffers, unsigned maxTrBuffers, const MetricExporter_t) |
| Size the per-contributor vectors from the number of bits in prms.contributors, initialize the EventBuilder for (EB_TMO_MS / 1000) * (maxEvBuffers / maxEntries) + maxTrBuffers epochs, register metrics if exporter is non-null and accept the contributor links with linksConnect(). | |
| int | configure () |
| For each link, receive the buffer size requested by the contributor, (re)allocate the local region if its size changed (that size times prms.numBuffers for the contributor, plus maxTrBuffers transition buffers of prms.maxTrSize), then register it and send its description with EbLfSvrLink::setupMr(). | |
| void | unconfigure () |
| Call EventBuilder::clear(). | |
| void | disconnect () |
| Call unconfigure(), disconnect all links and reset the ID, the contract table and the buffer size vectors. | |
| void | shutdown () |
| Call disconnect(), then shut down the transport. | |
| int | process () |
| Wait up to 100 ms for one buffer notification and pass the referenced batch or transition datagram, chosen by the immediate data flags, to EventBuilder::process() (the immediate data is passed only for contributors in prms.indexSources). | |
| void | post (const EbDgram *const *begin, const EbDgram **const end) |
| For each datagram in [begin, end), send its transition buffer index back to the contributor named by its source (immediate data NoResponse_Transition with this builder's ID). | |
| void | trim (unsigned dst) |
| Remove contributor dst from the contract of every readout group. | |
| virtual void | fixup (Pds::Eb::EbEvent *event, unsigned srcId) |
| Handle event missing contributor srcId: set DroppedContribution damage, send asynchronous error messages naming the missing contributors of the first such event to the collection server, log the first 50 fixups and timeouts, and record srcId in the fixup histogram if present. | |
| virtual uint64_t | contract (const Pds::EbDgram *contrib) const |
| Return the OR of the contracts (contributor bit lists) of all readout groups set in the readoutGroups() of contrib. | |
Public Member Functions inherited from Pds::Eb::EventBuilder | |
| EventBuilder (unsigned timeout, const unsigned &verbose) | |
| Set the event timeout to timeout milliseconds (0 means effectively no timeout) and keep verbose by reference; prints the timeout to stderr. | |
| virtual | ~EventBuilder () |
| Does nothing; empty body. | |
| virtual void | flush () |
| Hook called by expired() when nothing is pending; the default does nothing. | |
| virtual void | process (EbEvent *)=0 |
| Pure virtual: handle a completed or fixed-up event; called in pulse ID order just before the event is freed. | |
| void | expired () |
| Periodic timeout handler. | |
| void | process (const Pds::EbDgram *dgrams, const size_t bufSize, unsigned imm, const void *const end) |
| Insert a batch of contributions starting at dgrams (entries bufSize bytes apart, ending at the EOL entry or after the maximum number of entries) into their events, with immediate data imm incremented per entry; end is only used to report a missing EOL. | |
| void | resetCounters () |
| Zero the pool counters, the timeout and fixup counts, the missing bit list, the occupancy counts, the event age, the processing time and the arrival times. | |
| void | clear () |
| Delete all pending events, discard the now-empty epochs, reset the counters and clear the epoch and event lookup tables. | |
| void | dump (unsigned detail) const |
| Print the pending epochs (and their events, depending on detail) and the state of both object pools to stderr. | |
| const uint64_t | epochAllocCnt () const |
| Return the number of allocations from the epoch pool (0 before initialize()). | |
| const uint64_t | epochFreeCnt () const |
| Return the number of frees to the epoch pool (0 before initialize()). | |
| const int64_t | epochOccCnt () const |
| Return the number of epochs in use (allocations minus frees), also caching it. | |
| const uint64_t | eventAllocCnt () const |
| Return the number of allocations from the event pool (0 before initialize()). | |
| const uint64_t | eventFreeCnt () const |
| Return the number of frees to the event pool (0 before initialize()). | |
| const int64_t | eventOccCnt () const |
| Return the number of events in use (allocations minus frees), also caching it. | |
| const uint64_t | eventPoolDepth () const |
| Return the number of objects in the event pool (0 before initialize()); returned by value. | |
| const uint64_t | timeoutCnt () const |
| Return the number of incomplete events forced out because they were older than the timeout. | |
| const uint64_t | fixupCnt () const |
| Return the number of incomplete events forced out before reaching the timeout. | |
| const uint64_t | missing () const |
| Return the bit list of contributors still missing from the most recently fixed-up event. | |
| const int64_t | eventAge () const |
| Return the most recently recorded event age in nanoseconds (updated while flushing and when an event is retired). | |
| const int64_t | ebTime () const |
| Return the time spent in the most recent process(dgrams, ...) call, in nanoseconds. | |
| const int64_t | arrTime (unsigned src) const |
| Return, for contributor src, the time in nanoseconds from the creation of the last event in its most recent batch to the start of processing that batch; 0 if src is out of range. | |
Protected Member Functions | |
| const std::vector< size_t > & | bufferSizes () const |
Protected Member Functions inherited from Pds::Eb::EventBuilder | |
| int | initialize (unsigned epochs, unsigned entries, unsigned sources, uint64_t duration) |
EventBuilder fed by inbound libfabric server links from the contributors (DRPs).
Each contributor gets a local region holding its input buffers followed by its transition buffers.
| using Pds::Eb::EbAppBase::MetricExporter_t = std::shared_ptr<Pds::MetricExporter> |
Shared pointer to a Pds::MetricExporter.
| using Pds::Eb::EbAppBase::PromHisto_t = std::shared_ptr<Pds::PromHistogram> |
Shared pointer to a Pds::PromHistogram.
| using Pds::Eb::EbAppBase::u64arr_t = std::array<uint64_t, NUM_READOUT_GROUPS> |
Array of NUM_READOUT_GROUPS uint64_t values (contributor bit lists per readout group).
| Pds::Eb::EbAppBase::EbAppBase | ( | EbParams & | prms, |
| const std::string & | pfx | ||
| ) |
Construct the EventBuilder with the timeout from the eb_timeout entry of prms.kwargs (inserted as EB_TMO_MS if absent), create the server transport and connect a ZMQ PUSH socket to tcp://collSrv:(CollectionApp::zmq_base_port + partition) for asynchronous error messages.
pfx labels metrics and messages.
|
virtual |
Free the per-contributor regions.
|
inlineprotected |
| int Pds::Eb::EbAppBase::configure | ( | ) |
For each link, receive the buffer size requested by the contributor, (re)allocate the local region if its size changed (that size times prms.numBuffers for the contributor, plus maxTrBuffers transition buffers of prms.maxTrSize), then register it and send its description with EbLfSvrLink::setupMr().
Returns 0 or the first error (ENOMEM if allocation fails).
| int Pds::Eb::EbAppBase::connect | ( | unsigned | maxEvBuffers, |
| unsigned | maxTrBuffers, | ||
| const MetricExporter_t | |||
| ) |
Size the per-contributor vectors from the number of bits in prms.contributors, initialize the EventBuilder for (EB_TMO_MS / 1000) * (maxEvBuffers / maxEntries) + maxTrBuffers epochs, register metrics if exporter is non-null and accept the contributor links with linksConnect().
Returns 0 or the first error.
|
virtual |
Return the OR of the contracts (contributor bit lists) of all readout groups set in the readoutGroups() of contrib.
Implements Pds::Eb::EventBuilder.
| void Pds::Eb::EbAppBase::disconnect | ( | ) |
Call unconfigure(), disconnect all links and reset the ID, the contract table and the buffer size vectors.
|
virtual |
Handle event missing contributor srcId: set DroppedContribution damage, send asynchronous error messages naming the missing contributors of the first such event to the collection server, log the first 50 fixups and timeouts, and record srcId in the fixup histogram if present.
Implements Pds::Eb::EventBuilder.
For each datagram in [begin, end), send its transition buffer index back to the contributor named by its source (immediate data NoResponse_Transition with this builder's ID).
Aborts on an invalid contributor ID or index; a failed post is only logged.
| int Pds::Eb::EbAppBase::process | ( | ) |
Wait up to 100 ms for one buffer notification and pass the referenced batch or transition datagram, chosen by the immediate data flags, to EventBuilder::process() (the immediate data is passed only for contributors in prms.indexSources).
On -FI_EAGAIN, call EventBuilder::expired() to time out incomplete events. Returns 0 or the negative pend() error; aborts on an invalid source ID or a failed sanity check (source, index, region bounds, size, pulse ID order).
| int Pds::Eb::EbAppBase::resetCounters | ( | ) |
Reset the buffer counter and the notification pulse ID, clear the histograms if present and reset the EventBuilder counters; returns 0.
| void Pds::Eb::EbAppBase::shutdown | ( | ) |
Call disconnect(), then shut down the transport.
| int Pds::Eb::EbAppBase::startConnection | ( | const std::string & | ifAddr, |
| std::string & | port, | ||
| unsigned | nLinks | ||
| ) |
Listen for nLinks contributor connections on ifAddr:port with EbLfServer::listen(); if port is empty, the bound ephemeral port is written back into port.
Returns 0 or the listen error.
| void Pds::Eb::EbAppBase::trim | ( | unsigned | dst | ) |
Remove contributor dst from the contract of every readout group.
| void Pds::Eb::EbAppBase::unconfigure | ( | ) |
Call EventBuilder::clear().