| The Gaudi Framework v29r0 (ff2e7097)

- 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...
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 output level 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 > >
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 238 of file IODataManager.cpp.

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

211 {
212 auto j = m_fidMap.find( dataset );
213 if ( j == m_fidMap.end() ) return nullptr;
214 auto i = m_connectionMap.find( j->second );
215 return ( i != m_connectionMap.end() ) ? i->second->connection : nullptr;
216 }
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 87 of file IODataManager.cpp.

88 {
89 Connections conns;
90 transform_copy_if( std::begin( m_connectionMap ), std::end( m_connectionMap ), std::back_inserter( conns ),
91 []( ConnectionMap::const_reference i ) { return i.second->connection; },
92 [&]( const IDataConnection* c ) { return !owner || c->owner() == owner; } );
93 return conns;
94 }
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 97 of file IODataManager.cpp.

98 {
99 if ( !establishConnection( con ) ) {
100 return connectDataIO( UNKNOWN, Connection::READ, con->name(), "UNKNOWN", keep_open, con );
101 }
102 std::string dsn = con ? con->name() : std::string( "Unknown" );
103 return error( "Failed to connect to data:" + dsn, false );
104 }
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:218
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
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:238
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 107 of file IODataManager.cpp.

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

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

Release data stream.

Definition at line 134 of file IODataManager.cpp.

135 {
136 if ( con ) {
137 std::string dataset = con->name();
138 std::string dsn = dataset;
139 StatusCode sc = con->disconnect();
140 if (::strncasecmp( dsn.c_str(), "FID:", 4 ) == 0 )
141 dsn = dataset.substr( 4 );
142 else if (::strncasecmp( dsn.c_str(), "LFN:", 4 ) == 0 )
143 dsn = dataset.substr( 4 );
144 else if (::strncasecmp( dsn.c_str(), "PFN:", 4 ) == 0 )
145 dsn = dataset.substr( 4 );
146
147 auto j = m_fidMap.find( dataset );
148 if ( j != m_fidMap.end() ) {
149 std::string fid = j->second;
150 std::string gfal_name = "gfal:guid:" + fid;
151 auto i = m_connectionMap.find( fid );
152 m_fidMap.erase( j );
153 if ( ( j = m_fidMap.find( fid ) ) != m_fidMap.end() ) m_fidMap.erase( j );
154 if ( ( j = m_fidMap.find( gfal_name ) ) != m_fidMap.end() ) m_fidMap.erase( j );
155 if ( i != m_connectionMap.end() && i->second ) {
156 IDataConnection* c = i->second->connection;
157 if ( ( j = m_fidMap.find( c->pfn() ) ) != m_fidMap.end() ) m_fidMap.erase( j );
158 if ( c->isConnected() ) {
159 MsgStream log( msgSvc(), name() );
160 c->disconnect();
161 log << MSG::INFO << "Disconnect from dataset " << dsn << " [" << fid << "]" << endmsg;
162 }
163 delete i->second;
164 m_connectionMap.erase( i );
165 }
166 }
167 return sc;
168 }
169 return S_ERROR;
170 }
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)
S_ERROR
Definition: IODataManager.cpp:42
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:28
std::map::erase
T erase(T...args)
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)
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:76
std::string::substr
T substr(T...args)
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 78 of file IODataManager.cpp.

79 {
80 MsgStream log( msgSvc(), name() );
81 log << MSG::ERROR << "Error: " << msg << endmsg;
82 if ( rethrow ) System::breakExecution();
83 return S_ERROR;
84 }
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
S_ERROR
Definition: IODataManager.cpp:42
System::breakExecution
GAUDI_API long breakExecution()
Break the execution of the application and invoke the debugger.
Definition: Debugger.cpp:48
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:76
MSG::ERROR
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

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

Definition at line 218 of file IODataManager.cpp.

