Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
19 #define ERS_WARNING( message ) \
21 ERS_REPORT_IMPL( ers::warning, ers::Message, message, ); \
24 #define ERS_ERROR( message ) \
26 ERS_REPORT_IMPL( ers::error, ers::Message, message, ); \
30 std::string fmterror(
int code) {
32 return std::string(strerror_r(
code, buf,
sizeof(buf)));
76 int retVal = pthread_mutex_init(&m_accessLock,NULL);
78 ERS_WARNING(
"Unable to initialize access lock while starting server: " << fmterror(retVal));
79 return StatusCode::FAILURE;
94 return StatusCode::FAILURE;
97 return StatusCode::SUCCESS;
120 ERS_ERROR(
"Unable to create shutdown client for local server");
121 return StatusCode::FAILURE;
133 # pragma GCC diagnostic push
134 # pragma GCC diagnostic ignored "-Wcast-function-type"
136 #if defined(__clang__) && __clang_major__ >= 19
137 # pragma clang diagnostic push
138 # pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
140 clnt_call(
client, NULLPROC, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, NULL,
timeout);
141 #if defined(__clang__) && __clang_major__ >= 19
142 # pragma clang diagnostic pop
145 # pragma GCC diagnostic pop
151 ERS_INFO(
"Waiting for server thread to terminate ...");
153 ERS_INFO(
" ... finished server thread");
158 unsigned long NRequests = *(
unsigned long*)ret;
159 ERS_DEBUG(
MSG::DEBUG,
"Server thread stopped after handling " << NRequests <<
" requests");
164 int retVal = pthread_mutex_destroy(&m_accessLock);
166 ERS_WARNING(
"Unable to destroy access lock after stopping server: " << fmterror(retVal));
167 return StatusCode::FAILURE;
170 return StatusCode::SUCCESS;
192 ERS_INFO(
"Reached post-condition after received signal " <<
m_receivedSignal );
214 ERS_ERROR(
"Invalid event stream identifier - cannot add event");
215 return StatusCode::FAILURE;
220 ERS_ERROR(
"Reached max. allowed number of streams " <<
NSTREAMMAX <<
" - cannot add event");
221 return StatusCode::FAILURE;
226 ERS_ERROR(
"Event is larger than allowed max. of " <<
NBYTESMAX <<
" bytes - cannot add event");
227 return StatusCode::FAILURE;
235 struct timespec
timeout = { 30, 0 };
237 int retVal = pthread_mutex_timedlock(&m_accessLock, &
timeout);
239 ERS_ERROR(
"Unable to obtain access lock to update event: " << fmterror(retVal));
240 return StatusCode::FAILURE;
260 ERS_ERROR(
"Exception caught while updating event for stream "
263 pthread_mutex_unlock(&m_accessLock);
265 return StatusCode::FAILURE;
269 retVal = pthread_mutex_unlock(&m_accessLock);
271 ERS_ERROR(
"Unable to release access lock after updating event: " << fmterror(retVal));
272 return StatusCode::FAILURE;
277 <<
" from run Nr. " << evtStreamID.
RunNumber());
279 return StatusCode::SUCCESS;
303 int retVal = pthread_mutex_lock(&m_accessLock);
305 ERS_ERROR(
"Unable to obtain access lock to get stream names: " << fmterror(retVal));
321 retVal = pthread_mutex_unlock(&m_accessLock);
323 ERS_ERROR(
"Unable to release access lock after getting stream names: " << fmterror(retVal));
335 int retVal = pthread_mutex_lock(&m_accessLock);
337 ERS_ERROR(
"Unable to obtain access lock to get stream ID: " << fmterror(retVal));
353 retVal = pthread_mutex_unlock(&m_accessLock);
355 ERS_ERROR(
"Unable to release access lock after getting stream ID: " << fmterror(retVal));
367 int retVal = pthread_mutex_lock(&m_accessLock);
369 ERS_ERROR(
"Unable to obtain access lock to get event: " << fmterror(retVal));
370 return std::string(
"");
382 event = std::string((*MapItr).second);
386 retVal = pthread_mutex_unlock(&m_accessLock);
388 ERS_ERROR(
"Unable to release access lock after getting stream event: " << fmterror(retVal));
JetConstituentVector::iterator iterator
static void signalHandler(int signum)
When the signal handler is called, switch the lock to the post condition.
EventStreamMap m_eventStreamMap
virtual const std::string GetEvent(const EventStreamID &evtStreamID) const override
get the current event for a particular stream
unsigned long EventNumber() const
virtual int GetState() const override
get the Status of the application
StatusCode StopServingThread()
Stop the serving thread.
struct ServerThreadArguments_t ServerThreadArguments
Arguments handed over fromt the main (Athena) thread to the server thread.
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.
void * ONCRPCServerThread(void *args)
This is the actual server thread, which takes above arguments.
JiveXMLServer(int port=0)
Constructor.
POOL::TEvent event(POOL::TEvent::kClassAccess)
::StatusCode StatusCode
StatusCode definition for legacy code.
virtual MSG::Level LogLevel() const override
Get the logging level.
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 NBYTESMAX
#define ERS_WARNING(message)
For the client-server communication, each event is uniquely identified by the run number,...
const std::string & StreamName() const
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
virtual const EventStreamID GetEventStreamID(const std::string &streamName) const override
get the current EventStreamID for a particular stream
#define ERS_ERROR(message)
static std::atomic< int > m_receivedSignal
StatusCode StartServingThread()
Start the serving thread.
pthread_t m_ServerThreadHandle
virtual void ServerThreadStopped() override
Callback whenever the server thread is stopped.
void Wait()
Wait for the server finish.
virtual ~JiveXMLServer()
Destructor.
unsigned int RunNumber() const
virtual StatusCode UpdateEventForStream(const EventStreamID &evtStreamID, const std::string &event) override
Put this event as new current event for stream given by name.
const unsigned int NSTREAMMAX