4#ifndef ATHREMOTEEXECCORE_REMOTEEXECHIVEEVENTLOOPMGR_H
5#define ATHREMOTEEXECCORE_REMOTEEXECHIVEEVENTLOOPMGR_H
42#include <condition_variable>
53#include "Gaudi/Property.h"
66 virtual StatusCode
finalize()
override;
70 virtual StatusCode
nextEvent(
int maxevt)
override;
73 virtual StatusCode
stopRun()
override;
88 std::unique_ptr<Server::Job>& job);
94 using Clock = std::chrono::steady_clock;
100 std::unique_ptr<Server::Job>
job;
112 EventContext*
ctx =
nullptr;
113 Clock::time_point
at;
138 std::string& diagnostics)
const;
142 std::unique_ptr<Server::Job> job);
159 const std::unique_ptr<Server::Job>& job,
161 const std::string& diagnostics);
167 std::string
replyKeyFor(
const std::string& sequence)
const;
175 this,
"Sequences", {},
"Names of the algorithm sequences (fragments) this server offers"};
176 Gaudi::Property<std::map<std::string, std::vector<std::string>>>
m_inputKeys{
177 this,
"Decoders", {},
"Per sequence, The boundaries the client must supply."};
178 Gaudi::Property<std::map<std::string, std::vector<std::string>>>
m_outputKeys{
179 this,
"Encoders", {},
"Per sequence, the boundaries returned to the client."};
181 this,
"ReplyKeys", {},
"Per sequence, the key its pack algorithm stages the reply under."};
183 this,
"RequestKey",
"RemoteExecRequest",
"StoreGate key that the request is recorded under."};
186 this,
"Address",
"0.0.0.0",
"Interface the server binds to"};
188 this,
"Port", 0,
"TCP port to bind. 0 lets the OS choose."};
190 this,
"PortFile",
"",
"If set, the bound port is written to this file once the server is up. Lets a test client discover a port chosen by the OS"};
192 this,
"MaxMessageBytes", 256 * 1024 * 1024,
"Largest request or reply the server will accept."};
194 this,
"QueueLimit", 128,
"Maximum number of queued requests before clients are told the server is overloaded"};
197 this,
"RequestTimeout", 0.0,
"Seconds before an in-flight request is answered with TIMEOUT. 0 disables the timeout."};
199 this,
"PollInterval", 5,
"Milliseconds between scheduler polls."};
202 this,
"ReportTiming",
true,
""};
The default ATLAS batch event loop manager.
Plain C++ interfaces of RPC wire.
Minimal RPC server; transport part of RemoteExecHiveEventLoopMgr.
virtual ~RemoteExecHiveEventLoopMgr() override
Take
Where the next request came from.
@ Stopped
no more requests will ever come
std::chrono::steady_clock Clock
StatusCode eventFinished(const EventContext &ctx) override
Process an event's result and decide whether the driving loop may continue.
std::mutex m_messageMutex
std::string replyKeyFor(const std::string &sequence) const
The reply key of sequence, or an empty string if it declares none.
Gaudi::Property< int > m_port
std::condition_variable m_pending
loop waits here
void inputLoop()
Loop and wait for incoming job.
std::map< size_t, InFlight > m_inFlight
keyed by whiteboard slot
StatusCode complete(const Finished &finished)
Read the result of one finished event and release its slot.
Gaudi::Property< std::string > m_address
std::condition_variable m_incomingRoom
input thread waits here
void respond(InFlight &entry, ExecuteReply reply)
Reply to the request.
void respondDirect(const ExecuteRequest &request, const std::unique_ptr< Server::Job > &job, AthRemoteExec::Status status, const std::string &diagnostics)
Reply to the request that never got assigned to slot.
std::mutex m_pendingMutex
Gaudi::Property< std::map< std::string, std::vector< std::string > > > m_inputKeys
StatusCode dispatch(ExecuteRequest request, std::unique_ptr< Server::Job > job)
Give a request a slot and push it to the scheduler.
Gaudi::Property< int > m_maxMessageBytes
void expireDeadlines()
Reply to all request that passed their deadline.
Gaudi::Property< bool > m_reportTiming
virtual Take takeRequest(ExecuteRequest &request, std::unique_ptr< Server::Job > &job)
Take the next request from the incoming event queue.
void drainPending()
Answer to anything that the loop did not manage to finish.
virtual StatusCode startServing()
Create and start the server.
RemoteExecHiveEventLoopMgr(const std::string &name, ISvcLocator *svcLoc)
void startHelpers()
Starts input/output loops.
std::unique_ptr< Server > m_server
void stopHelpers()
Stops input/output loops.
Gaudi::Property< std::map< std::string, std::vector< std::string > > > m_outputKeys
std::condition_variable m_inFlightCv
output thread waits here
virtual StatusCode initialize() override
implementation of IAppMgrUI::initalize
std::deque< std::unique_ptr< Server::Job > > m_incoming
Gaudi::Property< std::string > m_requestKey
ExecuteReply buildReply(const EventContext &ctx, const InFlight &entry)
Turn a finished event into the reply for its request.
AthRemoteExec::Status validate(const ExecuteRequest &request, std::string &diagnostics) const
Reject requests that cannot possibly run, before a slot is spent on them.
virtual StatusCode stopRun() override
Ask the loop to stop accepting work and drain what is in flight.
std::vector< Finished > takeFinished()
Take whatever the output thread has collected from finished event queue.
Gaudi::Property< double > m_requestTimeout
std::thread m_inputThread
void outputLoop()
Loop and wait for finished job.
bool clearStoreOnEndAlgorithms() const override
Batch jobs clear in the algorithm context; external drivers can retain the store until eventFinished(...
Gaudi::Property< size_t > m_queueLimit
Gaudi::Property< std::vector< std::string > > m_sequences
virtual StatusCode finalize() override
implementation of IAppMgrUI::finalize
std::thread m_outputThread
Gaudi::Property< std::string > m_portFile
void serverMessage(Server::Level level, const std::string &text)
Thread-safe log sink handed to the RPC server.
Gaudi::Property< unsigned int > m_pollInterval
std::deque< Finished > m_finishedEvents
size_t m_awaitingCompletion
Gaudi::Property< std::map< std::string, std::string > > m_replyKeys
std::atomic< bool > m_stopRequested
virtual StatusCode nextEvent(int maxevt) override
Serve requests.
std::string failedAlgorithms(const EventContext &ctx)
Names of the algorithms that failed in ctx. For the reply diagnostics.
Level
Severity levels, matching MSG::Level so the funnel can forward them.
virtual const std::string & name() const override
AthenaHiveEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
The Athena Transient Store API.
A finished event, from the scheduler's point of view.
A request that has been given a slot and handed to the scheduler.
bool answered
Set once the client has been answered.
std::unique_ptr< Server::Job > job
The RPC job whose promise must be fulfilled.
Clock::time_point deadline