All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RootCnvSvc.cpp
Go to the documentation of this file.
1 // $Id: RootCnvSvc.cpp,v 1.12 2010-09-27 15:43:53 frankb Exp $
2 //====================================================================
3 // RootCnvSvc implementation
4 //--------------------------------------------------------------------
5 //
6 // Description: Implementation of the ROOT data storage
7 //
8 // Author : M.Frank
9 //
10 //====================================================================
11 
12 // Framework include files
13 #include "GaudiKernel/MsgStream.h"
14 #include "GaudiKernel/IRegistry.h"
15 #include "GaudiKernel/IUpdateable.h"
16 #include "GaudiKernel/IIncidentSvc.h"
17 #include "GaudiKernel/IDataManagerSvc.h"
18 #include "GaudiKernel/IDataProviderSvc.h"
19 #include "GaudiKernel/KeyedContainer.h"
20 #include "GaudiKernel/DataIncident.h"
21 #include "GaudiKernel/LinkManager.h"
22 #include "GaudiKernel/Incident.h"
23 #include "GaudiKernel/System.h"
24 #include "GaudiUtils/IIODataManager.h"
25 #include "RootCnv/RootRefs.h"
26 #include "RootCnv/RootCnvSvc.h"
27 #include "RootCnv/RootAddress.h"
28 #include "RootCnv/RootConverter.h"
29 #include "RootCnv/RootDatabaseCnv.h"
30 #include "RootCnv/RootDirectoryCnv.h"
31 #include "RootCnv/RootNTupleCnv.h"
32 #include "RootCnv/RootDataConnection.h"
33 #include "RootUtils.h"
34 
35 using namespace std;
36 using namespace Gaudi;
37 typedef const string& CSTR;
38 
39 #define S_OK StatusCode::SUCCESS
40 #define S_FAIL StatusCode::FAILURE
41 namespace GaudiRoot { bool patchStreamers(MsgStream& log); }
42 
43 namespace {
44  static map<string, TClass*> s_classesNames;
45  static map<CLID, TClass*> s_classesClids;
46 }
47 #define MBYTE 1024*1024
48 #define kBYTE 1024
49 // Standard constructor
50 RootCnvSvc::RootCnvSvc(CSTR nam, ISvcLocator* svc)
51 : ConversionSvc( nam, svc, ROOT_StorageType),
52  m_ioMgr(0), m_incidentSvc(0), m_current(0), m_setup(0)
53 {
54  m_classRefs = m_classDO = 0;
55  m_setup = new RootConnectionSetup();
56  m_setup->cacheBranches.push_back("*");
57  declareProperty("IOPerfStats", m_ioPerfStats);
58  declareProperty("ShareFiles", m_shareFiles = "NO");
59  declareProperty("EnableIncident", m_incidentEnabled = true);
60  declareProperty("RecordsName", m_recordName = "/FileRecords");
61  declareProperty("LoadSection", m_setup->loadSection = "Event");
62 
63  // ROOT Write parameters
64  declareProperty("AutoFlush", m_autoFlush = 100);
65  declareProperty("BasketSize", m_basketSize = 2*MBYTE);
66  declareProperty("BufferSize", m_bufferSize = 2*kBYTE);
67  declareProperty("SplitLevel", m_splitLevel = 0);
68  declareProperty("GlobalCompression",m_compression); // empty: do nothing
69 
70  // ROOT Read parameters: must be shared for the entire file!
71  declareProperty("CacheSize", m_setup->cacheSize = 10*MBYTE);
72  declareProperty("LearnEntries", m_setup->learnEntries = 10);
73  declareProperty("CacheBranches", m_setup->cacheBranches);
74  declareProperty("VetoBranches", m_setup->vetoBranches);
75 }
76 
77 // Standard destructor
78 RootCnvSvc::~RootCnvSvc() {
79  if (m_setup) m_setup->release();
80 }
81 
82 // Small routine to issue exceptions
83 StatusCode RootCnvSvc::error(CSTR msg) {
84  if ( m_log ) {
85  log() << MSG::ERROR << "Error: " << msg << endmsg;
86  return S_FAIL;
87  }
88  MsgStream m(msgSvc(),name());
89  m << MSG::ERROR << "Error: " << msg << endmsg;
90  return S_FAIL;
91 }
92 
93 // Initialize the Db data persistency service
95  string cname;
97  if ( !status.isSuccess() ) {
98  return error("Failed to initialize ConversionSvc base class.");
99  }
100  m_log = new MsgStream(msgSvc(),name());
101  if ( !m_compression.empty() ) {
102  log() << MSG::INFO << "Setting global ROOT compression to:" << m_compression << endmsg;
103  if ( !(status=RootConnectionSetup::setCompression(m_compression)).isSuccess() ) {
104  return error("Unable to interprete ROOT compression encoding:"+m_compression);
105  }
106  }
107  if( !(status=service("IODataManager", m_ioMgr)).isSuccess() )
108  return error("Unable to localize interface from service:IODataManager");
109  if( !(status=service("IncidentSvc", m_incidentSvc)).isSuccess() )
110  return error("Unable to localize interface from service:IncidentSvc");
111  m_setup->setMessageSvc(new MsgStream(msgSvc(),name()));
112  m_setup->setIncidentSvc(m_incidentSvc);
114  cname = System::typeinfoName(typeid(DataObject));
115  m_classDO = TClass::GetClass(cname.c_str());
116  if ( 0 == m_classDO )
117  return error("Unable to load class description for DataObject");
118  cname = System::typeinfoName(typeid(RootObjectRefs));
119  m_classRefs = TClass::GetClass(cname.c_str());
120  if ( 0 == m_classRefs )
121  return error("Unable to load class description for ObjectRefs");
122  return S_OK;
123 }
124 
125 // Finalize the Db data persistency service
126 StatusCode RootCnvSvc::finalize() {
127  log() << MSG::INFO;
128  if ( m_ioMgr ) {
129  IIODataManager::Connections cons = m_ioMgr->connections(0);
130  for(IIODataManager::Connections::iterator i=cons.begin(); i != cons.end(); ++i) {
131  RootDataConnection* pc = dynamic_cast<RootDataConnection*>(*i);
132  if ( pc ) {
133  if ( pc->owner() == this && !m_ioPerfStats.empty() ) {
134  pc->saveStatistics(m_ioPerfStats);
135  }
136  if ( pc->lookupClient(this) ) {
137  size_t num_clients = pc->removeClient(this);
138  if ( num_clients == 0 ) {
139  if ( m_ioMgr->disconnect(pc).isSuccess() ) {
140  log() << "Disconnected data IO:" << pc->fid()
141  << " [" << pc->pfn() << "]" << endmsg;
142  delete pc;
143  }
144  }
145  }
146  }
147  }
148  releasePtr(m_ioMgr);
149  }
150  deletePtr(m_log);
151  releasePtr(m_incidentSvc);
152  m_setup->setIncidentSvc(0);
153  return ConversionSvc::finalize();
154 }
155 
156 // ConversionSvc overload: Create new Converter using factory
157 IConverter* RootCnvSvc::createConverter(long typ,const CLID& wanted,const ICnvFactory*) {
158  if ( wanted == CLID_StatisticsFile )
159  return new RootDatabaseCnv(typ,wanted,serviceLocator().get(),this);
160  else if ( wanted == CLID_StatisticsDirectory )
161  return new RootDirectoryCnv(typ,wanted,serviceLocator().get(),this);
162  else if ( wanted == CLID_RowWiseTuple )
163  return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
164  else if ( wanted == CLID_ColumnWiseTuple )
165  return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
166  else
167  return new RootConverter(typ,wanted,serviceLocator().get(),this);
168 }
169 
170 // ConversionSvc overload: Load the class (dictionary) for the converter
171 void RootCnvSvc::loadConverter(DataObject* pObject) {
172  if (pObject) {
173  string cname = System::typeinfoName(typeid(*pObject));
174  if( log().level() <= MSG::DEBUG )
175  log() << MSG::DEBUG << "Trying to 'Autoload' dictionary for class " << cname << endmsg;
176  TClass* cl = s_classesNames[cname];
177  if ( 0 == cl ) {
178  cl = TClass::GetClass(cname.c_str());
179  if ( cl ) {
180  s_classesNames[cname] = cl;
181  s_classesClids[pObject->clID()] = cl;
182  }
183  }
184  }
185 }
186 
187 // Helper: Get TClass for a given DataObject pointer
188 TClass* RootCnvSvc::getClass(DataObject* pObject) {
189  map<CLID, TClass*>::iterator i=s_classesClids.find(pObject->clID());
190  if ( i != s_classesClids.end() ) return (*i).second;
191  loadConverter(pObject);
192  i=s_classesClids.find(pObject->clID());
193  if ( i != s_classesClids.end() ) return (*i).second;
194 
195  string cname = System::typeinfoName(typeid(*pObject));
196  throw runtime_error("Unknown ROOT class for object:"+cname);
197  return 0;
198 }
199 
200 // Connect the output file to the service with open mode.
201 StatusCode RootCnvSvc::connectOutput(CSTR dsn, CSTR openMode) {
202  StatusCode sc = S_FAIL;
203  m_current = 0;
204  m_currSection = "";
205  if ( ::strncasecmp(openMode.c_str(),"RECREATE",3)==0 )
206  sc = connectDatabase(dsn, IDataConnection::RECREATE, &m_current);
207  else if ( ::strncasecmp(openMode.c_str(),"NEW",1)==0 )
208  sc = connectDatabase(dsn, IDataConnection::CREATE, &m_current);
209  else if ( ::strncasecmp(openMode.c_str(),"CREATE",1)==0 )
210  sc = connectDatabase(dsn, IDataConnection::CREATE, &m_current);
211  else if ( ::strncasecmp(openMode.c_str(),"UPDATE",1)==0 )
212  sc = connectDatabase(dsn, IDataConnection::UPDATE, &m_current);
213  if ( sc.isSuccess() && m_current && m_current->isConnected() ) {
214  return S_OK;
215  }
216  m_incidentSvc->fireIncident(Incident(dsn,IncidentType::FailOutputFile));
217  log() << MSG::ERROR << "The dataset " << dsn << " cannot be opened in mode "
218  << openMode << ". [Invalid mode]" << endmsg;
219  return sc;
220 }
221 
222 // Connect the output file to the service with open mode.
224 RootCnvSvc::connectDatabase(CSTR dataset, int mode, RootDataConnection** con) {
225  try {
226  IDataConnection* c = m_ioMgr->connection(dataset);
227  bool fire_incident = false;
228  *con = 0;
229  if ( !c ) {
230  auto_ptr<RootDataConnection> connection(new RootDataConnection(this,dataset,m_setup));
231  StatusCode sc = (mode != IDataConnection::READ)
232  ? m_ioMgr->connectWrite(connection.get(),IDataConnection::IoType(mode),"ROOT")
233  : m_ioMgr->connectRead(false,connection.get());
234  c = sc.isSuccess() ? m_ioMgr->connection(dataset) : 0;
235  if ( c ) {
236  bool writable = 0 != (mode&(IDataConnection::UPDATE|IDataConnection::RECREATE));
237  fire_incident = m_incidentEnabled && (0 != (mode&(IDataConnection::UPDATE|IDataConnection::READ)));
238  if ( writable ) {
239  m_incidentSvc->fireIncident(ContextIncident<TFile*>(connection->pfn(),"CONNECTED_OUTPUT",connection->file()));
240  }
241  if ( 0 != (mode&IDataConnection::READ) ) {
242  if ( !m_ioPerfStats.empty() ) {
243  connection->enableStatistics(m_setup->loadSection);
244  }
245  }
246  connection.release();
247  }
248  else {
249  m_incidentSvc->fireIncident(Incident(dataset,mode == IDataConnection::READ
252  // An error message was already printed by the IODataManager. no need to do it here!
253  return StatusCode::FAILURE;
254  }
255  }
256  RootDataConnection* pc = dynamic_cast<RootDataConnection*>(c);
257  if ( pc ) {
258  if ( !pc->isConnected() ) pc->connectRead();
259  *con = pc;
260  pc->resetAge();
261  pc->addClient(this);
262  }
263  if ( *con ) {
264  if ( fire_incident ) {
265  IOpaqueAddress* pAddr = 0;
266  string fid = pc->fid();
267  string section = m_recordName[0] == '/' ? m_recordName.substr(1) : m_recordName;
268  TBranch* b = pc->getBranch(section,m_recordName);
269  if ( b ) {
270  const string par[2] = { fid, m_recordName };
271  unsigned long ipar[2] = { (unsigned long)(*con), (unsigned long)b->GetEntries()-1 };
272  for(int i=0; i<b->GetEntries(); ++i) {
273  ipar[1] = i;
274  if ( !pc->mergeFIDs().empty() )
275  fid = pc->mergeFIDs()[i];
276  if ( !createAddress(repSvcType(),CLID_DataObject,par,ipar,pAddr).isSuccess() ) {
277  if( log().level() <= MSG::VERBOSE )
278  log() << MSG::VERBOSE << "Failed to create address for " << m_recordName << " in:" << fid
279  << " [" << pc->fid() << "][" << i << "]" << endmsg;
280  continue;
281  }
282  if( log().level() <= MSG::VERBOSE )
283  log() << MSG::VERBOSE << "Prepare " << m_recordName << " " << fid << " [" << par[0] << "][" << i << "]" << endmsg;
284  m_incidentSvc->fireIncident(ContextIncident<IOpaqueAddress*>(fid,"FILE_OPEN_READ",pAddr));
285  }
286  }
287  else {
288  if( log().level() <= MSG::VERBOSE )
289  log() << MSG::VERBOSE << "No valid Records " << m_recordName << " present in:" << pc->fid() << endmsg;
290  }
291  }
292 
293  // We can remove retired connections, which are no longer used....
294  IIODataManager::Connections cons = m_ioMgr->connections(this);
295  for(IIODataManager::Connections::iterator i=cons.begin(); i != cons.end(); ++i) {
296  if ( (*i) != *con && !(*i)->isConnected() ) {
297  RootDataConnection* pc = dynamic_cast<RootDataConnection*>(*i);
298  if ( pc && pc->lookupClient(this) ) {
299  size_t num_client = pc->removeClient(this);
300  if ( num_client == 0 ) {
301  if ( m_ioMgr->disconnect(pc).isSuccess() ) {
302  log() << MSG::INFO << "Removed disconnected IO stream:" << pc->fid()
303  << " [" << pc->pfn() << "]" << endmsg;
304  delete pc;
305  }
306  }
307  }
308  }
309  }
310  return S_OK;
311  }
312  m_incidentSvc->fireIncident(Incident(dataset,IncidentType::FailOutputFile));
313  return S_FAIL;
314  }
315  catch (exception& e) {
316  m_incidentSvc->fireIncident(Incident(dataset,IncidentType::FailOutputFile));
317  return error(string("connectDatabase> Caught exception:")+e.what());
318  }
319  catch (...) {
320  m_incidentSvc->fireIncident(Incident(dataset,IncidentType::FailOutputFile));
321  return error("connectDatabase> Unknown Fatal Exception for "+dataset);
322  }
323 }
324 
325 // Conect output stream (valid until overwritten)
326 StatusCode RootCnvSvc::connectOutput(CSTR db_name) {
327  return connectOutput(db_name, "NEW");
328 }
329 
330 // Commit pending output on open container
331 StatusCode RootCnvSvc::commitOutput(CSTR dsn, bool /* doCommit */) {
332  if ( m_current ) {
333  size_t len = m_currSection.find('/',1);
334  string section = m_currSection.substr(1,len==string::npos ? string::npos : len-1);
335  TBranch* b = m_current->getBranch(section, m_currSection);
336  if ( b ) {
337  Long64_t evt = b->GetEntries();
338  TTree* t = b->GetTree();
339  TObjArray* a = t->GetListOfBranches();
340  Int_t nb = a->GetEntriesFast();
342  for(Int_t i=0; i<nb; ++i) {
343  TBranch* br_ptr = (TBranch*)a->UncheckedAt(i);
344  Long64_t br_evt = br_ptr->GetEntries();
345  if ( br_evt < evt ) {
346  Long64_t num = evt-br_evt;
347  br_ptr->SetAddress(0);
348  while(num>0) {
349  br_ptr->Fill();
350  --num;
351  }
352  if( log().level() <= MSG::DEBUG ) log() << MSG::DEBUG
353  << "commit: Added " << long(evt-br_evt)
354  << " Section: " << evt << " Branch: " << br_ptr->GetEntries()
355  << " RefNo: " << br_ptr->GetEntries()-1
356  << " NULL entries to:" << br_ptr->GetName() << endmsg;
357  }
358  }
359 
360  b->GetTree()->SetEntries(evt);
361  if ( evt == 1 ) {
362  b->GetTree()->OptimizeBaskets(m_basketSize,1.1,"");
363  }
364  if ( evt > 0 && (evt%m_autoFlush)==0 ) {
365  if ( evt == m_autoFlush ) {
366  b->GetTree()->SetAutoFlush(m_autoFlush);
367  b->GetTree()->OptimizeBaskets(m_basketSize,1.,"");
368  }
369  else {
370  b->GetTree()->FlushBaskets();
371  }
372  }
373  if( log().level() <= MSG::DEBUG )
374  log() << MSG::DEBUG << "Set section entries of " << m_currSection
375  << " to " << long(evt) << " entries." << endmsg;
376  }
377  else {
378  return error("commitOutput> Failed to update entry numbers on "+dsn);
379  }
380  }
381  return S_OK;
382 }
383 
384 // Disconnect from an existing data stream.
385 StatusCode RootCnvSvc::disconnect(CSTR dataset) {
386  IDataConnection* c = m_ioMgr->connection(dataset);
387  return c ? m_ioMgr->disconnect(c) : S_FAIL;
388 }
389 
390 // IAddressCreator implementation: Address creation
391 StatusCode RootCnvSvc::createAddress(long typ,
392  const CLID& clid,
393  const string* par,
394  const unsigned long* ip,
395  IOpaqueAddress*& refpAddress)
396 {
397  refpAddress = new RootAddress(typ,clid,par[0],par[1],ip[0],ip[1]);
398  return S_OK;
399 }
400 
401 // Insert null marker for not existent transient object
402 StatusCode RootCnvSvc::createNullRep(const std::string& path) {
403  size_t len = path.find('/',1);
404  string section = path.substr(1,len==string::npos ? string::npos : len-1);
405  m_current->saveObj(section,path,0,0,m_bufferSize,m_splitLevel);
406  return S_OK;
407 }
408 
409 // Insert null marker for not existent transient object
410 StatusCode RootCnvSvc::createNullRef(const std::string& path) {
411  RootObjectRefs* refs = 0;
412  size_t len = path.find('/',1);
413  string section = path.substr(1,len==string::npos ? string::npos : len-1);
414  pair<int,unsigned long> ret =
415  m_current->save(section,path+"#R",0,refs,m_bufferSize,m_splitLevel);
416  if( log().level() <= MSG::VERBOSE )
417  log() << MSG::VERBOSE << "Writing object:" << path << " "
418  << ret.first << " " << hex << ret.second << dec << " [NULL]" << endmsg;
419  return S_OK;
420 }
421 
422 // Mark an object for write given an object reference
423 StatusCode RootCnvSvc::i__createRep(DataObject* pObj, IOpaqueAddress*& refpAddr) {
424  refpAddr = 0;
425  if ( pObj ) {
426  CLID clid = pObj->clID();
427  IRegistry* pR = pObj->registry();
428  string p[2] = {m_current->fid(), pR->identifier()};
429  TClass* cl = (clid == CLID_DataObject) ? m_classDO : getClass(pObj);
430  size_t len = p[1].find('/',1);
431  string sect = p[1].substr(1,len==string::npos ? string::npos : len-1);
432  pair<int,unsigned long> ret =
433  m_current->saveObj(sect,p[1],cl,pObj,m_bufferSize,m_splitLevel,true);
434  if ( ret.first > 1 || (clid == CLID_DataObject && ret.first==1) ) {
435  unsigned long ip[2] = {0,ret.second};
436  if ( m_currSection.empty() ) m_currSection = p[1];
437  return createAddress(repSvcType(),clid,p,ip,refpAddr);
438  }
439  return error("Failed to write object data for:"+p[1]);
440  }
441  return error("createRep> Current Database is invalid!");
442 }
443 
444 // Save object references to data file
445 StatusCode RootCnvSvc::i__fillRepRefs(IOpaqueAddress* /* pA */, DataObject* pObj) {
446  if ( pObj ) {
447  typedef vector<IRegistry*> Leaves;
448  Leaves leaves;
449  RootObjectRefs refs;
450  IRegistry* pR = pObj->registry();
451  SmartIF<IDataManagerSvc> dataMgr(pR->dataSvc());
452  if ( dataMgr ) {
453  StatusCode status = dataMgr->objectLeaves(pObj, leaves);
454  if ( status.isSuccess() ) {
455  RootRef ref;
456  const string& id = pR->identifier();
457  size_t len = id.find('/',1);
458  string sect = id.substr(1,len==string::npos ? string::npos : len-1);
459  LinkManager* pLinks = pObj->linkMgr();
460  for(Leaves::iterator i=leaves.begin(), iend=leaves.end(); i != iend; ++i) {
461  if ( (*i)->address() ) {
462  m_current->makeRef(*i,ref);
463  ref.entry = (*i)->address()->ipar()[1];
464  refs.refs.push_back(ref);
465  }
466  }
467  for(int i = 0, n=pLinks->size(); i < n; ++i) {
468  LinkManager::Link* lnk = pLinks->link(i);
469  int link_id = m_current->makeLink(lnk->path());
470  refs.links.push_back(link_id);
471  }
472  pair<int,unsigned long> ret =
473  m_current->save(sect,id+"#R",m_classRefs,&refs,m_bufferSize,m_splitLevel,true);
474  if ( ret.first > 1 ) {
475  if( log().level() <= MSG::DEBUG )
476  log() << MSG::DEBUG << "Writing object:" << id << " "
477  << ret.first << " " << hex << ret.second << dec << endmsg;
478  return S_OK;
479  }
480  }
481  }
482  }
483  return S_FAIL;
484 }
485 
486 // Read existing object. Open transaction in read mode if not active
487 StatusCode RootCnvSvc::i__createObj(IOpaqueAddress* pA, DataObject*& refpObj) {
488  refpObj = 0;
489  if ( pA ) {
490  RootDataConnection* con = 0;
491  const string* par = pA->par();
492  unsigned long* ipar = const_cast<unsigned long*>(pA->ipar());
493  StatusCode sc = connectDatabase(par[0],IDataConnection::READ,&con);
494  if ( sc.isSuccess() ) {
495  ipar[0] = (unsigned long)con;
496  DataObject* pObj = 0;
497  size_t len = par[1].find('/',1);
498  string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
499 
500  int nb = con->loadObj(section,par[1],ipar[1],pObj);
501  if ( nb > 1 || (nb == 1 && pObj->clID() == CLID_DataObject) ) {
502  refpObj = pObj;
503  return S_OK;
504  }
505  delete pObj;
506  }
507  string tag = par[0]+":"+par[1];
508  if ( m_badFiles.find(tag) == m_badFiles.end() ) {
509  m_badFiles.insert(tag);
510  return error("createObj> Cannot access the object:"+tag);
511  }
512  return S_FAIL;
513  }
514  return S_FAIL;
515 }
516 
517 // Resolve the references of the created transient object.
518 StatusCode RootCnvSvc::i__fillObjRefs(IOpaqueAddress* pA, DataObject* pObj) {
519  if ( pA && pObj ) {
520  const unsigned long* ipar = pA->ipar();
521  RootDataConnection* con = (RootDataConnection*)ipar[0];
522  if ( con ) {
523  RootObjectRefs refs;
524  const string* par = pA->par();
525  size_t len = par[1].find('/',1);
526  string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
527  int nb = con->loadRefs(section,par[1],ipar[1],refs);
528  if ( nb >= 1 ) {
529  string npar[3];
530  unsigned long nipar[2];
531  IOpaqueAddress* nPA;
532  IRegistry* pR = pObj->registry();
533  SmartIF<IService> isvc(pR->dataSvc());
534  SmartIF<IDataManagerSvc> dataMgr(pR->dataSvc());
535  LinkManager* mgr = pObj->linkMgr();
536  for(vector<int>::const_iterator i=refs.links.begin(); i!=refs.links.end();++i) {
537  mgr->addLink(con->getLink(*i),0);
538  }
539  for(size_t j=0, n=refs.refs.size(); j<n; ++j) {
540  const RootRef& r = refs.refs[j];
541  npar[0] = con->getDb(r.dbase);
542  npar[1] = con->getCont(r.container);
543  npar[2] = con->getLink(r.link);
544  nipar[0] = 0;
545  nipar[1] = r.entry;
546  StatusCode sc = addressCreator()->createAddress(r.svc,r.clid,npar,nipar,nPA);
547  if ( sc.isSuccess() ) {
548  if( log().level() <= MSG::VERBOSE )
549  log() << MSG::VERBOSE << isvc->name() << " -> Register:" << pA->registry()->identifier()
550  << "#" << npar[2] << "[" << r.entry << "]" << endmsg;
551  sc = dataMgr->registerAddress(pA->registry(),npar[2],nPA);
552  if ( sc.isSuccess() ) {
553  continue;
554  }
555  }
556  log() << MSG::ERROR << con->fid() << ": Failed to create address!!!!" << endmsg;
557  return S_FAIL;
558  }
559  return pObj->update();
560  }
561  else if ( nb < 0 ) {
562  string tag = par[0]+":"+par[1];
563  if ( m_badFiles.find(tag) == m_badFiles.end() ) {
564  m_badFiles.insert(tag);
565  return error("createObj> Cannot access the object:"+tag+" [Corrupted file]");
566  }
567  }
568  }
569  return S_FAIL;
570  }
571  return error("read> Cannot read object -- no valid object address present ");
572 }