lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::TebReceiverBase Class Referenceabstract

Base of the DRP trigger result receivers. More...

#include <DrpBase.hh>

Inherits Pds::Eb::EbCtrbInBase.

Inherited by Drp::Gpu::TebReceiver, and Drp::TebReceiver.

Public Member Functions

 TebReceiverBase (const Parameters &, DrpBase &)
 Construct the EbCtrbInBase from the TEB parameters of the DRP, keep references to the DRP and its pool, and allocate a buffer of para.maxTrSize bytes for the Configure datagram.
 
virtual ~TebReceiverBase ()
 Does nothing; empty body.
 
void resetCounters (bool all)
 Reset the EbCtrbInBase counters, the damage count and histogram and the latency; with all true, also reset the expected next buffer index so that index 0 is expected.
 
int connect (const std::shared_ptr< Pds::MetricExporter >)
 Register metrics (if the exporter is non-null), remember the node ID on the timing-system DRP (detType ts), and connect to the TEBs with EbCtrbInBase::connect().
 
void unconfigure ()
 Close the files (in case BeginRun failed), then call EbCtrbInBase::unconfigure().
 
std::string openFiles (const RunInfo &runInfo)
 If runInfo.runNumber is non-zero, create the directories and open the data file outputDir/instrument/experiment/xtc/RUN.xtc2 and the small-data file RUN.smd.xtc2 in its smalldata subdirectory (RUN is experiment-rNNNN-sNNN-c000), sending a file report message for each.
 
bool advanceChunkId ()
 If no chunk change is pending, increment the chunk ID in the file parameters, mark a change pending and return true; otherwise return false.
 
std::string reopenFiles ()
 Close the current data file and open the data file for the new chunk (name from FileParameters::runName()), sending a file report message and clearing the pending flag on success.
 
std::string closeFiles ()
 If writing, clear the writing flag and close the small-data and data files.
 
uint64_t chunkSize () const
 Return the number of bytes recorded since the current chunk started.
 
void chunkRequestSet ()
 Set the chunk-request flag.
 
void chunkReset ()
 Clear the chunk offset, the chunk-request flag and the pending flag left from a previous run.
 
void offsetReset ()
 Set the recorded byte offset to 0.
 
void offsetAppend (size_t size)
 Add size to the recorded byte offset.
 
bool writing () const
 Return true while files are open for recording (from a successful openFiles() until closeFiles()).
 
const FileParameters & fileParameters () const
 Return the file parameters cached by openFiles(); valid only after a successful openFiles().
 
virtual FileWriterBase & fileWriter ()=0
 Pure virtual: return the writer used for the data file.
 
virtual SmdWriterBase & smdWriter ()=0
 Pure virtual: return the writer used for the small-data file.
 
- Public Member Functions inherited from Pds::Eb::EbCtrbInBase
 EbCtrbInBase (const TebCtrbParams &)
 Keep a reference to the parameters and create the server transport from prms.verbose and prms.kwargs.
 
virtual ~EbCtrbInBase ()
 Free the result region.
 
int resetCounters ()
 Reset the batch, event, missing, bypass and no-progress counters; returns 0.
 
int startConnection (std::string &port)
 Listen on prms.ifAddr:port for up to MAX_TEBS TEB connections with EbLfServer::listen(); an empty port is replaced by the bound ephemeral port.
 
int connect (const std::shared_ptr< MetricExporter >)
 Register metrics with the exporter (if non-null) and accept one link per builder in prms.builders with linksConnect().
 
int configure (unsigned numBuffers)
 Forget left-over inputs and deferred results, then for each TEB link receive the result region size, (re)allocate the shared result region if the size changed, and register it and send its description with EbLfSvrLink::setupMr().
 
void unconfigure ()
 Does nothing; empty body.
 
void disconnect ()
 Call unconfigure(), then disconnect and drop all links.
 
void shutdown ()
 Call disconnect(), then shut down the transport.
 
