| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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 | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public 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 236 of file IODataManager.cpp.

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

84 {
85 Connections conns;
86 transform_copy_if( std::begin(m_connectionMap), std::end(m_connectionMap),
87 std::back_inserter(conns),
88 [](ConnectionMap::const_reference i ) { return i.second->connection; },
89 [&](const IDataConnection* c) { return !owner || c->owner() == owner; } );
90 return conns;
91 }
gaudirun.c
c
Definition: gaudirun.py:391
std::end
T end(T...args)
Gaudi::IDataConnection
ABC describing basic data connection.
Definition: IIODataManager.h:24
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 94 of file IODataManager.cpp.

94 {
95 if ( !establishConnection(con) ) {
96 return connectDataIO(UNKNOWN,Connection::READ,con->name(),"UNKNOWN",keep_open,con);
97 }
98 std::string dsn = con ? con->name() : std::string("Unknown");
99 return error("Failed to connect to data:"+dsn,false);
100 }
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:117
Io::READ
Definition: IFileMgr.h:26
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:151

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

103 {
104 if ( !establishConnection(con) ) {
105 return connectDataIO(UNKNOWN,mode,con->name(),doctype,true,con);
106 }
107 std::string dsn = con ? con->name() : std::string("Unknown");
108 return error("Failed to connect to data:"+dsn,false);
109 }
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:117
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:151

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

Release data stream.

Definition at line 126 of file IODataManager.cpp.

126 {
127 if ( con ) {
128 std::string dataset = con->name();
129 std::string dsn = dataset;
130 StatusCode sc = con->disconnect();
131 if ( ::strncasecmp(dsn.c_str(),"FID:",4)==0 )
132 dsn = dataset.substr(4);
133 else if ( ::strncasecmp(dsn.c_str(),"LFN:",4)==0 )
134 dsn = dataset.substr(4);
135 else if ( ::strncasecmp(dsn.c_str(),"PFN:",4)==0 )
136 dsn = dataset.substr(4);
137
138 auto j = m_fidMap.find(dataset);
139 if ( j != m_fidMap.end() ) {
140 std::string fid = j->second;
141 std::string gfal_name = "gfal:guid:" + fid;
142 auto i=m_connectionMap.find(fid);
143 m_fidMap.erase(j);
144 if ( (j=m_fidMap.find(fid)) != m_fidMap.end() )
145 m_fidMap.erase(j);
146 if ( (j=m_fidMap.find(gfal_name)) != m_fidMap.end() )
147 m_fidMap.erase(j);
148 if ( i != m_connectionMap.end() && i->second ) {
149 IDataConnection* c = i->second->connection;
150 if ( (j=m_fidMap.find(c->pfn())) != m_fidMap.end() )
151 m_fidMap.erase(j);
152 if ( c->isConnected() ) {
153 MsgStream log(msgSvc(),name());
154 c->disconnect();
155 log << MSG::INFO << "Disconnect from dataset " << dsn
156 << " [" << fid << "]" << endmsg;
157 }
158 delete i->second;
159 m_connectionMap.erase(i);
160 }
161 }
162 return sc;
163 }
164 return S_ERROR;
165 }
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:391
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:40
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:54
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)
std::map::find
T find(T...args)
Gaudi::IDataConnection
ABC describing basic data connection.
Definition: IIODataManager.h:24
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:70
std::string::substr
T substr(T...args)
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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.

76 {
77 MsgStream log(msgSvc(),name());
78 log << MSG::ERROR << "Error: " << msg << endmsg;
79 if ( rethrow ) System::breakExecution();
80 return S_ERROR;
81 }
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:40
System::breakExecution
GAUDI_API long breakExecution()
Break the execution of the application and invoke the debugger.
Definition: Debugger.cpp:47
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:70
MSG::ERROR
Definition: IMessageSvc.h:21
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi.Configuration.log
log
Definition: Configuration.py:13

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

Definition at line 216 of file IODataManager.cpp.

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

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

IService implementation: finalize the service.

Definition at line 70 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.

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

112 {
113 return establishConnection(con).isSuccess() ? con->read(data,len) : S_ERROR;
114 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:216
S_ERROR
Definition: IODataManager.cpp:40

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

Definition at line 167 of file IODataManager.cpp.

167 {
168 StatusCode sc = S_ERROR;
169 if ( e && e->connection ) {
170 switch(e->ioType) {
171 case Connection::READ:
172 sc = e->connection->connectRead();
173 break;
174 case Connection::UPDATE:
175 case Connection::CREATE:
176 case Connection::RECREATE:
177 sc = e->connection->connectWrite(e->ioType);
178 break;
179 default:
180 return S_ERROR;
181 }
182 if ( sc.isSuccess() && e->ioType == Connection::READ ) {
183 std::vector<Entry*> to_retire;
184 e->connection->resetAge();
185 transform_copy_if( std::begin(m_connectionMap), std::end(m_connectionMap),
186 std::back_inserter(to_retire),
187 select2nd,
188 [&](Entry* i) {
189 IDataConnection* c = i->connection;
190 return e->connection!=c && c->isConnected() &&
191 !i->keepOpen && c->ageFile() > m_ageLimit;
192 });
193 if ( !to_retire.empty() ) {
194 MsgStream log(msgSvc(),name());
195 std::for_each( std::begin(to_retire), std::end(to_retire),
196 [&](Entry* j) {
197 IDataConnection* c = j->connection;
198 c->disconnect();
199 log << MSG::INFO << "Disconnect from dataset " << c->pfn()
200 << " [" << c->fid() << "]" << endmsg;
201 } );
202 }
203 }
204 }
205 return sc;
206 }
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:391
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:52
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
std::end
T end(T...args)
S_ERROR
Definition: IODataManager.cpp:40
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:54
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:58
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Io::READ
Definition: IFileMgr.h:26
std::vector
STL class.
Gaudi::IDataConnection
ABC describing basic data connection.
Definition: IIODataManager.h:24
std::begin
T begin(T...args)
Io::CREATE
Definition: IFileMgr.h:30
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:70
MSG::INFO
Definition: IMessageSvc.h:19
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:244
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 122 of file IODataManager.cpp.

122 {
123 return establishConnection(con).isSuccess() ? con->seek(where,origin) : -1;
124 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
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 117 of file IODataManager.cpp.

117 {
118 return establishConnection(con).isSuccess() ? con->write(data,len) : S_ERROR;
119 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
Gaudi::IODataManager::establishConnection
StatusCode establishConnection(Connection *con)
Definition: IODataManager.cpp:216
S_ERROR
Definition: IODataManager.cpp:40

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