14 using namespace Gaudi;
20 static std::set<std::string> s_badFiles;
30 "if set to True, we will not report when a file "
31 "is opened by it's physical name");
47 <<
"Unable to localize interface IFileCatalog from service:"
81 if ( 0 == owner || c->
owner() == owner )
92 std::string dsn = con ? con->name() : std::string(
"Unknown");
93 return error(
"Failed to connect to data:"+dsn,
false);
101 std::string dsn = con ? con->name() : std::string(
"Unknown");
102 return error(
"Failed to connect to data:"+dsn,
false);
122 std::string dataset = con->name();
123 std::string dsn = dataset;
125 if ( ::strncasecmp(dsn.c_str(),
"FID:",4)==0 )
126 dsn = dataset.substr(4);
127 else if ( ::strncasecmp(dsn.c_str(),
"LFN:",4)==0 )
128 dsn = dataset.substr(4);
129 else if ( ::strncasecmp(dsn.c_str(),
"PFN:",4)==0 )
130 dsn = dataset.substr(4);
132 FidMap::iterator j =
m_fidMap.find(dataset);
134 std::string fid = (*j).second;
135 std::string gfal_name =
"gfal:guid:" + fid;
145 std::string pfn = c->
pfn();
151 log <<
MSG::INFO <<
"Disconnect from dataset " << dsn
152 <<
" [" << fid <<
"]" <<
endmsg;
171 case Connection::UPDATE:
173 case Connection::RECREATE:
180 std::vector<Entry*> to_retire;
187 to_retire.push_back((*i).second);
191 if ( !to_retire.empty() ) {
193 for(std::vector<Entry*>::iterator j=to_retire.begin(); j!=to_retire.end();++j) {
196 log <<
MSG::INFO <<
"Disconnect from dataset " << c->
pfn()
207 FidMap::const_iterator j =
m_fidMap.find(dataset);
217 if ( !con->isConnected() ) {
220 Connection*
c = (*i).second->connection;
223 return error(
"Severe logic bug: Twice identical connection object for DSN:"+con->name(),
true);
234 return error(
"Severe logic bug: No connection object avalible.",
true);
240 std::string dsn = dataset;
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;
250 return connectDataIO(PFN, rw, dsn, technology, keep_open, connection);
252 if(std::find(s_badFiles.begin(),s_badFiles.end(),dsn) != s_badFiles.end()) {
261 if ( files.size() == 0 ) {
265 error(
"connectDataIO> failed to resolve FID:"+dsn,
false).ignore();
268 else if ( dsn.length() == 36 && dsn[8]==
'-' && dsn[13]==
'-' ) {
269 std::string gfal_name =
"gfal:guid:" + dsn;
271 sc =
connectDataIO(PFN, rw, gfal_name, technology, keep_open, connection);
277 error(
"connectDataIO> Failed to resolve FID:"+dsn,
false).ignore();
284 for(IFileCatalog::Files::const_iterator
i=files.begin();
i!=files.end(); ++
i) {
285 std::string pfn = (*i).first;
286 if (
i != files.begin() ) {
288 <<
" with next entry in data federation:" << pfn <<
"." <<
endmsg;
290 sc =
connectDataIO(PFN, rw, pfn, technology, keep_open, connection);
302 log <<
MSG::ERROR <<
"Failed to open dsn:" << dsn
303 <<
" Federated file could not be resolved from "
304 << files.size() <<
" entries." <<
endmsg;
310 FidMap::iterator j =
m_fidMap.find(dsn);
318 log <<
MSG::ERROR <<
"Failed to resolve LFN:" << dsn
319 <<
" Cannot access this dataset." <<
endmsg;
325 if ( !fid.empty() )
m_catalog->getPFN(fid, files);
326 if ( files.empty() ) {
328 if ( fid.empty() ) fid =
m_catalog->createFID();
329 m_catalog->registerPFN(fid,dsn,technology);
330 log <<
MSG::INFO <<
"Referring to dataset " << dsn
331 <<
" by its file ID:" << fid <<
endmsg;
347 connection->setFID(fid);
348 connection->setPFN(dsn);
349 Entry* e =
new Entry(technology, keep_open, rw, connection);
355 error(
"connectDataIO> Cannot connect to database: PFN="+dsn+
" FID="+fid,
false).ignore();
358 fid = connection->fid();
362 log <<
MSG::ERROR <<
"Referring to existing dataset " << dsn
363 <<
" by its physical name." <<
endmsg;
364 log <<
"You may not be able to navigate back to the input file"
365 <<
" -- processing continues" <<
endmsg;
375 error(
"connectDataIO> Cannot connect to database: PFN="+dsn+
" FID="+fid,
false).ignore();
380 sc =
connectDataIO(FID, rw, fid, technology, keep_open, connection);
382 s_badFiles.insert(fid);
384 else if ( typ == LFN ) {
389 catch (std::exception& e) {
390 error(std::string(
"connectDataIO> Caught exception:")+e.what(),
false).ignore();
393 error(std::string(
"connectDataIO> Caught unknown exception"),
false).ignore();
396 error(
"connectDataIO> The dataset "+dsn+
" cannot be opened.",
false).ignore();
397 s_badFiles.insert(dsn);
int age() const
Access age counter.
int getAppReturnCode(const SmartIF< IProperty > &appmgr)
Get the application (current) return code.
Definition of the MsgStream class used to transmit messages.
virtual StatusCode connectWrite(IoType type)=0
Open data stream in write mode.
virtual StatusCode disconnect()=0
Release data stream.
virtual Connections connections(const IInterface *owner) const
Get connection by owner instance (0=ALL)
int m_ageLimit
Property: Age limit.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual StatusCode read(Connection *ioDesc, void *const data, size_t len)
Read raw byte buffer from input stream.
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.
virtual Connection * connection(const std::string &dsn) const
Retrieve known connection.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
std::vector< NamedItem > Files
SmartIF< IIncidentSvc > m_incSvc
StatusCode establishConnection(Connection *con)
const std::string FailInputFile
could not open or read from this file
virtual StatusCode write(Connection *con, const void *data, int len)
Write raw byte buffer to output stream.
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.
virtual StatusCode disconnect(Connection *ioDesc)
Release data stream.
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)
bool isValid() const
Allow for check if smart pointer is valid.
This class is used for returning status codes from appropriate routines.
SmartIF< IFileCatalog > m_catalog
Reference to file catalog.
Definition of the basic interface.
virtual StatusCode connectRead(bool keep_open, Connection *ioDesc)
Open data stream in read mode.
virtual StatusCode connectWrite(Connection *con, IoType mode=Connection::CREATE, CSTR doctype="UNKNOWN")
Open data stream in write mode.
virtual long long int seek(Connection *ioDesc, long long int where, int origin)
Seek on the file described by ioDesc. Arguments as in ::seek()
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.
virtual const std::string & name() const
Retrieve name of the service.
const IInterface * owner() const
Owner instance.
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
ABC describing basic data connection.
ConnectionMap m_connectionMap
Map with I/O descriptors.
IDataConnection * connection
void resetAge()
Reset age.
Base class for all Incidents (computing events).
Templated class to add the standard messaging functionalities.
StatusCode connectDataIO(int typ, IoType rw, CSTR fn, CSTR technology, bool keep, Connection *con)
virtual StatusCode initialize()
IService implementation: initialize the service.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
This is a number of static methods for bootstrapping the Gaudi framework.
void ageFile()
Increase age of I/O source.
virtual StatusCode connectRead()=0
Open data stream in read mode.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode reconnect(Entry *e)
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
IODataManager(CSTR nam, ISvcLocator *loc)
the incident service
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode finalize()
IService implementation: finalize the service.
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
FidMap m_fidMap
Map of FID to PFN.