16 constexpr
struct select2nd_t {
17 template<
typename S,
typename T>
18 const T& operator()(
const std::pair<S,T>& p)
const {
return p.second; }
21 template <
typename InputIterator,
typename OutputIterator,
22 typename UnaryOperation,
typename UnaryPredicate>
23 OutputIterator transform_copy_if( InputIterator first, InputIterator last,
24 OutputIterator result,
26 UnaryPredicate pred) {
27 while (first != last) {
28 auto val = op(*first);
29 if (pred(val)) *result++ =
std::move(val);
36 using namespace Gaudi;
52 "if set to True, we will not report when a file "
53 "is opened by its physical name");
69 <<
"Unable to localize interface IFileCatalog from service:"
100 [](ConnectionMap::const_reference
i ) {
return i.second->connection; },
111 return error(
"Failed to connect to data:"+dsn,
false);
120 return error(
"Failed to connect to data:"+dsn,
false);
143 if ( ::strncasecmp(dsn.
c_str(),
"FID:",4)==0 )
145 else if ( ::strncasecmp(dsn.
c_str(),
"LFN:",4)==0 )
147 else if ( ::strncasecmp(dsn.
c_str(),
"PFN:",4)==0 )
167 log <<
MSG::INFO <<
"Disconnect from dataset " << dsn
168 <<
" [" << fid <<
"]" <<
endmsg;
186 case Connection::UPDATE:
188 case Connection::RECREATE:
205 if ( !to_retire.
empty() ) {
211 log <<
MSG::INFO <<
"Disconnect from dataset " << c->
pfn()
229 if ( !con )
return error(
"Severe logic bug: No connection object avalible.",
true);
231 if ( con->isConnected() ) {
237 Connection*
c =
i->second->connection;
240 return error(
"Severe logic bug: Twice identical connection object for DSN:"+con->name(),
true);
253 if ( ::strncasecmp(dsn.
c_str(),
"FID:",4)==0 )
254 dsn = dataset.
substr(4), typ = FID;
255 else if ( ::strncasecmp(dsn.
c_str(),
"LFN:",4)==0 )
256 dsn = dataset.
substr(4), typ = LFN;
257 else if ( ::strncasecmp(dsn.
c_str(),
"PFN:",4)==0 )
258 dsn = dataset.
substr(4), typ = PFN;
260 return connectDataIO(PFN, rw, dsn, technology, keep_open, connection);
271 if ( files.
empty() ) {
275 error(
"connectDataIO> failed to resolve FID:"+dsn,
false).ignore();
278 else if ( dsn.
length() == 36 && dsn[8]==
'-' && dsn[13]==
'-' ) {
281 sc =
connectDataIO(PFN, rw, gfal_name, technology, keep_open, connection);
287 error(
"connectDataIO> Failed to resolve FID:"+dsn,
false).ignore();
298 <<
" with next entry in data federation:" << pfn <<
"." <<
endmsg;
300 sc =
connectDataIO(PFN, rw, pfn, technology, keep_open, connection);
312 log <<
MSG::ERROR <<
"Failed to open dsn:" << dsn
313 <<
" Federated file could not be resolved from "
328 log <<
MSG::ERROR <<
"Failed to resolve LFN:" << dsn
329 <<
" Cannot access this dataset." <<
endmsg;
336 if ( files.
empty() ) {
339 m_catalog->registerPFN(fid,dsn,technology);
340 log <<
MSG::INFO <<
"Referring to dataset " << dsn
341 <<
" by its file ID:" << fid <<
endmsg;
357 connection->setFID(fid);
358 connection->setPFN(dsn);
359 auto e =
new Entry(technology, keep_open, rw, connection);
365 error(
"connectDataIO> Cannot connect to database: PFN="+dsn+
" FID="+fid,
false).ignore();
368 fid = connection->fid();
372 log <<
MSG::ERROR <<
"Referring to existing dataset " << dsn
373 <<
" by its physical name." <<
endmsg;
374 log <<
"You may not be able to navigate back to the input file"
375 <<
" -- processing continues" <<
endmsg;
385 error(
"connectDataIO> Cannot connect to database: PFN="+dsn+
" FID="+fid,
false).ignore();
390 sc =
connectDataIO(FID, rw, fid, technology, keep_open, connection);
394 else if ( typ == LFN ) {
403 error(
std::string(
"connectDataIO> Caught unknown exception"),
false).ignore();
406 error(
"connectDataIO> The dataset "+dsn+
" cannot be opened.",
false).ignore();
StatusCode finalize() override
IService implementation: finalize the service.
int getAppReturnCode(const SmartIF< IProperty > &appmgr)
Get the application (current) return code.
Definition of the MsgStream class used to transmit messages.
StatusCode initialize() override
virtual StatusCode connectWrite(IoType type)=0
Open data stream in write mode.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
virtual StatusCode disconnect()=0
Release data stream.
int m_ageLimit
Property: Age limit.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual bool isConnected() const =0
Check if connected to data source.
bool m_useGFAL
Property: Flag for auto gfal data access.
const std::string & fid() const
Access file id.
StatusCode finalize() override
bool isSuccess() const
Test for a status code of SUCCESS.
StatusCode disconnect(Connection *ioDesc) override
Release data stream.
SmartIF< IIncidentSvc > m_incSvc
StatusCode establishConnection(Connection *con)
std::string m_catalogSvcName
Property: Name of the file catalog service.
GAUDI_API long breakExecution()
Break the execution of the application and invoke the debugger.
const std::string & pfn() const
Access physical file name.
bool m_disablePFNWarning
Property DisablePFNWarning: if set to True will not report when a file is opened by it's physical nam...
#define DECLARE_COMPONENT(type)
StatusCode read(Connection *ioDesc, void *const data, size_t len) override
Read raw byte buffer from input stream.
Connection * connection(const std::string &dsn) const override
Retrieve known connection.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
const std::string & name() const override
Retrieve name of the service.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
int ageFile()
Increase age of I/O source.
StatusCode initialize() override
IService implementation: initialize the service.
This class is used for returning status codes from appropriate routines.
SmartIF< IFileCatalog > m_catalog
Reference to file catalog.
Definition of the basic interface.
StatusCode write(Connection *con, const void *data, int len) override
Write raw byte buffer to output stream.
StatusCode connectWrite(Connection *con, IoType mode=Connection::CREATE, CSTR doctype="UNKNOWN") override
Open data stream in write mode.
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
bool m_quarantine
Property: Flag if unaccessible files should be quarantines in job.
ABC describing basic data connection.
T back_inserter(T...args)
ConnectionMap m_connectionMap
Map with I/O descriptors.
IDataConnection * connection
void resetAge()
Reset age.
Base class for all Incidents (computing events).
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
StatusCode connectDataIO(int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
StatusCode connectRead(bool keep_open, Connection *ioDesc) override
Open data stream in read mode.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
The IProperty is the basic interface for all components which have properties that can be set or get...
virtual StatusCode connectRead()=0
Open data stream in read mode.
Connections connections(const IInterface *owner) const override
Get connection by owner instance (0=ALL)
long long int seek(Connection *ioDesc, long long int where, int origin) override
Seek on the file described by ioDesc. Arguments as in ::seek()
Helper functions to set/get the application return code.
StatusCode reconnect(Entry *e)
IODataManager(CSTR nam, ISvcLocator *loc)
the incident service
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
FidMap m_fidMap
Map of FID to PFN.