|
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 clnt_call(
client, NULLPROC, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, NULL,
timeout);
138 # pragma GCC diagnostic pop
144 ERS_INFO(
"Waiting for server thread to terminate ...");
146 ERS_INFO(
" ... finished server thread");
151 unsigned long NRequests = *(
unsigned long*)ret;
152 ERS_DEBUG(
MSG::DEBUG,
"Server thread stopped after handling " << NRequests <<
" requests");
157 int retVal = pthread_mutex_destroy(&m_accessLock);
159 ERS_WARNING(
"Unable to destroy access lock after stopping server: " << fmterror(retVal));
160 return StatusCode::FAILURE;
163 return StatusCode::SUCCESS;
185 ERS_INFO(
"Reached post-condition after received signal " <<
m_receivedSignal );
207 ERS_ERROR(
"Invalid event stream identifier - cannot add event");
208 return StatusCode::FAILURE;
213 ERS_ERROR(
"Reached max. allowed number of streams " <<
NSTREAMMAX <<
" - cannot add event");
214 return StatusCode::FAILURE;
219 ERS_ERROR(
"Event is larger than allowed max. of " <<
NBYTESMAX <<
" bytes - cannot add event");
220 return StatusCode::FAILURE;
228 struct timespec
timeout = { 30, 0 };
230 int retVal = pthread_mutex_timedlock(&m_accessLock, &
timeout);
232 ERS_ERROR(
"Unable to obtain access lock to update event: " << fmterror(retVal));
233 return StatusCode::FAILURE;
253 ERS_ERROR(
"Exception caught while updating event for stream "
256 pthread_mutex_unlock(&m_accessLock);
258 return StatusCode::FAILURE;
262 retVal = pthread_mutex_unlock(&m_accessLock);
264 ERS_ERROR(
"Unable to release access lock after updating event: " << fmterror(retVal));
265 return StatusCode::FAILURE;
270 <<
" from run Nr. " << evtStreamID.
RunNumber());
272 return StatusCode::SUCCESS;
296 int retVal = pthread_mutex_lock(&m_accessLock);
298 ERS_ERROR(
"Unable to obtain access lock to get stream names: " << fmterror(retVal));
314 retVal = pthread_mutex_unlock(&m_accessLock);
316 ERS_ERROR(
"Unable to release access lock after getting stream names: " << fmterror(retVal));
328 int retVal = pthread_mutex_lock(&m_accessLock);
330 ERS_ERROR(
"Unable to obtain access lock to get stream ID: " << fmterror(retVal));
346 retVal = pthread_mutex_unlock(&m_accessLock);
348 ERS_ERROR(
"Unable to release access lock after getting stream ID: " << fmterror(retVal));
360 int retVal = pthread_mutex_lock(&m_accessLock);
362 ERS_ERROR(
"Unable to obtain access lock to get event: " << fmterror(retVal));
363 return std::string(
"");
375 event = std::string((*MapItr).second);
379 retVal = pthread_mutex_unlock(&m_accessLock);
381 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