void receiver (TebContributor &, std::atomic< bool > &running)
 Thread body: pin to prms.core[1], name the thread drp/TEBreceiver and repeatedly wait (100 ms each) for result batches and match them with the pending inputs of ctrb, until running becomes false.
 

Static Public Attributes

static const uint64_t DefaultChunkThresh = 500ull * 1024ull * 1024ull * 1024ull
 Chunk threshold of 500 * 1024^3 bytes (500 GB per the comment): process() requests a new chunk when chunkSize() exceeds it, and DrpBase::enable() advances the chunk once chunkSize() exceeds half of it.
 

Protected Member Functions

void process (const Pds::Eb::ResultDgram &, unsigned index) override
 Pure virtual: handle the result of one event; index is the buffer index of the matching input datagram.
 
virtual int setupMetrics (const std::shared_ptr< Pds::MetricExporter >, std::map< std::string, std::string > &labels)=0
 
virtual void complete (unsigned index, const Pds::Eb::ResultDgram &result)=0
 

Protected Attributes

MemPool & m_pool
 
DrpBase & m_drp
 
unsigned m_tsId
 
ZmqSocket & m_inprocSend
 
bool m_chunkRequest
 
unsigned m_configureIndex
 
std::vector< uint8_t > m_configureBuffer
 
uint64_t m_evtSize
 
uint64_t m_latPid
 
int64_t m_latency
 

Detailed Description

Base of the DRP trigger result receivers.

process() checks each result against the pebble datagram, transfers the result damage, requests file chunking and calls complete(); the class also opens and closes the data and small-data files. Subclasses provide the writers, metrics and complete().

Constructor & Destructor Documentation

◆ TebReceiverBase()

Drp::TebReceiverBase::TebReceiverBase ( const Parameters &  ,
DrpBase &   
)

Construct the EbCtrbInBase from the TEB parameters of the DRP, keep references to the DRP and its pool, and allocate a buffer of para.maxTrSize bytes for the Configure datagram.

◆ ~TebReceiverBase()

virtual Drp::TebReceiverBase::~TebReceiverBase ( )
inlinevirtual

Does nothing; empty body.

Member Function Documentation

◆ advanceChunkId()

bool Drp::TebReceiverBase::advanceChunkId ( )

If no chunk change is pending, increment the chunk ID in the file parameters, mark a change pending and return true; otherwise return false.

◆ chunkRequestSet()

void Drp::TebReceiverBase::chunkRequestSet ( )

Set the chunk-request flag.

◆ chunkReset()

void Drp::TebReceiverBase::chunkReset ( )

Clear the chunk offset, the chunk-request flag and the pending flag left from a previous run.

◆ chunkSize()

uint64_t Drp::TebReceiverBase::chunkSize ( ) const
inline

Return the number of bytes recorded since the current chunk started.

◆ closeFiles()

std::string Drp::TebReceiverBase::closeFiles ( )

If writing, clear the writing flag and close the small-data and data files.

Always returns an empty string.

◆ complete()

virtual void Drp::TebReceiverBase::complete ( unsigned  index,
const Pds::Eb::ResultDgram &  result 
)
protectedpure virtual

◆ connect()

int Drp::TebReceiverBase::connect ( const std::shared_ptr< Pds::MetricExporter >  )

Register metrics (if the exporter is non-null), remember the node ID on the timing-system DRP (detType ts), and connect to the TEBs with EbCtrbInBase::connect().

Returns 0 or the first error.

◆ fileParameters()

const FileParameters & Drp::TebReceiverBase::fileParameters ( ) const
inline

Return the file parameters cached by openFiles(); valid only after a successful openFiles().

◆ fileWriter()

virtual FileWriterBase & Drp::TebReceiverBase::fileWriter ( )
pure virtual

Pure virtual: return the writer used for the data file.

Implemented in Drp::TebReceiver, and Drp::Gpu::TebReceiver.

