The Gaudi Framework  v30r3 (a5ef0a68)
Gaudi::IODataManager Class Reference

#include <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. 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::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () 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
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
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. More...
 
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. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (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::PropertyBasegetProperty (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
 
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) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Protected Types

typedef const std::stringCSTR
 
typedef std::map< std::string, Entry * > ConnectionMap
 
typedef std::map< std::string, std::stringFidMap
 

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::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

Gaudi::Property< std::stringm_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< IFileCatalogm_catalog
 Reference to file catalog. More...
 
FidMap m_fidMap
 Map of FID to PFN. More...
 
SmartIF< IIncidentSvcm_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< IAuditorSvcm_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
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- 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.

Member Function Documentation

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

Definition at line 236 of file IODataManager.cpp.

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

Retrieve known connection.

Definition at line 208 of file IODataManager.cpp.

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

Get connection by owner instance (0=ALL)

Definition at line 85 of file IODataManager.cpp.

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

Open data stream in read mode.

Connect data file for writing.

Definition at line 95 of file IODataManager.cpp.

96 {
97  if ( !establishConnection( con ) ) {
98  return connectDataIO( UNKNOWN, Connection::READ, con->name(), "UNKNOWN", keep_open, con );
99  }
100  std::string dsn = con ? con->name() : std::string( "Unknown" );
101  return error( "Failed to connect to data:" + dsn, false );
102 }
StatusCode establishConnection(Connection *con)
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode connectDataIO(int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
StatusCode IODataManager::connectWrite ( Connection *  con,
IoType  mode = Connection::CREATE,
CSTR  doctype = "UNKNOWN" 
)
override

Open data stream in write mode.

Connect data file for reading.

Definition at line 105 of file IODataManager.cpp.

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

Release data stream.

Definition at line 132 of file IODataManager.cpp.

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

Small routine to issue exceptions.

Definition at line 76 of file IODataManager.cpp.

77 {
78  MsgStream log( msgSvc(), name() );
79  log << MSG::ERROR << "Error: " << msg << endmsg;
80  if ( rethrow ) System::breakExecution();
81  return StatusCode::FAILURE;
82 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
GAUDI_API long breakExecution()
Break the execution of the application and invoke the debugger.
Definition: Debugger.cpp:48
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode IODataManager::establishConnection ( Connection *  con)
protected

Definition at line 216 of file IODataManager.cpp.

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

IService implementation: finalize the service.

Definition at line 69 of file IODataManager.cpp.

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

IService implementation: initialize the service.

IService implementation: Db event selector override.

Definition at line 45 of file IODataManager.cpp.

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

Read raw byte buffer from input stream.

Definition at line 115 of file IODataManager.cpp.

116 {
117  return establishConnection( con ).isSuccess() ? con->read( data, len ) : StatusCode::FAILURE;
118 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
bool isSuccess() const
Definition: StatusCode.h:287
StatusCode establishConnection(Connection *con)
StatusCode IODataManager::reconnect ( Entry e)
protected

Definition at line 170 of file IODataManager.cpp.

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

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

Definition at line 127 of file IODataManager.cpp.

128 {
129  return establishConnection( con ).isSuccess() ? con->seek( where, origin ) : -1;
130 }
bool isSuccess() const
Definition: StatusCode.h:287
StatusCode establishConnection(Connection *con)
StatusCode IODataManager::write ( Connection *  con,
const void *  data,
int  len 
)
override

Write raw byte buffer to output stream.

Definition at line 121 of file IODataManager.cpp.

122 {
123  return establishConnection( con ).isSuccess() ? con->write( data, len ) : StatusCode::FAILURE;
124 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
bool isSuccess() const
Definition: StatusCode.h:287
StatusCode establishConnection(Connection *con)

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: