18 #include "ThreadLocalStorage.h" 19 #include "tbb/recursive_mutex.h" 20 #include "tbb/spin_mutex.h" 48 Partition() : dataProvider( 0 ), dataManager( 0 ), eventNumber( -1 ) {}
50 Partition(
const Partition& entry )
51 : dataProvider( entry.dataProvider ), dataManager( entry.dataManager ), eventNumber( entry.eventNumber )
54 Partition&
operator=(
const Partition& entry )
56 dataProvider = entry.dataProvider;
57 dataManager = entry.dataManager;
68 ~DataAgent()
override {}
69 bool analyse(
IRegistry* pReg,
int )
override 71 if ( 0 != pReg->
object() ) {
104 Gaudi::Property<bool> m_forceLeaves{
this,
"ForceLeaves",
false,
"force creation of default leaves on registerObject"};
106 "enable incidents on data creation requests"};
122 #define _CALL( P, F, ARGS ) \ 124 wbMutex::scoped_lock lock; \ 125 lock.acquire( s_current->storeMutex ); \ 126 return s_current->P ? s_current->P->F ARGS : IDataProviderSvc::INVALID_ROOT; \ 128 return IDataProviderSvc::INVALID_ROOT; 133 _CALL( dataManager, registerAddress, ( path, pAddr ) );
138 _CALL( dataManager, registerAddress, ( parent, path, pAddr ) );
143 _CALL( dataManager, registerAddress, ( parent, path, pAdd ) );
148 _CALL( dataManager, unregisterAddress, ( path ) );
153 _CALL( dataManager, unregisterAddress, ( pParent, path ) );
158 _CALL( dataManager, unregisterAddress, ( pParent, path ) );
163 _CALL( dataManager, objectLeaves, ( pObject, leaves ) );
168 _CALL( dataManager, objectLeaves, ( pObject, leaves ) );
173 _CALL( dataManager, objectParent, ( pObject, refpParent ) );
178 _CALL( dataManager, objectParent, ( pObject, refpParent ) );
187 for (
auto& p : m_partitions ) p.dataManager->clearStore().
ignore();
194 _CALL( dataManager, traverseSubTree, ( path, pAgent ) );
199 _CALL( dataManager, traverseSubTree, ( pObject, pAgent ) );
211 _CALL( dataManager, setRoot, ( path, pAddr ) );
221 if ( 0 != pDataLoader ) pDataLoader->
addRef();
222 if ( 0 != m_dataLoader ) m_dataLoader->
release();
223 if ( 0 != pDataLoader ) {
226 m_dataLoader = pDataLoader;
227 for (
auto& p : m_partitions ) {
228 p.dataManager->setDataLoader( m_dataLoader,
this ).ignore();
235 for (
auto& p : m_partitions ) p.dataProvider->addPreLoadItem( item );
241 for (
auto& p : m_partitions ) p.dataProvider->addPreLoadItem( item );
247 for (
auto& p : m_partitions ) p.dataProvider->removePreLoadItem( item );
253 for (
auto& p : m_partitions ) p.dataProvider->removePreLoadItem( item );
259 for (
auto& p : m_partitions ) p.dataProvider->resetPreLoad();
265 wbMutex::scoped_lock lock;
266 lock.acquire( s_current->storeMutex );
267 StatusCode sc = s_current->dataProvider->preLoad();
268 DataAgent da( s_current->newDataObjects );
269 s_current->dataManager->traverseTree( &da );
275 wbMutex::scoped_lock lock;
276 lock.acquire( s_current->storeMutex );
277 StatusCode sc = s_current->dataProvider->registerObject( path, pObj );
279 s_current->newDataObjects.insert(
DataObjID( path ) );
286 _CALL( dataProvider, registerObject, ( parent, obj, pObj ) );
291 _CALL( dataProvider, registerObject, ( parent, item, pObj ) );
296 _CALL( dataProvider, registerObject, ( parent, obj, pObj ) );
301 _CALL( dataProvider, registerObject, ( parent, obj, pObj ) );
308 _CALL( dataProvider, unregisterObject, ( parent, obj ) );
313 _CALL( dataProvider, unregisterObject, ( parent, obj ) );
320 _CALL( dataProvider, unregisterObject, ( pObj, path ) );
325 _CALL( dataProvider, unregisterObject, ( pObj, item ) );
330 _CALL( dataProvider, retrieveObject, ( parent, path, pObj ) );
335 _CALL( dataProvider, retrieveObject, ( path, pObj ) );
340 _CALL( dataProvider, retrieveObject, ( parent, path, pObj ) );
345 _CALL( dataProvider, retrieveObject, ( parent, item, pObj ) );
350 _CALL( dataProvider, retrieveObject, ( parent, path, pObj ) );
355 _CALL( dataProvider, retrieveObject, ( parent, item, pObj ) );
360 _CALL( dataProvider, retrieveObject, ( path, pObj ) );
365 _CALL( dataProvider, retrieveObject, ( parent, path, pObj ) );
370 _CALL( dataProvider, retrieveObject, ( parent, path, pObj ) );
375 _CALL( dataProvider, findObject, ( parent, item, pObject ) );
380 _CALL( dataProvider, findObject, ( parent, path, pObject ) );
385 _CALL( dataProvider, findObject, ( parent, item, pObject ) );
390 _CALL( dataProvider, linkObject, ( from, objPath, to ) );
395 _CALL( dataProvider, linkObject, ( from, objPath, to ) );
400 _CALL( dataProvider, linkObject, ( from, objPath, to ) );
405 _CALL( dataProvider, linkObject, ( fullPath, to ) );
410 _CALL( dataProvider, unlinkObject, ( from, objPath ) );
415 _CALL( dataProvider, unlinkObject, ( from, objPath ) );
420 _CALL( dataProvider, unlinkObject, ( from, objPath ) );
433 _CALL( dataProvider, updateObject, ( parent, updatePath ) );
438 _CALL( dataProvider, updateObject, ( parent, updatePath ) );
446 StatusCode clearStore(
size_t partition )
override {
return m_partitions[partition].dataManager->clearStore(); }
451 s_current = &m_partitions[partition];
459 warning() <<
"Too late to change the number of slots!" <<
endmsg;
472 wbMutex::scoped_lock lock;
473 lock.acquire( s_current->storeMutex );
474 products = s_current->newDataObjects;
475 s_current->newDataObjects.
clear();
482 wbMutex::scoped_lock lock;
483 lock.acquire( s_current->storeMutex );
484 return s_current->newDataObjects.size() != 0;
492 for (
auto& p : m_partitions ) {
493 if ( p.eventNumber == evtnumber ) {
494 error() <<
"Attempt to allocate a store partition for an event that is still active" <<
endmsg;
495 return std::string::npos;
496 }
else if ( p.eventNumber == -1 ) {
497 p.eventNumber = evtnumber;
503 return std::string::npos;
509 m_partitions[partition].eventNumber = -1;
518 for (
auto& p : m_partitions ) {
519 if ( p.eventNumber == eventnumber )
return index;
522 return std::string::npos;
527 StatusCode sc = service( m_loader, m_addrCreator,
true );
529 error() <<
"Failed to retrieve data loader " 530 <<
"\"" << m_loader <<
"\"" <<
endmsg;
534 sc = service( m_loader, dataLoader,
true );
536 error() <<
MSG::ERROR <<
"Failed to retrieve data loader " 537 <<
"\"" << m_loader <<
"\"" <<
endmsg;
540 sc = setDataLoader( dataLoader );
543 error() <<
MSG::ERROR <<
"Failed to set data loader " 544 <<
"\"" << m_loader <<
"\"" <<
endmsg;
552 if ( m_addrCreator ) m_addrCreator->
release();
553 if ( m_dataLoader ) m_dataLoader->
release();
568 error() <<
"Unable to initialize base class" <<
endmsg;
573 error() <<
"Invalid number of slots (" << m_slots <<
")" <<
endmsg;
577 for (
int i = 0; i < m_slots; i++ ) {
579 oss <<
name() <<
"_" << i;
589 error() <<
"Failed to instantiate DataSvc as store partition" <<
endmsg;
592 m_partitions.
push_back( Partition( svc, svc ) );
594 selectStore( 0 ).ignore();
595 return attachServices();
603 error() <<
"Unable to reinitialize base class" <<
endmsg;
607 sc = attachServices();
609 error() <<
"Failed to attach necessary services." <<
endmsg;
618 setDataLoader( 0 ).
ignore();
619 clearStore().ignore();
624 using extends::extends;
629 setDataLoader( 0 ).ignore();
630 resetPreLoad().ignore();
631 clearStore().ignore();
633 for ( Partitions::iterator i = m_partitions.
begin(); i != m_partitions.
end(); ++i ) {
634 ( *i ).dataManager->release();
635 ( *i ).dataProvider->release();
637 m_partitions.
clear();
StatusCode unlinkObject(const std::string &path) override
Remove a link to another object.
StatusCode unlinkObject(IRegistry *from, const std::string &objPath) override
Remove a link to another object.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
StatusCode retrieveObject(const std::string &parent, const std::string &path, DataObject *&pObj) override
Retrieve object from data store.
StatusCode registerAddress(IRegistry *parent, const std::string &path, IOpaqueAddress *pAdd) override
IDataManagerSvc: Register object address with the data store.
StatusCode linkObject(DataObject *from, const std::string &objPath, DataObject *to) override
Add a link to another object.
StatusCode retrieveObject(const std::string &parent, int item, DataObject *&pObj) override
Retrieve object from data store.
StatusCode registerObject(const std::string &path, DataObject *pObj) override
Register object with the data store. (The most common one is the only monitored one for the time bein...
StatusCode initialize() override
StatusCode registerObject(const std::string &parent, int item, DataObject *pObj) override
Register object with the data store.
StatusCode unregisterObject(DataObject *pObj) override
Unregister object from the data store.
size_t allocateStore(int evtnumber) override
Allocate a store partition for a given event number.
StatusCode traverseSubTree(const std::string &path, IDataStoreAgent *pAgent) override
Analyze by traversing all data objects below the sub tree.
StatusCode unregisterAddress(const std::string &path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode setDataLoader(IConversionSvc *pDataLoader, IDataProviderSvc *dpsvc __attribute__((unused))=nullptr) override
IDataManagerSvc: Pass a default data loader to the service.
StatusCode registerAddress(const std::string &path, IOpaqueAddress *pAddr) override
IDataManagerSvc: Register object address with the data store.
StatusCode finalize() override
Implementation of property with value of concrete type.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
StatusCode retrieveObject(DataObject *parent, const std::string &path, DataObject *&pObj) override
Retrieve object from data store.
StatusCode freeStore(size_t partition) override
Free a store partition.
size_t getPartitionNumber(int eventnumber) const override
Get the partition number corresponding to a given event.
StatusCode clearStore(size_t partition) override
Remove all data objects in one 'slot' of the data store.
bool isSuccess() const
Test for a status code of SUCCESS.
StatusCode retrieveObject(const std::string &path, DataObject *&pObj) override
Retrieve object identified by its full path from the data store.
StatusCode registerObject(const std::string &parent, const std::string &obj, DataObject *pObj) override
Register object with the data store.
StatusCode findObject(DataObject *parent, int item, DataObject *&pObject) override
Find object in the data store.
StatusCode unregisterObject(const std::string &parent, const std::string &obj) override
Unregister object from the data store.
IAddressCreator interface definition.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
StatusCode unregisterObject(DataObject *pObj, const std::string &path) override
Unregister object from the data store.
StatusCode resetPreLoad() override
Clear the preload list.
StatusCode addPreLoadItem(const std::string &item) override
Add an item to the preload list.
StatusCode finalize() override
Service initialisation.
StatusCode clearSubTree(DataObject *pObject) override
Remove all data objects below the sub tree identified.
#define _CALL(P, F, ARGS)
StatusCode clearSubTree(const std::string &path) override
Remove all data objects below the sub tree identified.
size_t getNumberOfStores() const override
Get the number of event slots (copies of DataSvc objects).
StatusCode objectParent(const IRegistry *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode updateObject(DataObject *pObj) override
Update object.
StatusCode registerAddress(DataObject *parent, const std::string &path, IOpaqueAddress *pAddr) override
IDataManagerSvc: Register object address with the data store.
Data provider interface definition.
StatusCode preLoad() override
load all preload items of the list
Description of the DataStoreItem class.
StatusCode unregisterObject(DataObject *pObj, int item) override
Unregister object from the data store.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
StatusCode selectStore(size_t partition) override
Activate a partition object. The identifies the partition uniquely.
PropertyMgr & operator=(const PropertyMgr &)=delete
tbb::recursive_mutex wbMutex
StatusCode removePreLoadItem(const std::string &item) override
Add an item to the preload list.
StatusCode detachServices()
StatusCode findObject(DataObject *parent, const std::string &path, DataObject *&pObject) override
Find object in the data store.
StatusCode linkObject(const std::string &from, const std::string &objPath, DataObject *to) override
Add a link to another object.
StatusCode findObject(const std::string &path, DataObject *&pObj) override
Find object identified by its full path in the data store.
virtual const id_type & identifier() const =0
Full identifier (or key)
StatusCode objectLeaves(const IRegistry *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
StatusCode updateObject(const std::string &path) override
Update object.
This class is used for returning status codes from appropriate routines.
StatusCode linkObject(const std::string &fullPath, DataObject *to) override
Add a link to another object.
StatusCode unregisterObject(const std::string &path) override
Unregister object from the data store.
StatusCode updateObject(const std::string &parent, const std::string &updatePath) override
Update object.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
bool newDataObjectsPresent() override
Check if new DataObjects are in the current store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode reinitialize() override
#define DECLARE_SERVICE_FACTORY(x)
StatusCode linkObject(IRegistry *from, const std::string &objPath, DataObject *to) override
Add a link to another object.
unsigned int CLID
Class ID definition.
StatusCode registerObject(DataObject *parent, int obj, DataObject *pObj) override
Register object with the data store.
StatusCode unlinkObject(DataObject *from, const std::string &objPath) override
Remove a link to another object.
virtual DataObject * object() const =0
Retrieve object behind the link.
StatusCode attachServices()
StatusCode traverseSubTree(DataObject *pObject, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree.
StatusCode registerObject(DataObject *parent, const std::string &obj, DataObject *pObj) override
Register object with the data store.
TTHREAD_TLS(Partition *) s_current(0)
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode setRoot(std::string path, IOpaqueAddress *pAddr) override
Initialize data store for new event by giving new event path and address of root object.
Partitions m_partitions
Datastore partitions.
StatusCode findObject(IRegistry *parent, const std::string &path, DataObject *&pObj) override
Find object identified by its full path in the data store.
virtual unsigned long release()=0
Release Interface instance.
Generic data agent interface.
virtual ~HiveWhiteBoard()
Standard Destructor.
Base class used to extend a class implementing other interfaces.
StatusCode initialize() override
Service initialization.
StatusCode unregisterAddress(IRegistry *pParent, const std::string &path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode setRoot(std::string path, DataObject *pObj) override
Initialize data store for new event by giving new event path and root object.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
StatusCode retrieveObject(DataObject *parent, int item, DataObject *&pObj) override
Retrieve object from data store.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
StatusCode unregisterObject(const std::string &parent, int obj) override
Unregister object from the data store.
StatusCode initialize() override
Service initialisation.
StatusCode updateObject(DataObject *parent, const std::string &updatePath) override
Update object.
StatusCode findObject(const std::string &parent, const std::string &path, DataObject *&pObj) override
Find object in the data store.
StatusCode unlinkObject(const std::string &from, const std::string &objPath) override
Remove a link to another object.
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
Opaque address interface definition.
StatusCode findObject(const std::string &parent, int item, DataObject *&pObject) override
Find object in the data store.
std::vector< Partition > Partitions
A DataObject is the base class of any identifiable object on any data store.
StatusCode retrieveObject(IRegistry *parent, const std::string &path, DataObject *&pObj) override
Retrieve object from data store.
StatusCode getNewDataObjects(DataObjIDColl &products) override
Get the list of new DataObjects in the current store.
StatusCode unregisterAddress(DataObject *pParent, const std::string &path) override
IDataManagerSvc: Unregister object address from the data store.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
const std::string & rootName() const override
Name for root Event.
StatusCode reinitialize() override
Service initialisation.
StatusCode setNumberOfStores(size_t slots) override
Set the number of event slots (copies of DataSvc objects).