◆ offsetAppend()

void Drp::TebReceiverBase::offsetAppend ( size_t  size)
inline

Add size to the recorded byte offset.

◆ offsetReset()

void Drp::TebReceiverBase::offsetReset ( )
inline

Set the recorded byte offset to 0.

◆ openFiles()

std::string Drp::TebReceiverBase::openFiles ( const RunInfo &  runInfo)

If runInfo.runNumber is non-zero, create the directories and open the data file outputDir/instrument/experiment/xtc/RUN.xtc2 and the small-data file RUN.smd.xtc2 in its smalldata subdirectory (RUN is experiment-rNNNN-sNNN-c000), sending a file report message for each.

Returns an empty string on success, after which writing() is true, or a message naming the file that failed.

◆ process()

void Drp::TebReceiverBase::process ( const Pds::Eb::ResultDgram &  result,
unsigned  index 
)
overrideprotectedvirtual

Pure virtual: handle the result of one event; index is the buffer index of the matching input datagram.

Called from the receiver thread for each input matched with a result, and with a locally built persist result for inputs that bypassed the TEBs.

Implements Pds::Eb::EbCtrbInBase.

◆ reopenFiles()

std::string Drp::TebReceiverBase::reopenFiles ( )

Close the current data file and open the data file for the new chunk (name from FileParameters::runName()), sending a file report message and clearing the pending flag on success.

Returns an empty string on success or an error message (also when not writing).

◆ resetCounters()

void Drp::TebReceiverBase::resetCounters ( bool  all)

Reset the EbCtrbInBase counters, the damage count and histogram and the latency; with all true, also reset the expected next buffer index so that index 0 is expected.

◆ setupMetrics()

virtual int Drp::TebReceiverBase::setupMetrics ( const std::shared_ptr< Pds::MetricExporter >  ,
std::map< std::string, std::string > &  labels 
)
protectedpure virtual

◆ smdWriter()

virtual SmdWriterBase & Drp::TebReceiverBase::smdWriter ( )
pure virtual

Pure virtual: return the writer used for the small-data file.

Implemented in Drp::TebReceiver, and Drp::Gpu::TebReceiver.

◆ unconfigure()

void Drp::TebReceiverBase::unconfigure ( )

Close the files (in case BeginRun failed), then call EbCtrbInBase::unconfigure().

◆ writing()

bool Drp::TebReceiverBase::writing ( ) const
inline

Return true while files are open for recording (from a successful openFiles() until closeFiles()).

Member Data Documentation

◆ DefaultChunkThresh

const uint64_t Drp::TebReceiverBase::DefaultChunkThresh = 500ull * 1024ull * 1024ull * 1024ull
static

Chunk threshold of 500 * 1024^3 bytes (500 GB per the comment): process() requests a new chunk when chunkSize() exceeds it, and DrpBase::enable() advances the chunk once chunkSize() exceeds half of it.

◆ m_chunkRequest

bool Drp::TebReceiverBase::m_chunkRequest
protected

◆ m_configureBuffer

std::vector<uint8_t> Drp::TebReceiverBase::m_configureBuffer
protected

◆ m_configureIndex

unsigned Drp::TebReceiverBase::m_configureIndex
protected

◆ m_drp

DrpBase& Drp::TebReceiverBase::m_drp
protected

◆ m_evtSize

uint64_t Drp::TebReceiverBase::m_evtSize
protected

◆ m_inprocSend

ZmqSocket& Drp::TebReceiverBase::m_inprocSend
protected

◆ m_latency

int64_t Drp::TebReceiverBase::m_latency
protected

◆ m_latPid

uint64_t Drp::TebReceiverBase::m_latPid
protected

◆ m_pool

MemPool& Drp::TebReceiverBase::m_pool
protected

◆ m_tsId

unsigned Drp::TebReceiverBase::m_tsId
protected

The documentation for this class was generated from the following file: