| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Gaudi::IODataManager Class Reference

`#include <src/component/IODataManager.h>`

Inheritance diagram for Gaudi::IODataManager:
[legend]
Collaboration diagram for Gaudi::IODataManager:
[legend]

## Classes
struct | Entry

## Public Member Functions
| ~IODataManager () override=default
| Standard destructor. More...
StatusCode | initialize () override
| IService implementation: initialize the service. More...
StatusCode | finalize () override
| IService implementation: finalize the service. More...
StatusCode | connectRead (bool keep_open, Connection *ioDesc) override
| Open data stream in read mode. More...
StatusCode | connectWrite (Connection *con, IoType mode=Connection::CREATE, CSTR doctype="UNKNOWN") override
| Open data stream in write mode. More...
StatusCode | disconnect (Connection *ioDesc) override
| Release data stream. More...
Connection * | connection (const std::string &dsn) const override
| Retrieve known connection. More...
Connections | connections (const IInterface *owner) const override
| Get connection by owner instance (0=ALL) More...
StatusCode | read (Connection *ioDesc, void *const data, size_t len) override
| Read raw byte buffer from input stream. More...
StatusCode | write (Connection *con, const void *data, int len) override
| Write raw byte buffer to output stream. More...
long long int | seek (Connection *ioDesc, long long int where, int origin) override
| Seek on the file described by ioDesc. Arguments as in ::seek() More...
Public Member Functions inherited from extends< Service, IIODataManager >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
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. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Protected Types
typedef const std::string & | CSTR
typedef std::map< std::string, Entry * > | ConnectionMap
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, bool rethrow)
| Small routine to issue exceptions. More...
StatusCode | establishConnection (Connection *con)
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | setUpMessaging ()
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## 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. More...
SmartIF< IFileCatalog > | m_catalog
| Reference to file catalog. More...
FidMap | m_fidMap
| Map of FID to PFN. More...
SmartIF< IIncidentSvc > | m_incSvc
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
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()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

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

## Detailed Description

Definition at line 30 of file IODataManager.h.

## Member Typedef Documentation

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

Definition at line 44 of file IODataManager.h.

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

Definition at line 33 of file IODataManager.h.

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

Definition at line 45 of file IODataManager.h.

## Constructor & Destructor Documentation

Gaudi::IODataManager::~IODataManager | ( |  | ) |
| override default

Standard destructor.

## Member Function Documentation

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

Definition at line 236 of file IODataManager.cpp.

