17#include "GaudiKernel/FileIncident.h"
18#include "GaudiKernel/IIncidentSvc.h"
19#include "GaudiKernel/StatusCode.h"
28 long eventNumber,
const void* source,
29 size_t nbytes,
unsigned int status) {
37 base_class(name, pSvcLocator) {
42 return StatusCode::FAILURE;
47 return StatusCode::FAILURE;
54 m_incidentSvc->removeListener(
this, IncidentType::BeginProcessing);
55 m_incidentSvc->removeListener(
this, IncidentType::EndProcessing);
57 return StatusCode::SUCCESS;
62 return StatusCode::SUCCESS;
69 return StatusCode::SUCCESS;
77 delete m_endIter; m_endIter =
nullptr;
78 return ::AthService::finalize();
97 while (
sc.isRecoverable()) {
104 void* tokenStrPtr =
nullptr;
105 unsigned int status = 0;
107 std::unique_ptr<const char[]> tokenStr{
static_cast<const char*
>(tokenStrPtr)};
108 if (
sc.isRecoverable()) {
112 return StatusCode::FAILURE;
114 if (
sc.isFailure()) {
115 ATH_MSG_FATAL(
"Cannot get NextEvent from AthenaSharedMemoryTool");
116 return StatusCode::FAILURE;
118 if (!eventStore()->clearStore().isSuccess()) {
121 std::unique_ptr<AthenaAttributeList> athAttrList = std::make_unique<AthenaAttributeList>();
122 athAttrList->extend(
"eventRef",
"string");
123 (*athAttrList)[
"eventRef"].data<std::string>() = tokenStr.get();
125 if (!wh.record(std::move(athAttrList)).isSuccess()) {
127 return StatusCode::FAILURE;
132 if (guid != m_guid && m_processMetadata.value()) {
134 "FID:" + guid.toString(), guid.toString(),
138 return StatusCode::SUCCESS;
145 for (
int i = 0; i < jump; i++) {
148 return StatusCode::SUCCESS;
150 return StatusCode::FAILURE;
157 return StatusCode::FAILURE;
160 if (ds->makeServer(num - 1).isFailure()) {
161 ATH_MSG_ERROR(
"Failed to switch AthenaPoolCnvSvc to output DataStreaming server");
163 return StatusCode::SUCCESS;
165 if (ds->makeServer(num + 1).isFailure()) {
166 ATH_MSG_ERROR(
"Failed to switch AthenaPoolCnvSvc to input DataStreaming server");
167 return StatusCode::FAILURE;
170 return StatusCode::SUCCESS;
172 m_processMetadata =
false;
182 return StatusCode::FAILURE;
184 if (ds->makeClient(num + 1).isFailure()) {
185 ATH_MSG_ERROR(
"Failed to switch AthenaPoolCnvSvc to DataStreaming client");
186 return StatusCode::FAILURE;
189 return StatusCode::SUCCESS;
192 std::string dummyStr;
201 return StatusCode::FAILURE;
205 while (
sc.isRecoverable()) {
210 if (
sc.isFailure()) {
211 if (ds->makeClient(0).isFailure()) {
212 return StatusCode::FAILURE;
215 while (
sc.isRecoverable() ||
sc.isFailure()) {
220 if (ds->makeClient(1).isFailure()) {
221 return StatusCode::FAILURE;
226 return StatusCode::FAILURE;
234 return StatusCode::FAILURE;
237 ATH_MSG_ERROR(
"No AthenaSharedMemoryTool configured for readEvent()");
238 return StatusCode::FAILURE;
241 std::unique_ptr<IEvtSelector::Context> ctxt = std::make_unique<EventContextAthenaPool>(
this);
242 for (
int i = 0; i < maxevt || maxevt == -1; ++i) {
243 if (!
next(*ctxt).isSuccess()) {
244 if (m_evtCount == -1) {
245 ATH_MSG_VERBOSE(
"Called read Event and read last event from input: " << i);
248 ATH_MSG_ERROR(
"Cannot read Event " << m_evtCount - 1 <<
" into AthenaSharedMemoryTool");
249 return StatusCode::FAILURE;
258 while (ds->readData().isSuccess()) {
259 ATH_MSG_VERBOSE(
"Called last readData, while marking last event in readEvent()");
263 if (!
sc.isSuccess()) {
264 ATH_MSG_ERROR(
"Cannot put last Event marker to AthenaSharedMemoryTool");
265 return StatusCode::FAILURE;
268 while (
sc.isSuccess() ||
sc.isRecoverable()) {
271 ATH_MSG_DEBUG(
"Failed last readData -> Clients are stopped, after marking last event in readEvent()");
273 return StatusCode::SUCCESS;
282 return StatusCode::FAILURE;
284 std::string token = m_headerIterator->eventRef().toString();
287 m_evtCount - 1, token.c_str(),
288 token.length() + 1, 0)).isRecoverable() ) {
289 while (ds->readData().isSuccess()) {
290 ATH_MSG_VERBOSE(
"Called last readData, while putting next event in next()");
294 if (!
sc.isSuccess()) {
295 ATH_MSG_ERROR(
"Cannot put Event " << m_evtCount - 1 <<
" to AthenaSharedMemoryTool");
296 return StatusCode::FAILURE;
299 return StatusCode::SUCCESS;
304 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_FATAL(x,...)
This file contains the class definition for the EventContextAthenaPool class.
This file contains the class definition for the EventSelectorAthenaPoolSharedIO class.
This file contains the class definition for the Token class (migrated from POOL).
#define ATLAS_THREAD_SAFE
virtual StatusCode finalize() override
virtual StatusCode next(IEvtSelector::Context &ctxt) const override
Gaudi::Property< int > m_makeStreamingToolClient
Make this instance a Streaming Client during first iteration automatically.
virtual StatusCode start() override
virtual StatusCode makeServer(int num) override
Make this a server.
virtual StatusCode makeClient(int num) override
Make this a client.
virtual StatusCode stop() override
EventSelectorAthenaPoolSharedIO(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
virtual StatusCode initialize() override
Required of all Gaudi Services.
virtual StatusCode share(int evtnum) override
Request to share a given event number.
virtual StatusCode readEvent(int maxevt) override
Read the next maxevt events.
virtual StatusCode io_reinit() override
Callback method to reinitialize the internal state of the component for I/O purposes (e....
virtual StatusCode recordAttributeList() const override
Record AttributeList in StoreGate.
ToolHandle< IAthenaIPCTool > m_eventStreamingTool
virtual StatusCode start() override
virtual StatusCode initialize() override
Required of all Gaudi Services.
virtual StatusCode io_reinit() override
Callback method to reinitialize the internal state of the component for I/O purposes (e....
virtual StatusCode stop() override
virtual StatusCode next(IEvtSelector::Context &ctxt) const override
virtual StatusCode finalize() override
virtual StatusCode recordAttributeList() const override
Record AttributeList in StoreGate.
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
static const Guid & null() noexcept
NULL-Guid: static class method.
Abstract interface for sharing data.
static const std::string & storeName(const StoreID::type &s)
This class provides a token that identifies in a unique way objects on the persistent storage.
Token & fromString(const std::string_view from)
Build from the string representation of a token.
const Guid & dbID() const
Access database identifier.
::StatusCode StatusCode
StatusCode definition for legacy code.