219 {
220 if ( !con ) return error( "Severe logic bug: No connection object avalible.", true );
221
222 if ( con->isConnected() ) {
223 con->resetAge();
224 return S_OK;
225 }
226 auto i = m_connectionMap.find( con->name() );
227 if ( i != m_connectionMap.end() ) {
228 Connection* c = i->second->connection;
229 if ( c != con ) {
230 m_incSvc->fireIncident( Incident( con->name(), IncidentType::FailInputFile ) );
231 return error( "Severe logic bug: Twice identical connection object for DSN:" + con->name(), true );
232 }
233 if ( reconnect( i->second ).isSuccess() ) return S_OK;
234 }
235 return S_ERROR;
236 }
gaudirun.c
c
Definition: gaudirun.py:407
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
Gaudi::IODataManager::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition: IODataManager.h:68
S_OK
Definition: IODataManager.cpp:42
std::map::end
T end(T...args)
S_ERROR
Definition: IODataManager.cpp:42
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
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
Gaudi::IODataManager::reconnect
StatusCode reconnect(Entry *e)
Definition: IODataManager.cpp:172

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

IService implementation: finalize the service.

Definition at line 71 of file IODataManager.cpp.

72 {
73 m_catalog = nullptr; // release
74 return Service::finalize();
75 }
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 47 of file IODataManager.cpp.

48 {
49 // Initialize base class
50 StatusCode status = Service::initialize();
51 MsgStream log( msgSvc(), name() );
52 if ( !status.isSuccess() ) {
53 log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
54 return status;
55 }
56 // Retrieve conversion service handling event iteration
57 m_catalog = serviceLocator()->service( m_catalogSvcName );
58 if ( !m_catalog ) {
59 log << MSG::ERROR << "Unable to localize interface IFileCatalog from service:" << m_catalogSvcName << endmsg;
60 return StatusCode::FAILURE;
61 }
62 m_incSvc = serviceLocator()->service( "IncidentSvc" );
63 if ( !m_incSvc ) {
64 log << MSG::ERROR << "Error initializing IncidentSvc Service!" << endmsg;
65 return status;
66 }
67 return status;
68 }
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::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
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:28
Gaudi::IODataManager::m_catalog
SmartIF< IFileCatalog > m_catalog
Reference to file catalog.
Definition: IODataManager.h:60
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:76
MSG::ERROR
Definition: IMessageSvc.h:16
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 117 of file IODataManager.cpp.

118 {
119 return establishConnection( con ).isSuccess() ? con->read( data, len ) : S_ERROR;
120 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:218
S_ERROR
Definition: IODataManager.cpp:42

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

Definition at line 172 of file IODataManager.cpp.

173 {
174 StatusCode sc = S_ERROR;
175 if ( e && e->connection ) {
176 switch ( e->ioType ) {
177 case Connection::READ:
178 sc = e->connection->connectRead();
179 break;
180 case Connection::UPDATE:
181 case Connection::CREATE:
182 case Connection::RECREATE:
183 sc = e->connection->connectWrite( e->ioType );
184 break;
185 default:
186 return S_ERROR;
187 }
188 if ( sc.isSuccess() && e->ioType == Connection::READ ) {
189 std::vector<Entry*> to_retire;
190 e->connection->resetAge();
191 transform_copy_if( std::begin( m_connectionMap ), std::end( m_connectionMap ), std::back_inserter( to_retire ),
192 select2nd, [&]( Entry* i ) {
193 IDataConnection* c = i->connection;
194 return e->connection != c && c->isConnected() && !i->keepOpen && c->ageFile() > m_ageLimit;
195 } );
196 if ( !to_retire.empty() ) {
197 MsgStream log( msgSvc(), name() );
198 std::for_each( std::begin( to_retire ), std::end( to_retire ), [&]( Entry* j ) {
199 IDataConnection* c = j->connection;
200 c->disconnect();
201 log << MSG::INFO << "Disconnect from dataset " << c->pfn() << " [" << c->fid() << "]" << endmsg;
202 } );
203 }
204 }
205 }
206 return sc;
207 }
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:75
std::end
T end(T...args)
S_ERROR
Definition: IODataManager.cpp:42
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:28
Io::READ
Definition: IFileMgr.h:27
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
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:76
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 129 of file IODataManager.cpp.

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

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

Write raw byte buffer to output stream.

Definition at line 123 of file IODataManager.cpp.

124 {
125 return establishConnection( con ).isSuccess() ? con->write( data, len ) : S_ERROR;
126 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:218
S_ERROR
Definition: IODataManager.cpp:42

## 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