20#define ERS_WARNING( message ) \
22 ERS_REPORT_IMPL( ers::warning, ers::Message, message, ); \
25#define ERS_ERROR( message ) \
27 ERS_REPORT_IMPL( ers::error, ers::Message, message, ); \
66 ERS_DEBUG(MSG::VERBOSE,
"StartServingThread()");
80 return StatusCode::FAILURE;
83 return StatusCode::SUCCESS;
95 ERS_DEBUG(MSG::VERBOSE,
"StopServingThread()");
106 ERS_ERROR(
"Unable to create shutdown client for local server");
107 return StatusCode::FAILURE;
116 struct timeval timeout; timeout.tv_sec = 1; timeout.tv_usec = 0;
119# pragma GCC diagnostic push
120# pragma GCC diagnostic ignored "-Wcast-function-type"
122#if defined(__clang__) && __clang_major__ >= 19
123# pragma clang diagnostic push
124# pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
126 clnt_call(client, NULLPROC, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, NULL, timeout);
127#if defined(__clang__) && __clang_major__ >= 19
128# pragma clang diagnostic pop
131# pragma GCC diagnostic pop
137 ERS_INFO(
"Waiting for server thread to terminate ...");
139 ERS_INFO(
" ... finished server thread");
144 unsigned long NRequests = *(
unsigned long*)ret;
145 ERS_DEBUG(MSG::DEBUG,
"Server thread stopped after handling " << NRequests <<
" requests");
149 return StatusCode::SUCCESS;
157 m_receivedSignal.set_value(signal);
166 auto signal = m_receivedSignal.get_future();
170 ERS_INFO(
"Reached post-condition after received signal " << signal.get() );
188 ERS_DEBUG(MSG::VERBOSE,
"UpdateEventForStream");
192 ERS_ERROR(
"Invalid event stream identifier - cannot add event");
193 return StatusCode::FAILURE;
198 ERS_ERROR(
"Reached max. allowed number of streams " <<
NSTREAMMAX <<
" - cannot add event");
199 return StatusCode::FAILURE;
204 ERS_ERROR(
"Event is larger than allowed max. of " <<
NBYTESMAX <<
" bytes - cannot add event");
205 return StatusCode::FAILURE;
213 using namespace std::chrono_literals;
214 std::unique_lock
lock(m_accessLock, 30s);
217 ERS_ERROR(
"Unable to obtain access lock to update event");
218 return StatusCode::FAILURE;
229 ERS_DEBUG(MSG::DEBUG,
"Updated stream " << evtStreamID.
StreamName()
231 <<
" from run Nr. " << evtStreamID.
RunNumber());
233 return StatusCode::SUCCESS;
254 std::scoped_lock
lock(m_accessLock);
259 | std::ranges::to<std::vector>();
268 std::scoped_lock
lock(m_accessLock);
272 return MapItr->first;
284 std::scoped_lock
lock(m_accessLock);
288 return MapItr->second;
299 if (level <= MSG::DEBUG) ERS_REPORT_IMPL( ers::debug, ers::Message,
msg, level);
300 if (level == MSG::INFO) ERS_REPORT_IMPL( ers::info, ers::Message,
msg, );
301 if (level == MSG::WARNING) ERS_REPORT_IMPL( ers::warning, ers::Message,
msg, );
302 if (level == MSG::ERROR) ERS_REPORT_IMPL( ers::error, ers::Message,
msg, );
303 if (level >= MSG::FATAL) ERS_REPORT_IMPL( ers::fatal, ers::Message,
msg, );
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
#define ERS_WARNING(message)
#define ERS_ERROR(message)
For the client-server communication, each event is uniquely identified by the run number,...
unsigned int RunNumber() const
unsigned long EventNumber() const
const std::string & StreamName() const
virtual StatusCode UpdateEventForStream(const EventStreamID &evtStreamID, const std::string &event) override
Put this event as new current event for stream given by name.
virtual ~JiveXMLServer()
Destructor.
virtual std::vector< std::string > GetStreamNames() const override
get the names of all the streams
virtual void Message(const MSG::Level level, const std::string &msg) const override
This function is exposed to allow using ERS messaging service from other threads.
virtual MSG::Level LogLevel() const override
Get the logging level.
virtual void ServerThreadStopped() override
Callback whenever the server thread is stopped.
static void signalHandler(int signum)
When the signal handler is called, switch the lock to the post condition.
StatusCode StartServingThread()
Start the serving thread.
void Wait()
Wait for the server finish.
EventStreamMap m_eventStreamMap
StatusCode StopServingThread()
Stop the serving thread.
pthread_t m_ServerThreadHandle
JiveXMLServer(int port=0)
Constructor.
virtual int GetState() const override
get the Status of the application
virtual const std::string GetEvent(const EventStreamID &evtStreamID) const override
get the current event for a particular stream
virtual const EventStreamID GetEventStreamID(const std::string &streamName) const override
get the current EventStreamID for a particular stream
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
const unsigned int NBYTESMAX
std::pair< const EventStreamID, const std::string > EventStreamPair
A map that stores events according to their EventStreamID Due to the way EventStreamID is build,...
const unsigned int NSTREAMMAX
struct ServerThreadArguments_t ServerThreadArguments
Arguments handed over fromt the main (Athena) thread to the server thread.
void * ONCRPCServerThread(void *args)
This is the actual server thread, which takes above arguments.