// -------------------- -*- C++ -*- -------------------- /* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ // OffloadSvc.h // Header file for class OffloadSvc // Author: Sami Kama // ----------------------------------------------------- #ifndef OFFLOADSERVICE_OFFLOADSVC_H #define OFFLOADSERVICE_OFFLOADSVC_H // STL includes #include #include #include #include #include #include #include #include // FrameWork includes #include "AthenaBaseComps/AthService.h" #include "GaudiKernel/IIncidentListener.h" #include "GaudiKernel/ServiceHandle.h" // OffloadManagerSvc includes #include "OffloadSvc/IOffloadSvc.h" #include "yampl/SocketFactory.h" #include "StoreGate/StoreGateSvc.h" // Forward declaration template class SvcFactory; namespace APE{ class BufferContainer; } class IIncidentSvc; class OffloadSvc : virtual public IOffloadSvc, public AthService,public virtual IIncidentListener{ protected: friend class SvcFactory; public: /// Constructor with parameters: OffloadSvc( const std::string& name, ISvcLocator* pSvcLocator ); /// Destructor: virtual ~OffloadSvc(); /// Gaudi Service Implementation //@{ StatusCode initialize(); StatusCode finalize(); virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ); //@} /////////////////////////////////////////////////////////////////// // Const methods: /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // Non-const methods: /////////////////////////////////////////////////////////////////// static const InterfaceID& interfaceID(); virtual StatusCode sendData(std::unique_ptr &buff, int &token,bool requiresResponse=true); virtual StatusCode receiveData(std::unique_ptr &buff, int token, int timeOut=-1); virtual void handle(const Incident &); /////////////////////////////////////////////////////////////////// // Private methods: /////////////////////////////////////////////////////////////////// private: /// Default constructor: OffloadSvc(); bool openCommChannel(bool postFork=false); bool closeCommChannel(bool preFork=false); /////////////////////////////////////////////////////////////////// // Private data: /////////////////////////////////////////////////////////////////// private: /// The quote of the day //StringProperty m_qotd; struct TransferStats{ std::chrono::system_clock::time_point sendStart; std::chrono::system_clock::time_point sendEnd; size_t uploadSize; size_t downloadSize; }; std::string m_connType; std::string m_commChannelSend; std::string m_commChannelRecv; uint m_forkDelay; bool m_useUID; bool m_isConnected; bool m_dumpOffloadRequests; bool m_dumpReplies; std::map m_stats; std::shared_ptr m_sendSock,m_recvSock; std::queue m_tokens; int m_maxTokens; std::condition_variable m_tCond; std::mutex m_cMutex; uint64_t m_currEvt; int m_requestNumber; ServiceHandle m_evtStore; yampl::ISocketFactory *m_fact; }; /// I/O operators ////////////////////// /////////////////////////////////////////////////////////////////// /// Inline methods: /////////////////////////////////////////////////////////////////// inline const InterfaceID& OffloadSvc::interfaceID() { return IOffloadSvc::interfaceID(); } #endif