238 {
239 MsgStream log( msgSvc(), name() );
240 std::string dsn = dataset;
241 try {
242 StatusCode sc( StatusCode::SUCCESS, true );
243 if (::strncasecmp( dsn.c_str(), "FID:", 4 ) == 0 )
244 dsn = dataset.substr( 4 ), typ = FID;
245 else if (::strncasecmp( dsn.c_str(), "LFN:", 4 ) == 0 )
246 dsn = dataset.substr( 4 ), typ = LFN;
247 else if (::strncasecmp( dsn.c_str(), "PFN:", 4 ) == 0 )
248 dsn = dataset.substr( 4 ), typ = PFN;
249 else if ( typ == UNKNOWN )
250 return connectDataIO( PFN, rw, dsn, technology, keep_open, connection );
251
252 if ( std::find( s_badFiles.begin(), s_badFiles.end(), dsn ) != s_badFiles.end() ) {
253 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
254 return IDataConnection::BAD_DATA_CONNECTION;
255 }
256 if ( typ == FID ) {
257 auto fi = m_connectionMap.find( dsn );
258 if ( fi == m_connectionMap.end() ) {
259 IFileCatalog::Files files;
260 m_catalog->getPFN( dsn, files );
261 if ( files.empty() ) {
262 if ( !m_useGFAL ) {
263 if ( m_quarantine ) s_badFiles.insert( dsn );
264 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
265 error( "connectDataIO> failed to resolve FID:" + dsn, false ).ignore();
266 return IDataConnection::BAD_DATA_CONNECTION;
267 } else if ( dsn.length() == 36 && dsn[8] == '-' && dsn[13] == '-' ) {
268 std::string gfal_name = "gfal:guid:" + dsn;
269 m_fidMap[dsn] = m_fidMap[dataset] = m_fidMap[gfal_name] = dsn;
270 sc = connectDataIO( PFN, rw, gfal_name, technology, keep_open, connection );
271 if ( sc.isSuccess() ) return sc;
272 if ( m_quarantine ) s_badFiles.insert( dsn );
273 }
274 if ( m_quarantine ) s_badFiles.insert( dsn );
275 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
276 error( "connectDataIO> Failed to resolve FID:" + dsn, false ).ignore();
277 return IDataConnection::BAD_DATA_CONNECTION;
278 }
279 // keep track of the current return code before we start iterating over
280 // replicas
281 auto appmgr = serviceLocator()->as<IProperty>();
282 int origReturnCode = Gaudi::getAppReturnCode( appmgr );
283 for ( auto i = files.cbegin(); i != files.cend(); ++i ) {
284 std::string pfn = i->first;
285 if ( i != files.cbegin() ) {
286 log << MSG::WARNING << "Attempt to connect dsn:" << dsn << " with next entry in data federation:" << pfn
287 << "." << endmsg;
288 }
289 sc = connectDataIO( PFN, rw, pfn, technology, keep_open, connection );
290 if ( !sc.isSuccess() ) {
291 if ( m_quarantine ) s_badFiles.insert( pfn );
292 m_incSvc->fireIncident( Incident( pfn, IncidentType::FailInputFile ) );
293 } else {
294 m_fidMap[dsn] = m_fidMap[dataset] = m_fidMap[pfn] = dsn;
295 // we found a working replica, let's reset the return code to the old value
296 Gaudi::setAppReturnCode( appmgr, origReturnCode, true ).ignore();
297 return sc;
298 }
299 }
300 log << MSG::ERROR << "Failed to open dsn:" << dsn << " Federated file could not be resolved from "
301 << files.size() << " entries." << endmsg;
302 return IDataConnection::BAD_DATA_CONNECTION;
303 }
304 return StatusCode::FAILURE;
305 }
306 std::string fid;
307 auto j = m_fidMap.find( dsn );
308 if ( j == m_fidMap.end() ) {
309 IFileCatalog::Files files;
310 switch ( typ ) {
311 case LFN:
312 fid = m_catalog->lookupLFN( dsn );
313 if ( fid.empty() ) {
314 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
315 log << MSG::ERROR << "Failed to resolve LFN:" << dsn << " Cannot access this dataset." << endmsg;
316 return IDataConnection::BAD_DATA_CONNECTION;
317 }
318 break;
319 case PFN:
320 fid = m_catalog->lookupPFN( dsn );
321 if ( !fid.empty() ) m_catalog->getPFN( fid, files );
322 if ( files.empty() ) {
323 if ( rw == Connection::CREATE || rw == Connection::RECREATE ) {
324 if ( fid.empty() ) fid = m_catalog->createFID();
325 m_catalog->registerPFN( fid, dsn, technology );
326 log << MSG::INFO << "Referring to dataset " << dsn << " by its file ID:" << fid << endmsg;
327 } else {
328 fid = dsn;
329 }
330 }
331 break;
332 }
333 } else {
334 fid = j->second;
335 }
336 if ( typ == PFN ) {
337 // Open PFN
338 auto fi = m_connectionMap.find( fid );
339 if ( fi == m_connectionMap.end() ) {
340 connection->setFID( fid );
341 connection->setPFN( dsn );
342 auto e = new Entry( technology, keep_open, rw, connection );
343 // Here we open the file!
344 if ( !reconnect( e ).isSuccess() ) {
345 delete e;
346 if ( m_quarantine ) s_badFiles.insert( dsn );
347 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
348 error( "connectDataIO> Cannot connect to database: PFN=" + dsn + " FID=" + fid, false ).ignore();
349 return IDataConnection::BAD_DATA_CONNECTION;
350 }
351 fid = connection->fid();
352 m_fidMap[dataset] = m_fidMap[dsn] = m_fidMap[fid] = fid;
353 if ( !( rw == Connection::CREATE || rw == Connection::RECREATE ) ) {
354 if ( !m_disablePFNWarning && strcasecmp( dsn.c_str(), fid.c_str() ) == 0 ) {
355 log << MSG::ERROR << "Referring to existing dataset " << dsn << " by its physical name." << endmsg;
356 log << "You may not be able to navigate back to the input file"
357 << " -- processing continues" << endmsg;
358 }
359 }
360 m_connectionMap.emplace( fid, e ); // note: only if we disconnect does e get deleted??
361 return StatusCode::SUCCESS;
362 }
363 // Here we open the file!
364 if ( !reconnect( ( *fi ).second ).isSuccess() ) {
365 if ( m_quarantine ) s_badFiles.insert( dsn );
366 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
367 error( "connectDataIO> Cannot connect to database: PFN=" + dsn + " FID=" + fid, false ).ignore();
368 return IDataConnection::BAD_DATA_CONNECTION;
369 }
370 return StatusCode::SUCCESS;
371 }
372 sc = connectDataIO( FID, rw, fid, technology, keep_open, connection );
373 if ( !sc.isSuccess() && m_quarantine ) {
374 s_badFiles.insert( fid );
375 } else if ( typ == LFN ) {
376 m_fidMap[dataset] = fid;
377 }
378 return sc;
379 } catch ( std::exception& e ) {
380 error( std::string( "connectDataIO> Caught exception:" ) + e.what(), false ).ignore();
381 } catch ( ... ) {
382 error( std::string( "connectDataIO> Caught unknown exception" ), false ).ignore();
383 }
384 m_incSvc->fireIncident( Incident( dsn, IncidentType::FailInputFile ) );
385 error( "connectDataIO> The dataset " + dsn + " cannot be opened.", false ).ignore();
386 s_badFiles.insert( dsn );
387 return IDataConnection::BAD_DATA_CONNECTION;
388 }
Gaudi::getAppReturnCode
int getAppReturnCode(const SmartIF< IProperty > &appmgr)
Get the application (current) return code.
Definition: AppReturnCode.h:72
StatusCode::SUCCESS
Definition: StatusCode.h:29
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Gaudi::IDataConnection::BAD_DATA_CONNECTION
Definition: IIODataManager.h:43
std::vector::empty
T empty(T...args)
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
Gaudi::IODataManager::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition: IODataManager.h:68
std::set::end
T end(T...args)
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
std::string
STL class.
Gaudi::IODataManager::m_quarantine
Gaudi::Property< bool > m_quarantine
Definition: IODataManager.h:50
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Gaudi::IODataManager::m_catalog
SmartIF< IFileCatalog > m_catalog
Reference to file catalog.
Definition: IODataManager.h:60
Gaudi::IODataManager::m_useGFAL
Gaudi::Property< bool > m_useGFAL
Definition: IODataManager.h:49
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:75
std::exception
STL class.
Gaudi::setAppReturnCode
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:51
std::set::insert
T insert(T...args)
std::find
T find(T...args)
std::string::length
T length(T...args)
std::vector
STL class.
std::set::begin
T begin(T...args)
Io::CREATE
Definition: IFileMgr.h:31
Gaudi::IODataManager::m_connectionMap
ConnectionMap m_connectionMap
Map with I/O descriptors.
Definition: IODataManager.h:58
std::string::c_str
T c_str(T...args)
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
Gaudi::IODataManager::m_disablePFNWarning
Gaudi::Property< bool > m_disablePFNWarning
Definition: IODataManager.h:53
Gaudi::IODataManager::connection
Connection * connection(const std::string &dsn) const override
Retrieve known connection.
Definition: IODataManager.cpp:208
std::map::emplace
T emplace(T...args)
Gaudi::IODataManager::connectDataIO
StatusCode connectDataIO(int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
Definition: IODataManager.cpp:236
MSG::ERROR
Definition: IMessageSvc.h:16
std::string::substr
T substr(T...args)
MSG::WARNING
Definition: IMessageSvc.h:16
StatusCode::FAILURE
Definition: StatusCode.h:29
Io::UNKNOWN
Definition: IFileMgr.h:157
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:84
MSG::INFO
Definition: IMessageSvc.h:16
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
Gaudi::IODataManager::reconnect
StatusCode reconnect(Entry *e)
Definition: IODataManager.cpp:170
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13
Gaudi::IODataManager::m_fidMap
FidMap m_fidMap
Map of FID to PFN.
Definition: IODataManager.h:62

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

Retrieve known connection.

Definition at line 208 of file IODataManager.cpp.

209 {
210 auto j = m_fidMap.find( dataset );
211 if ( j == m_fidMap.end() ) return nullptr;
212 auto i = m_connectionMap.find( j->second );
213 return ( i != m_connectionMap.end() ) ? i->second->connection : nullptr;
214 }
std::map::end
T end(T...args)
std::map::find
T find(T...args)
Gaudi::IODataManager::m_connectionMap
ConnectionMap m_connectionMap
Map with I/O descriptors.
Definition: IODataManager.h:58
Gaudi::IODataManager::Entry::connection
IDataConnection * connection
Definition: IODataManager.h:37
Gaudi::IODataManager::m_fidMap
FidMap m_fidMap
Map of FID to PFN.
Definition: IODataManager.h:62

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

Get connection by owner instance (0=ALL)

Definition at line 85 of file IODataManager.cpp.

86 {
87 Connections conns;
88 transform_copy_if( std::begin( m_connectionMap ), std::end( m_connectionMap ), std::back_inserter( conns ),
89 []( ConnectionMap::const_reference i ) { return i.second->connection; },
90 [&]( const IDataConnection* c ) { return !owner || c->owner() == owner; } );
91 return conns;
92 }
gaudirun.c
c
Definition: gaudirun.py:407
std::end
T end(T...args)
Gaudi::IDataConnection
ABC describing basic data connection.
Definition: IIODataManager.h:25
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
Gaudi::IODataManager::m_connectionMap
ConnectionMap m_connectionMap
Map with I/O descriptors.
Definition: IODataManager.h:58

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

Open data stream in read mode.

Connect data file for writing.

Definition at line 95 of file IODataManager.cpp.

96 {
97 if ( !establishConnection( con ) ) {
98 return connectDataIO( UNKNOWN, Connection::READ, con->name(), "UNKNOWN", keep_open, con );
99 }
100 std::string dsn = con ? con->name() : std::string( "Unknown" );
101 return error( "Failed to connect to data:" + dsn, false );
102 }
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:216
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
Io::READ
Definition: IFileMgr.h:27
Gaudi::IODataManager::connectDataIO
StatusCode connectDataIO(int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
Definition: IODataManager.cpp:236
Io::UNKNOWN
Definition: IFileMgr.h:157

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 105 of file IODataManager.cpp.

106 {
107 if ( !establishConnection( con ) ) {
108 return connectDataIO( UNKNOWN, mode, con->name(), doctype, true, con );
109 }
110 std::string dsn = con ? con->name() : std::string( "Unknown" );
111 return error( "Failed to connect to data:" + dsn, false );
112 }
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:216
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
Gaudi::IODataManager::connectDataIO
StatusCode connectDataIO(int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
Definition: IODataManager.cpp:236
Io::UNKNOWN
Definition: IFileMgr.h:157

StatusCode IODataManager::disconnect | ( | Connection * | ioDesc | ) |
| override

Release data stream.

Definition at line 132 of file IODataManager.cpp.

133 {
134 if ( con ) {
135 std::string dataset = con->name();
136 std::string dsn = dataset;
137 StatusCode sc = con->disconnect();
138 if (::strncasecmp( dsn.c_str(), "FID:", 4 ) == 0 )
139 dsn = dataset.substr( 4 );
140 else if (::strncasecmp( dsn.c_str(), "LFN:", 4 ) == 0 )
141 dsn = dataset.substr( 4 );
142 else if (::strncasecmp( dsn.c_str(), "PFN:", 4 ) == 0 )
143 dsn = dataset.substr( 4 );
144
145 auto j = m_fidMap.find( dataset );
146 if ( j != m_fidMap.end() ) {
147 std::string fid = j->second;
148 std::string gfal_name = "gfal:guid:" + fid;
149 auto i = m_connectionMap.find( fid );
150 m_fidMap.erase( j );
151 if ( ( j = m_fidMap.find( fid ) ) != m_fidMap.end() ) m_fidMap.erase( j );
152 if ( ( j = m_fidMap.find( gfal_name ) ) != m_fidMap.end() ) m_fidMap.erase( j );
153 if ( i != m_connectionMap.end() && i->second ) {
154 IDataConnection* c = i->second->connection;
155 if ( ( j = m_fidMap.find( c->pfn() ) ) != m_fidMap.end() ) m_fidMap.erase( j );
156 if ( c->isConnected() ) {
157 MsgStream log( msgSvc(), name() );
158 c->disconnect();
159 log << MSG::INFO << "Disconnect from dataset " << dsn << " [" << fid << "]" << endmsg;
160 }
161 delete i->second;
162 m_connectionMap.erase( i );
163 }
164 }
165 return sc;
166 }
167 return StatusCode::FAILURE;
168 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Gaudi::IDataConnection::disconnect
virtual StatusCode disconnect()=0
Release data stream.
gaudirun.c
c
Definition: gaudirun.py:407
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
std::map::end
T end(T...args)
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:57
std::string
STL class.
Gaudi::IDataConnection::isConnected
virtual bool isConnected() const =0
Check if connected to data source.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::map::erase
T erase(T...args)
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:75
std::map::find
T find(T...args)
Gaudi::IDataConnection
ABC describing basic data connection.
Definition: IIODataManager.h:25
Gaudi::IODataManager::m_connectionMap
ConnectionMap m_connectionMap
Map with I/O descriptors.
Definition: IODataManager.h:58
std::string::c_str
T c_str(T...args)
std::string::substr
T substr(T...args)
StatusCode::FAILURE
Definition: StatusCode.h:29
MSG::INFO
Definition: IMessageSvc.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13
Gaudi::IODataManager::m_fidMap
FidMap m_fidMap
Map of FID to PFN.
Definition: IODataManager.h:62

StatusCode IODataManager::error | ( | CSTR | msg,
|  | bool | rethrow
| ) |  |
| protected

Small routine to issue exceptions.

Definition at line 76 of file IODataManager.cpp.

77 {
78 MsgStream log( msgSvc(), name() );
79 log << MSG::ERROR << "Error: " << msg << endmsg;
80 if ( rethrow ) System::breakExecution();
81 return StatusCode::FAILURE;
82 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
System::breakExecution
GAUDI_API long breakExecution()
Break the execution of the application and invoke the debugger.
Definition: Debugger.cpp:48
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:75
MSG::ERROR
Definition: IMessageSvc.h:16
StatusCode::FAILURE
Definition: StatusCode.h:29
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

StatusCode IODataManager::establishConnection | ( | Connection * | con | ) |
| protected

Definition at line 216 of file IODataManager.cpp.

217 {
218 if ( !con ) return error( "Severe logic bug: No connection object avalible.", true );
219
220 if ( con->isConnected() ) {
221 con->resetAge();
222 return StatusCode::SUCCESS;
223 }
224 auto i = m_connectionMap.find( con->name() );
225 if ( i != m_connectionMap.end() ) {
226 Connection* c = i->second->connection;
227 if ( c != con ) {
228 m_incSvc->fireIncident( Incident( con->name(), IncidentType::FailInputFile ) );
229 return error( "Severe logic bug: Twice identical connection object for DSN:" + con->name(), true );
230 }
231 if ( reconnect( i->second ).isSuccess() ) return StatusCode::SUCCESS;
232 }
233 return StatusCode::FAILURE;
234 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
gaudirun.c
c
Definition: gaudirun.py:407
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
Gaudi::IODataManager::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition: IODataManager.h:68
std::map::end
T end(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
std::map::find
T find(T...args)
Gaudi::IODataManager::m_connectionMap
ConnectionMap m_connectionMap
Map with I/O descriptors.
Definition: IODataManager.h:58
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
StatusCode::FAILURE
Definition: StatusCode.h:29
Gaudi::IODataManager::reconnect
StatusCode reconnect(Entry *e)
Definition: IODataManager.cpp:170

StatusCode IODataManager::finalize | ( |  | ) |
| override

IService implementation: finalize the service.

Definition at line 69 of file IODataManager.cpp.

70 {
71 m_catalog = nullptr; // release
72 return Service::finalize();
73 }
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
Gaudi::IODataManager::m_catalog
SmartIF< IFileCatalog > m_catalog
Reference to file catalog.
Definition: IODataManager.h:60

StatusCode IODataManager::initialize | ( |  | ) |
| override

IService implementation: initialize the service.

IService implementation: Db event selector override.

Definition at line 45 of file IODataManager.cpp.

46 {
47 // Initialize base class
48 StatusCode status = Service::initialize();
49 MsgStream log( msgSvc(), name() );
50 if ( !status.isSuccess() ) {
51 log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
52 return status;
53 }
54 // Retrieve conversion service handling event iteration
55 m_catalog = serviceLocator()->service( m_catalogSvcName );
56 if ( !m_catalog ) {
57 log << MSG::ERROR << "Unable to localize interface IFileCatalog from service:" << m_catalogSvcName << endmsg;
58 return StatusCode::FAILURE;
59 }
60 m_incSvc = serviceLocator()->service( "IncidentSvc" );
61 if ( !m_incSvc ) {
62 log << MSG::ERROR << "Error initializing IncidentSvc Service!" << endmsg;
63 return status;
64 }
65 return status;
66 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
Gaudi::IODataManager::m_catalogSvcName
Gaudi::Property< std::string > m_catalogSvcName
Definition: IODataManager.h:47
Gaudi::IODataManager::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition: IODataManager.h:68
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Gaudi::IODataManager::m_catalog
SmartIF< IFileCatalog > m_catalog
Reference to file catalog.
Definition: IODataManager.h:60
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:75
MSG::ERROR
Definition: IMessageSvc.h:16
StatusCode::FAILURE
Definition: StatusCode.h:29
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

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

Read raw byte buffer from input stream.

Definition at line 115 of file IODataManager.cpp.

116 {
117 return establishConnection( con ).isSuccess() ? con->read( data, len ) : StatusCode::FAILURE;
118 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:216
StatusCode::FAILURE
Definition: StatusCode.h:29

StatusCode IODataManager::reconnect | ( | Entry * | e | ) |
| protected

Definition at line 170 of file IODataManager.cpp.

171 {
172 StatusCode sc = StatusCode::FAILURE;
173 if ( e && e->connection ) {
174 switch ( e->ioType ) {
175 case Connection::READ:
176 sc = e->connection->connectRead();
177 break;
178 case Connection::UPDATE:
179 case Connection::CREATE:
180 case Connection::RECREATE:
181 sc = e->connection->connectWrite( e->ioType );
182 break;
183 default:
184 return StatusCode::FAILURE;
185 }
186 if ( sc.isSuccess() && e->ioType == Connection::READ ) {
187 std::vector<Entry*> to_retire;
188 e->connection->resetAge();
189 transform_copy_if( std::begin( m_connectionMap ), std::end( m_connectionMap ), std::back_inserter( to_retire ),
190 select2nd, [&]( Entry* i ) {
191 IDataConnection* c = i->connection;
192 return e->connection != c && c->isConnected() && !i->keepOpen && c->ageFile() > m_ageLimit;
193 } );
194 if ( !to_retire.empty() ) {
195 MsgStream log( msgSvc(), name() );
196 std::for_each( std::begin( to_retire ), std::end( to_retire ), [&]( Entry* j ) {
197 IDataConnection* c = j->connection;
198 c->disconnect();
199 log << MSG::INFO << "Disconnect from dataset " << c->pfn() << " [" << c->fid() << "]" << endmsg;
200 } );
201 }
202 }
203 }
204 return sc;
205 }
Gaudi::IODataManager::m_ageLimit
Gaudi::Property< int > m_ageLimit
Definition: IODataManager.h:52
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Gaudi::IDataConnection::disconnect
virtual StatusCode disconnect()=0
Release data stream.
std::vector::empty
T empty(T...args)
gaudirun.c
c
Definition: gaudirun.py:407
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
Gaudi::IDataConnection::fid
const std::string & fid() const
Access file id.
Definition: IIODataManager.h:55
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
std::end
T end(T...args)
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:57
Gaudi::IDataConnection::isConnected
virtual bool isConnected() const =0
Check if connected to data source.
Gaudi::IDataConnection::ageFile
int ageFile()
Increase age of I/O source.
Definition: IIODataManager.h:61
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Io::READ
Definition: IFileMgr.h:27
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:75
std::vector
STL class.
Gaudi::IDataConnection
ABC describing basic data connection.
Definition: IIODataManager.h:25
std::begin
T begin(T...args)
Io::CREATE
Definition: IFileMgr.h:31
std::back_inserter
T back_inserter(T...args)
Gaudi::IODataManager::m_connectionMap
ConnectionMap m_connectionMap
Map with I/O descriptors.
Definition: IODataManager.h:58
StatusCode::FAILURE
Definition: StatusCode.h:29
MSG::INFO
Definition: IMessageSvc.h:16
std::for_each
T for_each(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

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 127 of file IODataManager.cpp.

128 {
129 return establishConnection( con ).isSuccess() ? con->seek( where, origin ) : -1;
130 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:216

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

Write raw byte buffer to output stream.

Definition at line 121 of file IODataManager.cpp.

122 {
123 return establishConnection( con ).isSuccess() ? con->write( data, len ) : StatusCode::FAILURE;
124 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:216
StatusCode::FAILURE
Definition: StatusCode.h:29

## Member Data Documentation

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

Definition at line 52 of file IODataManager.h.

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

Reference to file catalog.

Definition at line 60 of file IODataManager.h.

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 47 of file IODataManager.h.

ConnectionMap Gaudi::IODataManager::m_connectionMap
| protected

Map with I/O descriptors.

Definition at line 58 of file IODataManager.h.

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 53 of file IODataManager.h.

FidMap Gaudi::IODataManager::m_fidMap
| protected

Map of FID to PFN.

Definition at line 62 of file IODataManager.h.

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

Definition at line 68 of file IODataManager.h.

Gaudi::Property<bool> Gaudi::IODataManager::m_quarantine
| protected

Initial value:
{this, "QuarantineFiles", true,
"if unaccessible files should be quarantines in job"}

Definition at line 50 of file IODataManager.h.

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

Definition at line 49 of file IODataManager.h.

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

- GaudiUtils/src/component/IODataManager.h
- GaudiUtils/src/component/IODataManager.cpp