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

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

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

Classes

struct  Entry
 

Public Member Functions

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

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)
 Small routine to issue exceptions.
 
StatusCode establishConnection (Connection *con)
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 

Protected Attributes

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

Additional Inherited Members

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

Detailed Description

Definition at line 38 of file IODataManager.h.

Member Typedef Documentation

◆ ConnectionMap

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

Definition at line 49 of file IODataManager.h.

◆ CSTR

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

Definition at line 40 of file IODataManager.h.

◆ FidMap

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

Definition at line 50 of file IODataManager.h.

Member Function Documentation

◆ connectDataIO()

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

Definition at line 227 of file IODataManager.cpp.

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

◆ connection()

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

Retrieve known connection.

Definition at line 201 of file IODataManager.cpp.

201 {
202 auto j = m_fidMap.find( dataset );
203 if ( j == m_fidMap.end() ) return nullptr;
204 auto i = m_connectionMap.find( j->second );
205 return ( i != m_connectionMap.end() ) ? i->second->connection : nullptr;
206}

◆ connections()

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

Get connection by owner instance (0=ALL)

Definition at line 87 of file IODataManager.cpp.

87 {
88 Connections conns;
89 transform_copy_if(
90 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}

◆ connectRead()

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.

97 {
98 if ( !establishConnection( con ) ) {
99 return connectDataIO( UNKNOWN, Connection::READ, con->name(), "UNKNOWN", keep_open, con );
100 }
101 std::string dsn = con ? con->name() : std::string( "Unknown" );
102 return error( "Failed to connect to data:" + dsn );
103}
StatusCode establishConnection(Connection *con)

◆ connectWrite()

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

Open data stream in write mode.

Connect data file for reading.

Definition at line 106 of file IODataManager.cpp.

106 {
107 if ( !establishConnection( con ) ) { return connectDataIO( UNKNOWN, mode, con->name(), doctype, true, con ); }
108 std::string dsn = con ? con->name() : std::string( "Unknown" );
109 return error( "Failed to connect to data:" + dsn );
110}

◆ disconnect()

StatusCode IODataManager::disconnect ( Connection * ioDesc)
override

Release data stream.

Definition at line 127 of file IODataManager.cpp.

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

◆ error()

StatusCode IODataManager::error ( CSTR msg)
protected

Small routine to issue exceptions.

Definition at line 80 of file IODataManager.cpp.

80 {
81 MsgStream log( msgSvc(), name() );
82 log << MSG::ERROR << "Error: " << msg << endmsg;
84}
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)

◆ establishConnection()

StatusCode IODataManager::establishConnection ( Connection * con)
protected

Definition at line 208 of file IODataManager.cpp.

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

◆ finalize()

StatusCode IODataManager::finalize ( )
override

IService implementation: finalize the service.

Definition at line 74 of file IODataManager.cpp.

74 {
75 m_catalog = nullptr; // release
76 return Service::finalize();
77}
StatusCode finalize() override
Definition Service.cpp:223

◆ initialize()

StatusCode IODataManager::initialize ( )
override

IService implementation: initialize the service.

IService implementation: Db event selector override.

Definition at line 51 of file IODataManager.cpp.

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

◆ read()

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

Read raw byte buffer from input stream.

Definition at line 113 of file IODataManager.cpp.

113 {
114 return establishConnection( con ).isSuccess() ? con->read( data, len ) : StatusCode::FAILURE;
115}

◆ reconnect()

StatusCode IODataManager::reconnect ( Entry * e)
protected

Definition at line 164 of file IODataManager.cpp.

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

◆ seek()

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

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

Definition at line 123 of file IODataManager.cpp.

123 {
124 return establishConnection( con ).isSuccess() ? con->seek( where, origin ) : -1;
125}

◆ write()

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

Write raw byte buffer to output stream.

Definition at line 118 of file IODataManager.cpp.

118 {
119 return establishConnection( con ).isSuccess() ? con->write( data, len ) : StatusCode::FAILURE;
120}

Member Data Documentation

◆ m_ageLimit

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

Definition at line 57 of file IODataManager.h.

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

◆ m_catalog

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

Reference to file catalog.

Definition at line 65 of file IODataManager.h.

◆ m_catalogSvcName

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

Definition at line 52 of file IODataManager.h.

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

◆ m_connectionMap

ConnectionMap Gaudi::IODataManager::m_connectionMap
protected

Map with I/O descriptors.

Definition at line 63 of file IODataManager.h.

◆ m_disablePFNWarning

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

Definition at line 58 of file IODataManager.h.

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

◆ m_fidMap

FidMap Gaudi::IODataManager::m_fidMap
protected

Map of FID to PFN.

Definition at line 67 of file IODataManager.h.

◆ m_incSvc

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

Definition at line 73 of file IODataManager.h.

◆ m_quarantine

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

Definition at line 55 of file IODataManager.h.

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

◆ m_useGFAL

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

Definition at line 54 of file IODataManager.h.

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

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