The Gaudi Framework  master (9f3f8895)
Loading...
Searching...
No Matches
Gaudi::IODataManager Class Reference

#include </builds/gaudi/Gaudi/GaudiUtils/src/component/IODataManager.h>

Inheritance diagram for Gaudi::IODataManager:
Collaboration diagram for Gaudi::IODataManager:

Classes

struct  Entry

Public Member Functions

StatusCode initialize () override
 IService implementation: initialize the service.
StatusCode finalize () override
 IService implementation: finalize the service.
StatusCode connectRead (bool keep_open, Connection *ioDesc) override
 Open data stream in read mode.
StatusCode connectWrite (Connection *con, IoType mode=Connection::CREATE, CSTR doctype="UNKNOWN") override
 Open data stream in write mode.
StatusCode disconnect (Connection *ioDesc) override
 Release data stream.
Connection * connection (const std::string &dsn) const override
 Retrieve known connection.
Connections connections (const IInterface *owner) const override
 Get connection by owner instance (0=ALL).
StatusCode read (Connection *ioDesc, void *const data, size_t len) override
 Read raw byte buffer from input stream.
StatusCode write (Connection *con, const void *data, int len) override
 Write raw byte buffer to output stream.
long long int seek (Connection *ioDesc, long long int where, int origin) override
 Seek on the file described by ioDesc. Arguments as in ::seek().
Public Member Functions inherited from extends< Service, IIODataManager >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
StatusCode configure () override
StatusCode initialize () override
StatusCode start () override
StatusCode stop () override
StatusCode finalize () override
StatusCode terminate () override
Gaudi::StateMachine::State FSMState () const override
Gaudi::StateMachine::State targetFSMState () const override
StatusCode reinitialize () override
StatusCode restart () override
StatusCode sysInitialize () override
 Initialize Service.
StatusCode sysStart () override
 Initialize Service.
StatusCode sysStop () override
 Initialize Service.
StatusCode sysFinalize () override
 Finalize Service.
StatusCode sysReinitialize () override
 Re-initialize the Service.
