14 #include <boost/filesystem.hpp> 21 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG)) 22 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE)) 24 #define DEBMSG ON_DEBUG debug() 25 #define VERMSG ON_VERBOSE verbose() 39 os <<
"INVALID";
break;
53 error() <<
"Unable to initialize Service base class" <<
endmsg;
59 if (
service(
"IncidentSvc", p_incSvc,
true).isFailure()) {
60 error() <<
"unable to get the IncidentSvc" <<
endmsg;
63 p_incSvc->
addListener(
this, IncidentType::BeginOutputFile, 100,
true);
64 p_incSvc->
addListener(
this, IncidentType::BeginInputFile, 100,
true);
86 if ( 0 == iocomponent ) {
104 if ( 0 == iocomponent ) {
109 DEBMSG <<
"io_contains: c: " << ioname <<
" f: " << fname <<
endmsg;
112 if (fit.first == fit.second) {
116 for (it=fit.first; it != fit.second; ++it) {
120 error() <<
"IIoComponent " << ioname
121 <<
" has empty old filename" <<
endmsg;
143 if ( !iocomponent ) {
145 <<
"io_register (component) received a NULL pointer !" <<
endmsg;
149 DEBMSG <<
"--> io_register(" << ioname <<
")" <<
endmsg;
152 DEBMSG <<
" registering IoComponent \"" << ioname <<
"\"" <<
endmsg;
157 info() <<
"IoComponent[" << iocomponent->
name()
158 <<
"] already registered @" << (
void*)itr->second << endmsg;
177 if ( 0 == iocomponent ) {
182 DEBMSG <<
"--> io_register(" << ioname <<
"," 184 <<
"," << fname <<
")" <<
endmsg;
189 <<
"could not register component [" << iocomponent->
name() <<
"] " 190 <<
"with the I/O component manager !" 197 if (fit.first != fit.second) {
198 for (
iodITR it=fit.first; it != fit.second; ++it) {
202 info() <<
"IoComponent " << ioname
203 <<
" has already had file " << fname
204 <<
" registered with i/o mode " << iomode <<
endmsg;
207 warning() <<
"IoComponent " << ioname
208 <<
" has already had file " << fname
209 <<
" registered with a different i/o mode " << ioe.
m_iomode 210 <<
" - now trying " << iomode <<
endmsg;
219 bool from_eos = tmp_name.
find(
"root:")==0;
220 IoComponentEntry ioc(fname,(from_eos?tmp_name:boost::filesystem::absolute(tmp_name).
string()),iomode);
235 if ( 0 == iocomponent ) {
242 DEBMSG <<
"--> io_retrieve(" << ioname <<
"," << fname <<
")" 246 if (!
findComp(iocomponent,ofname,it)) {
247 DEBMSG <<
"could not find c: " << ioname <<
" old_f: " << ofname <<
endmsg;
251 IoDict_t::iterator it;
256 if (it->second.m_oldfname == ofname) {
257 DEBMSG <<
"retrieving new name for the component " << iocomponent->
name()
258 <<
" old name: " << ofname
259 <<
", new name: " << it->second.m_newfname <<
endmsg;
260 fname = it->second.m_newfname;
266 DEBMSG <<
"Unexpected error! Unable to find entry in the dictionary corresponding to old filename: " << ofname <<
endmsg;
281 debug() <<
"reinitializing I/O subsystem..." <<
endmsg;
288 DEBMSG <<
" [" << io->name() <<
"]->io_reinit()..." <<
endmsg;
289 if ( !io->io_reinit().isSuccess() ) {
291 error() <<
"problem in [" << io->name()
292 <<
"]->io_reinit() !" <<
endmsg;
315 DEBMSG <<
"--> io_update(" << ioc->
name() <<
"," 316 << old_fname <<
"," << new_fname <<
")" <<
endmsg;
318 IoDict_t::iterator it;
323 if (it->second.m_oldfname == old_fname) {
324 DEBMSG <<
"updating " << ioc->
name() <<
" f: " << old_fname <<
" -> " 326 it->second.m_newfname = new_fname;
340 DEBMSG <<
"--> io_update(" << ioc->
name() <<
"," 341 << work_dir <<
")" <<
endmsg;
343 IoDict_t::iterator it;
348 switch(it->second.m_iomode) {
351 it->second.m_newfname = it->second.m_oldabspath;
357 if(oldPath.is_relative() &&
358 oldPath.filename()==oldPath.relative_path()) {
369 it->second.m_newfname = newfname.string();
373 it->second.m_newfname = it->second.m_oldabspath;
381 error() <<
"Unable to update IoComponent for the mode " << it->second.m_iomode <<
endmsg;
397 DEBMSG <<
"-->io_update_all for the directory " << work_dir <<
endmsg;
404 error() <<
"problem in [" << (*io)->name()
405 <<
"]->io_update() !" <<
endmsg;
422 debug() <<
"finalizing I/O subsystem..." <<
endmsg;
431 DEBMSG <<
" [" << (*io)->name() <<
"]->io_finalize()..." 433 if ( !(*io)->io_finalize().isSuccess() ) {
435 error() <<
"problem in [" << (*io)->name()
436 <<
"]->io_finalize() !" <<
endmsg;
457 [&](IoDict_t::const_reference i)
458 { return i.second.m_oldfname == f; } );
468 return pit.first != pit.second;
492 ost <<
"Listing all IoComponents (" <<
m_cdict.
size() <<
"): " <<
endl;
493 for (
const auto& i :
m_cdict ) {
494 ost <<
" " << i.first->name() <<
" " << i.second <<
endl;
508 if ( i.
type() == IncidentType::BeginInputFile ) {
517 while (pit.first != pit.second) {
525 DEBMSG <<
" could not find component \"" << fi->
source()
531 }
else if ( i.
type() == IncidentType::BeginOutputFile ) {
540 while (pit.first != pit.second) {
548 DEBMSG <<
" could not find component \"" << fi->
source()
StatusCode finalize() override
StatusCode initialize() override
This class is the FileIncident.
const std::string & type() const
Access to the incident type.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool io_contains(IIoComponent *iocomponent, const std::string &fname) const override
: check if the registry contains a given IIoComponent and that component had
This file contains the class definition for the FileIncident class.
const std::string & source() const
Access to the source of the incident.
bool isSuccess() const
Test for a status code of SUCCESS.
IoDict_t::const_iterator iodITR
IoRegistry_t m_ioregistry
Registry of IIoComponents.
void handle(const Incident &) override
#define DECLARE_COMPONENT(type)
StatusCode initialize() override
Gaudi Service Implementation.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool findComp(IIoComponent *, const std::string &, iodITR &) const
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
StatusCode io_register(IIoComponent *iocomponent) override
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
StatusCode io_update(IIoComponent *iocomponent, const std::string &old_fname, const std::string &new_fname) override
: allow a IIoComponent to update the contents of the registry with a new file name ...
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
IIoComponentMgr::IoMode::Type m_iomode
StatusCode io_update_all(const std::string &work_dir) override
: Update all IIoComponents with a new work directory
Base class for all Incidents (computing events).
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
const std::string & fileGuid() const
StatusCode io_retrieve(IIoComponent *iocomponent, std::string &fname) override
: retrieve the new filename for a given IIoComponent and
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.
StatusCode io_finalize() override
: finalize the I/O subsystem.
StatusCode io_reinitialize() override
: reinitialize the I/O subsystem.
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
const std::string & fileName() const
Type
the list of available types for ntuples
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual const std::string & name() const =0
Retrieve the name of the instance.
The interface implemented by the IncidentSvc service.
bool io_hasitem(IIoComponent *iocomponent) const override
: check if the registry contains a given IIoComponent