StatusCode sysRestart () override
 Re-initialize the Service.
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
template<class T>
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
template<class T>
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
const std::vector< IAlgTool * > & tools () const
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 PropertyHolder ()=default
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
Gaudi::Details::PropertyBase * declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
Gaudi::Details::PropertyBase * property (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
PropertyHolder & operator= (const PropertyHolder &)=delete
Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
MsgStream & msgStream () const
 Return an uninitialized MsgStream.
MsgStream & msgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
MsgStream & always () const
 shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & fatal () const
 shortcut for the method msgStream(MSG::FATAL)
MsgStream & err () const
 shortcut for the method msgStream(MSG::ERROR)
MsgStream & error () const
 shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning () const
 shortcut for the method msgStream(MSG::WARNING)
MsgStream & info () const
 shortcut for the method msgStream(MSG::INFO)
MsgStream & debug () const
 shortcut for the method msgStream(MSG::DEBUG)
MsgStream & verbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & msg () const
 shortcut for the method msgStream(MSG::INFO)
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream

Protected Types

typedef const std::string & CSTR
typedef std::map< std::string, std::unique_ptr< Entry > > ConnectionMap
 Book-keeping entries are owned by the map. The connections they refer to are owned by the clients.
typedef std::map< std::string, std::string > FidMap

Protected Member Functions

StatusCode connectDataIO (int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
StatusCode reconnect (Entry *e)
StatusCode error (CSTR msg)
 Small routine to issue exceptions.
StatusCode establishConnection (Connection *con)
Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 ~Service () override
int outputLevel () const
 get the Service's output level
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const override final
 Set up local caches.
MSG::Level resetMessaging ()
 Reinitialize internal states.
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.

Protected Attributes

Gaudi::Property< std::string > m_catalogSvcName
Gaudi::Property< bool > m_useGFAL { this, "UseGFAL", true, "flag for auto gfal data access" }
Gaudi::Property< bool > m_quarantine
Gaudi::Property< int > m_ageLimit { this, "AgeLimit", 2, "age limit" }
Gaudi::Property< bool > m_disablePFNWarning
ConnectionMap m_connectionMap
 Map with I/O descriptors.
SmartIF< IFileCatalog > m_catalog
 Reference to file catalog.
FidMap m_fidMap
 Map of FID to PFN.
SmartIF< IIncidentSvc > m_incSvc
Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
Gaudi::Property< bool > m_autoRetrieveTools
Gaudi::Property< bool > m_checkToolDeps
SmartIF< IAuditorSvc > m_pAuditorSvc
 Auditor Service.

Additional Inherited Members

Public Types inherited from extends< Service, IIODataManager >
using base_class
 Typedef to this class.
using extend_interfaces_base
 Typedef to the base of this class.
Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory<IService*( const std::string&, ISvcLocator* )>
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...

Detailed Description

Definition at line 39 of file IODataManager.h.

Member Typedef Documentation

◆ ConnectionMap

typedef std::map<std::string, std::unique_ptr<Entry> > Gaudi::IODataManager::ConnectionMap
protected

Book-keeping entries are owned by the map. The connections they refer to are owned by the clients.

Definition at line 51 of file IODataManager.h.

◆ CSTR

typedef const std::string& Gaudi::IODataManager::CSTR
protected

Definition at line 41 of file IODataManager.h.

◆ FidMap

typedef std::map<std::string, std::string> Gaudi::IODataManager::FidMap
protected

Definition at line 52 of file IODataManager.h.

Member Function Documentation

◆ connectDataIO()

StatusCode IODataManager::connectDataIO ( int typ,
IoType rw,
CSTR fn,
CSTR technology,
bool keep,
Connection * con )
protected

Definition at line 221 of file IODataManager.cpp.

222 {
223 MsgStream log( msgSvc(), name() );
224 std::string dsn = dataset;
225 try {
226 StatusCode sc = StatusCode::SUCCESS;
227 if ( ::strncasecmp( dsn.c_str(), "FID:", 4 ) == 0 )
228 dsn = dataset.substr( 4 ), typ = FID;
229 else if ( ::strncasecmp( dsn.c_str(), "LFN:", 4 ) == 0 )
230 dsn = dataset.substr( 4 ), typ = LFN;
231 else if ( ::strncasecmp( dsn.c_str(), "PFN:", 4 ) == 0 )
232 dsn = dataset.substr( 4 ), typ = PFN;
233 else if ( typ == UNKNOWN )
234 return connectDataIO( PFN, rw, dsn, technology, keep_open, connection );
235
236 if ( std::find( s_badFiles.begin(), s_badFiles.end(), dsn ) != s_badFiles.end() ) {
237 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
238 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
239 }
240 if ( typ == FID ) {
241 auto fi = m_connectionMap.find( dsn );
242 if ( fi == m_connectionMap.end() ) {
244 m_catalog->getPFN( dsn, files );
245 if ( files.empty() ) {
246 if ( !m_useGFAL ) {
247 if ( m_quarantine ) s_badFiles.insert( dsn );
248 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
249 error( "connectDataIO> failed to resolve FID:" + dsn ).ignore();
250 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
251 } else if ( dsn.length() == 36 && dsn[8] == '-' && dsn[13] == '-' ) {
252 std::string gfal_name = "gfal:guid:" + dsn;
253 m_fidMap[dsn] = m_fidMap[dataset] = m_fidMap[gfal_name] = dsn;
254 sc = connectDataIO( PFN, rw, gfal_name, technology, keep_open, connection );
255 if ( sc.isSuccess() ) return sc;
256 if ( m_quarantine ) s_badFiles.insert( dsn );
257 }
258 if ( m_quarantine ) s_badFiles.insert( dsn );
259 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
260 error( "connectDataIO> Failed to resolve FID:" + dsn ).ignore();
261 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
262 }
263 // keep track of the current return code before we start iterating over
264 // replicas
265 auto appmgr = serviceLocator()->as<IProperty>();
266 int origReturnCode = Gaudi::getAppReturnCode( appmgr );
267 for ( auto i = files.cbegin(); i != files.cend(); ++i ) {
268 std::string pfn = i->first;
269 if ( i != files.cbegin() ) {
270 log << MSG::WARNING << "Attempt to connect dsn:" << dsn << " with next entry in data federation:" << pfn
271 << "." << endmsg;
272 }
273 sc = connectDataIO( PFN, rw, pfn, technology, keep_open, connection );
274 if ( !sc.isSuccess() ) {
275 if ( m_quarantine ) s_badFiles.insert( pfn );
276 m_incSvc->fireIncident( Incident( pfn, IncidentType::FailInputFile ) );
277 } else {
278 m_fidMap[dsn] = m_fidMap[dataset] = m_fidMap[pfn] = dsn;
279 // we found a working replica, let's reset the return code to the old value
280 Gaudi::setAppReturnCode( appmgr, origReturnCode, true ).ignore();
281 return sc;
282 }
283 }
284 log << MSG::ERROR << "Failed to open dsn:" << dsn << " Federated file could not be resolved from "
285 << files.size() << " entries." << endmsg;
286 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
287 }
288 return StatusCode::FAILURE;
289 }
290 std::string fid;
291 auto j = m_fidMap.find( dsn );
292 if ( j == m_fidMap.end() ) {
294 switch ( typ ) {
295 case LFN:
296 fid = m_catalog->lookupLFN( dsn );
297 if ( fid.empty() ) {
298 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
299 log << MSG::ERROR << "Failed to resolve LFN:" << dsn << " Cannot access this dataset." << endmsg;
300 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
301 }
302 break;
303 case PFN:
304 fid = m_catalog->lookupPFN( dsn );
305 if ( !fid.empty() ) m_catalog->getPFN( fid, files );
306 if ( files.empty() ) {
307 if ( rw == Connection::CREATE || rw == Connection::RECREATE ) {
308 if ( fid.empty() ) fid = m_catalog->createFID();
309 m_catalog->registerPFN( fid, dsn, technology );
310 log << MSG::INFO << "Referring to dataset " << dsn << " by its file ID:" << fid << endmsg;
311 } else {
312 fid = dsn;
313 }
314 }
315 break;
316 }
317 } else {
318 fid = j->second;
319 }
320 if ( typ == PFN ) {
321 // Open PFN
322 auto fi = m_connectionMap.find( fid );
323 if ( fi == m_connectionMap.end() ) {
324 connection->setFID( fid );
325 connection->setPFN( dsn );
326 auto e = std::make_unique<Entry>( technology, keep_open, rw, connection );
327 // Here we open the file!
328 if ( !reconnect( e.get() ).isSuccess() ) {
329 if ( m_quarantine ) s_badFiles.insert( dsn );
330 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
331 error( "connectDataIO> Cannot connect to database: PFN=" + dsn + " FID=" + fid ).ignore();
332 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
333 }
334 fid = connection->fid();
335 if ( m_connectionMap.contains( fid ) ) {
336 // The FID is the one stored in the file itself, so a copy or replica of a file that is
337 // already connected through another PFN reports the same FID. Track this connection by
338 // its PFN: keying it by the FID would drop its entry and alias its dataset name to the
339 // other connection, which a later disconnect() of this dataset would then tear down.
340 log << MSG::DEBUG << "Dataset " << dsn << " has the same FID " << fid
341 << " as an already connected dataset, tracking it by its PFN" << endmsg;
342 fid = dsn;
343 }
344 m_fidMap[dataset] = m_fidMap[dsn] = m_fidMap[fid] = fid;
345 if ( !( rw == Connection::CREATE || rw == Connection::RECREATE ) ) {
346 if ( !m_disablePFNWarning && strcasecmp( dsn.c_str(), connection->fid().c_str() ) == 0 ) {
347 log << MSG::ERROR << "Referring to existing dataset " << dsn << " by its physical name." << endmsg;
348 log << "You may not be able to navigate back to the input file"
349 << " -- processing continues" << endmsg;
350 }
351 }
352 m_connectionMap.emplace( fid, std::move( e ) );
353 return StatusCode::SUCCESS;
354 }
355 // Here we open the file!
356 if ( !reconnect( fi->second.get() ).isSuccess() ) {
357 if ( m_quarantine ) s_badFiles.insert( dsn );
358 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
359 error( "connectDataIO> Cannot connect to database: PFN=" + dsn + " FID=" + fid ).ignore();
360 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
361 }
362 return StatusCode::SUCCESS;
363 }
364 sc = connectDataIO( FID, rw, fid, technology, keep_open, connection );
365 if ( !sc.isSuccess() && m_quarantine ) {
366 s_badFiles.insert( fid );
367 } else if ( typ == LFN ) {
368 m_fidMap[dataset] = fid;
369 }
370 return sc;
371 } catch ( std::exception& e ) {
372 error( std::string( "connectDataIO> Caught exception:" ) + e.what() ).ignore();
373 } catch ( ... ) { error( std::string( "connectDataIO> Caught unknown exception" ) ).ignore(); }
374 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
375 error( "connectDataIO> The dataset " + dsn + " cannot be opened." ).ignore();
376 s_badFiles.insert( dsn );
377 return StatusCode( IDataConnection::BAD_DATA_CONNECTION );
378}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
std::vector< NamedItem > Files
ConnectionMap m_connectionMap
Map with I/O descriptors.
FidMap m_fidMap
Map of FID to PFN.
Gaudi::Property< bool > m_quarantine
SmartIF< IFileCatalog > m_catalog
Reference to file catalog.
Gaudi::Property< bool > m_useGFAL
Connection * connection(const std::string &dsn) const override
Retrieve known connection.
StatusCode reconnect(Entry *e)
Gaudi::Property< bool > m_disablePFNWarning
SmartIF< IIncidentSvc > m_incSvc
StatusCode connectDataIO(int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
SmartIF< IFace > as()
Definition ISvcLocator.h:64
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition Service.cpp:336
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333
void ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:128
bool isSuccess() const
Definition StatusCode.h:302
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
int getAppReturnCode(const SmartIF< IProperty > &appmgr)
Get the application (current) return code.
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
@ WARNING
Definition IMessageSvc.h:22
@ DEBUG
Definition IMessageSvc.h:22
@ ERROR
Definition IMessageSvc.h:22
@ INFO
Definition IMessageSvc.h:22

◆ connection()

IIODataManager::Connection * IODataManager::connection ( const std::string & dsn) const
override

Retrieve known connection.

Definition at line 195 of file IODataManager.cpp.

195 {
196 auto j = m_fidMap.find( dataset );
197 if ( j == m_fidMap.end() ) return nullptr;
198 auto i = m_connectionMap.find( j->second );
199 return ( i != m_connectionMap.end() ) ? i->second->connection : nullptr;
200}

◆ connections()

IODataManager::Connections IODataManager::connections ( const IInterface * owner) const
override

Get connection by owner instance (0=ALL).

Definition at line 80 of file IODataManager.cpp.

80 {
81 Connections conns;
82 transform_copy_if(
83 std::begin( m_connectionMap ), std::end( m_connectionMap ), std::back_inserter( conns ),
84 []( ConnectionMap::const_reference i ) { return i.second->connection; },
85 [&]( const IDataConnection* c ) { return !owner || c->owner() == owner; } );
86 return conns;
87}

◆ connectRead()

StatusCode IODataManager::connectRead ( bool keep_open,
Connection * ioDesc )
override

Open data stream in read mode.

Connect data file for writing.

Definition at line 90 of file IODataManager.cpp.

90 {
91 if ( !establishConnection( con ) ) {
92 return connectDataIO( UNKNOWN, Connection::READ, con->name(), "UNKNOWN", keep_open, con );
93 }
94 std::string dsn = con ? con->name() : std::string( "Unknown" );
95 return error( "Failed to connect to data:" + dsn );
96}
StatusCode establishConnection(Connection *con)

◆ connectWrite()

StatusCode IODataManager::connectWrite ( Connection * con,
IoType mode = Connection::CREATE,
CSTR doctype = "UNKNOWN" )
override

Open data stream in write mode.

Connect data file for reading.

Definition at line 99 of file IODataManager.cpp.

99 {
100 if ( !establishConnection( con ) ) { return connectDataIO( UNKNOWN, mode, con->name(), doctype, true, con ); }
101 std::string dsn = con ? con->name() : std::string( "Unknown" );
102 return error( "Failed to connect to data:" + dsn );
103}

◆ disconnect()

StatusCode IODataManager::disconnect ( Connection * ioDesc)
override

Release data stream.

Definition at line 120 of file IODataManager.cpp.

120 {
121 if ( con ) {
122 std::string dataset = con->name();
123 std::string dsn = dataset;
124 StatusCode sc = con->disconnect();
125 if ( ::strncasecmp( dsn.c_str(), "FID:", 4 ) == 0 )
126 dsn = dataset.substr( 4 );
127 else if ( ::strncasecmp( dsn.c_str(), "LFN:", 4 ) == 0 )
128 dsn = dataset.substr( 4 );
129 else if ( ::strncasecmp( dsn.c_str(), "PFN:", 4 ) == 0 )
130 dsn = dataset.substr( 4 );
131
132 auto j = m_fidMap.find( dataset );
133 if ( j != m_fidMap.end() ) {
134 std::string fid = j->second;
135 std::string gfal_name = "gfal:guid:" + fid;
136 auto i = m_connectionMap.find( fid );
137 m_fidMap.erase( j );
138 if ( ( j = m_fidMap.find( fid ) ) != m_fidMap.end() ) m_fidMap.erase( j );
139 if ( ( j = m_fidMap.find( gfal_name ) ) != m_fidMap.end() ) m_fidMap.erase( j );
140 if ( i != m_connectionMap.end() && i->second ) {
141 IDataConnection* c = i->second->connection;
142 if ( ( j = m_fidMap.find( c->pfn() ) ) != m_fidMap.end() ) m_fidMap.erase( j );
143 if ( c->isConnected() ) {
144 MsgStream log( msgSvc(), name() );
145 c->disconnect().ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
146 log << MSG::INFO << "Disconnect from dataset " << dsn << " [" << fid << "]" << endmsg;
147 }
148 m_connectionMap.erase( i );
149 }
150 }
151 return sc;
152 }
153 return StatusCode::FAILURE;
154}

◆ error()

StatusCode IODataManager::error ( CSTR msg)
protected

Small routine to issue exceptions.

Definition at line 73 of file IODataManager.cpp.

73 {
74 MsgStream log( msgSvc(), name() );
75 log << MSG::ERROR << "Error: " << msg << endmsg;
77}
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)

◆ establishConnection()

StatusCode IODataManager::establishConnection ( Connection * con)
protected

Definition at line 202 of file IODataManager.cpp.

202 {
203 if ( !con ) return error( "Severe logic bug: No connection object avalible." );
204
205 if ( con->isConnected() ) {
206 con->resetAge();
207 return StatusCode::SUCCESS;
208 }
209 auto i = m_connectionMap.find( con->name() );
210 if ( i != m_connectionMap.end() ) {
211 Connection* c = i->second->connection;
212 if ( c != con ) {
213 m_incSvc->fireIncident( Incident( con->name(), IncidentType::FailInputFile ) );
214 return error( "Severe logic bug: Twice identical connection object for DSN:" + con->name() );
215 }
216 if ( reconnect( i->second.get() ).isSuccess() ) return StatusCode::SUCCESS;
217 }
218 return StatusCode::FAILURE;
219}

◆ finalize()

StatusCode IODataManager::finalize ( )
override

IService implementation: finalize the service.

Definition at line 67 of file IODataManager.cpp.

67 {
68 m_catalog = nullptr; // release
69 return Service::finalize();
70}
StatusCode finalize() override
Definition Service.cpp:223

◆ initialize()

StatusCode IODataManager::initialize ( )
override

IService implementation: initialize the service.

IService implementation: Db event selector override.

Definition at line 44 of file IODataManager.cpp.

44 {
45 // Initialize base class
46 StatusCode status = Service::initialize();
47 MsgStream log( msgSvc(), name() );
48 if ( !status.isSuccess() ) {
49 log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
50 return status;
51 }
52 // Retrieve conversion service handling event iteration
54 if ( !m_catalog ) {
55 log << MSG::ERROR << "Unable to localize interface IFileCatalog from service:" << m_catalogSvcName << endmsg;
57 }
58 m_incSvc = serviceLocator()->service( "IncidentSvc" );
59 if ( !m_incSvc ) {
60 log << MSG::ERROR << "Error initializing IncidentSvc Service!" << endmsg;
61 return status;
62 }
63 return status;
64}
Gaudi::Property< std::string > m_catalogSvcName
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
StatusCode initialize() override
Definition Service.cpp:118

◆ read()

StatusCode IODataManager::read ( Connection * ioDesc,
void *const data,
size_t len )
override

Read raw byte buffer from input stream.

Definition at line 106 of file IODataManager.cpp.

106 {
107 return establishConnection( con ).isSuccess() ? con->read( data, len ) : StatusCode::FAILURE;
108}

◆ reconnect()

StatusCode IODataManager::reconnect ( Entry * e)
protected

Definition at line 156 of file IODataManager.cpp.

156 {
157 StatusCode sc = StatusCode::FAILURE;
158 if ( e && e->connection ) {
159 switch ( e->ioType ) {
160 case Connection::READ:
161 sc = e->connection->connectRead();
162 break;
163 case Connection::UPDATE:
164 case Connection::CREATE:
165 case Connection::RECREATE:
166 sc = e->connection->connectWrite( e->ioType );
167 break;
168 default:
169 return StatusCode::FAILURE;
170 }
171 if ( sc.isSuccess() && e->ioType == Connection::READ ) {
172 std::vector<Entry*> to_retire;
173 e->connection->resetAge();
174 transform_copy_if(
175 std::begin( m_connectionMap ), std::end( m_connectionMap ), std::back_inserter( to_retire ),
176 []( ConnectionMap::const_reference i ) { return i.second.get(); },
177 [&]( Entry* i ) {
178 IDataConnection* c = i->connection;
179 return e->connection != c && c->isConnected() && !i->keepOpen && c->ageFile() > m_ageLimit;
180 } );
181 if ( !to_retire.empty() ) {
182 MsgStream log( msgSvc(), name() );
183 std::for_each( std::begin( to_retire ), std::end( to_retire ), [&]( Entry* j ) {
184 IDataConnection* c = j->connection;
185 c->disconnect().ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
186 log << MSG::INFO << "Disconnect from dataset " << c->pfn() << " [" << c->fid() << "]" << endmsg;
187 } );
188 }
189 }
190 }
191 return sc;
192}
Gaudi::Property< int > m_ageLimit

◆ seek()

long long int IODataManager::seek ( Connection * ioDesc,
long long int where,
int origin )
override

Seek on the file described by ioDesc. Arguments as in ::seek().

Definition at line 116 of file IODataManager.cpp.

116 {
117 return establishConnection( con ).isSuccess() ? con->seek( where, origin ) : -1;
118}

◆ write()

StatusCode IODataManager::write ( Connection * con,
const void * data,
int len )
override

Write raw byte buffer to output stream.

Definition at line 111 of file IODataManager.cpp.

111 {
112 return establishConnection( con ).isSuccess() ? con->write( data, len ) : StatusCode::FAILURE;
113}

Member Data Documentation

◆ m_ageLimit

Gaudi::Property<int> Gaudi::IODataManager::m_ageLimit { this, "AgeLimit", 2, "age limit" }
protected

Definition at line 59 of file IODataManager.h.

59{ this, "AgeLimit", 2, "age limit" };

◆ m_catalog

SmartIF<IFileCatalog> Gaudi::IODataManager::m_catalog
protected

Reference to file catalog.

Definition at line 67 of file IODataManager.h.

◆ m_catalogSvcName

Gaudi::Property<std::string> Gaudi::IODataManager::m_catalogSvcName
protected
Initial value:
{ this, "CatalogType", "Gaudi::MultiFileCatalog/FileCatalog",
"name of the file catalog service" }

Definition at line 54 of file IODataManager.h.

54 { this, "CatalogType", "Gaudi::MultiFileCatalog/FileCatalog",
55 "name of the file catalog service" };

◆ m_connectionMap

ConnectionMap Gaudi::IODataManager::m_connectionMap
protected

Map with I/O descriptors.

Definition at line 65 of file IODataManager.h.

◆ m_disablePFNWarning

Gaudi::Property<bool> Gaudi::IODataManager::m_disablePFNWarning
protected
Initial value:
{
this, "DisablePFNWarning", false,
"if set to True, we will not report when a file is opened by its physical name" }

Definition at line 60 of file IODataManager.h.

60 {
61 this, "DisablePFNWarning", false,
62 "if set to True, we will not report when a file is opened by its physical name" };

◆ m_fidMap

FidMap Gaudi::IODataManager::m_fidMap
protected

Map of FID to PFN.

Definition at line 69 of file IODataManager.h.

◆ m_incSvc

SmartIF<IIncidentSvc> Gaudi::IODataManager::m_incSvc
protected

Definition at line 75 of file IODataManager.h.

◆ m_quarantine

Gaudi::Property<bool> Gaudi::IODataManager::m_quarantine
protected
Initial value:
{ this, "QuarantineFiles", true,
"if unaccessible files should be quarantines in job" }

Definition at line 57 of file IODataManager.h.

57 { this, "QuarantineFiles", true,
58 "if unaccessible files should be quarantines in job" };

◆ m_useGFAL

Gaudi::Property<bool> Gaudi::IODataManager::m_useGFAL { this, "UseGFAL", true, "flag for auto gfal data access" }
protected

Definition at line 56 of file IODataManager.h.

56{ this, "UseGFAL", true, "flag for auto gfal data access" };

The documentation for this class was generated from the following files: